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

org.distributeme.agents.transporter.generated.RemoteTransporterServiceSkeleton Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
package org.distributeme.agents.transporter.generated;
//BEGIN GENERATED CODE

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import org.distributeme.core.Verbosity;
import org.distributeme.core.Defaults;
import org.distributeme.core.ServerSideCallContext;
import org.distributeme.core.interceptor.ServerSideRequestInterceptor;
import org.distributeme.core.interceptor.InterceptorResponse;
import org.distributeme.core.interceptor.InterceptionContext;
import org.distributeme.core.interceptor.InterceptorRegistry;
import org.distributeme.core.interceptor.InterceptionPhase;
import org.distributeme.core.concurrencycontrol.ConcurrencyControlStrategy;

// Generated by org.distributeme.generator.SkeletonGenerator
@SuppressWarnings("PMD")
public class RemoteTransporterServiceSkeleton implements RemoteTransporterService {

	private static Logger log = LoggerFactory.getLogger(RemoteTransporterServiceSkeleton.class);

	private org.distributeme.agents.transporter.TransporterService implementation;

	private long lastAccess;
	private long created;

	// CONCURRENCY CONTROL
	// Class wide concurrency control strategy 
	private ConcurrencyControlStrategy clazzWideCCStrategy = Defaults.getDefaultConcurrencyControlStrategy();

	private ConcurrencyControlStrategy receiveAndAwakeAgentCCStrategy_orgdistributemeagentsAgentPackageagent = clazzWideCCStrategy;
	// CONCURRENCY CONTROL end

	public RemoteTransporterServiceSkeleton(){
		this(null);
	}

	public RemoteTransporterServiceSkeleton(org.distributeme.agents.transporter.TransporterService anImplementation){
		created = System.currentTimeMillis();
		implementation = anImplementation;
	}

	public List receiveAndAwakeAgent(org.distributeme.agents.AgentPackage agent, Map __transportableCallContext) throws org.distributeme.agents.transporter.TransporterServiceException{
		lastAccess = System.currentTimeMillis();
		ServerSideCallContext diMeCallContext = new ServerSideCallContext("receiveAndAwakeAgent", __transportableCallContext);
		diMeCallContext.setServiceId(TransporterServiceConstants.getServiceId());
		ArrayList diMeParameters = new ArrayList();
		diMeParameters.add(agent);
		diMeCallContext.setParameters(diMeParameters);
		InterceptionContext diMeInterceptionContext = new InterceptionContext();
		// Initialize interceptors
		List diMeInterceptors = InterceptorRegistry.getInstance().getServerSideRequestInterceptors();

		ArrayList __return = new ArrayList();

		diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVANT_CALL);
		for (ServerSideRequestInterceptor interceptor : diMeInterceptors){
			InterceptorResponse interceptorResponse = interceptor.beforeServantCall(diMeCallContext, diMeInterceptionContext);
			switch(interceptorResponse.getCommand()){
			case ABORT:
				if (interceptorResponse.getException() instanceof RuntimeException)
					throw (RuntimeException) interceptorResponse.getException();
				if (interceptorResponse.getException() instanceof org.distributeme.agents.transporter.TransporterServiceException)
					throw (org.distributeme.agents.transporter.TransporterServiceException) interceptorResponse.getException();
				throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
			case RETURN:
				__return.set(0, interceptorResponse.getReturnValue());
				diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
				break;
			case OVERWRITE_RETURN_AND_CONTINUE:
				__return.set(0, interceptorResponse.getReturnValue());
				diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
				break;
			case CONTINUE:
				break;
			} //...switch
		} //...for
		// Concurrency control, server side - 
		receiveAndAwakeAgentCCStrategy_orgdistributemeagentsAgentPackageagent.notifyServerSideCallStarted(diMeCallContext);

		try{
			implementation.receiveAndAwakeAgent(agent);
			__return.add(org.distributeme.core.util.VoidMarker.VOID);
			__return.add(diMeCallContext.getTransportableCallContext());
			diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVANT_CALL);
			for (ServerSideRequestInterceptor interceptor : diMeInterceptors){
				InterceptorResponse interceptorResponse = interceptor.afterServantCall(diMeCallContext, diMeInterceptionContext);
				switch(interceptorResponse.getCommand()){
				case ABORT:
					if (interceptorResponse.getException() instanceof RuntimeException)
						throw (RuntimeException) interceptorResponse.getException();
					if (interceptorResponse.getException() instanceof org.distributeme.agents.transporter.TransporterServiceException)
						throw (org.distributeme.agents.transporter.TransporterServiceException) interceptorResponse.getException();
					throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
				case RETURN:
					__return.set(0, interceptorResponse.getReturnValue());
					diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
					break;
				case OVERWRITE_RETURN_AND_CONTINUE:
					__return.set(0, interceptorResponse.getReturnValue());
					diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
					break;
				case CONTINUE:
					break;
				} //...switch
			} //...for
			return __return;
		}catch(org.distributeme.agents.transporter.TransporterServiceException e){
			if (Verbosity.logServerSideExceptions())
				log.error("receiveAndAwakeAgent()", e);
			throw(e);
		}finally{
			receiveAndAwakeAgentCCStrategy_orgdistributemeagentsAgentPackageagent.notifyServerSideCallFinished(diMeCallContext);
		}
	}

	// Service adapter methods
	public long getCreationTimestamp(){ return created; }
	public long getLastAccessTimestamp(){ return lastAccess; }

}