org.mule.registry
Class AbstractRegistry

java.lang.Object
  extended by org.mule.registry.AbstractRegistry
All Implemented Interfaces:
Disposable, Initialisable, Registry
Direct Known Subclasses:
TransientRegistry

public abstract class AbstractRegistry
extends Object
implements Registry


Field Summary
protected  Map exactTransformerCache
           
protected  LifecycleManager lifecycleManager
           
protected  Log logger
           
protected  Map transformerListCache
           
 
Fields inherited from interface org.mule.api.registry.Registry
DEFAULT_SCOPE, SCOPE_IMMEDIATE, SCOPE_LOCAL, SCOPE_REMOTE
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
protected AbstractRegistry(String id)
          Default Constructor
protected AbstractRegistry(String id, Registry parent)
           
 
Method Summary
protected abstract  LifecycleManager createLifecycleManager()
           
 void dispose()
          A lifecycle method where implementor should free up any resources.
protected  void doDispose()
           
protected  void doInitialise()
           
protected abstract  Object doLookupObject(String key)
           
protected abstract  Collection doLookupObjects(Class type)
           
protected abstract  void doRegisterObject(String key, Object value, Object metadata)
           
protected abstract  void doRegisterTransformer(Transformer transformer)
           
 Collection getAgents()
           
 Collection getConnectors()
           
 int getDefaultScope()
           
 Collection getEndpoints()
           
protected  LifecycleManager getLifecycleManager()
           
 Collection getModels()
           
protected  Transformer getNearestTransformerMatch(List trans, Class input, Class output)
           
 Registry getParent()
           
 String getRegistryId()
           
 Collection getTransformers()
           
 void initialise()
          Method used to perform any initialisation work.
 boolean isDisposed()
           
 boolean isDisposing()
           
 boolean isInitialised()
           
 boolean isInitialising()
           
 Agent lookupAgent(String name)
           
 Connector lookupConnector(String name)
           
 ImmutableEndpoint lookupEndpoint(String name)
          Removed this method from Registry API as it should only be used internally and may confuse users.
 EndpointBuilder lookupEndpointBuilder(String name)
          Looks-up endpoint builders which can be used to repeatably create endpoints with the same configuration.
 EndpointFactory lookupEndpointFactory()
           
 Model lookupModel(String name)
           
 Object lookupObject(Class type)
          Look up a single object by type.
 Object lookupObject(Class type, int scope)
          Look up a single object by type.
 Object lookupObject(String key)
          Look up a single object by name.
 Object lookupObject(String key, int scope)
          Look up a single object by name.
 Collection lookupObjects(Class type)
          Look up all objects of a given type.
 Collection lookupObjects(Class type, int scope)
          Look up all objects of a given type.
 Service lookupService(String name)
           
 Collection lookupServices()
           
 Collection lookupServices(String model)
           
 Model lookupSystemModel()
           
 Transformer lookupTransformer(Class inputType, Class outputType)
          Will find a transformer that is the closest match to the desired input and output.
 Transformer lookupTransformer(String name)
           
 List lookupTransformers(Class input, Class output)
          This method will return a list of Transformer objects that accept the given input and return the given output type of object
 void registerObject(String key, Object value)
           
 void registerObject(String key, Object value, Object metadata)
           
 void registerTransformer(Transformer transformer)
           
 void setDefaultScope(int scope)
           
 void setParent(Registry registry)
           
protected  void unsupportedOperation(String operation, Object o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mule.api.registry.Registry
isReadOnly, isRemote, lookupServiceDescriptor, registerAgent, registerConnector, registerEndpoint, registerEndpointBuilder, registerModel, registerObjects, registerService, unregisterAgent, unregisterConnector, unregisterEndpoint, unregisterModel, unregisterObject, unregisterService, unregisterTransformer
 

Field Detail

logger

protected transient Log logger

lifecycleManager

protected LifecycleManager lifecycleManager

transformerListCache

protected Map transformerListCache

exactTransformerCache

protected Map exactTransformerCache
Constructor Detail

AbstractRegistry

protected AbstractRegistry(String id)
Default Constructor


AbstractRegistry

protected AbstractRegistry(String id,
                           Registry parent)
Method Detail

createLifecycleManager

protected abstract LifecycleManager createLifecycleManager()

getLifecycleManager

protected LifecycleManager getLifecycleManager()

dispose

public final void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable

doDispose

protected void doDispose()

isDisposed

public boolean isDisposed()
Specified by:
isDisposed in interface Registry

isDisposing

public boolean isDisposing()
Specified by:
isDisposing in interface Registry

isInitialised

public boolean isInitialised()
Specified by:
isInitialised in interface Registry

isInitialising

public boolean isInitialising()
Specified by:
isInitialising in interface Registry

initialise

public final void initialise()
                      throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an 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.

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

doInitialise

protected void doInitialise()
                     throws InitialisationException
Throws:
InitialisationException

lookupConnector

public Connector lookupConnector(String name)
Specified by:
lookupConnector in interface Registry

lookupEndpoint

public ImmutableEndpoint lookupEndpoint(String name)
Removed this method from Registry API as it should only be used internally and may confuse users. The EndpointFactory should be used for creating endpoints.

Looks up an returns endpoints registered in the registry by their idendifier (currently endpoint name)

NOTE: This method does not create new endpoint instances, but rather returns existing endpoint instances that have been registered. This lookup method should be avoided and the intelligent, role specific endpoint lookup methods should be used instead.

Parameters:
name - the idendtifer/name used to register endpoint in registry
See Also:
#lookupInboundEndpoint(String, org.mule.api.MuleContext), #lookupResponseEndpoint(String, org.mule.api.MuleContext)

lookupEndpointBuilder

public EndpointBuilder lookupEndpointBuilder(String name)
Description copied from interface: Registry
Looks-up endpoint builders which can be used to repeatably create endpoints with the same configuration. These endpoint builder are either global endpoints or they are builders used to create named endpoints configured on routers and exception strategies.

Specified by:
lookupEndpointBuilder in interface Registry

lookupEndpointFactory

public EndpointFactory lookupEndpointFactory()
Specified by:
lookupEndpointFactory in interface Registry

lookupTransformer

public Transformer lookupTransformer(String name)
Specified by:
lookupTransformer in interface Registry

lookupTransformer

public Transformer lookupTransformer(Class inputType,
                                     Class outputType)
                              throws TransformerException
Will find a transformer that is the closest match to the desired input and output.

Specified by:
lookupTransformer in interface Registry
Parameters:
inputType - The desiered input type for the transformer
outputType - the desired output type for the transformer
Returns:
A transformer that exactly matches or the will accept the input and output parameters
Throws:
TransformerException - will be thrown if there is more than one match

getNearestTransformerMatch

protected Transformer getNearestTransformerMatch(List trans,
                                                 Class input,
                                                 Class output)
                                          throws TransformerException
Throws:
TransformerException

lookupTransformers

public List lookupTransformers(Class input,
                               Class output)
This method will return a list of Transformer objects that accept the given input and return the given output type of object

Specified by:
lookupTransformers in interface Registry
Parameters:
input - The desiered input type for the transformer
output - the desired output type for the transformer
Returns:
a list of matching transformers. If there were no matchers an empty list is returned.

lookupModel

public Model lookupModel(String name)
Specified by:
lookupModel in interface Registry

lookupSystemModel

public Model lookupSystemModel()
Specified by:
lookupSystemModel in interface Registry

getModels

public Collection getModels()
Specified by:
getModels in interface Registry

getConnectors

public Collection getConnectors()
Specified by:
getConnectors in interface Registry

getAgents

public Collection getAgents()
Specified by:
getAgents in interface Registry

getEndpoints

public Collection getEndpoints()
Specified by:
getEndpoints in interface Registry

getTransformers

public Collection getTransformers()
Specified by:
getTransformers in interface Registry

lookupAgent

public Agent lookupAgent(String name)
Specified by:
lookupAgent in interface Registry

lookupService

public Service lookupService(String name)
Specified by:
lookupService in interface Registry

lookupServices

public Collection lookupServices()
Specified by:
lookupServices in interface Registry

lookupServices

public Collection lookupServices(String model)
Specified by:
lookupServices in interface Registry

lookupObject

public final Object lookupObject(String key,
                                 int scope)
Description copied from interface: Registry
Look up a single object by name.

Specified by:
lookupObject in interface Registry

lookupObject

public final Object lookupObject(Class type)
                          throws RegistrationException
Description copied from interface: Registry
Look up a single object by type.

Specified by:
lookupObject in interface Registry
Throws:
RegistrationException

lookupObject

public final Object lookupObject(Class type,
                                 int scope)
                          throws RegistrationException
Look up a single object by type.

Specified by:
lookupObject in interface Registry
Returns:
null if no object is found
Throws:
RegistrationException - if more than one object is found

lookupObjects

public final Collection lookupObjects(Class type)
Description copied from interface: Registry
Look up all objects of a given type.

Specified by:
lookupObjects in interface Registry

lookupObjects

public final Collection lookupObjects(Class type,
                                      int scope)
Description copied from interface: Registry
Look up all objects of a given type.

Specified by:
lookupObjects in interface Registry

doLookupObjects

protected abstract Collection doLookupObjects(Class type)

lookupObject

public Object lookupObject(String key)
Description copied from interface: Registry
Look up a single object by name.

Specified by:
lookupObject in interface Registry

doLookupObject

protected abstract Object doLookupObject(String key)
Returns:
null if object not found

unsupportedOperation

protected void unsupportedOperation(String operation,
                                    Object o)
                             throws UnsupportedOperationException
Throws:
UnsupportedOperationException

registerObject

public final void registerObject(String key,
                                 Object value)
                          throws RegistrationException
Specified by:
registerObject in interface Registry
Throws:
RegistrationException

registerObject

public final void registerObject(String key,
                                 Object value,
                                 Object metadata)
                          throws RegistrationException
Specified by:
registerObject in interface Registry
Throws:
RegistrationException

doRegisterObject

protected abstract void doRegisterObject(String key,
                                         Object value,
                                         Object metadata)
                                  throws RegistrationException
Throws:
RegistrationException

registerTransformer

public final void registerTransformer(Transformer transformer)
                               throws MuleException
Specified by:
registerTransformer in interface Registry
Throws:
MuleException

doRegisterTransformer

protected abstract void doRegisterTransformer(Transformer transformer)
                                       throws MuleException
Throws:
MuleException

getRegistryId

public final String getRegistryId()
Specified by:
getRegistryId in interface Registry

getParent

public Registry getParent()
Specified by:
getParent in interface Registry

setParent

public void setParent(Registry registry)
Specified by:
setParent in interface Registry

getDefaultScope

public int getDefaultScope()
Specified by:
getDefaultScope in interface Registry

setDefaultScope

public void setDefaultScope(int scope)
Specified by:
setDefaultScope in interface Registry


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.