View Javadoc

1   /* This file is part of COPAL (COntext Provisioning for All).
2    *
3    * COPAL is a part of SM4All (Smart hoMes for All) project.
4    *
5    * COPAL is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU Lesser General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    *
10   * COPAL is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public License
16   * along with COPAL. If not, see <http://www.gnu.org/licenses/>.
17   */
18  package at.ac.tuwien.infosys.sm4all.copal.api.helpers;
19  
20  import org.osgi.framework.ServiceReference;
21  import org.osgi.util.tracker.ServiceTracker;
22  import org.osgi.util.tracker.ServiceTrackerCustomizer;
23  
24  /**
25   * Customized interface of {@link ServiceTrackerCustomizer} with added argument
26   * for dependency name. This interface helps when same class wants to be used as
27   * {@link ServiceTrackerCustomizer} for multiple {@link ServiceTracker}s, so it
28   * can separate which {@link ServiceTracker} called the methods. This interface
29   * is used in combination with {@link DependencyTracker} to achieve this goal.
30   * 
31   * @author sanjin
32   */
33  public interface DependencyTrackerCustomizer {
34  
35      /**
36       * A dependency is being added to the {@link DependencyTracker}.
37       * 
38       * @param dependencyName the name of the added dependency.
39       * @param reference a dependency is being added to the
40       *        {@link DependencyTracker}.
41       * @return the dependency object to be tracked for the specified referenced
42       *         service or <code>null</code> if the specified referenced service
43       *         should not be tracked.
44       */
45      Object addingService(String dependencyName, ServiceReference reference);
46  
47      /**
48       * A service tracked by the {@link DependencyTracker} has been modified.
49       * 
50       * @param dependencyName the name of the modified dependency.
51       * @param reference the reference to the service that has been modified.
52       * @param service the service object for the specified referenced service.
53       */
54      void modifiedService(String dependencyName, ServiceReference reference,
55              Object service);
56  
57      /**
58       * A service tracked by the {@link DependencyTracker} has been removed.
59       * 
60       * @param dependencyName the name of the removed dependency.
61       * @param reference the reference to the service that has been removed.
62       * @param service the service object for the specified referenced service.
63       */
64      void removedService(String dependencyName, ServiceReference reference,
65              Object service);
66  }