Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.object
Class AbstractObjectFactory

    java.lang.Object
      org.mule.object.AbstractObjectFactory

All Implemented Interfaces:
  FlowConstructAware, Disposable, Initialisable, ObjectFactory

Direct Known Subclasses:
  PrototypeObjectFactory, SingletonObjectFactory, SpringBeanLookup

    public abstract class AbstractObjectFactory

extends Object
implements ObjectFactory, FlowConstructAware

Creates object instances based on the class and sets any properties. This factory is also responsible for applying any object processors on the object before the lifecycle callbacks are called.

Field Summary
`static String` | `ATTRIBUTE_OBJECT_CLASS`
`static String` | `ATTRIBUTE_OBJECT_CLASS_NAME`
`protected boolean` | `disposed`
`protected FlowConstruct` | `flowConstruct`
`protected List<InitialisationCallback>` | `initialisationCallbacks`
`protected Log` | `logger`
`protected Class<?>` | `objectClass`
`protected String` | `objectClassName`
`protected Map` | `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
`AbstractObjectFactory()` For Spring only
`AbstractObjectFactory(Class<?> objectClass)`
`AbstractObjectFactory(Class<?> objectClass, Map properties)`
`AbstractObjectFactory(String objectClassName)`
`AbstractObjectFactory(String objectClassName, Map properties)`

Method Summary
`void` | `addObjectInitialisationCallback(InitialisationCallback callback)` Register a custom initialiser
`void` | `dispose()` A lifecycle method where implementor should free up any resources.
`protected void` | `fireInitialisationCallbacks(Object component)`
`Object` | `getInstance(MuleContext muleContext)` Creates an initialized object instance based on the class and sets any properties.
`Class<?>` | `getObjectClass()` Returns the class of the object to be instantiated without actually creating an instance.
`protected String` | `getObjectClassName()`
`protected Map` | `getProperties()`
`void` | `initialise()` Method used to perform any initialisation work.
`boolean` | `isAutoWireObject()` Return true if the created object should get its dependencies wired from the registry automatically.
`boolean` | `isExternallyManagedLifecycle()` Returns true if Mule should not manage the life-cycle the object instance returned from the ObjectFactory.
`boolean` | `isSingleton()` Returns true if the ObjectFactory implementation always returns the same object instance.
`void` | `setFlowConstruct(FlowConstruct flowConstruct)`
`void` | `setObjectClass(Class<?> objectClass)`
`void` | `setObjectClassName(String objectClassName)`
`void` | `setProperties(Map properties)`
`protected Class<?>` | `setupObjectClassFromObjectClassName()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ATTRIBUTE_OBJECT_CLASS_NAME

    public static final String ATTRIBUTE_OBJECT_CLASS_NAME

See Also:
  Constant Field Values

### ATTRIBUTE_OBJECT_CLASS

    public static final String ATTRIBUTE_OBJECT_CLASS

See Also:
  Constant Field Values

### objectClassName

    protected String objectClassName

### objectClass

    protected Class<?> objectClass

### properties

    protected Map properties

### initialisationCallbacks

    protected List<InitialisationCallback> initialisationCallbacks

### flowConstruct

    protected FlowConstruct flowConstruct

### disposed

    protected boolean disposed

### logger

    protected transient Log logger

Constructor Detail

### AbstractObjectFactory

    public AbstractObjectFactory()

  For Spring only

### AbstractObjectFactory

    public AbstractObjectFactory(String objectClassName)

### AbstractObjectFactory

    public AbstractObjectFactory(String objectClassName,
                                 Map properties)

### AbstractObjectFactory

    public AbstractObjectFactory(Class<?> objectClass)

### AbstractObjectFactory

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

Method Detail

### setupObjectClassFromObjectClassName

    protected Class<?> setupObjectClassFromObjectClassName()

### setFlowConstruct

    public void setFlowConstruct(FlowConstruct flowConstruct)

  Specified by:
    `setFlowConstruct` in interface `FlowConstructAware`

### 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`

### getInstance

    public Object getInstance(MuleContext muleContext)
                       throws Exception

  Creates an initialized object instance based on the class and sets any properties. This method handles all injection of properties for the resulting object

  Specified by:
    `getInstance` in interface `ObjectFactory`
  Parameters:
    `muleContext` - the current `MuleContext` instance. This can be used for performing registry lookups applying processors to newly created objects or even firing custom notifications
  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

### fireInitialisationCallbacks

    protected void fireInitialisationCallbacks(Object component)
                                        throws InitialisationException

  Throws:
    `InitialisationException`

### 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`

### setObjectClass

    public void setObjectClass(Class<?> objectClass)

### getObjectClassName

    protected String getObjectClassName()

### setObjectClassName

    public void setObjectClassName(String objectClassName)

### getProperties

    protected Map getProperties()

### setProperties

    public void setProperties(Map properties)

### addObjectInitialisationCallback

    public void addObjectInitialisationCallback(InitialisationCallback callback)

  Description copied from interface: `ObjectFactory`
  Register a custom initialiser

  Specified by:
    `addObjectInitialisationCallback` in interface `ObjectFactory`

### 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`

### isExternallyManagedLifecycle

    public boolean isExternallyManagedLifecycle()

  Description copied from interface: `ObjectFactory`
  Returns true if Mule should not manage the life-cycle the object instance returned from the ObjectFactory. This is normally false except when an ObjectFactory implementation obtains instance from containers (e.g. Spring) that already manages the objects lifecycle. instance.

  Specified by:
    `isExternallyManagedLifecycle` in interface `ObjectFactory`

### isAutoWireObject

    public boolean isAutoWireObject()

  Description copied from interface: `ObjectFactory`
  Return true if the created object should get its dependencies wired from the registry automatically. Typically Mule object factories would return true for this value, objects managed by DI container such as Spring should set this to false.

  Specified by:
    `isAutoWireObject` in interface `ObjectFactory`
  Returns:

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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