public class SimpleRegistry extends TransientRegistry implements LifecycleRegistry, Injector
LifecycleRegistry
. Useful for starting really lightweight
contexts which don't depend on heavier object containers such as Spring or Guice (testing being
the best example).
The inject(Object)
operation will only consider fields annotated with Inject
and will perform
the injection using simple, not-cached reflection. Also, initialisation lifecycle will be performed
in pseudo-random order, no analysis will be done to ensure that dependencies of a given object
get their lifecycle before it.TransientRegistry.RegistryMap
lifecycleManager, logger, muleContext
PHASE_NAME
PHASE_NAME
Constructor and Description |
---|
SimpleRegistry(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. |
protected Object |
applyProcessors(Object object,
Object metadata) |
protected void |
doInitialise() |
protected void |
doRegisterObject(String key,
Object object,
Object metadata) |
<T> T |
inject(T object)
Injects dependencies into the given object
|
<T> T |
lookupObject(String key,
boolean applyLifecycle)
This implementation doesn't support applying lifecycle upon lookup
and thus this method simply delegates into
TransientRegistry.lookupObject(String) |
applyProcessors, checkDisposed, doDispose, doGet, doPut, doUnregisterObject, hasFlag, isReadOnly, isRemote, lookupByType, lookupLocalObjects, lookupObject, lookupObject, lookupObjects, registerObject, registerObject, registerObjects
createLifecycleManager, dispose, fireLifecycle, get, getLifecycleManager, getRegistryId, initialise, isInitialised, lookupObjectsForLifecycle, unregisterObject, unregisterObject
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
fireLifecycle, get, getRegistryId, isReadOnly, isRemote, lookupByType, lookupLocalObjects, lookupObject, lookupObject, lookupObjects, lookupObjectsForLifecycle, registerObject, registerObject, registerObjects, unregisterObject, unregisterObject
initialise
dispose
public SimpleRegistry(MuleContext muleContext)
protected void doInitialise() throws InitialisationException
doInitialise
in class TransientRegistry
InitialisationException
public <T> T lookupObject(String key, boolean applyLifecycle)
TransientRegistry.lookupObject(String)
lookupObject
in interface LifecycleRegistry
key
- 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 foundprotected void doRegisterObject(String key, Object object, Object metadata) throws RegistrationException
doRegisterObject
in class TransientRegistry
RegistrationException
public Object applyLifecycle(Object object) throws MuleException
TransientRegistry
applyLifecycle
in interface LifecycleRegistry
object
- the object to processMuleException
- if the registry fails to perform the lifecycle change for the object.public Object applyLifecycle(Object object, String phase) throws MuleException
LifecycleRegistry
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 LifecycleRegistry
object
- the object to processphase
- the specific lifecycle phase you want to fireMuleException
- if the registry fails to perform the lifecycle change for the object.public <T> T inject(T object)
Injector
protected Object applyProcessors(Object object, Object metadata)
applyProcessors
in class TransientRegistry
Copyright © 2003–2015 MuleSoft, Inc.. All rights reserved.