Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.distributeme.test.eecho.generated.RemoteEEchoServiceStub Maven / Gradle / Ivy
package org.distributeme.test.eecho.generated;
//CHECKSTYLE:OFF
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import java.rmi.RemoteException;
import java.rmi.NotBoundException;
import org.distributeme.core.RegistryUtil;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import org.distributeme.core.ServiceDescriptor;
import org.distributeme.core.ServiceDescriptor.Protocol;
import org.distributeme.core.DiscoveryMode;
import org.distributeme.core.failing.FailingStrategy;
import org.distributeme.core.concurrencycontrol.ConcurrencyControlStrategy;
import org.distributeme.core.failing.FailDecision;
import org.distributeme.core.ClientSideCallContext;
import org.distributeme.core.exception.DistributemeRuntimeException;
import org.distributeme.core.exception.NoConnectionToServerException;
import org.distributeme.core.exception.ServiceUnavailableException;
import org.distributeme.core.Defaults;
import org.distributeme.core.interceptor.ClientSideRequestInterceptor;
import org.distributeme.core.interceptor.InterceptorRegistry;
import org.distributeme.core.interceptor.InterceptorResponse;
import org.distributeme.core.interceptor.InterceptionContext;
import org.distributeme.core.interceptor.InterceptionPhase;
public class RemoteEEchoServiceStub implements org.distributeme.test.eecho.EEchoService{
private volatile ConcurrentMap delegates = new ConcurrentHashMap();
private DiscoveryMode discoveryMode = DiscoveryMode.AUTO;
// ROUTER DECL V2
// No class-wide-router set, skipping.
// Method wide routers if applicable
// Method wide routers END
// ROUTER DECL V2 end
// Failing
// Class wide failing strategy
private FailingStrategy clazzWideFailingStrategy = Defaults.getDefaultFailingStrategy();
private FailingStrategy eechoFailingStrategy_longparam = clazzWideFailingStrategy;
private FailingStrategy echoFailingStrategy_longparameter = clazzWideFailingStrategy;
private FailingStrategy printHelloFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy methodWithMultipleParametersFailingStrategy_javalangStringparam1_javalangStringparam2_javalangStringparam3 = clazzWideFailingStrategy;
private FailingStrategy echoFailingStrategy_orgdistributemetestechoEchoin = clazzWideFailingStrategy;
private FailingStrategy throwExceptionFailingStrategy_javalangStringmessage = clazzWideFailingStrategy;
private FailingStrategy dontThrowExceptionFailingStrategy_javalangStringmessage = clazzWideFailingStrategy;
private FailingStrategy echoFailingStrategy_TaValue = clazzWideFailingStrategy;
private FailingStrategy echoFailingStrategy_TaValue_YaParameter = clazzWideFailingStrategy;
private FailingStrategy testCallByRefFailingStrategy_javautilHashMapparams = clazzWideFailingStrategy;
private FailingStrategy testCallByRefWithInterceptorsFailingStrategy_javautilHashMapparams = clazzWideFailingStrategy;
// Failing end
// CONCURRENCY CONTROL
// Class wide concurrency control strategy
private ConcurrencyControlStrategy clazzWideCCStrategy = Defaults.getDefaultConcurrencyControlStrategy();
private ConcurrencyControlStrategy eechoCCStrategy_longparam = clazzWideCCStrategy;
private ConcurrencyControlStrategy echoCCStrategy_longparameter = clazzWideCCStrategy;
private ConcurrencyControlStrategy printHelloCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy methodWithMultipleParametersCCStrategy_javalangStringparam1_javalangStringparam2_javalangStringparam3 = clazzWideCCStrategy;
private ConcurrencyControlStrategy echoCCStrategy_orgdistributemetestechoEchoin = clazzWideCCStrategy;
private ConcurrencyControlStrategy throwExceptionCCStrategy_javalangStringmessage = clazzWideCCStrategy;
private ConcurrencyControlStrategy dontThrowExceptionCCStrategy_javalangStringmessage = clazzWideCCStrategy;
private ConcurrencyControlStrategy echoCCStrategy_TaValue = clazzWideCCStrategy;
private ConcurrencyControlStrategy echoCCStrategy_TaValue_YaParameter = clazzWideCCStrategy;
private ConcurrencyControlStrategy testCallByRefCCStrategy_javautilHashMapparams = clazzWideCCStrategy;
private ConcurrencyControlStrategy testCallByRefWithInterceptorsCCStrategy_javautilHashMapparams = clazzWideCCStrategy;
// CONCURRENCY CONTROL end
public RemoteEEchoServiceStub(){
discoveryMode = DiscoveryMode.AUTO;
}
private ServiceDescriptor manuallySetDescriptor;
private RemoteEEchoService manuallySetTarget;
public RemoteEEchoServiceStub(ServiceDescriptor target){
discoveryMode = DiscoveryMode.MANUAL;
manuallySetDescriptor = target;
try{
manuallySetTarget = lookup(manuallySetDescriptor);
}catch(NoConnectionToServerException e){
throw new IllegalStateException("Can not resolve manually set reference", e);
}
}
public long eecho(long param) throws org.distributeme.test.eecho.EEchoServiceException{
return eecho(param, (ClientSideCallContext)null);
} //...public long eecho(long param) throws org.distributeme.test.eecho.EEchoServiceException
private long eecho(long param, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.eecho.EEchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("eecho");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
eechoCCStrategy_longparam.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(param);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.eecho.EEchoServiceException)
throw (org.distributeme.test.eecho.EEchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return ((Long)interceptorResponse.getReturnValue()).longValue();
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
param = ((Long)diMeParameters.get(0)).longValue();
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).eecho(param, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return ((Long)__fromServerSide.get(0)).longValue();
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
eechoCCStrategy_longparam.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.eecho.EEchoServiceException)
throw (org.distributeme.test.eecho.EEchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return ((Long)interceptorResponse.getReturnValue()).longValue();
case OVERWRITE_RETURN_AND_CONTINUE:
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
if (diMeReturnOverriden)
return ((Long)__fromServerSide.get(0)).longValue();
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = eechoFailingStrategy_longparam.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return eecho(param, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return eecho(param, diMeCallContext.increaseCallCount());
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public long echo(long parameter) throws org.distributeme.test.echo.EchoServiceException{
return echo(parameter, (ClientSideCallContext)null);
} //...public long echo(long parameter) throws org.distributeme.test.echo.EchoServiceException
private long echo(long parameter, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echo");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoCCStrategy_longparameter.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(parameter);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return ((Long)interceptorResponse.getReturnValue()).longValue();
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
parameter = ((Long)diMeParameters.get(0)).longValue();
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echo(parameter, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return ((Long)__fromServerSide.get(0)).longValue();
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
echoCCStrategy_longparameter.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return ((Long)interceptorResponse.getReturnValue()).longValue();
case OVERWRITE_RETURN_AND_CONTINUE:
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
if (diMeReturnOverriden)
return ((Long)__fromServerSide.get(0)).longValue();
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = echoFailingStrategy_longparameter.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return echo(parameter, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return echo(parameter, diMeCallContext.increaseCallCount());
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public void printHello() throws org.distributeme.test.echo.EchoServiceException{
printHello((ClientSideCallContext)null);
} //...public void printHello() throws org.distributeme.test.echo.EchoServiceException
private void printHello(org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("printHello");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
printHelloCCStrategy.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).printHello( __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return;
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
printHelloCCStrategy.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = printHelloFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
printHello(diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
printHello(diMeCallContext.increaseCallCount());
return;
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public java.lang.String methodWithMultipleParameters(java.lang.String param1, java.lang.String param2, java.lang.String param3) throws org.distributeme.test.echo.EchoServiceException{
return methodWithMultipleParameters(param1, param2, param3, (ClientSideCallContext)null);
} //...public java.lang.String methodWithMultipleParameters(java.lang.String param1, java.lang.String param2, java.lang.String param3) throws org.distributeme.test.echo.EchoServiceException
private java.lang.String methodWithMultipleParameters(java.lang.String param1, java.lang.String param2, java.lang.String param3, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("methodWithMultipleParameters");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
methodWithMultipleParametersCCStrategy_javalangStringparam1_javalangStringparam2_javalangStringparam3.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(param1);
diMeParameters.add(param2);
diMeParameters.add(param3);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.lang.String) interceptorResponse.getReturnValue();
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
param1 = (java.lang.String) diMeParameters.get(0);
param2 = (java.lang.String) diMeParameters.get(1);
param3 = (java.lang.String) diMeParameters.get(2);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).methodWithMultipleParameters(param1, param2, param3, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (java.lang.String) __fromServerSide.get(0);
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
methodWithMultipleParametersCCStrategy_javalangStringparam1_javalangStringparam2_javalangStringparam3.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.lang.String) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
if (diMeReturnOverriden)
return (java.lang.String) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = methodWithMultipleParametersFailingStrategy_javalangStringparam1_javalangStringparam2_javalangStringparam3.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return methodWithMultipleParameters(param1, param2, param3, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return methodWithMultipleParameters(param1, param2, param3, diMeCallContext.increaseCallCount());
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public org.distributeme.test.echo.Echo echo(org.distributeme.test.echo.Echo in) throws org.distributeme.test.echo.EchoServiceException{
return echo(in, (ClientSideCallContext)null);
} //...public org.distributeme.test.echo.Echo echo(org.distributeme.test.echo.Echo in) throws org.distributeme.test.echo.EchoServiceException
private org.distributeme.test.echo.Echo echo(org.distributeme.test.echo.Echo in, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echo");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoCCStrategy_orgdistributemetestechoEchoin.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(in);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (org.distributeme.test.echo.Echo) interceptorResponse.getReturnValue();
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
in = (org.distributeme.test.echo.Echo) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echo(in, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (org.distributeme.test.echo.Echo) __fromServerSide.get(0);
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
echoCCStrategy_orgdistributemetestechoEchoin.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (org.distributeme.test.echo.Echo) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
if (diMeReturnOverriden)
return (org.distributeme.test.echo.Echo) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = echoFailingStrategy_orgdistributemetestechoEchoin.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return echo(in, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return echo(in, diMeCallContext.increaseCallCount());
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public void throwException(java.lang.String message) throws org.distributeme.test.echo.EchoServiceException{
throwException(message, (ClientSideCallContext)null);
} //...public void throwException(java.lang.String message) throws org.distributeme.test.echo.EchoServiceException
private void throwException(java.lang.String message, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("throwException");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
throwExceptionCCStrategy_javalangStringmessage.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(message);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
message = (java.lang.String) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).throwException(message, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return;
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
throwExceptionCCStrategy_javalangStringmessage.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = throwExceptionFailingStrategy_javalangStringmessage.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
throwException(message, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
throwException(message, diMeCallContext.increaseCallCount());
return;
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public void dontThrowException(java.lang.String message){
dontThrowException(message, (ClientSideCallContext)null);
} //...public void dontThrowException(java.lang.String message)
private void dontThrowException(java.lang.String message, org.distributeme.core.ClientSideCallContext diMeCallContext){
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("dontThrowException");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
dontThrowExceptionCCStrategy_javalangStringmessage.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(message);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
message = (java.lang.String) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).dontThrowException(message, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return;
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
dontThrowExceptionCCStrategy_javalangStringmessage.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = dontThrowExceptionFailingStrategy_javalangStringmessage.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
dontThrowException(message, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
dontThrowException(message, diMeCallContext.increaseCallCount());
return;
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public T echo(T aValue) throws org.distributeme.test.echo.EchoServiceException{
return echo(aValue, (ClientSideCallContext)null);
} //...public T echo(T aValue) throws org.distributeme.test.echo.EchoServiceException
private T echo(T aValue, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echo");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoCCStrategy_TaValue.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(aValue);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (T) interceptorResponse.getReturnValue();
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
aValue = (T) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echo(aValue, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (T) __fromServerSide.get(0);
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
echoCCStrategy_TaValue.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (T) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
if (diMeReturnOverriden)
return (T) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = echoFailingStrategy_TaValue.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return echo(aValue, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return echo(aValue, diMeCallContext.increaseCallCount());
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public T echo(T aValue, Y aParameter) throws org.distributeme.test.echo.EchoServiceException{
return echo(aValue, aParameter, (ClientSideCallContext)null);
} //...public T echo(T aValue, Y aParameter) throws org.distributeme.test.echo.EchoServiceException
private T echo(T aValue, Y aParameter, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echo");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoCCStrategy_TaValue_YaParameter.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(aValue);
diMeParameters.add(aParameter);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (T) interceptorResponse.getReturnValue();
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
aValue = (T) diMeParameters.get(0);
aParameter = (Y) diMeParameters.get(1);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echo(aValue, aParameter, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (T) __fromServerSide.get(0);
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
echoCCStrategy_TaValue_YaParameter.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (T) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
if (diMeReturnOverriden)
return (T) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = echoFailingStrategy_TaValue_YaParameter.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return echo(aValue, aParameter, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return echo(aValue, aParameter, diMeCallContext.increaseCallCount());
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public void testCallByRef(java.util.HashMap params) throws org.distributeme.test.echo.EchoServiceException{
testCallByRef(params, (ClientSideCallContext)null);
} //...public void testCallByRef(java.util.HashMap params) throws org.distributeme.test.echo.EchoServiceException
private void testCallByRef(java.util.HashMap params, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("testCallByRef");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
testCallByRefCCStrategy_javautilHashMapparams.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(params);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
params = (java.util.HashMap) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).testCallByRef(params, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return;
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
testCallByRefCCStrategy_javautilHashMapparams.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = testCallByRefFailingStrategy_javautilHashMapparams.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
testCallByRef(params, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
testCallByRef(params, diMeCallContext.increaseCallCount());
return;
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
public void testCallByRefWithInterceptors(java.util.HashMap params) throws org.distributeme.test.echo.EchoServiceException{
testCallByRefWithInterceptors(params, (ClientSideCallContext)null);
} //...public void testCallByRefWithInterceptors(java.util.HashMap params) throws org.distributeme.test.echo.EchoServiceException
private void testCallByRefWithInterceptors(java.util.HashMap params, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.echo.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("testCallByRefWithInterceptors");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EEchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
testCallByRefWithInterceptorsCCStrategy_javautilHashMapparams.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(params);
diMeCallContext.setParameters(diMeParameters);
try{
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.BEFORE_SERVICE_CALL);
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.beforeServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// Reparse parameters in case an interceptor modified them
params = (java.util.HashMap) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).testCallByRefWithInterceptors(params, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return;
}catch(RemoteException e){
// handle exceptions properly
e.printStackTrace();
notifyDelegateFailed(diMeCallContext.getServiceId());
exceptionInMethod = e;
}catch(NoConnectionToServerException e){
exceptionInMethod = e;
}finally{
// Concurrency control, client side - end
testCallByRefWithInterceptorsCCStrategy_javautilHashMapparams.notifyClientSideCallFinished(diMeCallContext);
diMeInterceptionContext.setCurrentPhase(InterceptionPhase.AFTER_SERVICE_CALL);
if (__fromServerSide!=null){
diMeInterceptionContext.setReturnValue(__fromServerSide.get(0));
}
diMeInterceptionContext.setException(exceptionInMethod);
boolean diMeReturnOverriden = false;
for (ClientSideRequestInterceptor interceptor : diMeInterceptors){
InterceptorResponse interceptorResponse = interceptor.afterServiceCall(diMeCallContext, diMeInterceptionContext);
switch(interceptorResponse.getCommand()){
case ABORT:
if (interceptorResponse.getException() instanceof RuntimeException)
throw (RuntimeException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof org.distributeme.test.echo.EchoServiceException)
throw (org.distributeme.test.echo.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = testCallByRefWithInterceptorsFailingStrategy_javautilHashMapparams.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
testCallByRefWithInterceptors(params, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
testCallByRefWithInterceptors(params, diMeCallContext.increaseCallCount());
return;
case FAIL:
default:
// Fail or default is to do nothing at all and let the request fail
} //...switch(failDecision)
}
// fail through, if we are here, we must have had an exception before.
throw mapException(exceptionInMethod);
}
private void notifyDelegateFailed(){
notifyDelegateFailed(EEchoServiceConstants.getServiceId());
}
private void notifyDelegateFailed(String serviceId){
if (discoveryMode==DiscoveryMode.MANUAL){
manuallySetTarget = null;
return;
}
if (serviceId!=null)
delegates.remove(serviceId);
} //...notifyDelegateFailed
private RemoteEEchoService getDelegate() throws NoConnectionToServerException{
if (discoveryMode==DiscoveryMode.MANUAL){
if (manuallySetTarget!=null)
return manuallySetTarget;
manuallySetTarget = lookup(manuallySetDescriptor);
return manuallySetTarget;
} //...if (mode==MANUAL)
return getDelegate(EEchoServiceConstants.getServiceId());
}
private RemoteEEchoService getDelegate(String serviceId) throws NoConnectionToServerException{
// if no serviceid is provided, fallback to default resolve with manual mode
if (serviceId==null)
return getDelegate();
RemoteEEchoService delegate = delegates.get(serviceId);
if (delegate==null){
try{
delegate = lookup(serviceId);
delegates.putIfAbsent(serviceId, delegate);
}catch(Exception e){
// //TODO - generate and throw typed exception.
throw new NoConnectionToServerException("Couldn't lookup delegate because: "+e.getMessage()+" at "+RegistryUtil.describeRegistry(), e);
}//try
} //...first if (del==null)
return delegate;
} //...fun
private RemoteEEchoService lookup(String serviceId) throws NoConnectionToServerException{
// //first we need to lookup target host.
ServiceDescriptor toLookup = new ServiceDescriptor(Protocol.RMI, serviceId);
ServiceDescriptor targetService = RegistryUtil.resolve(toLookup);
if (targetService==null)
throw new RuntimeException("Can't resolve host for an instance of "+EEchoServiceConstants.getServiceId());
Registry registry = null;
try{
registry = LocateRegistry.getRegistry(targetService.getHost(), targetService.getPort());
}catch(Exception e){
System.err.println("lookup - couldn't obtain rmi registry on "+targetService+", aborting lookup"); e.printStackTrace();
throw new NoConnectionToServerException("Can't resolve rmi registry for an instance of "+EEchoServiceConstants.getServiceId());
}
try{
return (RemoteEEchoService) registry.lookup(serviceId);
}catch(RemoteException e){
throw new NoConnectionToServerException("Can't lookup service in the target rmi registry for an instance of "+serviceId, e);
}catch(NotBoundException e){
throw new NoConnectionToServerException("Can't lookup service in the target rmi registry for an instance of "+serviceId, e);
}
}
private RemoteEEchoService lookup(ServiceDescriptor serviceDescriptor) throws NoConnectionToServerException{
Registry registry = null;
try{
registry = LocateRegistry.getRegistry(serviceDescriptor.getHost(), serviceDescriptor.getPort());
}catch(Exception e){
System.err.println("lookup - couldn't obtain rmi registry on "+serviceDescriptor+", aborting lookup"); e.printStackTrace();
throw new NoConnectionToServerException("Can't resolve rmi registry for "+serviceDescriptor);
}
try{
return (RemoteEEchoService) registry.lookup(serviceDescriptor.getServiceId());
}catch(RemoteException e){
throw new NoConnectionToServerException("Can't lookup service in the target rmi registry for an instance of "+serviceDescriptor, e);
}catch(NotBoundException e){
throw new NoConnectionToServerException("Can't lookup service in the target rmi registry for an instance of "+serviceDescriptor, e);
}
}
private DistributemeRuntimeException mapException(Exception in){
if (in instanceof DistributemeRuntimeException)
return (DistributemeRuntimeException) in;
if (in instanceof RemoteException)
return new ServiceUnavailableException ("Service unavailable due to rmi failure: "+in.getMessage(), in);
return new ServiceUnavailableException("Unexpected exception: "+in.getMessage()+" " + in.getClass().getName(), in);
}
}