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.jsonrpc.generated.RemoteEchoServiceStub Maven / Gradle / Ivy
package org.distributeme.test.jsonrpc.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 RemoteEchoServiceStub implements org.distributeme.test.jsonrpc.EchoService{
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 echoFailingStrategy_longaValue = clazzWideFailingStrategy;
private FailingStrategy echoObjectParam1FailingStrategy_javalangObjectaValue = clazzWideFailingStrategy;
private FailingStrategy echoObjectParamFailingStrategy_orgdistributemetestjsonrpcAaValue = clazzWideFailingStrategy;
private FailingStrategy echoManyParamsFailingStrategy_intind_javalangStringstrNum_javalangLongincremt = clazzWideFailingStrategy;
// Failing end
// CONCURRENCY CONTROL
// Class wide concurrency control strategy
private ConcurrencyControlStrategy clazzWideCCStrategy = Defaults.getDefaultConcurrencyControlStrategy();
private ConcurrencyControlStrategy echoCCStrategy_longaValue = clazzWideCCStrategy;
private ConcurrencyControlStrategy echoObjectParam1CCStrategy_javalangObjectaValue = clazzWideCCStrategy;
private ConcurrencyControlStrategy echoObjectParamCCStrategy_orgdistributemetestjsonrpcAaValue = clazzWideCCStrategy;
private ConcurrencyControlStrategy echoManyParamsCCStrategy_intind_javalangStringstrNum_javalangLongincremt = clazzWideCCStrategy;
// CONCURRENCY CONTROL end
public RemoteEchoServiceStub(){
discoveryMode = DiscoveryMode.AUTO;
}
private ServiceDescriptor manuallySetDescriptor;
private RemoteEchoService manuallySetTarget;
public RemoteEchoServiceStub(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 echo(long aValue) throws org.distributeme.test.jsonrpc.EchoServiceException{
return echo(aValue, (ClientSideCallContext)null);
} //...public long echo(long aValue) throws org.distributeme.test.jsonrpc.EchoServiceException
private long echo(long aValue, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.jsonrpc.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echo");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoCCStrategy_longaValue.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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.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
aValue = ((Long)diMeParameters.get(0)).longValue();
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echo(aValue, __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_longaValue.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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.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_longaValue.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 java.lang.Object echoObjectParam1(java.lang.Object aValue) throws org.distributeme.test.jsonrpc.EchoServiceException{
return echoObjectParam1(aValue, (ClientSideCallContext)null);
} //...public java.lang.Object echoObjectParam1(java.lang.Object aValue) throws org.distributeme.test.jsonrpc.EchoServiceException
private java.lang.Object echoObjectParam1(java.lang.Object aValue, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.jsonrpc.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echoObjectParam1");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoObjectParam1CCStrategy_javalangObjectaValue.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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.lang.Object) 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 = (java.lang.Object) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echoObjectParam1(aValue, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (java.lang.Object) __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
echoObjectParam1CCStrategy_javalangObjectaValue.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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.lang.Object) 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.Object) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = echoObjectParam1FailingStrategy_javalangObjectaValue.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return echoObjectParam1(aValue, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return echoObjectParam1(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 org.distributeme.test.jsonrpc.A echoObjectParam(org.distributeme.test.jsonrpc.A aValue) throws org.distributeme.test.jsonrpc.EchoServiceException{
return echoObjectParam(aValue, (ClientSideCallContext)null);
} //...public org.distributeme.test.jsonrpc.A echoObjectParam(org.distributeme.test.jsonrpc.A aValue) throws org.distributeme.test.jsonrpc.EchoServiceException
private org.distributeme.test.jsonrpc.A echoObjectParam(org.distributeme.test.jsonrpc.A aValue, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.jsonrpc.EchoServiceException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echoObjectParam");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoObjectParamCCStrategy_orgdistributemetestjsonrpcAaValue.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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (org.distributeme.test.jsonrpc.A) 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 = (org.distributeme.test.jsonrpc.A) diMeParameters.get(0);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echoObjectParam(aValue, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (org.distributeme.test.jsonrpc.A) __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
echoObjectParamCCStrategy_orgdistributemetestjsonrpcAaValue.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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.EchoServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (org.distributeme.test.jsonrpc.A) 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.jsonrpc.A) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = echoObjectParamFailingStrategy_orgdistributemetestjsonrpcAaValue.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return echoObjectParam(aValue, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return echoObjectParam(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 org.distributeme.test.jsonrpc.A echoManyParams(int ind, java.lang.String strNum, java.lang.Long incremt) throws org.distributeme.test.jsonrpc.EchoServiceException, java.io.IOException{
return echoManyParams(ind, strNum, incremt, (ClientSideCallContext)null);
} //...public org.distributeme.test.jsonrpc.A echoManyParams(int ind, java.lang.String strNum, java.lang.Long incremt) throws org.distributeme.test.jsonrpc.EchoServiceException, java.io.IOException
private org.distributeme.test.jsonrpc.A echoManyParams(int ind, java.lang.String strNum, java.lang.Long incremt, org.distributeme.core.ClientSideCallContext diMeCallContext) throws org.distributeme.test.jsonrpc.EchoServiceException, java.io.IOException{
List __fromServerSide = null;;
Exception exceptionInMethod = null;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("echoManyParams");
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(EchoServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
echoManyParamsCCStrategy_intind_javalangStringstrNum_javalangLongincremt.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(ind);
diMeParameters.add(strNum);
diMeParameters.add(incremt);
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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.EchoServiceException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof java.io.IOException)
throw (java.io.IOException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (org.distributeme.test.jsonrpc.A) 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
ind = ((Integer)diMeParameters.get(0)).intValue();
strNum = (java.lang.String) diMeParameters.get(1);
incremt = (java.lang.Long) diMeParameters.get(2);
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).echoManyParams(ind, strNum, incremt, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (org.distributeme.test.jsonrpc.A) __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
echoManyParamsCCStrategy_intind_javalangStringstrNum_javalangLongincremt.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.jsonrpc.EchoServiceException)
throw (org.distributeme.test.jsonrpc.EchoServiceException) interceptorResponse.getException();
if (interceptorResponse.getException() instanceof java.io.IOException)
throw (java.io.IOException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (org.distributeme.test.jsonrpc.A) 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.jsonrpc.A) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null){
FailDecision failDecision = echoManyParamsFailingStrategy_intind_javalangStringstrNum_javalangLongincremt.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return echoManyParams(ind, strNum, incremt, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return echoManyParams(ind, strNum, incremt, 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);
}
private void notifyDelegateFailed(){
notifyDelegateFailed(EchoServiceConstants.getServiceId());
}
private void notifyDelegateFailed(String serviceId){
if (discoveryMode==DiscoveryMode.MANUAL){
manuallySetTarget = null;
return;
}
if (serviceId!=null)
delegates.remove(serviceId);
} //...notifyDelegateFailed
private RemoteEchoService getDelegate() throws NoConnectionToServerException{
if (discoveryMode==DiscoveryMode.MANUAL){
if (manuallySetTarget!=null)
return manuallySetTarget;
manuallySetTarget = lookup(manuallySetDescriptor);
return manuallySetTarget;
} //...if (mode==MANUAL)
return getDelegate(EchoServiceConstants.getServiceId());
}
private RemoteEchoService getDelegate(String serviceId) throws NoConnectionToServerException{
// if no serviceid is provided, fallback to default resolve with manual mode
if (serviceId==null)
return getDelegate();
RemoteEchoService 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 RemoteEchoService 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 "+EchoServiceConstants.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 "+EchoServiceConstants.getServiceId());
}
try{
return (RemoteEchoService) 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 RemoteEchoService 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 (RemoteEchoService) 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);
}
}