KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > routing > ComponentCatchAllStrategy


1 /*
2  * $Id: ComponentCatchAllStrategy.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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;
12
13 import org.mule.impl.MuleEvent;
14 import org.mule.impl.RequestContext;
15 import org.mule.umo.UMOEvent;
16 import org.mule.umo.UMOException;
17 import org.mule.umo.UMOMessage;
18 import org.mule.umo.UMOSession;
19 import org.mule.umo.endpoint.UMOEndpoint;
20 import org.mule.umo.routing.ComponentRoutingException;
21 import org.mule.umo.routing.RoutingException;
22
23 /**
24  * <code>ComponentCatchAllStrategy</code> is used to catch any events and forward
25  * the events to the component as is.
26  *
27  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
28  * @version $Revision: 3798 $
29  */

30 public class ComponentCatchAllStrategy extends AbstractCatchAllStrategy
31 {
32     public void setEndpoint(UMOEndpoint endpoint)
33     {
34         throw new UnsupportedOperationException JavaDoc("The endpoint cannot be set on this catch all");
35     }
36
37     public UMOEndpoint getEndpoint()
38     {
39         return null;
40     }
41
42     public synchronized UMOMessage catchMessage(UMOMessage message, UMOSession session, boolean synchronous)
43         throws RoutingException
44     {
45         UMOEvent event = RequestContext.getEvent();
46         try
47         {
48             event = new MuleEvent(message, event.getEndpoint(), session.getComponent(), event);
49             if (synchronous)
50             {
51                 statistics.incrementRoutedMessage(event.getEndpoint());
52                 logger.info("Event being routed from catch all strategy for endpoint: "
53                             + RequestContext.getEvent().getEndpoint());
54                 return session.getComponent().sendEvent(event);
55             }
56             else
57             {
58                 statistics.incrementRoutedMessage(event.getEndpoint());
59                 session.getComponent().dispatchEvent(event);
60                 return null;
61             }
62         }
63         catch (UMOException e)
64         {
65             throw new ComponentRoutingException(event.getMessage(), event.getEndpoint(),
66                 session.getComponent(), e);
67         }
68     }
69 }
70
Popular Tags