|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Registry.java | - | - | - | - |
|
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;
|
|
18 |
import java.util.Locale;
|
|
19 |
|
|
20 |
/**
|
|
21 |
* The HiveMind registry; primarily this is used
|
|
22 |
* to gain access to services.
|
|
23 |
*
|
|
24 |
* <p>
|
|
25 |
* In addition, Registry implements {@link org.apache.hivemind.SymbolSource}
|
|
26 |
* which allows programatic access to substitution symbols.
|
|
27 |
*
|
|
28 |
*
|
|
29 |
* @author Howard Lewis Ship
|
|
30 |
*/
|
|
31 |
|
|
32 |
public interface Registry extends SymbolSource |
|
33 |
{ |
|
34 |
/**
|
|
35 |
* Returns true if a configuration for the specified id exists.
|
|
36 |
*
|
|
37 |
* @param configurationId
|
|
38 |
* @return true if a configuration for the specified id exists
|
|
39 |
*/
|
|
40 |
public boolean containsConfiguration(String configurationId); |
|
41 |
|
|
42 |
/**
|
|
43 |
* Returns true if a single service for the specified service interface
|
|
44 |
* class exists.
|
|
45 |
*
|
|
46 |
* @param serviceInterface
|
|
47 |
* @return true if a single service for the specified service interface
|
|
48 |
* exists
|
|
49 |
*/
|
|
50 |
public boolean containsService(Class serviceInterface); |
|
51 |
|
|
52 |
/**
|
|
53 |
* Returns true if a service for the specified service id and service
|
|
54 |
* interface exists.
|
|
55 |
*
|
|
56 |
* @param serviceId
|
|
57 |
* @param serviceInterface
|
|
58 |
* @return true if a service for the specified service id and service
|
|
59 |
* interface exists
|
|
60 |
*/
|
|
61 |
public boolean containsService(String serviceId, Class serviceInterface); |
|
62 |
|
|
63 |
/**
|
|
64 |
* Returns a configuration as a List of elements (as defined by the schema
|
|
65 |
* for the configuration point, or as {@link Element}s if no configuration point
|
|
66 |
* does not define a schema.
|
|
67 |
*
|
|
68 |
* @param configurationId the fully qualified id of the configuration to obtain
|
|
69 |
* @return the configuration as an immutable List
|
|
70 |
* @throws ApplicationRuntimeException if the configuration does not exist, etc.
|
|
71 |
*/
|
|
72 |
public List getConfiguration(String configurationId);
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Expands any substitution symbols in the input string, replacing
|
|
76 |
* each symbol with the symbols value (if known). If a symbol
|
|
77 |
* is unknown, then the symbol is passed
|
|
78 |
* through unchanged (complete with the <code>${</code> and <code>}</code>
|
|
79 |
* delimiters) and an error is logged.
|
|
80 |
*
|
|
81 |
* @param input input string to be converted, which may (or may not) contain
|
|
82 |
* any symbols.
|
|
83 |
* @param location the location from which the string was obtained, used if
|
|
84 |
* an error is logged.
|
|
85 |
*/
|
|
86 |
|
|
87 |
public String expandSymbols(String input, Location location);
|
|
88 |
|
|
89 |
/**
|
|
90 |
* Obtains a service from the registry. Typically, what's returned is a proxy,
|
|
91 |
* but that's irrelevant to the caller, which simply will invoke methods
|
|
92 |
* of the service interface.
|
|
93 |
*
|
|
94 |
* @param serviceId the fully qualified id of the service to obtain
|
|
95 |
* @param serviceInterface the class to which the service will be cast
|
|
96 |
* @return the service
|
|
97 |
* @throws ApplicationRuntimeException if the service does not exist, or if
|
|
98 |
* it can't be cast to the specified service interface
|
|
99 |
*/
|
|
100 |
|
|
101 |
public Object getService(String serviceId, Class serviceInterface);
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Convenience method to obtain a service with a single implementation from the registry.
|
|
105 |
* Exactly one service point must implement the service.
|
|
106 |
*
|
|
107 |
* @param serviceInterface the class to which the service will be cast.
|
|
108 |
* @return the service implementing the given interface.
|
|
109 |
* @throws ApplicationRuntimeException if there are no service extension points implementing
|
|
110 |
* the given interface, or if there multiple service points implementing it.
|
|
111 |
* @see #getService(String, Class)
|
|
112 |
*/
|
|
113 |
|
|
114 |
public Object getService(Class serviceInterface);
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Returns the locale for which the registry was created.
|
|
118 |
*/
|
|
119 |
|
|
120 |
public Locale getLocale();
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Shuts down the registry; this notifies all
|
|
124 |
* {@link RegistryShutdownListener} services and objects. Once the registry
|
|
125 |
* is shutdown, it is no longer valid to obtain new services or configurations, or
|
|
126 |
* even use existing services and configurations.
|
|
127 |
*/
|
|
128 |
|
|
129 |
public void shutdown(); |
|
130 |
|
|
131 |
/**
|
|
132 |
* Convienience for invoking {@link org.apache.hivemind.service.ThreadEventNotifier#fireThreadCleanup()}.
|
|
133 |
*/
|
|
134 |
|
|
135 |
public void cleanupThread(); |
|
136 |
} |
|
137 |
|
|