Coverage Report - org.mule.providers.AbstractMessageDispatcherFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMessageDispatcherFactory
50%
8/16
50%
1/2
1
 
 1  
 /*
 2  
  * $Id: AbstractMessageDispatcherFactory.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.providers;
 12  
 
 13  
 import org.mule.umo.UMOException;
 14  
 import org.mule.umo.endpoint.UMOImmutableEndpoint;
 15  
 import org.mule.umo.provider.UMOMessageDispatcher;
 16  
 import org.mule.umo.provider.UMOMessageDispatcherFactory;
 17  
 import org.mule.util.ClassUtils;
 18  
 
 19  
 /**
 20  
  * <code>AbstractMessageDispatcherFactory</code> is a base implementation of the
 21  
  * <code>UMOMessageDispatcherFactory</code> interface for managing the lifecycle of
 22  
  * message dispatchers.
 23  
  * 
 24  
  * @see UMOMessageDispatcherFactory
 25  
  */
 26  
 public abstract class AbstractMessageDispatcherFactory implements UMOMessageDispatcherFactory
 27  
 {
 28  
 
 29  
     public AbstractMessageDispatcherFactory()
 30  
     {
 31  778
         super();
 32  778
     }
 33  
 
 34  
     /**
 35  
      * This default implementation of
 36  
      * {@link UMOMessageDispatcherFactory#isCreateDispatcherPerRequest()} returns
 37  
      * <code>false</code>, which means that dispatchers are pooled according to
 38  
      * their lifecycle as described in {@link UMOMessageDispatcher}.
 39  
      * 
 40  
      * @return <code>false</code> by default, unless overwritten by a subclass.
 41  
      */
 42  
     public boolean isCreateDispatcherPerRequest()
 43  
     {
 44  10
         return false;
 45  
     }
 46  
 
 47  
     public abstract UMOMessageDispatcher create(UMOImmutableEndpoint endpoint) throws UMOException;
 48  
 
 49  
     public void activate(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher) throws UMOException
 50  
     {
 51  10
         dispatcher.activate();
 52  10
     }
 53  
 
 54  
     public void destroy(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher)
 55  
     {
 56  0
         dispatcher.dispose();
 57  0
     }
 58  
 
 59  
     public void passivate(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher)
 60  
     {
 61  10
         dispatcher.passivate();
 62  10
     }
 63  
 
 64  
     public boolean validate(UMOImmutableEndpoint endpoint, UMOMessageDispatcher dispatcher)
 65  
     {
 66  
         // Unless dispatchers are to be disposed of after every request, we check if
 67  
         // the dispatcher is still valid or has e.g. disposed itself after an
 68  
         // exception.
 69  10
         return (this.isCreateDispatcherPerRequest() ? false : dispatcher.validate());
 70  
     }
 71  
 
 72  
     // @Override
 73  
     public String toString()
 74  
     {
 75  0
         final StringBuffer sb = new StringBuffer(60);
 76  0
         sb.append(ClassUtils.getSimpleName(this.getClass()));
 77  0
         sb.append("{this=").append(Integer.toHexString(System.identityHashCode(this)));
 78  0
         sb.append(", createDispatcherPerRequest=").append(this.isCreateDispatcherPerRequest());
 79  0
         sb.append('}');
 80  0
         return sb.toString();
 81  
     }
 82  
 
 83  
 }