public class MuleRegistryHelper extends Object implements MuleRegistry
Modifier and Type | Field and Description |
---|---|
protected ConcurrentHashMap |
exactTransformerCache
We cache transformer searches so that we only search once
|
protected Log |
logger |
protected ConcurrentHashMap |
transformerListCache |
INJECT_PROCESSORS_BYPASS_FLAG, LIFECYCLE_BYPASS_FLAG, PRE_INIT_PROCESSORS_BYPASS_FLAG
PHASE_NAME
PHASE_NAME
Constructor and Description |
---|
MuleRegistryHelper(DefaultRegistryBroker registry,
MuleContext muleContext) |
Modifier and Type | Method and Description |
---|---|
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) |
<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.
|
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> 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 |
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) |
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.
|
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 |
unregisterScheduler(Scheduler scheduler) |
void |
unregisterService(String serviceName) |
void |
unregisterTransformer(String transformerName) |
protected transient 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 Initialisable
InitialisationException
- 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 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 findpublic 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
directlylookupTransformer
in interface MuleRegistry
inputType
- 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 MuleRegistry
input
- 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 MuleRegistry
source
- 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
TransformerException
public List<Transformer> lookupTransformers(DataType source, DataType result)
Transformer
objects that accept the given
input and return the given output type of objectlookupTransformers
in interface MuleRegistry
source
- 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 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
@Deprecated 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 registerScheduler(Scheduler scheduler) throws MuleException
registerScheduler
in interface MuleRegistry
MuleException
public void unregisterScheduler(Scheduler scheduler) throws MuleException
unregisterScheduler
in interface MuleRegistry
MuleException
public Collection<Scheduler> lookupScheduler(Predicate<String> schedulerNamePredicate)
lookupScheduler
in interface MuleRegistry
public void unregisterConnector(String connectorName) throws MuleException
unregisterConnector
in interface MuleRegistry
MuleException
public void unregisterEndpoint(String endpointName) throws MuleException
unregisterEndpoint
in interface MuleRegistry
MuleException
@Deprecated 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 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 MuleRegistry
object
- the object to processMuleException
- 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 appliedMuleException
- 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 toMuleException
- 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> lookupLocalObjects(Class<T> type)
Registry
lookupLocalObjects
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
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 methodRegistrationException
- 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 valueRegistrationException
- 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 registryRegistrationException
- 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 methodRegistrationException
- 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 registryRegistrationException
- 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 inspectpublic String getRegistryId()
getRegistryId
in interface Registry
public boolean isReadOnly()
isReadOnly
in interface Registry
Copyright © 2003–2015 MuleSoft, Inc.. All rights reserved.