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