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

org.distributeme.support.eventservice.generated.RemoteEventServiceRMIBridgeServiceSkeleton Maven / Gradle / Ivy

There is a newer version: 4.0.2
Show newest version
package org.distributeme.support.eventservice.generated;
//CHECKSTYLE:OFF

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;
import net.anotheria.moskito.core.dynamic.MoskitoInvokationProxy;
import net.anotheria.moskito.core.logging.DefaultStatsLogger;
import net.anotheria.moskito.core.logging.IntervalStatsLogger;
import net.anotheria.moskito.core.logging.SLF4JLogOutput;
import net.anotheria.moskito.core.stats.DefaultIntervals;
import net.anotheria.moskito.core.predefined.ServiceStatsCallHandler;
import net.anotheria.moskito.core.predefined.ServiceStatsFactory;
import net.anotheria.moskito.core.registry.IProducerRegistryAPI;
import net.anotheria.moskito.core.registry.ProducerRegistryAPIFactory;
import net.anotheria.moskito.core.producers.IStatsProducer;

// Generated by org.distributeme.generator.SkeletonGenerator
public class RemoteEventServiceRMIBridgeServiceSkeleton implements RemoteEventServiceRMIBridgeService {

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

	private org.distributeme.support.eventservice.EventServiceRMIBridgeService implementation;

	private long lastAccess;
	private long created;

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

	private ConcurrencyControlStrategy deliverEventCCStrategy_netanotheriaanopriseeventserviceEventTransportShellshell = clazzWideCCStrategy;
	private ConcurrencyControlStrategy registerRemoteConsumerCCStrategy_javalangStringchannelName_orgdistributemecoreServiceDescriptormyReference = clazzWideCCStrategy;
	private ConcurrencyControlStrategy registerRemoteSupplierCCStrategy_javalangStringchannelName_orgdistributemecoreServiceDescriptormyReference = clazzWideCCStrategy;
	private ConcurrencyControlStrategy getInstanceIdCCStrategy = clazzWideCCStrategy;
	// CONCURRENCY CONTROL end

	public RemoteEventServiceRMIBridgeServiceSkeleton(){
		this(null);
	}

	public RemoteEventServiceRMIBridgeServiceSkeleton(org.distributeme.support.eventservice.EventServiceRMIBridgeService anImplementation){
		created = System.currentTimeMillis();
		MoskitoInvokationProxy proxy = new MoskitoInvokationProxy(
			anImplementation,
			new ServiceStatsCallHandler(),
			new ServiceStatsFactory(),
			"EventServiceRMIBridgeService", 
			"service",
			"default",
			org.distributeme.support.eventservice.EventServiceRMIBridgeService.class, net.anotheria.anoprise.metafactory.Service.class
		);
		implementation = (org.distributeme.support.eventservice.EventServiceRMIBridgeService) proxy.createProxy();
		// add moskito logger
		new DefaultStatsLogger(proxy.getProducer(), new SLF4JLogOutput(LoggerFactory.getLogger("moskito.custom.default")));
		new IntervalStatsLogger(proxy.getProducer(), DefaultIntervals.FIVE_MINUTES, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.custom.5m")));
		new IntervalStatsLogger(proxy.getProducer(), DefaultIntervals.FIFTEEN_MINUTES, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.custom.15m")));
		new IntervalStatsLogger(proxy.getProducer(), DefaultIntervals.ONE_HOUR, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.custom.1h")));
		new IntervalStatsLogger(proxy.getProducer(), DefaultIntervals.ONE_DAY, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.custom.1d")));
		//end moskito logger
		// //ADD LOGGING FOR ALL BUILTIN PRODUCERS
		IProducerRegistryAPI api = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
		List stats = api.getAllProducersBySubsystem("builtin");
		for (IStatsProducer producer : stats){
			new DefaultStatsLogger(producer, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.bi.default")));
			new IntervalStatsLogger(producer, DefaultIntervals.FIVE_MINUTES, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.bi.5m")));
			new IntervalStatsLogger(producer, DefaultIntervals.FIFTEEN_MINUTES, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.bi.15m")));
			new IntervalStatsLogger(producer, DefaultIntervals.ONE_HOUR, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.bi.1h")));
			new IntervalStatsLogger(producer, DefaultIntervals.ONE_DAY, new SLF4JLogOutput(LoggerFactory.getLogger("moskito.bi.1d")));
		}
	}

	public List deliverEvent(net.anotheria.anoprise.eventservice.EventTransportShell shell, Map __transportableCallContext) throws org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException{
		lastAccess = System.currentTimeMillis();
		ServerSideCallContext diMeCallContext = new ServerSideCallContext("deliverEvent", __transportableCallContext);
		diMeCallContext.setServiceId(EventServiceRMIBridgeServiceConstants.getServiceId());
		ArrayList diMeParameters = new ArrayList();
		diMeParameters.add(shell);
		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.support.eventservice.EventServiceRMIBridgeServiceException)
					throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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 - 
		deliverEventCCStrategy_netanotheriaanopriseeventserviceEventTransportShellshell.notifyServerSideCallStarted(diMeCallContext);

		try{
			implementation.deliverEvent(shell);
			__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.support.eventservice.EventServiceRMIBridgeServiceException)
						throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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.support.eventservice.EventServiceRMIBridgeServiceException e){
			if (Verbosity.logServerSideExceptions())
				log.error("deliverEvent()", e);
			throw(e);
		}finally{
			deliverEventCCStrategy_netanotheriaanopriseeventserviceEventTransportShellshell.notifyServerSideCallFinished(diMeCallContext);
		}
	}

	public List registerRemoteConsumer(java.lang.String channelName, org.distributeme.core.ServiceDescriptor myReference, Map __transportableCallContext) throws org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException{
		lastAccess = System.currentTimeMillis();
		ServerSideCallContext diMeCallContext = new ServerSideCallContext("registerRemoteConsumer", __transportableCallContext);
		diMeCallContext.setServiceId(EventServiceRMIBridgeServiceConstants.getServiceId());
		ArrayList diMeParameters = new ArrayList();
		diMeParameters.add(channelName);
		diMeParameters.add(myReference);
		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.support.eventservice.EventServiceRMIBridgeServiceException)
					throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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 - 
		registerRemoteConsumerCCStrategy_javalangStringchannelName_orgdistributemecoreServiceDescriptormyReference.notifyServerSideCallStarted(diMeCallContext);

		try{
			implementation.registerRemoteConsumer(channelName, myReference);
			__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.support.eventservice.EventServiceRMIBridgeServiceException)
						throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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.support.eventservice.EventServiceRMIBridgeServiceException e){
			if (Verbosity.logServerSideExceptions())
				log.error("registerRemoteConsumer()", e);
			throw(e);
		}finally{
			registerRemoteConsumerCCStrategy_javalangStringchannelName_orgdistributemecoreServiceDescriptormyReference.notifyServerSideCallFinished(diMeCallContext);
		}
	}

	public List registerRemoteSupplier(java.lang.String channelName, org.distributeme.core.ServiceDescriptor myReference, Map __transportableCallContext) throws org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException{
		lastAccess = System.currentTimeMillis();
		ServerSideCallContext diMeCallContext = new ServerSideCallContext("registerRemoteSupplier", __transportableCallContext);
		diMeCallContext.setServiceId(EventServiceRMIBridgeServiceConstants.getServiceId());
		ArrayList diMeParameters = new ArrayList();
		diMeParameters.add(channelName);
		diMeParameters.add(myReference);
		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.support.eventservice.EventServiceRMIBridgeServiceException)
					throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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 - 
		registerRemoteSupplierCCStrategy_javalangStringchannelName_orgdistributemecoreServiceDescriptormyReference.notifyServerSideCallStarted(diMeCallContext);

		try{
			implementation.registerRemoteSupplier(channelName, myReference);
			__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.support.eventservice.EventServiceRMIBridgeServiceException)
						throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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.support.eventservice.EventServiceRMIBridgeServiceException e){
			if (Verbosity.logServerSideExceptions())
				log.error("registerRemoteSupplier()", e);
			throw(e);
		}finally{
			registerRemoteSupplierCCStrategy_javalangStringchannelName_orgdistributemecoreServiceDescriptormyReference.notifyServerSideCallFinished(diMeCallContext);
		}
	}

	public List getInstanceId(Map __transportableCallContext) throws org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException{
		lastAccess = System.currentTimeMillis();
		ServerSideCallContext diMeCallContext = new ServerSideCallContext("getInstanceId", __transportableCallContext);
		diMeCallContext.setServiceId(EventServiceRMIBridgeServiceConstants.getServiceId());
		ArrayList diMeParameters = new ArrayList();
		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.support.eventservice.EventServiceRMIBridgeServiceException)
					throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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 - 
		getInstanceIdCCStrategy.notifyServerSideCallStarted(diMeCallContext);

		try{
			Object __result = implementation.getInstanceId();
			__return.add(__result);
			diMeInterceptionContext.setReturnValue(__result);
			__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.support.eventservice.EventServiceRMIBridgeServiceException)
						throw (org.distributeme.support.eventservice.EventServiceRMIBridgeServiceException) 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.support.eventservice.EventServiceRMIBridgeServiceException e){
			if (Verbosity.logServerSideExceptions())
				log.error("getInstanceId()", e);
			throw(e);
		}finally{
			getInstanceIdCCStrategy.notifyServerSideCallFinished(diMeCallContext);
		}
	}

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

}