View Javadoc

1   /*
2    * $Id: TestMessageDispatcher.java 22156 2011-06-08 21:36:30Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.tck.testmodels.mule;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.endpoint.OutboundEndpoint;
16  import org.mule.api.routing.RoutingException;
17  import org.mule.transport.AbstractMessageDispatcher;
18  
19  public class TestMessageDispatcher extends AbstractMessageDispatcher
20  {
21      public TestMessageDispatcher(final OutboundEndpoint endpoint)
22      {
23          super(endpoint);
24      }
25  
26      @Override
27      protected void doInitialise()
28      {
29          // template method
30      }
31  
32      @Override
33      protected void doDispose()
34      {
35          // template method
36      }
37  
38      @Override
39      protected void doDispatch(MuleEvent event) throws Exception
40      {
41          if (endpoint.getEndpointURI().toString().equals("test://AlwaysFail"))
42          {
43              throw new RoutingException(event, (OutboundEndpoint) endpoint);
44          }
45      }
46  
47      @Override
48      protected MuleMessage doSend(MuleEvent event) throws Exception
49      {
50          if (endpoint.getEndpointURI().toString().equals("test://AlwaysFail"))
51          {
52              throw new RoutingException(event, (OutboundEndpoint) endpoint);
53          }
54          return event.getMessage();
55      }
56  
57      @Override
58      protected void doConnect() throws Exception
59      {
60          // no op
61      }
62  
63      @Override
64      protected void doDisconnect() throws Exception
65      {
66          // no op
67      }
68  
69      @Override
70      protected void doStart() 
71      {
72          // no op
73      }
74  
75      @Override
76      protected void doStop() 
77      {
78          // no op
79      }
80  }