public class MuleRegistryHelper extends Object implements MuleRegistry, RegistryProvider
| Modifier and Type | Field and Description |
|---|---|
protected ConcurrentHashMap |
exactTransformerCache
We cache transformer searches so that we only search once
|
protected org.apache.commons.logging.Log |
logger |
protected ConcurrentHashMap |
transformerListCache |
INJECT_PROCESSORS_BYPASS_FLAG, LIFECYCLE_BYPASS_FLAG, PRE_INIT_PROCESSORS_BYPASS_FLAGPHASE_NAMEPHASE_NAME| Constructor and Description |
|---|
MuleRegistryHelper(DefaultRegistryBroker registry,
MuleContext muleContext) |
| Modifier and Type | Method and Description |
|---|---|
Object |
applyLifecycle(Object object)
Will fire any lifecycle methods according to the current lifecycle without actually
registering the object in the registry.
|
Object |
applyLifecycle(Object object,
String phase)
Will fire the given lifecycle
phase without actually
registering the object in the registry. |
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)
Deprecated.
|
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) |
<T> T |
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()
Deprecated.
|
protected String |
getName(Object obj)
Returns the name for the object passed in.
|
Collection<Registry> |
getRegistries()
Returns an immutable view of all active
Registry instances for
the current MuleContext. |
String |
getRegistryId() |
Collection<Transformer> |
getTransformers() |
void |
initialise()
Method used to perform any initialisation work.
|
boolean |
isReadOnly() |
boolean |
isRemote() |
Agent |
lookupAgent(String name) |
<T> Map<String,T> |
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() |
<T> Collection<T> |
lookupLocalObjects(Class<T> type)
Look up all objects of a given type within the local registry.
|
Model |
lookupModel(String name)
Deprecated.
|
<T> T |
lookupObject(Class<T> type)
Look up a single object by type.
|
<T> T |
lookupObject(String key)
Look up a single object by name.
|
<T> T |
lookupObject(String key,
boolean applyLifecycle)
Look up a single object by name.
|
<T> Collection<T> |
lookupObjects(Class<T> type)
Look up all objects of a given type.
|
<T> Collection<T> |
lookupObjectsForLifecycle(Class<T> type)
Look up all objects of a given type that lifecycle should be applied to.
|
Collection<Scheduler> |
lookupScheduler(Predicate<String> schedulerNamePredicate) |
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()
Deprecated.
|
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 |
postObjectRegistrationActions(Object value) |
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)
Deprecated.
|
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 |
registerScheduler(Scheduler scheduler) |
void |
registerService(Service service) |
void |
registerTransformer(Transformer transformer) |
void |
registerTransformerResolver(TransformerResolver value) |
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)
Deprecated.
|
Object |
unregisterObject(String key)
Will remove an object by name from the registry.
|
Object |
unregisterObject(String key,
Object metadata)
Will remove an object by name from the registry.
|
void |
unregisterScheduler(Scheduler scheduler) |
void |
unregisterService(String serviceName) |
void |
unregisterTransformer(String transformerName) |
protected transient org.apache.commons.logging.Log logger
protected ConcurrentHashMap exactTransformerCache
protected ConcurrentHashMap transformerListCache
public MuleRegistryHelper(DefaultRegistryBroker registry, MuleContext muleContext)
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 InitialisableInitialisationException - if a fatal error occurs causing the Mule instance to shutdownRecoverableException - if an error occurs that can be recovered frompublic void dispose()
dispose in interface Disposablepublic void fireLifecycle(String phase) throws LifecycleException
fireLifecycle in interface RegistryLifecycleExceptionpublic Connector lookupConnector(String name)
lookupConnector in interface MuleRegistrypublic EndpointBuilder lookupEndpointBuilder(String name)
lookupEndpointBuilder in interface MuleRegistryname - the name of the endpointBuilder to findpublic EndpointFactory lookupEndpointFactory()
lookupEndpointFactory in interface MuleRegistrypublic 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
directlylookupTransformer in interface MuleRegistryinputType - The desiered input type for the transformeroutputType - the desired output type for the transformerTransformerException - 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
directlyTransformer objects that accept the given
input and return the given output type of objectlookupTransformers in interface MuleRegistryinput - The desiered input type for the transformeroutput - the desired output type for the transformerpublic Transformer lookupTransformer(DataType source, DataType result) throws TransformerException
lookupTransformer in interface MuleRegistrysource - The desiered input type for the transformerresult - the desired output type for the transformerTransformerException - will be thrown if there is more than one matchprotected Transformer resolveTransformer(DataType source, DataType result) throws TransformerException
TransformerExceptionpublic List<Transformer> lookupTransformers(DataType source, DataType result)
Transformer objects that accept the given
input and return the given output type of objectlookupTransformers in interface MuleRegistrysource - The desired input type for the transformerresult - the desired output type for the transformer@Deprecated public Model lookupModel(String name)
lookupModel in interface MuleRegistry@Deprecated public Model lookupSystemModel()
lookupSystemModel in interface MuleRegistry@Deprecated public Collection<Model> getModels()
getModels in interface MuleRegistrypublic Collection<Connector> getConnectors()
getConnectors in interface MuleRegistrypublic Collection<Agent> getAgents()
getAgents in interface MuleRegistrypublic Collection<ImmutableEndpoint> getEndpoints()
getEndpoints in interface MuleRegistrypublic Collection<Transformer> getTransformers()
getTransformers in interface MuleRegistrypublic Agent lookupAgent(String name)
lookupAgent in interface MuleRegistrypublic Service lookupService(String name)
lookupService in interface MuleRegistrypublic Collection<Service> lookupServices()
lookupServices in interface MuleRegistrypublic Collection<Service> lookupServices(String model)
lookupServices in interface MuleRegistrypublic FlowConstruct lookupFlowConstruct(String name)
lookupFlowConstruct in interface MuleRegistrypublic Collection<FlowConstruct> lookupFlowConstructs()
lookupFlowConstructs in interface MuleRegistrypublic final void registerTransformer(Transformer transformer) throws MuleException
registerTransformer in interface MuleRegistryMuleExceptionpublic void notifyTransformerResolvers(Transformer t, TransformerResolver.RegistryAction action)
public ServiceDescriptor lookupServiceDescriptor(ServiceType type, String name, Properties overrides) throws ServiceException
lookupServiceDescriptor in interface MuleRegistryServiceExceptionprotected ServiceDescriptor createServiceDescriptor(ServiceType type, String name, Properties overrides) throws ServiceException
ServiceExceptionpublic void registerAgent(Agent agent) throws MuleException
registerAgent in interface MuleRegistryMuleExceptionpublic void registerConnector(Connector connector) throws MuleException
registerConnector in interface MuleRegistryMuleExceptionpublic void registerEndpoint(ImmutableEndpoint endpoint) throws MuleException
registerEndpoint in interface MuleRegistryMuleExceptionpublic void registerEndpointBuilder(String name, EndpointBuilder builder) throws MuleException
registerEndpointBuilder in interface MuleRegistryMuleException@Deprecated public void registerModel(Model model) throws MuleException
registerModel in interface MuleRegistryMuleExceptionpublic void registerService(Service service) throws MuleException
registerService in interface MuleRegistryMuleExceptionpublic void unregisterService(String serviceName) throws MuleException
unregisterService in interface MuleRegistryMuleExceptionpublic void registerFlowConstruct(FlowConstruct flowConstruct) throws MuleException
registerFlowConstruct in interface MuleRegistryMuleExceptionpublic void unregisterFlowConstruct(String flowConstructName) throws MuleException
unregisterFlowConstruct in interface MuleRegistryMuleExceptionpublic void unregisterAgent(String agentName) throws MuleException
unregisterAgent in interface MuleRegistryMuleExceptionpublic void registerScheduler(Scheduler scheduler) throws MuleException
registerScheduler in interface MuleRegistryMuleExceptionpublic void unregisterScheduler(Scheduler scheduler) throws MuleException
unregisterScheduler in interface MuleRegistryMuleExceptionpublic Collection<Scheduler> lookupScheduler(Predicate<String> schedulerNamePredicate)
lookupScheduler in interface MuleRegistrypublic void unregisterConnector(String connectorName) throws MuleException
unregisterConnector in interface MuleRegistryMuleExceptionpublic void unregisterEndpoint(String endpointName) throws MuleException
unregisterEndpoint in interface MuleRegistryMuleException@Deprecated public void unregisterModel(String modelName) throws MuleException
unregisterModel in interface MuleRegistryMuleExceptionpublic void unregisterTransformer(String transformerName) throws MuleException
unregisterTransformer in interface MuleRegistryMuleExceptionpublic Object applyProcessorsAndLifecycle(Object object) throws MuleException
applyProcessorsAndLifecycle in interface MuleRegistryobject - the object to processMuleException - 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 MuleRegistryobject - the object to processMuleException - if the registry fails to process object processors for the object.@Deprecated public Object applyProcessors(Object object, int flags) throws MuleException
applyProcessors in interface MuleRegistryobject - the object to processflags - MuleRegistry flags which control which injectors will be appliedMuleException - if the registry fails to process object processors for the object.public Object applyLifecycle(Object object) throws MuleException
applyLifecycle in interface LifecycleRegistryobject - the object to processMuleException - if the registry fails to perform the lifecycle change for the object.public Object applyLifecycle(Object object, String phase) throws MuleException
phase without actually
registering the object in the registry. This is useful for prototype objects that are created per request and would
clutter the registry with single use objects.applyLifecycle in interface LifecycleRegistryobject - the object to processphase - the specific lifecycle phase you want to fireMuleException - if the registry fails to perform the lifecycle change for the object.public <T> T lookupObject(Class<T> type) throws RegistrationException
lookupObject in interface RegistryRegistrationException - if more than one object is found.public <T> T lookupObject(String key)
lookupObject in interface Registrypublic <T> T lookupObject(String key, boolean applyLifecycle)
Registry.lookupObject(String) will
return objects which had lifecycle phases
applied,this method exists for cases in which
you want to specify that lifecycle is not to be
applied. The actual semantics of that actually depends
on the implementation, since invoking this method
might return a new instance or an already existing one.
If an existing one is returned, then the lifecycle might
have been previously applied regardless.lookupObject in interface LifecycleRegistrykey - the key of the object you're looking forapplyLifecycle - if lifecycle should be applied to the returned object.
Passing true doesn't guarantee that the lifecycle is appliednull if not foundpublic <T> Collection<T> lookupObjects(Class<T> type)
lookupObjects in interface Registrypublic <T> Collection<T> lookupLocalObjects(Class<T> type)
RegistrylookupLocalObjects in interface Registrypublic <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 Registrypublic <T> T get(String key)
Registrypublic <T> Map<String,T> lookupByType(Class<T> type)
lookupByType in interface Registrypublic void registerObject(String key, Object value, Object metadata) throws RegistrationException
registerObject in interface Registrykey - 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 methodRegistrationException - if an object with the same key already existspublic void postObjectRegistrationActions(Object value)
public void registerObject(String key, Object value) throws RegistrationException
registerObject in interface Registrykey - 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 valueRegistrationException - if an object with the same key already existspublic void registerTransformerResolver(TransformerResolver value)
public void registerObjects(Map objects) throws RegistrationException
registerObjects in interface Registryobjects - a map of key value pairs, each will individually be registered in the registryRegistrationException - if an object with the same key already existspublic Object unregisterObject(String key, Object metadata) throws RegistrationException
unregisterObject in interface Registrykey - the name or key of the object to remove from the registrymetadata - an implementation specific argument that can be passed into the methodRegistrationException - if there is a problem unregistering the object. Typically this will be because
the object's lifecycle threw an exceptionpublic Object unregisterObject(String key) throws RegistrationException
unregisterObject in interface Registrykey - the name or key of the object to remove from the registrynull if no object was registered under that keyRegistrationException - if there is a problem unregistering the object. Typically this will be because
the object's lifecycle threw an exceptionpublic Collection<Registry> getRegistries()
RegistryProviderRegistry instances for
the current MuleContext.
Collections returned by this method will not remain synced with
the MuleContext. If a Registry is added or removed this
Collection will not be automatically updated.getRegistries in interface RegistryProviderprotected 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 inspectpublic String getRegistryId()
getRegistryId in interface Registrypublic boolean isReadOnly()
isReadOnly in interface RegistryCopyright © 2003–2015 MuleSoft, Inc.. All rights reserved.