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.slf4j.Logger |
logger |
protected ConcurrentHashMap |
transformerListCache |
INJECT_PROCESSORS_BYPASS_FLAG, LIFECYCLE_BYPASS_FLAG, PRE_INIT_PROCESSORS_BYPASS_FLAG| 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. |
void |
applyLifecycle(Object object,
String startPhase,
String toPhase)
Applies lifecycle phase to an object independent of the current lifecycle phase.
|
Object |
applyProcessors(Object object)
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.
|
void |
dispose() |
void |
fireLifecycle(String phase) |
<T> T |
get(String key)
Alias method performing the lookup, here to simplify syntax when called from dynamic languages.
|
MuleContext |
getMuleContext() |
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() |
void |
initialise() |
boolean |
isReadOnly() |
boolean |
isRemote() |
Agent |
lookupAgent(String name) |
<T> Map<String,T> |
lookupByType(Class<T> type) |
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.
|
<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.
|
Transformer |
lookupTransformer(org.mule.runtime.api.metadata.DataType source,
org.mule.runtime.api.metadata.DataType result)
Will find a transformer that is the closest match to the desired input and output.
|
Transformer |
lookupTransformer(String name) |
List<Transformer> |
lookupTransformers(org.mule.runtime.api.metadata.DataType source,
org.mule.runtime.api.metadata.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 |
registerFlowConstruct(FlowConstruct flowConstruct) |
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 |
registerTransformer(Transformer transformer) |
void |
registerTransformerResolver(TransformerResolver value) |
protected Transformer |
resolveTransformer(org.mule.runtime.api.metadata.DataType source,
org.mule.runtime.api.metadata.DataType result) |
void |
unregisterAgent(String agentName) |
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 |
unregisterTransformer(String transformerName) |
protected transient org.slf4j.Logger logger
protected ConcurrentHashMap exactTransformerCache
protected ConcurrentHashMap transformerListCache
public MuleRegistryHelper(DefaultRegistryBroker registry, MuleContext muleContext)
public void initialise()
throws org.mule.runtime.api.lifecycle.InitialisationException
initialise in interface org.mule.runtime.api.lifecycle.Initialisableorg.mule.runtime.api.lifecycle.InitialisationExceptionpublic void dispose()
dispose in interface org.mule.runtime.api.lifecycle.Disposablepublic void fireLifecycle(String phase) throws org.mule.runtime.api.lifecycle.LifecycleException
fireLifecycle in interface Registryorg.mule.runtime.api.lifecycle.LifecycleExceptionpublic MuleContext getMuleContext()
public Transformer lookupTransformer(String name)
lookupTransformer in interface MuleRegistrypublic Transformer lookupTransformer(org.mule.runtime.api.metadata.DataType source, org.mule.runtime.api.metadata.DataType result) throws TransformerException
lookupTransformer in interface MuleRegistrysource - The desired input type for the transformerresult - the desired output type for the transformerTransformerException - will be thrown if there is more than one matchprotected Transformer resolveTransformer(org.mule.runtime.api.metadata.DataType source, org.mule.runtime.api.metadata.DataType result) throws TransformerException
TransformerExceptionpublic List<Transformer> lookupTransformers(org.mule.runtime.api.metadata.DataType source, org.mule.runtime.api.metadata.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 transformerpublic Agent lookupAgent(String name)
lookupAgent in interface MuleRegistrypublic FlowConstruct lookupFlowConstruct(String name)
lookupFlowConstruct in interface MuleRegistrypublic Collection<FlowConstruct> lookupFlowConstructs()
lookupFlowConstructs in interface MuleRegistrypublic final void registerTransformer(Transformer transformer) throws org.mule.runtime.api.exception.MuleException
registerTransformer in interface MuleRegistryorg.mule.runtime.api.exception.MuleExceptionpublic void notifyTransformerResolvers(Transformer t, TransformerResolver.RegistryAction action)
public void registerAgent(Agent agent) throws org.mule.runtime.api.exception.MuleException
registerAgent in interface MuleRegistryorg.mule.runtime.api.exception.MuleExceptionpublic void registerFlowConstruct(FlowConstruct flowConstruct) throws org.mule.runtime.api.exception.MuleException
registerFlowConstruct in interface MuleRegistryorg.mule.runtime.api.exception.MuleExceptionpublic void unregisterAgent(String agentName) throws org.mule.runtime.api.exception.MuleException
unregisterAgent in interface MuleRegistryorg.mule.runtime.api.exception.MuleExceptionpublic void unregisterTransformer(String transformerName) throws org.mule.runtime.api.exception.MuleException
unregisterTransformer in interface MuleRegistryorg.mule.runtime.api.exception.MuleExceptionpublic Object applyProcessorsAndLifecycle(Object object) throws org.mule.runtime.api.exception.MuleException
applyProcessorsAndLifecycle in interface MuleRegistryobject - the object to processorg.mule.runtime.api.exception.MuleException - if the registry fails to perform the lifecycle change or process object
processors for the object.public Object applyProcessors(Object object) throws org.mule.runtime.api.exception.MuleException
applyProcessors in interface MuleRegistryobject - the object to processorg.mule.runtime.api.exception.MuleException - if the registry fails to process object processors for the object.public Object applyLifecycle(Object object) throws org.mule.runtime.api.exception.MuleException
applyLifecycle in interface LifecycleRegistryobject - the object to processorg.mule.runtime.api.exception.MuleException - if the registry fails to perform the lifecycle change for the object.public Object applyLifecycle(Object object, String phase) throws org.mule.runtime.api.exception.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 fireorg.mule.runtime.api.exception.MuleException - if the registry fails to perform the lifecycle change for the object.public void applyLifecycle(Object object, String startPhase, String toPhase) throws org.mule.runtime.api.exception.MuleException
LifecycleRegistrystartPhase
and the endPhase will be executed.applyLifecycle in interface LifecycleRegistryobject - the object to apply lifecycle tostartPhase - the lifecycle phase the object is currently in. Must not be null.toPhase - the lifecycle phase to transition the object to. Must not be null.org.mule.runtime.api.exception.MuleException - if there is an exception while invoking lifecycle on the objectpublic <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 RegistryProviderpublic 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–2017 MuleSoft, Inc.. All rights reserved.