1 /* 2 * $Id: ObjectFactory.java 11376 2008-03-16 17:44:10Z dfeist $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 11 package org.mule.api.object; 12 13 import org.mule.api.lifecycle.Disposable; 14 import org.mule.api.lifecycle.Initialisable; 15 import org.mule.api.lifecycle.InitialisationCallback; 16 17 /** 18 * <code>ObjectFactory</code> is a generic Factory interface. 19 */ 20 public interface ObjectFactory extends Initialisable, Disposable 21 { 22 /** 23 * Retrieve an instance of the object. This may create a new instance or look up 24 * an existing instance depending on the implementation. If a new instance is 25 * created it will also be initialized by this method 26 * (Initilisable.initialise()). 27 */ 28 Object getInstance() throws Exception; 29 30 /** 31 * Returns the class of the object to be instantiated without actually creating 32 * an instance. This may not be logical or even possible depending on the 33 * implementation. 34 */ 35 Class getObjectClass(); 36 37 /** 38 * Returns true if the ObjectFactory implementation always returns the same object 39 * instance. 40 * 41 * @return 42 */ 43 boolean isSingleton(); 44 45 /** 46 * Register a custom initialiser 47 */ 48 void addObjectInitialisationCallback(InitialisationCallback callback); 49 50 }