|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mule.registry.MuleRegistryHelper
public class MuleRegistryHelper
Adds lookup/register/unregister methods for Mule-specific entities to the standard Registry interface.
Field Summary | |
---|---|
protected ConcurrentHashMap |
exactTransformerCache
We cache transformer searches so that we only search once |
protected Log |
logger
|
protected ConcurrentHashMap |
transformerListCache
|
Fields inherited from interface org.mule.api.registry.MuleRegistry |
---|
INJECT_PROCESSORS_BYPASS_FLAG, LIFECYCLE_BYPASS_FLAG, PRE_INIT_PROCESSORS_BYPASS_FLAG |
Fields inherited from interface org.mule.api.lifecycle.Initialisable |
---|
PHASE_NAME |
Fields inherited from interface org.mule.api.lifecycle.Disposable |
---|
PHASE_NAME |
Constructor Summary | |
---|---|
MuleRegistryHelper(DefaultRegistryBroker registry,
MuleContext muleContext)
|
Method Summary | ||
---|---|---|
Object |
applyLifecycle(Object object)
Will execute any lifecycle phases on an object without actually registering the object in the registry. |
|
Object |
applyLifecycle(Object object,
String phase)
|
|
Object |
applyProcessors(Object object)
Will execute any processors on an object without actually registering the object in the registry. |
|
Object |
applyProcessors(Object object,
int flags)
Will execute any processors on an object without actually registering the object in the registry. |
|
Object |
applyProcessorsAndLifecycle(Object object)
Will execute any processors on an object and fire any lifecycle methods according to the current lifecycle without actually registering the object in the registry. |
|
protected ServiceDescriptor |
createServiceDescriptor(ServiceType type,
String name,
Properties overrides)
|
|
void |
dispose()
A lifecycle method where implementor should free up any resources. |
|
void |
fireLifecycle(String phase)
|
|
|
get(String key)
Alias method performing the lookup, here to simplify syntax when called from dynamic languages. |
|
Collection<Agent> |
getAgents()
|
|
Collection<Connector> |
getConnectors()
|
|
Collection<ImmutableEndpoint> |
getEndpoints()
|
|
Collection<Model> |
getModels()
|
|
protected String |
getName(Object obj)
Returns the name for the object passed in. |
|
String |
getRegistryId()
|
|
Collection<Transformer> |
getTransformers()
|
|
void |
initialise()
Method used to perform any initialisation work. |
|
boolean |
isReadOnly()
|
|
boolean |
isRemote()
|
|
Agent |
lookupAgent(String name)
|
|
|
lookupByType(Class<T> type)
|
|
Connector |
lookupConnector(String name)
|
|
EndpointBuilder |
lookupEndpointBuilder(String name)
Looks-up endpoint builders which can be used to repeatably create endpoints with the same configuration. |
|
EndpointFactory |
lookupEndpointFactory()
|
|
FlowConstruct |
lookupFlowConstruct(String name)
|
|
Collection<FlowConstruct> |
lookupFlowConstructs()
|
|
Model |
lookupModel(String name)
|
|
|
lookupObject(Class<T> type)
Look up a single object by type. |
|
|
lookupObject(String key)
Look up a single object by name. |
|
|
lookupObjects(Class<T> type)
Look up all objects of a given type. |
|
|
lookupObjectsForLifecycle(Class<T> type)
Look up all objects of a given type that lifecycle should be applied to. |
|
Service |
lookupService(String name)
|
|
ServiceDescriptor |
lookupServiceDescriptor(ServiceType type,
String name,
Properties overrides)
Looks up the service descriptor from a singleton cache and creates a new one if not found. |
|
Collection<Service> |
lookupServices()
|
|
Collection<Service> |
lookupServices(String model)
|
|
Model |
lookupSystemModel()
|
|
Transformer |
lookupTransformer(Class inputType,
Class outputType)
Deprecated. use lookupTransformer(org.mule.api.transformer.DataType, org.mule.api.transformer.DataType) instead. This
method should only be used internally to discover transformers, typically a user does not need ot do this
directly |
|
Transformer |
lookupTransformer(DataType source,
DataType result)
Will find a transformer that is the closest match to the desired input and output. |
|
Transformer |
lookupTransformer(String name)
|
|
List<Transformer> |
lookupTransformers(Class input,
Class output)
Deprecated. use lookupTransformer(org.mule.api.transformer.DataType, org.mule.api.transformer.DataType) instead. This
method should only be used internally to discover transformers, typically a user does not need ot do this
directly |
|
List<Transformer> |
lookupTransformers(DataType source,
DataType result)
This method will return a list of Transformer objects that accept the given
input and return the given output type of object |
|
void |
notifyTransformerResolvers(Transformer t,
TransformerResolver.RegistryAction action)
|
|
void |
registerAgent(Agent agent)
|
|
void |
registerConnector(Connector connector)
|
|
void |
registerEndpoint(ImmutableEndpoint endpoint)
|
|
void |
registerEndpointBuilder(String name,
EndpointBuilder builder)
|
|
void |
registerFlowConstruct(FlowConstruct flowConstruct)
|
|
void |
registerModel(Model model)
|
|
void |
registerObject(String key,
Object value)
Registers an object in the registry with a key. |
|
void |
registerObject(String key,
Object value,
Object metadata)
Registers an object in the registry with a key. |
|
void |
registerObjects(Map objects)
Registers a Map of objects into the registry |
|
void |
registerService(Service service)
|
|
void |
registerTransformer(Transformer transformer)
|
|
protected Transformer |
resolveTransformer(DataType source,
DataType result)
|
|
void |
unregisterAgent(String agentName)
|
|
void |
unregisterConnector(String connectorName)
|
|
void |
unregisterEndpoint(String endpointName)
|
|
void |
unregisterFlowConstruct(String flowConstructName)
|
|
void |
unregisterModel(String modelName)
|
|
void |
unregisterObject(String key)
Will remove an object by name from the registry. |
|
void |
unregisterObject(String key,
Object metadata)
Will remove an object by name from the registry. |
|
void |
unregisterService(String serviceName)
|
|
void |
unregisterTransformer(String transformerName)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient Log logger
protected ConcurrentHashMap exactTransformerCache
protected ConcurrentHashMap transformerListCache
Constructor Detail |
---|
public MuleRegistryHelper(DefaultRegistryBroker registry, MuleContext muleContext)
Method Detail |
---|
public void initialise() throws InitialisationException
InitialisationException
should be thrown,
causing the Mule instance to shutdown. If the error is recoverable, say by
retrying to connect, a RecoverableException
should be thrown.
There is no guarantee that by throwing a Recoverable exception that the Mule
instance will not shut down.
initialise
in interface Initialisable
InitialisationException
- if a fatal error occurs causing the Mule instance to shutdown
RecoverableException
- if an error occurs that can be recovered frompublic void dispose()
dispose
in interface Disposable
public void fireLifecycle(String phase) throws LifecycleException
fireLifecycle
in interface Registry
LifecycleException
public Connector lookupConnector(String name)
lookupConnector
in interface MuleRegistry
public EndpointBuilder lookupEndpointBuilder(String name)
lookupEndpointBuilder
in interface MuleRegistry
name
- the name of the endpointBuilder to find
public EndpointFactory lookupEndpointFactory()
lookupEndpointFactory
in interface MuleRegistry
public Transformer lookupTransformer(String name)
lookupTransformer
in interface MuleRegistry
@Deprecated public Transformer lookupTransformer(Class inputType, Class outputType) throws TransformerException
lookupTransformer(org.mule.api.transformer.DataType, org.mule.api.transformer.DataType)
instead. This
method should only be used internally to discover transformers, typically a user does not need ot do this
directly
lookupTransformer
in interface MuleRegistry
inputType
- The desiered input type for the transformeroutputType
- the desired output type for the transformer
TransformerException
- will be thrown if there is more than one match@Deprecated public List<Transformer> lookupTransformers(Class input, Class output)
lookupTransformer(org.mule.api.transformer.DataType, org.mule.api.transformer.DataType)
instead. This
method should only be used internally to discover transformers, typically a user does not need ot do this
directly
Transformer
objects that accept the given
input and return the given output type of object
lookupTransformers
in interface MuleRegistry
input
- The desiered input type for the transformeroutput
- the desired output type for the transformer
public Transformer lookupTransformer(DataType source, DataType result) throws TransformerException
lookupTransformer
in interface MuleRegistry
source
- The desiered input type for the transformerresult
- the desired output type for the transformer
TransformerException
- will be thrown if there is more than one matchprotected Transformer resolveTransformer(DataType source, DataType result) throws TransformerException
TransformerException
public List<Transformer> lookupTransformers(DataType source, DataType result)
Transformer
objects that accept the given
input and return the given output type of object
lookupTransformers
in interface MuleRegistry
source
- The desired input type for the transformerresult
- the desired output type for the transformer
public Model lookupModel(String name)
lookupModel
in interface MuleRegistry
public Model lookupSystemModel()
lookupSystemModel
in interface MuleRegistry
public Collection<Model> getModels()
getModels
in interface MuleRegistry
public Collection<Connector> getConnectors()
getConnectors
in interface MuleRegistry
public Collection<Agent> getAgents()
getAgents
in interface MuleRegistry
public Collection<ImmutableEndpoint> getEndpoints()
getEndpoints
in interface MuleRegistry
public Collection<Transformer> getTransformers()
getTransformers
in interface MuleRegistry
public Agent lookupAgent(String name)
lookupAgent
in interface MuleRegistry
public Service lookupService(String name)
lookupService
in interface MuleRegistry
public Collection<Service> lookupServices()
lookupServices
in interface MuleRegistry
public Collection<Service> lookupServices(String model)
lookupServices
in interface MuleRegistry
public FlowConstruct lookupFlowConstruct(String name)
lookupFlowConstruct
in interface MuleRegistry
public Collection<FlowConstruct> lookupFlowConstructs()
lookupFlowConstructs
in interface MuleRegistry
public final void registerTransformer(Transformer transformer) throws MuleException
registerTransformer
in interface MuleRegistry
MuleException
public void notifyTransformerResolvers(Transformer t, TransformerResolver.RegistryAction action)
public ServiceDescriptor lookupServiceDescriptor(ServiceType type, String name, Properties overrides) throws ServiceException
lookupServiceDescriptor
in interface MuleRegistry
ServiceException
protected ServiceDescriptor createServiceDescriptor(ServiceType type, String name, Properties overrides) throws ServiceException
ServiceException
public void registerAgent(Agent agent) throws MuleException
registerAgent
in interface MuleRegistry
MuleException
public void registerConnector(Connector connector) throws MuleException
registerConnector
in interface MuleRegistry
MuleException
public void registerEndpoint(ImmutableEndpoint endpoint) throws MuleException
registerEndpoint
in interface MuleRegistry
MuleException
public void registerEndpointBuilder(String name, EndpointBuilder builder) throws MuleException
registerEndpointBuilder
in interface MuleRegistry
MuleException
public void registerModel(Model model) throws MuleException
registerModel
in interface MuleRegistry
MuleException
public void registerService(Service service) throws MuleException
registerService
in interface MuleRegistry
MuleException
public void unregisterService(String serviceName) throws MuleException
unregisterService
in interface MuleRegistry
MuleException
public void registerFlowConstruct(FlowConstruct flowConstruct) throws MuleException
registerFlowConstruct
in interface MuleRegistry
MuleException
public void unregisterFlowConstruct(String flowConstructName) throws MuleException
unregisterFlowConstruct
in interface MuleRegistry
MuleException
public void unregisterAgent(String agentName) throws MuleException
unregisterAgent
in interface MuleRegistry
MuleException
public void unregisterConnector(String connectorName) throws MuleException
unregisterConnector
in interface MuleRegistry
MuleException
public void unregisterEndpoint(String endpointName) throws MuleException
unregisterEndpoint
in interface MuleRegistry
MuleException
public void unregisterModel(String modelName) throws MuleException
unregisterModel
in interface MuleRegistry
MuleException
public void unregisterTransformer(String transformerName) throws MuleException
unregisterTransformer
in interface MuleRegistry
MuleException
public Object applyProcessorsAndLifecycle(Object object) throws MuleException
applyProcessorsAndLifecycle
in interface MuleRegistry
object
- the object to process
MuleException
- if the registry fails to perform the lifecycle change or process object processors for the object.public Object applyProcessors(Object object) throws MuleException
applyProcessors
in interface MuleRegistry
object
- the object to process
MuleException
- if the registry fails to process object processors for the object.public Object applyProcessors(Object object, int flags) throws MuleException
applyProcessors
in interface MuleRegistry
object
- the object to processflags
- MuleRegistry
flags which control which injectors will be applied
MuleException
- if the registry fails to process object processors for the object.public Object applyLifecycle(Object object) throws MuleException
applyLifecycle
in interface MuleRegistry
object
- the object to apply the current lifecycle state to
MuleException
- if the registry fails to execute a lifecycle method.public Object applyLifecycle(Object object, String phase) throws MuleException
applyLifecycle
in interface MuleRegistry
MuleException
public <T> T lookupObject(Class<T> type) throws RegistrationException
lookupObject
in interface Registry
RegistrationException
- if more than one object is found.public <T> T lookupObject(String key)
Registry
lookupObject
in interface Registry
public <T> Collection<T> lookupObjects(Class<T> type)
lookupObjects
in interface Registry
public <T> Collection<T> lookupObjectsForLifecycle(Class<T> type)
Registry.lookupObjects(Class)
in that it allows
implementations to provide an alternative implementation of lookup for
lifecycle. For example only returning pre-existing objects and not creating
new ones on the fly.
lookupObjectsForLifecycle
in interface Registry
public <T> T get(String key)
Registry
get
in interface Registry
public <T> Map<String,T> lookupByType(Class<T> type)
lookupByType
in interface Registry
public void registerObject(String key, Object value, Object metadata) throws RegistrationException
registerObject
in interface Registry
key
- the key to store the value against. This is a non-null valuevalue
- the object to store in the registry. This is a non-null valuemetadata
- an implementation specific argument that can be passed into the method
RegistrationException
- if an object with the same key already existspublic void registerObject(String key, Object value) throws RegistrationException
registerObject
in interface Registry
key
- the key to store the value against. This is a non-null valuevalue
- the object to store in the registry. This is a non-null value
RegistrationException
- if an object with the same key already existspublic void registerObjects(Map objects) throws RegistrationException
registerObjects
in interface Registry
objects
- a map of key value pairs, each will individually be registered in the registry
RegistrationException
- if an object with the same key already existspublic void unregisterObject(String key, Object metadata) throws RegistrationException
unregisterObject
in interface Registry
key
- the name or key of the object to remove from the registrymetadata
- an implementation specific argument that can be passed into the method
RegistrationException
- if there is a problem unregistering the object. Typically this will be because
the object's lifecycle threw an exceptionpublic void unregisterObject(String key) throws RegistrationException
unregisterObject
in interface Registry
key
- the name or key of the object to remove from the registry
RegistrationException
- if there is a problem unregistering the object. Typically this will be because
the object's lifecycle threw an exceptionprotected String getName(Object obj)
NameableObject
, then
NamedObject.getName()
will be returned, otherwise a name is generated using the class name
and a generated UUID.
obj
- the object to inspect
public String getRegistryId()
getRegistryId
in interface Registry
public boolean isReadOnly()
isReadOnly
in interface Registry
public boolean isRemote()
isRemote
in interface Registry
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |