Coverage Report - org.mule.routing.inbound.WireTap
 
Classes in this File Line Coverage Branch Coverage Complexity
WireTap
0%
0/17
0%
0/3
2.25
 
 1  
 /*
 2  
  * $Id: WireTap.java 7976 2007-08-21 14:26:13Z 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.routing.inbound;
 12  
 
 13  
 import org.mule.MuleManager;
 14  
 import org.mule.impl.ImmutableMuleEndpoint;
 15  
 import org.mule.umo.MessagingException;
 16  
 import org.mule.umo.UMOEvent;
 17  
 import org.mule.umo.UMOException;
 18  
 import org.mule.umo.endpoint.UMOImmutableEndpoint;
 19  
 
 20  
 /**
 21  
  * An inbound router that can forward every message to another destination as defined
 22  
  * in the "endpoint" property. This can be a logical destination of a URI. <p/> A
 23  
  * filter can be applied to this router so that only events matching a criteria will
 24  
  * be tapped.
 25  
  */
 26  0
 public class WireTap extends SelectiveConsumer
 27  
 {
 28  
     private volatile String endpoint;
 29  
     private volatile UMOImmutableEndpoint tap;
 30  
 
 31  
     public boolean isMatch(UMOEvent event) throws MessagingException
 32  
     {
 33  0
         if (endpoint != null)
 34  
         {
 35  0
             return super.isMatch(event);
 36  
         }
 37  
         else
 38  
         {
 39  0
             logger.warn("No endpoint identifier is set on this wire tap");
 40  0
             return false;
 41  
         }
 42  
     }
 43  
 
 44  
     public UMOEvent[] process(UMOEvent event) throws MessagingException
 45  
     {
 46  
         try
 47  
         {
 48  0
             event.getSession().dispatchEvent(event.getMessage(), tap);
 49  
         }
 50  0
         catch (UMOException e)
 51  
         {
 52  
             // TODO MULE-863: What should we really do?
 53  0
             logger.error(e.getMessage(), e);
 54  0
         }
 55  0
         return super.process(event);
 56  
     }
 57  
 
 58  
     public String getEndpoint()
 59  
     {
 60  0
         return endpoint;
 61  
     }
 62  
 
 63  
     public void setEndpoint(String endpoint) throws UMOException
 64  
     {
 65  0
         this.endpoint = endpoint;
 66  0
         if (this.endpoint != null)
 67  
         {
 68  0
             tap = MuleManager.getInstance().lookupEndpoint(this.endpoint);
 69  0
             if (tap == null)
 70  
             {
 71  0
                 tap = new ImmutableMuleEndpoint(this.endpoint, false);
 72  
             }
 73  
         }
 74  0
     }
 75  
 
 76  
 }