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.core.internal;
19  
20  import org.osgi.framework.BundleActivator;
21  import org.osgi.framework.BundleContext;
22  import at.ac.tuwien.infosys.sm4all.copal.api.service.ContextEventTypeRegistry;
23  import at.ac.tuwien.infosys.sm4all.copal.api.service.ContextProcessorRegistry;
24  import at.ac.tuwien.infosys.sm4all.copal.api.service.ContextPublisherRegistry;
25  import at.ac.tuwien.infosys.sm4all.copal.api.service.ContextQueryFactory;
26  import at.ac.tuwien.infosys.sm4all.copal.api.service.ContextState;
27  import at.ac.tuwien.infosys.sm4all.copal.api.service.DeadLetterChannel;
28  
29  /**
30   * The OSGi {@link BundleActivator} of COPAL core services. This class registers
31   * implementations of {@link ContextEventTypeRegistry},
32   * {@link ContextQueryFactory}, {@link ContextState},
33   * {@link ContextPublisherRegistry}, {@link ContextProcessorRegistry}, and
34   * {@link DeadLetterChannel} interfaces.
35   * 
36   * @author fei
37   * @author sanjin
38   */
39  public class CoreActivator implements BundleActivator {
40  
41      private final DeadLetterChannelImpl deadLetterChannel = new DeadLetterChannelImpl();
42      private final ContextEventTypeRegistryImpl eventTypeRegistry = new ContextEventTypeRegistryImpl();
43      private final ContextSecurityManagerImpl securityManager = new ContextSecurityManagerImpl();
44      private final ContextQueryFactoryImpl queryFactory = new ContextQueryFactoryImpl();
45      private final ContextStateImpl state = new ContextStateImpl();
46      private final ContextPublisherRegistryImpl publisherRegistry = new ContextPublisherRegistryImpl();
47      private final ContextProcessorRegistryImpl processorRegistry = new ContextProcessorRegistryImpl();
48  
49      @Override
50      public void start(final BundleContext bundleContext) {
51          this.deadLetterChannel.start(bundleContext);
52          this.eventTypeRegistry.start(bundleContext);
53          this.securityManager.start(bundleContext);
54          this.queryFactory.start(bundleContext);
55          this.state.start(bundleContext);
56          this.publisherRegistry.start(bundleContext);
57          this.processorRegistry.start(bundleContext);
58      }
59  
60      @Override
61      public void stop(final BundleContext bundleContext) {
62          this.processorRegistry.stop(bundleContext);
63          this.publisherRegistry.stop(bundleContext);
64          this.state.stop(bundleContext);
65          this.queryFactory.stop(bundleContext);
66          this.securityManager.stop(bundleContext);
67          this.eventTypeRegistry.stop(bundleContext);
68          this.deadLetterChannel.stop(bundleContext);
69      }
70  }