View Javadoc

1   /*
2    * Copyright 2006-2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.springframework.osgi.extender.internal.dependencies.shutdown;
17  
18  import org.osgi.framework.Bundle;
19  
20  /**
21   * SPI for sorting OSGi bundles based on their service dependency. Given a
22   * number of bundles, implementors of this interface will return a list
23   * referencing the bundles in the order in which they should be shutdown based
24   * on their OSGi service dependencies.
25   * <p/>
26   * It is considered that bundle A depends on bundle B if A uses a service that
27   * belongs to a bundle which depends on B or is B itself. Note that bundles can
28   * depend on each other : A -> B -> A.
29   * <p/>
30   * Thus implementations should 'sort' direct, circular graphs without any
31   * guarantee on the node used for start.
32   *  
33   * @author Costin Leau
34   * 
35   */
36  public interface ServiceDependencySorter {
37  
38  	/**
39  	 * Given a number of bundles, determine the dependency between each other and compute
40  	 * the dependency tree.
41  	 * 
42  	 * @param bundles array of bundles
43  	 * @return an array of bundles, sorted out by their dependency. 
44  	 */
45  	Bundle[] computeServiceDependencyGraph(Bundle[] bundles);
46  }