KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > model > seda > optimised > OptimisedSedaComponent


1 /*
2  * $Id: OptimisedSedaComponent.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.impl.model.seda.optimised;
12
13 import org.mule.config.PoolingProfile;
14 import org.mule.config.i18n.Message;
15 import org.mule.config.i18n.Messages;
16 import org.mule.impl.MuleDescriptor;
17 import org.mule.impl.model.seda.SedaComponent;
18 import org.mule.umo.lifecycle.InitialisationException;
19
20 /**
21  * A Seda component runs inside a Seda Model and is responsible for managing a Seda
22  * Queue and thread pool for a Mule sevice component. In Seda terms this is
23  * equivilent to a stage.
24  *
25  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
26  * @version $Revision: 3798 $
27  */

28 public class OptimisedSedaComponent extends SedaComponent
29 {
30     /**
31      * Serial version
32      */

33     private static final long serialVersionUID = 4710126404530397113L;
34
35     /**
36      * Default constructor
37      */

38     public OptimisedSedaComponent(MuleDescriptor descriptor, OptimisedSedaModel model)
39     {
40         super(descriptor, model);
41     }
42
43     protected void initialisePool() throws InitialisationException
44     {
45         try
46         {
47             // Initialise the proxy pool
48

49             // overload the default Proxy Factory impl
50
proxyPool = descriptor.getPoolingProfile().getPoolFactory().createPool(descriptor,
51                 new OptimisedProxyFactory(descriptor));
52
53             if (descriptor.getPoolingProfile().getInitialisationPolicy() == PoolingProfile.POOL_INITIALISE_ALL_COMPONENTS)
54             {
55                 int threads = descriptor.getPoolingProfile().getMaxActive();
56                 for (int i = 0; i < threads; i++)
57                 {
58                     proxyPool.returnObject(proxyPool.borrowObject());
59                 }
60             }
61             else if (descriptor.getPoolingProfile().getInitialisationPolicy() == PoolingProfile.POOL_INITIALISE_ONE_COMPONENT)
62             {
63                 proxyPool.returnObject(proxyPool.borrowObject());
64             }
65             poolInitialised.set(true);
66         }
67         catch (Exception JavaDoc e)
68         {
69             throw new InitialisationException(new Message(Messages.X_FAILED_TO_INITIALISE, "Proxy Pool"), e,
70                 this);
71         }
72     }
73 }
74
Popular Tags