Coverage Report - org.mule.transport.AbstractMessageDispatcherFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMessageDispatcherFactory
0%
0/16
0%
0/2
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport;
 8  
 
 9  
 import org.mule.api.MuleException;
 10  
 import org.mule.api.endpoint.OutboundEndpoint;
 11  
 import org.mule.api.transport.MessageDispatcher;
 12  
 import org.mule.api.transport.MessageDispatcherFactory;
 13  
 import org.mule.util.ClassUtils;
 14  
 
 15  
 /**
 16  
  * <code>AbstractMessageDispatcherFactory</code> is a base implementation of the
 17  
  * <code>MessageDispatcherFactory</code> interface for managing the lifecycle of
 18  
  * message dispatchers.
 19  
  * 
 20  
  * @see MessageDispatcherFactory
 21  
  */
 22  
 public abstract class AbstractMessageDispatcherFactory implements MessageDispatcherFactory
 23  
 {
 24  
 
 25  
     public AbstractMessageDispatcherFactory()
 26  
     {
 27  0
         super();
 28  0
     }
 29  
 
 30  
     /**
 31  
      * This default implementation of
 32  
      * {@link MessageDispatcherFactory#isCreateDispatcherPerRequest()} returns
 33  
      * <code>false</code>, which means that dispatchers are pooled according to
 34  
      * their lifecycle as described in {@link MessageDispatcher}.
 35  
      * 
 36  
      * @return <code>false</code> by default, unless overwritten by a subclass.
 37  
      */
 38  
     public boolean isCreateDispatcherPerRequest()
 39  
     {
 40  0
         return false;
 41  
     }
 42  
 
 43  
     public abstract MessageDispatcher create(OutboundEndpoint endpoint) throws MuleException;
 44  
 
 45  
     public void activate(OutboundEndpoint endpoint, MessageDispatcher dispatcher) throws MuleException
 46  
     {
 47  0
         dispatcher.activate();
 48  0
     }
 49  
 
 50  
     public void destroy(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
 51  
     {
 52  0
         dispatcher.dispose();
 53  0
     }
 54  
 
 55  
     public void passivate(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
 56  
     {
 57  0
         dispatcher.passivate();
 58  0
     }
 59  
 
 60  
     public boolean validate(OutboundEndpoint endpoint, MessageDispatcher dispatcher)
 61  
     {
 62  
         // Unless dispatchers are to be disposed of after every request, we check if
 63  
         // the dispatcher is still valid or has e.g. disposed itself after an
 64  
         // exception.
 65  0
         return (this.isCreateDispatcherPerRequest() ? false : dispatcher.validate());
 66  
     }
 67  
 
 68  
     @Override
 69  
     public String toString()
 70  
     {
 71  0
         final StringBuffer sb = new StringBuffer(60);
 72  0
         sb.append(ClassUtils.getSimpleName(this.getClass()));
 73  0
         sb.append("{this=").append(Integer.toHexString(System.identityHashCode(this)));
 74  0
         sb.append(", createDispatcherPerRequest=").append(this.isCreateDispatcherPerRequest());
 75  0
         sb.append('}');
 76  0
         return sb.toString();
 77  
     }
 78  
 
 79  
 }