KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > config > pool > AbstractProxyFactory


1 /*
2  * $Id: AbstractProxyFactory.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.config.pool;
12
13 import org.mule.impl.MuleDescriptor;
14 import org.mule.impl.model.ComponentFactory;
15 import org.mule.impl.model.DefaultMuleProxy;
16 import org.mule.umo.UMOException;
17 import org.mule.umo.lifecycle.InitialisationException;
18 import org.mule.util.ObjectFactory;
19 import org.mule.util.ObjectPool;
20
21 /**
22  * <code>AbstractProxyFactory</code> provides common behaviour for creating proxy
23  * objects
24  *
25  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
26  * @version $Revision: 3798 $
27  */

28
29 public abstract class AbstractProxyFactory implements ObjectFactory
30 {
31     /**
32      * The UMODescriptor used to create new components in the pool
33      */

34     protected MuleDescriptor descriptor;
35     protected ObjectPool pool;
36
37     /**
38      * Creates a pool factory using the descriptor as the basis for creating its
39      * objects
40      *
41      * @param descriptor the descriptor to use to construct a MuleProxy
42      * @see org.mule.umo.UMODescriptor
43      */

44     public AbstractProxyFactory(MuleDescriptor descriptor)
45     {
46         this.descriptor = descriptor;
47     }
48
49     public Object JavaDoc create() throws UMOException
50     {
51         Object JavaDoc component = ComponentFactory.createComponent(descriptor);
52         afterComponentCreate(component);
53         return createProxy(component);
54     }
55
56     protected Object JavaDoc createProxy(Object JavaDoc component) throws UMOException
57     {
58         return new DefaultMuleProxy(component, descriptor, pool);
59     }
60
61     protected void afterComponentCreate(Object JavaDoc component) throws InitialisationException
62     {
63         // nothing to do
64
}
65
66     public ObjectPool getPool()
67     {
68         return pool;
69     }
70
71     public void setPool(ObjectPool pool)
72     {
73         this.pool = pool;
74     }
75 }
76
Popular Tags