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