KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > Registry


1 // Copyright 2004, 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.hivemind;
16
17 import java.util.List JavaDoc;
18 import java.util.Locale JavaDoc;
19
20 /**
21  * The HiveMind registry; primarily this is used to gain access to services.
22  * <p>
23  *
24  * @author Howard Lewis Ship
25  */

26 public interface Registry
27 {
28     /**
29      * Returns true if a configuration for the specified id exists.
30      *
31      * @param configurationId
32      * @return true if a configuration for the specified id exists
33      */

34     public boolean containsConfiguration(String JavaDoc configurationId);
35
36     /**
37      * Returns true if a single service for the specified service interface class exists.
38      *
39      * @param serviceInterface
40      * @return true if a single service for the specified service interface exists
41      */

42     public boolean containsService(Class JavaDoc serviceInterface);
43
44     /**
45      * Returns true if a service for the specified service id and service interface exists.
46      *
47      * @param serviceId
48      * @param serviceInterface
49      * @return true if a service for the specified service id and service interface exists
50      */

51     public boolean containsService(String JavaDoc serviceId, Class JavaDoc serviceInterface);
52
53     /**
54      * Returns the container of the configuration point.
55      *
56      * @param configurationId
57      * the fully qualified id of the configuration to obtain
58      * @return the configuration
59      * @throws ApplicationRuntimeException
60      * if the configuration does not exist, etc.
61      */

62     public Object JavaDoc getConfiguration(String JavaDoc configurationId);
63     
64     /**
65      * Finds a configuration of the specified type. Exactly one such configuration may exist or
66      * an exception is thrown.
67      *
68      * @param configurationType
69      * the configuration type
70      * @return the configuration
71      * @throws org.apache.hivemind.ApplicationRuntimeException
72      * if no such configuration extension point exists (or visible)
73      */

74     public Object JavaDoc getConfiguration(Class JavaDoc configurationType);
75
76     /**
77      * Obtains a service from the registry. Typically, what's returned is a proxy, but that's
78      * irrelevant to the caller, which simply will invoke methods of the service interface.
79      *
80      * @param serviceId
81      * the fully qualified id of the service to obtain
82      * @param serviceInterface
83      * the class to which the service will be cast
84      * @return the service
85      * @throws ApplicationRuntimeException
86      * if the service does not exist, or if it can't be cast to the specified service
87      * interface
88      */

89
90     public Object JavaDoc getService(String JavaDoc serviceId, Class JavaDoc serviceInterface);
91
92     /**
93      * Convenience method to obtain a service with a single implementation from the registry.
94      * Exactly one service point must implement the service.
95      *
96      * @param serviceInterface
97      * the class to which the service will be cast.
98      * @return the service implementing the given interface.
99      * @throws ApplicationRuntimeException
100      * if there are no service extension points implementing the given interface, or if
101      * there multiple service points implementing it.
102      * @see #getService(String, Class)
103      */

104
105     public Object JavaDoc getService(Class JavaDoc serviceInterface);
106
107     /**
108      * Returns the locale for which the registry was created.
109      */

110
111     public Locale JavaDoc getLocale();
112
113     /**
114      * Shuts down the registry; this notifies all
115      * {@link org.apache.hivemind.events.RegistryShutdownListener} services and objects. Once the
116      * registry is shutdown, it is no longer valid to obtain new services or configurations, or even
117      * use existing services and configurations.
118      */

119
120     public void shutdown();
121
122     /**
123      * To be invoked at the start of each request in a multi-threaded environment. Ensures that the
124      * receiving Registry will be used if any service proxies are de-serialized.
125      *
126      * @since 1.1
127      * @see org.apache.hivemind.internal.ser.ServiceSerializationHelper
128      * @see org.apache.hivemind.internal.ser.ServiceSerializationSupport
129      */

130
131     public void setupThread();
132
133     /**
134      * Convienience for invoking
135      * {@link org.apache.hivemind.service.ThreadEventNotifier#fireThreadCleanup()}.
136      */

137
138     public void cleanupThread();
139
140     /**
141      * Returns a list of service ids for service points which implement the desired service
142      * interface.
143      *
144      * @return Returns an empty List if no matching service points exist.
145      * @since 1.1
146      */

147     public List JavaDoc getServiceIds(Class JavaDoc serviceInterface);
148
149     /**
150      * Returns the Messages object for the specified module.
151      *
152      * @param moduleId
153      * the module id
154      * @return the Messages object for the specified module.
155      */

156     public Messages getModuleMessages(String JavaDoc moduleId);
157 }
Popular Tags