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.service;
19  
20  import at.ac.tuwien.infosys.sm4all.copal.api.event.ContextEventType;
21  import at.ac.tuwien.infosys.sm4all.copal.api.publisher.ContextPublisher;
22  import at.ac.tuwien.infosys.sm4all.copal.api.util.AlreadyRegisteredException;
23  import at.ac.tuwien.infosys.sm4all.copal.api.util.NotRegisteredException;
24  import at.ac.tuwien.infosys.sm4all.copal.api.util.Observable;
25  import at.ac.tuwien.infosys.sm4all.copal.api.util.Registry;
26  import at.ac.tuwien.infosys.sm4all.copal.api.util.RegistryObservable.RegistrationState;
27  import at.ac.tuwien.infosys.sm4all.copal.api.util.RegistryObservable.RegistryObserver;
28  
29  /**
30   * Interface which COPAL provides to register, unregister, and query
31   * {@link ContextPublisher}s.
32   * 
33   * @author fei
34   * @author sanjin
35   */
36  public interface ContextPublisherRegistry
37          extends
38          Registry<String, ContextPublisher>,
39          Observable<RegistrationState, ContextPublisher, RegistryObserver<ContextPublisher>> {
40  
41      /**
42       * Register {@link ContextPublisher} with COPAL.
43       * 
44       * @param publisher the context publisher.
45       * @throws AlreadyRegisteredException if a {@link ContextEventType} with
46       *         same name is already registered.
47       */
48      @Override
49      void register(ContextPublisher publisher) throws AlreadyRegisteredException;
50  
51      /**
52       * Unregister {@link ContextPublisher} with specified source ID from COPAL.
53       * 
54       * @param sourceID the source ID of a registered {@link ContextPublisher}.
55       * @throws NotRegisteredException if no {@link ContextPublisher} with
56       *         specified source ID is registered.
57       */
58      @Override
59      void unregister(String sourceID) throws NotRegisteredException;
60  
61      /**
62       * Returns if a {@link ContextPublisher} with specified source ID is
63       * currently registered with COPAL.
64       * 
65       * @param sourceID the source id of {@link ContextPublisher}.
66       * @return if a {@link ContextPublisher} with specified source ID is
67       *         currently registered with COPAL.
68       */
69      @Override
70      boolean isRegistered(String sourceID);
71  
72      /**
73       * Returns the {@link ContextPublisher} with specified source ID.
74       * 
75       * @param sourceID the source ID of a {@link ContextPublisher}.
76       * @return the {@link ContextPublisher} used in registration; or
77       *         <code>null</code> if there is no such {@link ContextPublisher}
78       *         registered.
79       */
80      @Override
81      ContextPublisher get(String sourceID);
82  
83      /**
84       * Returns all currently registered {@link ContextPublisher}s.
85       * 
86       * @return all currently registered {@link ContextPublisher}s.
87       */
88      @Override
89      ContextPublisher[] getAll();
90  
91      /**
92       * Returns all {@link ContextPublisher}s which publish events of specified
93       * event type.
94       * 
95       * @param eventType the name of the {@link ContextEventType}.
96       * @return all {@link ContextPublisher}s which publish events of specified
97       *         event type.
98       */
99      ContextPublisher[] getAll(String eventType);
100 }