01: /*
02: * $Id: ObjectFactory.java 11376 2008-03-16 17:44:10Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: * Retrieve an instance of the object. This may create a new instance or look up
23: * an existing instance depending on the implementation. If a new instance is
24: * created it will also be initialized by this method
25: * (Initilisable.initialise()).
26: */
27: Object getInstance() throws Exception;
28:
29: /**
30: * Returns the class of the object to be instantiated without actually creating
31: * an instance. This may not be logical or even possible depending on the
32: * implementation.
33: */
34: Class getObjectClass();
35:
36: /**
37: * Returns true if the ObjectFactory implementation always returns the same object
38: * instance.
39: *
40: * @return
41: */
42: boolean isSingleton();
43:
44: /**
45: * Register a custom initialiser
46: */
47: void addObjectInitialisationCallback(InitialisationCallback callback);
48:
49: }
|