001: /*
002: * $Id: Registry.java 11058 2008-02-27 03:02:33Z dfeist $
003: * --------------------------------------------------------------------------------------
004: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
005: *
006: * The software in this package is published under the terms of the CPAL v1.0
007: * license, a copy of which has been included with this distribution in the
008: * LICENSE.txt file.
009: */
010:
011: package org.mule.api.registry;
012:
013: import org.mule.api.MuleException;
014: import org.mule.api.agent.Agent;
015: import org.mule.api.endpoint.EndpointBuilder;
016: import org.mule.api.endpoint.EndpointFactory;
017: import org.mule.api.endpoint.ImmutableEndpoint;
018: import org.mule.api.lifecycle.Disposable;
019: import org.mule.api.lifecycle.Initialisable;
020: import org.mule.api.model.Model;
021: import org.mule.api.service.Service;
022: import org.mule.api.transformer.Transformer;
023: import org.mule.api.transformer.TransformerException;
024: import org.mule.api.transport.Connector;
025:
026: import java.util.Collection;
027: import java.util.List;
028: import java.util.Map;
029: import java.util.Properties;
030:
031: public interface Registry extends Initialisable, Disposable {
032: public static final int SCOPE_IMMEDIATE = 0;
033: public static final int SCOPE_LOCAL = 1;
034: public static final int SCOPE_REMOTE = 2;
035:
036: public static final int DEFAULT_SCOPE = SCOPE_REMOTE;
037:
038: // /////////////////////////////////////////////////////////////////////////
039: // Lookup methods - these should NOT create a new object, only return existing ones
040: // /////////////////////////////////////////////////////////////////////////
041:
042: /** Look up a single object by name. */
043: Object lookupObject(String key);
044:
045: /** Look up a single object by name. */
046: Object lookupObject(String key, int scope);
047:
048: /** Look up all objects of a given type. */
049: Collection lookupObjects(Class type);
050:
051: /** Look up all objects of a given type. */
052: Collection lookupObjects(Class type, int scope);
053:
054: /** Look up a single object by type. */
055: Object lookupObject(Class type) throws RegistrationException;
056:
057: /** Look up a single object by type. */
058: Object lookupObject(Class type, int scope)
059: throws RegistrationException;
060:
061: // TODO Not sure these methods are needed since the generic ones above can be used.
062:
063: Connector lookupConnector(String name);
064:
065: /**
066: * Looks-up endpoint builders which can be used to repeatably create endpoints with the same configuration.
067: * These endpoint builder are either global endpoints or they are builders used to create named
068: * endpoints configured on routers and exception strategies.
069: */
070: EndpointBuilder lookupEndpointBuilder(String name);
071:
072: EndpointFactory lookupEndpointFactory();
073:
074: Transformer lookupTransformer(String name);
075:
076: Service lookupService(String component);
077:
078: /**
079: * This method will return a list of {@link org.mule.api.transformer.Transformer} objects that accept the given
080: * input and return the given output type of object
081: *
082: * @param input The desiered input type for the transformer
083: * @param output the desired output type for the transformer
084: * @return a list of matching transformers. If there were no matchers an empty list is returned.
085: */
086: List lookupTransformers(Class input, Class output);
087:
088: /**
089: * Will find a transformer that is the closest match to the desired input and output.
090: *
091: * @param input The desiered input type for the transformer
092: * @param output the desired output type for the transformer
093: * @return A transformer that exactly matches or the will accept the input and output parameters
094: * @throws TransformerException will be thrown if there is more than one match
095: */
096: Transformer lookupTransformer(Class input, Class output)
097: throws TransformerException;
098:
099: Collection/*<Service>*/lookupServices(String model);
100:
101: Collection/*<Service>*/lookupServices();
102:
103: Model lookupModel(String name);
104:
105: Model lookupSystemModel();
106:
107: Agent lookupAgent(String agentName);
108:
109: /** @deprecated Use lookupModel() instead */
110: Collection getModels();
111:
112: /** @deprecated Use lookupConnector() instead */
113: Collection getConnectors();
114:
115: /** @deprecated Use lookupEndpoint() instead */
116: Collection getEndpoints();
117:
118: /** @deprecated Use lookupAgent() instead */
119: Collection getAgents();
120:
121: /** @deprecated Use lookupTransformer() instead */
122: Collection getTransformers();
123:
124: // /////////////////////////////////////////////////////////////////////////
125: // Registration methods
126: // /////////////////////////////////////////////////////////////////////////
127:
128: void registerObject(String key, Object value)
129: throws RegistrationException;
130:
131: void registerObject(String key, Object value, Object metadata)
132: throws RegistrationException;
133:
134: void registerObjects(Map objects) throws RegistrationException;
135:
136: void unregisterObject(String key) throws MuleException;
137:
138: // TODO MULE-2139 The following methods are Mule-specific and should be split out into a separate class;
139: // leave this one as a "pure" registry interface.
140:
141: void registerConnector(Connector connector) throws MuleException;
142:
143: void unregisterConnector(String connectorName) throws MuleException;
144:
145: //TODO MULE-2494
146: void registerEndpoint(ImmutableEndpoint endpoint)
147: throws MuleException;
148:
149: //TODO MULE-2494
150: void unregisterEndpoint(String endpointName) throws MuleException;
151:
152: public void registerEndpointBuilder(String name,
153: EndpointBuilder builder) throws MuleException;
154:
155: void registerTransformer(Transformer transformer)
156: throws MuleException;
157:
158: void unregisterTransformer(String transformerName)
159: throws MuleException;
160:
161: void registerService(Service service) throws MuleException;
162:
163: void unregisterService(String serviceName) throws MuleException;
164:
165: void registerModel(Model model) throws MuleException;
166:
167: void unregisterModel(String modelName) throws MuleException;
168:
169: void registerAgent(Agent agent) throws MuleException;
170:
171: void unregisterAgent(String agentName) throws MuleException;
172:
173: // /////////////////////////////////////////////////////////////////////////
174: // Creation methods
175: // /////////////////////////////////////////////////////////////////////////
176:
177: // TODO These methods are a mess (they blur lookup with creation, uris with names). Need to clean this up.
178:
179: ServiceDescriptor lookupServiceDescriptor(String type, String name,
180: Properties overrides) throws ServiceException;
181:
182: // /////////////////////////////////////////////////////////////////////////
183: // Registry Metadata
184: // /////////////////////////////////////////////////////////////////////////
185:
186: Registry getParent();
187:
188: void setParent(Registry registry);
189:
190: String getRegistryId();
191:
192: boolean isReadOnly();
193:
194: boolean isRemote();
195:
196: void setDefaultScope(int scope);
197:
198: int getDefaultScope();
199:
200: boolean isInitialised();
201:
202: boolean isInitialising();
203:
204: boolean isDisposed();
205:
206: boolean isDisposing();
207: }
|