org.mule.registry
Class AbstractRegistryBroker

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

public abstract class AbstractRegistryBroker
extends Object
implements RegistryBroker


Field Summary
protected  RegistryBrokerLifecycleManager lifecycleManager
           
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
AbstractRegistryBroker(MuleContext muleContext)
           
 
Method Summary
 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.
protected abstract  Collection<Registry> getRegistries()
           
 String getRegistryId()
           
 void initialise()
          Method used to perform any initialisation work.
 boolean isReadOnly()
           
 boolean isRemote()
           
<T> Map<String,T>
lookupByType(Class<T> type)
           
<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.
 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 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.
 
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.RegistryBroker
addRegistry, removeRegistry
 

Field Detail

lifecycleManager

protected RegistryBrokerLifecycleManager lifecycleManager
Constructor Detail

AbstractRegistryBroker

public AbstractRegistryBroker(MuleContext muleContext)
Method Detail

initialise

public 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

dispose

public 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

fireLifecycle

public void fireLifecycle(String phase)
                   throws LifecycleException
Specified by:
fireLifecycle in interface Registry
Throws:
LifecycleException

getRegistryId

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

isReadOnly

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

isRemote

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

getRegistries

protected abstract Collection<Registry> getRegistries()

get

public <T> T get(String key)
Description copied from interface: Registry
Alias method performing the lookup, here to simplify syntax when called from dynamic languages.

Specified by:
get in interface Registry

lookupObject

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

Specified by:
lookupObject in interface Registry
Returns:
object or null if not found

lookupObject

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

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

lookupObjects

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

Specified by:
lookupObjects in interface Registry
Returns:
collection of objects or empty collection if none found

lookupByType

public <T> Map<String,T> lookupByType(Class<T> type)
Specified by:
lookupByType in interface Registry
Returns:
key/object pairs

lookupObjectsForLifecycle

public <T> Collection<T> lookupObjectsForLifecycle(Class<T> type)
Description copied from interface: Registry
Look up all objects of a given type that lifecycle should be applied to. This method differs from 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.

Specified by:
lookupObjectsForLifecycle in interface Registry
Returns:
collection of objects or empty collection if none found

registerObject

public void registerObject(String key,
                           Object value)
                    throws RegistrationException
Description copied from interface: Registry
Registers an object in the registry with a key.

Specified by:
registerObject in interface Registry
Parameters:
key - the key to store the value against. This is a non-null value
value - the object to store in the registry. This is a non-null value
Throws:
RegistrationException - if an object with the same key already exists

registerObject

public void registerObject(String key,
                           Object value,
                           Object metadata)
                    throws RegistrationException
Description copied from interface: Registry
Registers an object in the registry with a key.

Specified by:
registerObject in interface Registry
Parameters:
key - the key to store the value against. This is a non-null value
value - the object to store in the registry. This is a non-null value
metadata - an implementation specific argument that can be passed into the method
Throws:
RegistrationException - if an object with the same key already exists

registerObjects

public void registerObjects(Map objects)
                     throws RegistrationException
Description copied from interface: Registry
Registers a Map of objects into the registry

Specified by:
registerObjects in interface Registry
Parameters:
objects - a map of key value pairs, each will individually be registered in the registry
Throws:
RegistrationException - if an object with the same key already exists

unregisterObject

public void unregisterObject(String key)
                      throws RegistrationException
Description copied from interface: Registry
Will remove an object by name from the registry. By default the registry must apply all remaining lifecycle phases to the object when it is removed.

Specified by:
unregisterObject in interface Registry
Parameters:
key - the name or key of the object to remove from the registry
Throws:
RegistrationException - if there is a problem unregistering the object. Typically this will be because the object's lifecycle threw an exception

unregisterObject

public void unregisterObject(String key,
                             Object metadata)
                      throws RegistrationException
Description copied from interface: Registry
Will remove an object by name from the registry. By default the registry must apply all remaining lifecycle phases to the object when it is removed.

Specified by:
unregisterObject in interface Registry
Parameters:
key - the name or key of the object to remove from the registry
metadata - an implementation specific argument that can be passed into the method
Throws:
RegistrationException - if there is a problem unregistering the object. Typically this will be because the object's lifecycle threw an exception


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.