View Javadoc

1   /*
2    * $Id: OptimisedProxyFactory.java 7963 2007-08-21 08:53:15Z dirk.olmes $
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.impl.model.seda.optimised;
12  
13  import org.mule.config.pool.CommonsPoolProxyFactory;
14  import org.mule.impl.MuleDescriptor;
15  import org.mule.umo.UMOException;
16  import org.mule.umo.lifecycle.Callable;
17  import org.mule.umo.model.UMOModel;
18  
19  /**
20   * Creates an optimised Mule proxy for pooling which does away with the reflection
21   * and inteception on objects
22   */
23  public class OptimisedProxyFactory extends CommonsPoolProxyFactory
24  {
25      public OptimisedProxyFactory(MuleDescriptor descriptor, UMOModel model)
26      {
27          super(descriptor, model);
28      }
29  
30      protected Object createProxy(Object component) throws UMOException
31      {
32          if (!(component instanceof Callable))
33          {
34              throw new IllegalArgumentException("Components for the Optimised Mule proxy must implement: "
35                                                 + Callable.class.getName());
36          }
37          return new OptimisedMuleProxy((Callable) component, descriptor, pool);
38      }
39  }