org.mule.module.guice
Class GuiceRegistry

java.lang.Object
  extended by org.mule.registry.AbstractRegistry
      extended by org.mule.module.guice.GuiceRegistry
All Implemented Interfaces:
Disposable, Initialisable, Registry

public class GuiceRegistry
extends AbstractRegistry

The internal Mule interface for retreiving objects from a Guice injector. This registry is read-only since all objects should be configured by Module objects. The lifecycle of objects will be managed by Mule since Guice does not provide lifecycle support.

To create modules extend the AbstractMuleGuiceModule since it provides hooks and helpers for working with Mule configuration. Any modules independent of Mule can just extend the Guice AbstractModule as normal.

Mule will discover modules on the classpath, if you need to configure a module before passing it to the Guice injector you need to implement a GuiceModuleFactory for your module.

See Also:
AbstractMuleGuiceModule, GuiceModuleFactory

Field Summary
 
Fields inherited from class org.mule.registry.AbstractRegistry
lifecycleManager, logger, muleContext
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
GuiceRegistry(MuleContext muleContext)
           
 
Method Summary
protected  void doDispose()
           
protected  void doInitialise()
           
 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.
 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 org.mule.registry.AbstractRegistry
createLifecycleManager, dispose, fireLifecycle, get, getLifecycleManager, getRegistryId, initialise, lookupObjectsForLifecycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuiceRegistry

public GuiceRegistry(MuleContext muleContext)
Method Detail

doInitialise

protected void doInitialise()
                     throws InitialisationException
Specified by:
doInitialise in class AbstractRegistry
Throws:
InitialisationException

doDispose

protected void doDispose()
Specified by:
doDispose in class AbstractRegistry

lookupObject

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

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
Overrides:
lookupObject in class AbstractRegistry
Returns:
object or null if not found
Throws:
RegistrationException - if more than one object is found.

lookupByType

public <T> Map<String,T> lookupByType(Class<T> type)
Returns:
key/object pairs

lookupObjects

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

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.

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.

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

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.

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.

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

isReadOnly

public boolean isReadOnly()

isRemote

public boolean isRemote()


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