
package org.mule.modules.salesforce.connectivity;

import javax.annotation.Generated;
import org.mule.api.ConnectionManager;
import org.mule.api.MuleContext;
import org.mule.api.MuleEvent;
import org.mule.api.process.ProcessCallback;
import org.mule.api.process.ProcessInterceptor;
import org.mule.api.process.ProcessTemplate;
import org.mule.api.processor.MessageProcessor;
import org.mule.modules.salesforce.adapters.SalesforceModuleConnectionIdentifierAdapter;
import org.mule.modules.salesforce.process.ManagedConnectionProcessInterceptor;
import org.mule.modules.salesforce.process.ProcessCallbackProcessInterceptor;
import org.mule.modules.salesforce.retry.RetryProcessInterceptor;

@Generated(value = "Mule DevKit Version 3.4-SNAPSHOT", date = "2012-07-18T11:29:04-05:00", comments = "Build UNKNOWN_BUILDNUMBER")
public class ManagedConnectionProcessTemplate<P >implements ProcessTemplate<P, SalesforceModuleConnectionIdentifierAdapter>
{

    private final ProcessInterceptor<P, SalesforceModuleConnectionIdentifierAdapter> processInterceptor;

    public ManagedConnectionProcessTemplate(ConnectionManager<SalesforceModuleConnectionKey, SalesforceModuleConnectionIdentifierAdapter> connectionManager, MuleContext muleContext) {
        ProcessInterceptor<P, SalesforceModuleConnectionIdentifierAdapter> processCallbackProcessInterceptor = new ProcessCallbackProcessInterceptor<P, SalesforceModuleConnectionIdentifierAdapter>();
        ProcessInterceptor<P, SalesforceModuleConnectionIdentifierAdapter> managedConnectionProcessInterceptor = new ManagedConnectionProcessInterceptor<P>(processCallbackProcessInterceptor, connectionManager, muleContext);
        ProcessInterceptor<P, SalesforceModuleConnectionIdentifierAdapter> retryProcessInterceptor = new RetryProcessInterceptor<P, SalesforceModuleConnectionIdentifierAdapter>(managedConnectionProcessInterceptor, muleContext, connectionManager.getRetryPolicyTemplate());
        processInterceptor = retryProcessInterceptor;
    }

    public P execute(ProcessCallback<P, SalesforceModuleConnectionIdentifierAdapter> processCallback, MessageProcessor messageProcessor, MuleEvent event)
        throws Exception
    {
        return processInterceptor.execute(processCallback, null, messageProcessor, event);
    }

}
