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.service.copal;
19  
20  import at.ac.tuwien.infosys.sm4all.copal.api.ContextPublisher;
21  import at.ac.tuwien.infosys.sm4all.copal.api.event.ContextEventType;
22  
23  /**
24   * Interface which COPAL core provides to register, unregister, and query
25   * {@link ContextPublisher}s.
26   * 
27   * @author fei
28   * @author sanjin
29   */
30  public interface ContextPublisherRegistry {
31  
32      /**
33       * Register {@link ContextPublisher} with COPAL core.
34       * 
35       * @param publisher the context publisher.
36       * @return <code>true</code> if registering was successful;
37       *         <code>false</code> otherwise.
38       */
39      boolean register(ContextPublisher publisher);
40  
41      /**
42       * Unregister {@link ContextPublisher} with specified source ID from COPAL
43       * core.
44       * 
45       * @param sourceID the source ID of a registered {@link ContextPublisher}.
46       * @return <code>true</code> if unregistering was successful;
47       *         <code>false</code> otherwise.
48       */
49      boolean unregister(String sourceID);
50  
51      /**
52       * Checks if a {@link ContextPublisher} with specified source ID is
53       * currently registered with COPAL core.
54       * 
55       * @param sourceID the source id of {@link ContextPublisher}.
56       * @return <code>true</code> if the {@link ContextPublisher} with specified
57       *         source ID is registered; <code>false</code> otherwise.
58       */
59      boolean isRegistered(String sourceID);
60  
61      /**
62       * @return all currently registered {@link ContextPublisher}s.
63       */
64      ContextPublisher[] getPublishers();
65  
66      /**
67       * @param sourceID the source ID of a {@link ContextPublisher}.
68       * @return the {@link ContextPublisher} used in registration; or
69       *         <code>null</code> if there is no registered
70       *         {@link ContextPublisher} with specified source ID.
71       */
72      ContextPublisher getPublisher(String sourceID);
73  
74      /**
75       * @param eventType the name of the {@link ContextEventType}.
76       * @return all {@link ContextPublisher}s which publish events of
77       *         {@link ContextEventType} that has name equal to specified
78       *         <code>eventType</code>.
79       */
80      ContextPublisher[] getPublishers(String eventType);
81  }