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