Coverage Report - org.mule.api.object.ObjectFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
ObjectFactory
N/A
N/A
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.api.object;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.lifecycle.Disposable;
 11  
 import org.mule.api.lifecycle.Initialisable;
 12  
 import org.mule.api.lifecycle.InitialisationCallback;
 13  
 
 14  
 /**
 15  
  * <code>ObjectFactory</code> is a generic Factory interface.
 16  
  */
 17  
 public interface ObjectFactory extends Initialisable, Disposable
 18  
 {
 19  
     /**
 20  
      * Retrieve an instance of the object. This may create a new instance or look up
 21  
      * an existing instance depending on the implementation. If a new instance is
 22  
      * created it will also be initialized by this method
 23  
      * (Initilisable.initialise()).
 24  
      * @param muleContext the current {@link org.mule.api.MuleContext} instance. This can be used for performing registry look-ups
 25  
      * applying processors to newly created objects or even firing custom notifications
 26  
      * @throws Exception if there is an exception thrown creating the new instance
 27  
      * @return A new instance of an object.  The factory may decide to return the same instance each type or create a new instance each time
 28  
      */
 29  
     Object getInstance(MuleContext muleContext) throws Exception;
 30  
 
 31  
     /**
 32  
      * Returns the class of the object to be instantiated without actually creating
 33  
      * an instance. This may not be logical or even possible depending on the
 34  
      * implementation.
 35  
      */
 36  
     Class<?> getObjectClass();
 37  
 
 38  
     /**
 39  
      * Returns true if the ObjectFactory implementation always returns the same object
 40  
      * instance.
 41  
      */
 42  
     boolean isSingleton();
 43  
 
 44  
     /**
 45  
      * Returns true if Mule should not manage the life-cycle the object instance returned from the ObjectFactory.
 46  
      * This is normally false except when an ObjectFactory implementation obtains instance from containers
 47  
      * (e.g. Spring) that already manages the objects lifecycle.
 48  
      * instance.
 49  
      */
 50  
     boolean isExternallyManagedLifecycle();
 51  
 
 52  
     /**
 53  
      * Return true if the created object should get its dependencies wired from the registry automatically.  Typically
 54  
      * Mule object factories would return true for this value, objects managed by DI container such as Spring should
 55  
      * set this to false.
 56  
      */
 57  
     boolean isAutoWireObject();
 58  
 
 59  
     /**
 60  
      * Register a custom initialiser
 61  
      */
 62  
     void addObjectInitialisationCallback(InitialisationCallback callback);
 63  
 
 64  
 }