org.mule.object
Class SingletonObjectFactory

java.lang.Object
  extended by org.mule.object.AbstractObjectFactory
      extended by org.mule.object.SingletonObjectFactory
All Implemented Interfaces:
FlowConstructAware, Disposable, Initialisable, ObjectFactory

public class SingletonObjectFactory
extends AbstractObjectFactory

Creates an instance of the object once and then always returns the same instance.


Field Summary
 
Fields inherited from class org.mule.object.AbstractObjectFactory
ATTRIBUTE_OBJECT_CLASS, ATTRIBUTE_OBJECT_CLASS_NAME, disposed, flowConstruct, initialisationCallbacks, logger, objectClass, objectClassName, properties
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
SingletonObjectFactory()
          For Spring only
SingletonObjectFactory(Class objectClass)
           
SingletonObjectFactory(Class<?> objectClass, Map properties)
           
SingletonObjectFactory(Object instance)
          Create the singleton based on a previously created object.
SingletonObjectFactory(String objectClassName)
           
SingletonObjectFactory(String objectClassName, Map properties)
           
 
Method Summary
 void dispose()
          A lifecycle method where implementor should free up any resources.
 Object getInstance(MuleContext muleContext)
          Always returns the same instance of the object.
 Class<?> getObjectClass()
          Returns the class of the object to be instantiated without actually creating an instance.
 boolean isSingleton()
          Returns true if the ObjectFactory implementation always returns the same object instance.
 
Methods inherited from class org.mule.object.AbstractObjectFactory
addObjectInitialisationCallback, fireInitialisationCallbacks, getObjectClassName, getProperties, initialise, isAutoWireObject, isExternallyManagedLifecycle, setFlowConstruct, setObjectClass, setObjectClassName, setProperties, setupObjectClassFromObjectClassName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingletonObjectFactory

public SingletonObjectFactory()
For Spring only


SingletonObjectFactory

public SingletonObjectFactory(String objectClassName)

SingletonObjectFactory

public SingletonObjectFactory(String objectClassName,
                              Map properties)

SingletonObjectFactory

public SingletonObjectFactory(Class objectClass)

SingletonObjectFactory

public SingletonObjectFactory(Class<?> objectClass,
                              Map properties)

SingletonObjectFactory

public SingletonObjectFactory(Object instance)
Create the singleton based on a previously created object.

Method Detail

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
Overrides:
dispose in class AbstractObjectFactory

getInstance

public Object getInstance(MuleContext muleContext)
                   throws Exception
Always returns the same instance of the object.

Specified by:
getInstance in interface ObjectFactory
Overrides:
getInstance in class AbstractObjectFactory
Parameters:
muleContext -
Returns:
A new instance of an object. The factory may decide to return the same instance each type or create a new instance each time
Throws:
Exception - Can throw any type of exception while creating a new object

getObjectClass

public Class<?> getObjectClass()
Description copied from interface: ObjectFactory
Returns the class of the object to be instantiated without actually creating an instance. This may not be logical or even possible depending on the implementation.

Specified by:
getObjectClass in interface ObjectFactory
Overrides:
getObjectClass in class AbstractObjectFactory

isSingleton

public boolean isSingleton()
Description copied from interface: ObjectFactory
Returns true if the ObjectFactory implementation always returns the same object instance.

Specified by:
isSingleton in interface ObjectFactory
Overrides:
isSingleton in class AbstractObjectFactory


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