KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > internal > Module


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.internal;
16
17 import java.util.Locale JavaDoc;
18
19 import org.apache.hivemind.ApplicationRuntimeException;
20 import org.apache.hivemind.ClassResolver;
21 import org.apache.hivemind.ErrorHandler;
22 import org.apache.hivemind.Locatable;
23 import org.apache.hivemind.Messages;
24
25 /**
26  * The definition of a HiveMind Module. A Module is a container of service extension points and
27  * configuration extension points. It also acts as a "gateway" so that services and configurations
28  * in other modules may be accessed.
29  * <p>
30  * Why do we expose the Module rather than the
31  * {@link org.apache.hivemind.internal.RegistryInfrastructure}? It's more than just qualifying ids
32  * before passing them up to the RI. At some future point, a concept of visibility will be added to
33  * HiveMind. This will make many services and configurations private to the module which defines
34  * them and the necessary visibility filtering logic will be here.
35  *
36  * @author Howard Lewis Ship
37  */

38 public interface Module extends Locatable
39 {
40     /**
41      * Returns the unique identifier for this module.
42      */

43     public String JavaDoc getModuleId();
44
45     /**
46      * Returns true if a single service exists which implements the specified service interface and
47      * is visible to this module.
48      *
49      * @param serviceInterface
50      * @return true if a single visible service for the specified service interface exists
51      * @since 1.1
52      */

53     public boolean containsService(Class JavaDoc serviceInterface);
54
55     /**
56      * Looks up the {@link ServicePoint} (throwing an exception if not found) and invokes
57      * {@link ServicePoint#getService(Class)}.
58      *
59      * @param serviceId
60      * an unqualified id for a service within this module, or a fully qualified id for a
61      * service in this or any other module
62      * @param serviceInterface
63      * type the result will be cast to
64      */

65     public Object JavaDoc getService(String JavaDoc serviceId, Class JavaDoc serviceInterface);
66
67     /**
68      * Finds a service that implements the provided interface. Exactly one such service may exist or
69      * an exception is thrown.
70      *
71      * @param serviceInterface
72      * used to locate the service
73      */

74     public Object JavaDoc getService(Class JavaDoc serviceInterface);
75
76     /**
77      * Returns the identified service extension point.
78      *
79      * @param serviceId
80      * an unqualified id for a service within this module, or a fully qualified id for a
81      * service in this or any other module
82      * @throws org.apache.hivemind.ApplicationRuntimeException
83      * if no such service extension point exists
84      */

85
86     public ServicePoint getServicePoint(String JavaDoc serviceId);
87
88     /**
89      * Returns the container for the specified configuration point.
90      *
91      * @param configurationId
92      * an unqualified id for a configuration within this module, or a fully qualified id
93      * for a configuration in this or any other module
94      * @throws ApplicationRuntimeException
95      * if this module does not contain the specified configuration extension point.
96      */

97     public Object JavaDoc getConfiguration(String JavaDoc configurationId);
98
99     /**
100      * Returns the resource resolver for this module. The resource resolver is used to locate
101      * classes by name (using the correct classloader).
102      */

103     public ClassResolver getClassResolver();
104
105     /**
106      * Returns the class matching the type. First, attempts to resolve the type exactly as is. If
107      * that fails, resolves the type within the module's defined package.
108      *
109      * @param type
110      * the Java type to convert into a class. May be a primitive type, or an array of
111      * objects or primitives.
112      * @return the corresponding {@link Class} object.
113      * @throws org.apache.hivemind.ApplicationRuntimeException
114      * if the type may not be converted into a Class.
115      * @since 1.1
116      */

117
118     public Class JavaDoc resolveType(String JavaDoc type);
119
120     /**
121      * Returns an object that can provide and format localized messages for this module. The
122      * messages come from a properties file, <code>hivemodule.properties</code> (localized) stored
123      * with the HiveMind deployment descriptor in the META-INF folder.
124      */

125
126     public Messages getMessages();
127
128     /**
129      * @see RegistryInfrastructure#getServiceModelFactory(String)
130      */

131     public ServiceModelFactory getServiceModelFactory(String JavaDoc name);
132
133     /**
134      * @see org.apache.hivemind.Registry#getLocale()
135      */

136     public Locale JavaDoc getLocale();
137
138     /**
139      * Returns the {@link org.apache.hivemind.ErrorHandler} for this Registry.
140      */

141
142     public ErrorHandler getErrorHandler();
143     
144     /**
145      * @return the registry infrastructure interface
146      */

147     public RegistryInfrastructure getRegistry();
148     
149 }
Popular Tags