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.processor.ContextProcessor;
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 ContextProcessor}s.
32   * 
33   * @author fei
34   * @author sanjin
35   */
36  public interface ContextProcessorRegistry
37          extends
38          Registry<String, ContextProcessor>,
39          Observable<RegistrationState, ContextProcessor, RegistryObserver<ContextProcessor>> {
40  
41      /**
42       * Register specified {@link ContextProcessor}.
43       * 
44       * @param processor the {@link ContextProcessor}
45       * @throws AlreadyRegisteredException if a {@link ContextProcessor} with
46       *         same name is already registered.
47       */
48      @Override
49      void register(ContextProcessor processor) throws AlreadyRegisteredException;
50  
51      /**
52       * Unregister {@link ContextProcessor} with specified name.
53       * 
54       * @param name the name of a registered {@link ContextProcessor}.
55       * @throws NotRegisteredException if no {@link ContextProcessor} with
56       *         specified name is registered.
57       */
58      @Override
59      void unregister(String name) throws NotRegisteredException;
60  
61      /**
62       * Returns if a {@link ContextProcessor} with specified name is currently
63       * registered.
64       * 
65       * @param name the name of {@link ContextProcessor}.
66       * @return if a {@link ContextProcessor} with specified name is currently
67       *         registered with COPAL.
68       */
69      @Override
70      boolean isRegistered(String name);
71  
72      /**
73       * Returns the {@link ContextProcessor} with specified name.
74       * 
75       * @param name the name of a {@link ContextProcessor}.
76       * @return the {@link ContextProcessor} used in registration; or
77       *         <code>null</code> if there is no such {@link ContextProcessor}
78       *         registered.
79       */
80      @Override
81      ContextProcessor get(String name);
82  
83      /**
84       * Returns all currently registered {@link ContextProcessor}s.
85       * 
86       * @return all currently registered {@link ContextProcessor}s.
87       */
88      @Override
89      ContextProcessor[] getAll();
90  
91      /**
92       * Returns all {@link ContextProcessor}s which process events of specified
93       * event type.
94       * 
95       * @param eventType the name of {@link ContextEventType}.
96       * @return all {@link ContextProcessor}s which process events of specified
97       *         event type.
98       */
99      ContextProcessor[] getAll(String eventType);
100 }