Coverage Report - org.mule.config.pool.CommonsPoolProxyFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
CommonsPoolProxyFactory
87%
13/15
N/A
1.286
 
 1  
 /*
 2  
  * $Id: CommonsPoolProxyFactory.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.config.pool;
 12  
 
 13  
 import org.mule.config.i18n.CoreMessages;
 14  
 import org.mule.impl.MuleDescriptor;
 15  
 import org.mule.umo.lifecycle.InitialisationException;
 16  
 import org.mule.umo.model.UMOModel;
 17  
 
 18  
 import org.apache.commons.beanutils.BeanUtils;
 19  
 import org.apache.commons.pool.PoolableObjectFactory;
 20  
 
 21  
 /**
 22  
  * <code>CommonsPoolProxyFactory</code> is used to create MuleProxies for use in a
 23  
  * proxy pool. This is a Jakarta commons-pool implementation.
 24  
  */
 25  
 public class CommonsPoolProxyFactory extends AbstractProxyFactory implements PoolableObjectFactory
 26  
 {
 27  
     /**
 28  
      * Creates a pool factory using the descriptor as the basis for creating its
 29  
      * objects
 30  
      * 
 31  
      * @param descriptor the descriptor to use to construct a MuleProxy
 32  
      * @see MuleDescriptor
 33  
      */
 34  
     public CommonsPoolProxyFactory(MuleDescriptor descriptor, UMOModel model)
 35  
     {
 36  52
         super(descriptor, model);
 37  52
     }
 38  
 
 39  
     public void activateObject(Object arg0) throws Exception
 40  
     {
 41  
         // nothing to do
 42  70
     }
 43  
 
 44  
     public void destroyObject(Object object) throws Exception
 45  
     {
 46  26
         pool.onRemove(object);
 47  26
     }
 48  
 
 49  
     public Object makeObject() throws Exception
 50  
     {
 51  68
         Object object = create();
 52  58
         pool.onAdd(object);
 53  58
         return object;
 54  
     }
 55  
 
 56  
     public void passivateObject(Object arg0) throws Exception
 57  
     {
 58  
         // nothing to do
 59  38
     }
 60  
 
 61  
     public boolean validateObject(Object arg0)
 62  
     {
 63  2
         return true;
 64  
     }
 65  
 
 66  
     protected void afterComponentCreate(Object component) throws InitialisationException
 67  
     {
 68  
         try
 69  
         {
 70  70
             BeanUtils.populate(component, descriptor.getProperties());
 71  
         }
 72  0
         catch (Exception e)
 73  
         {
 74  0
             throw new InitialisationException(
 75  
                 CoreMessages.failedToSetPropertiesOn("Component '" + descriptor.getName() + "'"), 
 76  
                 e, descriptor);
 77  70
         }
 78  70
     }
 79  
 
 80  
 }