View Javadoc
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.routing;
8   
9   import org.mule.api.MuleEvent;
10  import org.mule.api.MuleException;
11  import org.mule.api.routing.RoutingException;
12  import org.mule.api.service.Service;
13  
14  /**
15   * <code>ServiceCatchAllStrategy</code> is used to catch any events and forward the
16   * events to the service as is.
17   * @deprecated
18   */
19  @Deprecated
20  public class ServiceCatchAllStrategy extends AbstractCatchAllStrategy
21  {
22      @Override
23      public synchronized MuleEvent doCatchMessage(MuleEvent event)
24          throws RoutingException
25      {
26          if (!(event.getFlowConstruct() instanceof Service))
27          {
28              throw new UnsupportedOperationException(
29                  "CollectionResponseWithCallbackCorrelator is only supported with Service");
30          }
31  
32          logger.debug("Catch all strategy handling event: " + event);
33          try
34          {
35              if (event.getEndpoint().getExchangePattern().hasResponse())
36              {
37                  if (statistics.isEnabled())
38                  {
39                      statistics.incrementRoutedMessage(event.getEndpoint());
40                  }
41                  return ((Service) event.getFlowConstruct()).sendEvent(event);
42              }
43              else
44              {
45                  if (statistics.isEnabled())
46                  {
47                      statistics.incrementRoutedMessage(event.getEndpoint());
48                  }
49                  ((Service) event.getFlowConstruct()).dispatchEvent(event);
50                  return null;
51              }
52          }
53          catch (MuleException e)
54          {
55              throw new RoutingException(event, this, e);
56          }
57      }
58  }