All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mule.routing.ServiceCatchAllStrategy Maven / Gradle / Ivy

There is a newer version: 3.9.0
Show newest version
/*
 * $Id: ServiceCatchAllStrategy.java 20343 2010-11-24 21:02:10Z mike.schilling $
 * --------------------------------------------------------------------------------------
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

package org.mule.routing;

import org.mule.api.MuleEvent;
import org.mule.api.MuleException;
import org.mule.api.routing.RoutingException;
import org.mule.api.service.Service;

/**
 * ServiceCatchAllStrategy is used to catch any events and forward the
 * events to the service as is.
 * @deprecated
 */
@Deprecated
public class ServiceCatchAllStrategy extends AbstractCatchAllStrategy
{
    @Override
    public synchronized MuleEvent doCatchMessage(MuleEvent event)
        throws RoutingException
    {
        if (!(event.getFlowConstruct() instanceof Service))
        {
            throw new UnsupportedOperationException(
                "CollectionResponseWithCallbackCorrelator is only supported with Service");
        }

        logger.debug("Catch all strategy handling event: " + event);
        try
        {
            if (event.getEndpoint().getExchangePattern().hasResponse())
            {
                if (statistics.isEnabled())
                {
                    statistics.incrementRoutedMessage(event.getEndpoint());
                }
                return ((Service) event.getFlowConstruct()).sendEvent(event);
            }
            else
            {
                if (statistics.isEnabled())
                {
                    statistics.incrementRoutedMessage(event.getEndpoint());
                }
                ((Service) event.getFlowConstruct()).dispatchEvent(event);
                return null;
            }
        }
        catch (MuleException e)
        {
            throw new RoutingException(event, this, e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy