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.
net.anotheria.moskito.webui.journey.api.generated.RemoteJourneyAPIStub Maven / Gradle / Ivy
package net.anotheria.moskito.webui.journey.api.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;
import org.distributeme.core.interceptor.FailedByInterceptorException;
public class RemoteJourneyAPIStub implements net.anotheria.moskito.webui.journey.api.JourneyAPI{
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 = new org.distributeme.core.failing.RetryCallOnce();
private FailingStrategy getJourneysFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getJourneyFailingStrategy_javalangStringname = clazzWideFailingStrategy;
private FailingStrategy getTracedCallFailingStrategy_javalangStringjourneyName_intcallPosition_netanotheriamoskitocorestatsTimeUnitunit = clazzWideFailingStrategy;
private FailingStrategy getTracedCallByNameFailingStrategy_javalangStringjourneyName_javalangStringtraceName_netanotheriamoskitocorestatsTimeUnitunit = clazzWideFailingStrategy;
private FailingStrategy analyzeJourneyFailingStrategy_javalangStringjourneyName = clazzWideFailingStrategy;
private FailingStrategy deleteJourneyFailingStrategy_javalangStringjourneyName = clazzWideFailingStrategy;
private FailingStrategy initFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy deInitFailingStrategy = clazzWideFailingStrategy;
// Failing end
// CONCURRENCY CONTROL
// Class wide concurrency control strategy
private ConcurrencyControlStrategy clazzWideCCStrategy = Defaults.getDefaultConcurrencyControlStrategy();
private ConcurrencyControlStrategy getJourneysCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getJourneyCCStrategy_javalangStringname = clazzWideCCStrategy;
private ConcurrencyControlStrategy getTracedCallCCStrategy_javalangStringjourneyName_intcallPosition_netanotheriamoskitocorestatsTimeUnitunit = clazzWideCCStrategy;
private ConcurrencyControlStrategy getTracedCallByNameCCStrategy_javalangStringjourneyName_javalangStringtraceName_netanotheriamoskitocorestatsTimeUnitunit = clazzWideCCStrategy;
private ConcurrencyControlStrategy analyzeJourneyCCStrategy_javalangStringjourneyName = clazzWideCCStrategy;
private ConcurrencyControlStrategy deleteJourneyCCStrategy_javalangStringjourneyName = clazzWideCCStrategy;
private ConcurrencyControlStrategy initCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy deInitCCStrategy = clazzWideCCStrategy;
// CONCURRENCY CONTROL end
public RemoteJourneyAPIStub(){
discoveryMode = DiscoveryMode.AUTO;
}
private ServiceDescriptor manuallySetDescriptor;
private RemoteJourneyAPI manuallySetTarget;
public RemoteJourneyAPIStub(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 java.util.List getJourneys() throws net.anotheria.anoplass.api.APIException{
return getJourneys((ClientSideCallContext)null);
} //...public java.util.List getJourneys() throws net.anotheria.anoplass.api.APIException
private java.util.List getJourneys(org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.anoplass.api.APIException{
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("getJourneys");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getJourneysCCStrategy.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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.util.List) interceptorResponse.getReturnValue();
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getJourneys( __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (java.util.List) __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
getJourneysCCStrategy.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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.util.List) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
if (__fromServerSide == null)
throw new AssertionError("Incorrect use of interceptor, there is no return value in this method or it is null");
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
getJourneysFailingStrategy.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// The next check for null of __fromServerSide is unneeded but for security reasons.
if (diMeReturnOverriden && __fromServerSide!=null)
return (java.util.List) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getJourneysFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getJourneys(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getJourneys(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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
public net.anotheria.moskito.webui.journey.api.JourneyAO getJourney(java.lang.String name) throws net.anotheria.anoplass.api.APIException{
return getJourney(name, (ClientSideCallContext)null);
} //...public net.anotheria.moskito.webui.journey.api.JourneyAO getJourney(java.lang.String name) throws net.anotheria.anoplass.api.APIException
private net.anotheria.moskito.webui.journey.api.JourneyAO getJourney(java.lang.String name, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.anoplass.api.APIException{
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("getJourney");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getJourneyCCStrategy_javalangStringname.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(name);
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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.moskito.webui.journey.api.JourneyAO) interceptorResponse.getReturnValue();
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
name = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getJourney(name, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.moskito.webui.journey.api.JourneyAO) __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
getJourneyCCStrategy_javalangStringname.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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.moskito.webui.journey.api.JourneyAO) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
if (__fromServerSide == null)
throw new AssertionError("Incorrect use of interceptor, there is no return value in this method or it is null");
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
getJourneyFailingStrategy_javalangStringname.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// The next check for null of __fromServerSide is unneeded but for security reasons.
if (diMeReturnOverriden && __fromServerSide!=null)
return (net.anotheria.moskito.webui.journey.api.JourneyAO) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getJourneyFailingStrategy_javalangStringname.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getJourney(name, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getJourney(name, 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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
public net.anotheria.moskito.webui.journey.api.TracedCallAO getTracedCall(java.lang.String journeyName, int callPosition, net.anotheria.moskito.core.stats.TimeUnit unit) throws net.anotheria.anoplass.api.APIException{
return getTracedCall(journeyName, callPosition, unit, (ClientSideCallContext)null);
} //...public net.anotheria.moskito.webui.journey.api.TracedCallAO getTracedCall(java.lang.String journeyName, int callPosition, net.anotheria.moskito.core.stats.TimeUnit unit) throws net.anotheria.anoplass.api.APIException
private net.anotheria.moskito.webui.journey.api.TracedCallAO getTracedCall(java.lang.String journeyName, int callPosition, net.anotheria.moskito.core.stats.TimeUnit unit, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.anoplass.api.APIException{
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("getTracedCall");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getTracedCallCCStrategy_javalangStringjourneyName_intcallPosition_netanotheriamoskitocorestatsTimeUnitunit.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(journeyName);
diMeParameters.add(callPosition);
diMeParameters.add(unit);
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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) interceptorResponse.getReturnValue();
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
journeyName = (java.lang.String) diMeParameters.get(0);
callPosition = ((Integer)diMeParameters.get(1)).intValue();
unit = (net.anotheria.moskito.core.stats.TimeUnit) diMeParameters.get(2);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getTracedCall(journeyName, callPosition, unit, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) __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
getTracedCallCCStrategy_javalangStringjourneyName_intcallPosition_netanotheriamoskitocorestatsTimeUnitunit.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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
if (__fromServerSide == null)
throw new AssertionError("Incorrect use of interceptor, there is no return value in this method or it is null");
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
getTracedCallFailingStrategy_javalangStringjourneyName_intcallPosition_netanotheriamoskitocorestatsTimeUnitunit.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// The next check for null of __fromServerSide is unneeded but for security reasons.
if (diMeReturnOverriden && __fromServerSide!=null)
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getTracedCallFailingStrategy_javalangStringjourneyName_intcallPosition_netanotheriamoskitocorestatsTimeUnitunit.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getTracedCall(journeyName, callPosition, unit, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getTracedCall(journeyName, callPosition, unit, 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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
public net.anotheria.moskito.webui.journey.api.TracedCallAO getTracedCallByName(java.lang.String journeyName, java.lang.String traceName, net.anotheria.moskito.core.stats.TimeUnit unit) throws net.anotheria.anoplass.api.APIException{
return getTracedCallByName(journeyName, traceName, unit, (ClientSideCallContext)null);
} //...public net.anotheria.moskito.webui.journey.api.TracedCallAO getTracedCallByName(java.lang.String journeyName, java.lang.String traceName, net.anotheria.moskito.core.stats.TimeUnit unit) throws net.anotheria.anoplass.api.APIException
private net.anotheria.moskito.webui.journey.api.TracedCallAO getTracedCallByName(java.lang.String journeyName, java.lang.String traceName, net.anotheria.moskito.core.stats.TimeUnit unit, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.anoplass.api.APIException{
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("getTracedCallByName");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getTracedCallByNameCCStrategy_javalangStringjourneyName_javalangStringtraceName_netanotheriamoskitocorestatsTimeUnitunit.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(journeyName);
diMeParameters.add(traceName);
diMeParameters.add(unit);
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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) interceptorResponse.getReturnValue();
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
journeyName = (java.lang.String) diMeParameters.get(0);
traceName = (java.lang.String) diMeParameters.get(1);
unit = (net.anotheria.moskito.core.stats.TimeUnit) diMeParameters.get(2);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getTracedCallByName(journeyName, traceName, unit, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) __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
getTracedCallByNameCCStrategy_javalangStringjourneyName_javalangStringtraceName_netanotheriamoskitocorestatsTimeUnitunit.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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
if (__fromServerSide == null)
throw new AssertionError("Incorrect use of interceptor, there is no return value in this method or it is null");
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
getTracedCallByNameFailingStrategy_javalangStringjourneyName_javalangStringtraceName_netanotheriamoskitocorestatsTimeUnitunit.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// The next check for null of __fromServerSide is unneeded but for security reasons.
if (diMeReturnOverriden && __fromServerSide!=null)
return (net.anotheria.moskito.webui.journey.api.TracedCallAO) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getTracedCallByNameFailingStrategy_javalangStringjourneyName_javalangStringtraceName_netanotheriamoskitocorestatsTimeUnitunit.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getTracedCallByName(journeyName, traceName, unit, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getTracedCallByName(journeyName, traceName, unit, 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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
public java.util.List analyzeJourney(java.lang.String journeyName) throws net.anotheria.anoplass.api.APIException{
return analyzeJourney(journeyName, (ClientSideCallContext)null);
} //...public java.util.List analyzeJourney(java.lang.String journeyName) throws net.anotheria.anoplass.api.APIException
private java.util.List analyzeJourney(java.lang.String journeyName, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.anoplass.api.APIException{
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("analyzeJourney");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
analyzeJourneyCCStrategy_javalangStringjourneyName.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(journeyName);
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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.util.List) interceptorResponse.getReturnValue();
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
journeyName = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).analyzeJourney(journeyName, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (java.util.List) __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
analyzeJourneyCCStrategy_javalangStringjourneyName.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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (java.util.List) interceptorResponse.getReturnValue();
case OVERWRITE_RETURN_AND_CONTINUE:
if (__fromServerSide == null)
throw new AssertionError("Incorrect use of interceptor, there is no return value in this method or it is null");
__fromServerSide.set(0, interceptorResponse.getReturnValue());
diMeInterceptionContext.setReturnValue(interceptorResponse.getReturnValue());
diMeReturnOverriden = true;
break;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
analyzeJourneyFailingStrategy_javalangStringjourneyName.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// The next check for null of __fromServerSide is unneeded but for security reasons.
if (diMeReturnOverriden && __fromServerSide!=null)
return (java.util.List) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = analyzeJourneyFailingStrategy_javalangStringjourneyName.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return analyzeJourney(journeyName, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return analyzeJourney(journeyName, 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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
public void deleteJourney(java.lang.String journeyName) throws net.anotheria.anoplass.api.APIException{
deleteJourney(journeyName, (ClientSideCallContext)null);
} //...public void deleteJourney(java.lang.String journeyName) throws net.anotheria.anoplass.api.APIException
private void deleteJourney(java.lang.String journeyName, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.anoplass.api.APIException{
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("deleteJourney");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
deleteJourneyCCStrategy_javalangStringjourneyName.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(journeyName);
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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
journeyName = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).deleteJourney(journeyName, __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
deleteJourneyCCStrategy_javalangStringjourneyName.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 net.anotheria.anoplass.api.APIException)
throw (net.anotheria.anoplass.api.APIException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
deleteJourneyFailingStrategy_javalangStringjourneyName.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = deleteJourneyFailingStrategy_javalangStringjourneyName.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
deleteJourney(journeyName, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
deleteJourney(journeyName, 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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
public void init() throws net.anotheria.anoplass.api.APIInitException{
init((ClientSideCallContext)null);
} //...public void init() throws net.anotheria.anoplass.api.APIInitException
private void init(org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.anoplass.api.APIInitException{
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("init");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
initCCStrategy.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 net.anotheria.anoplass.api.APIInitException)
throw (net.anotheria.anoplass.api.APIInitException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).init( __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
initCCStrategy.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 net.anotheria.anoplass.api.APIInitException)
throw (net.anotheria.anoplass.api.APIInitException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
initFailingStrategy.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = initFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
init(diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
init(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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
public void deInit(){
deInit((ClientSideCallContext)null);
} //...public void deInit()
private void deInit(org.distributeme.core.ClientSideCallContext diMeCallContext){
List __fromServerSide = null;
Exception exceptionInMethod = null;
// This flag is used by the interceptor logic to mark a request es failed, even it is not.
boolean diMeForceFailing = false;
boolean abortAndFail = false;
if (diMeCallContext == null)
diMeCallContext = new ClientSideCallContext("deInit");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(JourneyAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
deInitCCStrategy.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();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return;
case CONTINUE:
break;
case ABORT_AND_FAIL:
abortAndFail = true;
exceptionInMethod = new FailedByInterceptorException();
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
diMeForceFailing = true;
exceptionInMethod = new FailedByInterceptorException();
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
// parse parameters again in case an interceptor modified them
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).deInit( __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
deInitCCStrategy.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;
case ABORT_AND_FAIL:
abortAndFail = true;
break;
case RETURN_AND_FAIL:
// Force failing logic to work.
deInitFailingStrategy.callFailed(diMeCallContext);
break;
default:
throw new IllegalStateException("Unsupported or unexpected command from interceptor " + interceptorResponse.getCommand()+ " in phase:"+diMeInterceptionContext.getCurrentPhase());
} //...switch
} //...for
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = deInitFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
deInit(diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
deInit(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.
if (exceptionInMethod == null)
throw new AssertionError("Exception must have been thrown before, but it wasn't, framework error!");
throw mapException(exceptionInMethod);
}
// according to findbugs this method is never used, so we remove it for now reduce warnings.
//private void notifyDelegateFailed(){
//notifyDelegateFailed(JourneyAPIConstants.getServiceId());
//}
private void notifyDelegateFailed(String serviceId){
if (discoveryMode==DiscoveryMode.MANUAL){
manuallySetTarget = null;
return;
}
if (serviceId!=null)
delegates.remove(serviceId);
} //...notifyDelegateFailed
private RemoteJourneyAPI getDelegate() throws NoConnectionToServerException{
if (discoveryMode==DiscoveryMode.MANUAL){
if (manuallySetTarget!=null)
return manuallySetTarget;
manuallySetTarget = lookup(manuallySetDescriptor);
return manuallySetTarget;
} //...if (mode==MANUAL)
return getDelegate(JourneyAPIConstants.getServiceId());
}
private RemoteJourneyAPI getDelegate(String serviceId) throws NoConnectionToServerException{
// if no serviceId is provided, fallback to default resolve with manual mode
if (serviceId==null || discoveryMode==DiscoveryMode.MANUAL)
return getDelegate();
RemoteJourneyAPI delegate = delegates.get(serviceId);
if (delegate==null){
try{
delegate = lookup(serviceId);
RemoteJourneyAPI existingDelegate = delegates.putIfAbsent(serviceId, delegate);
if (existingDelegate!=null)
delegate = existingDelegate;
}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 RemoteJourneyAPI 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 "+JourneyAPIConstants.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 "+JourneyAPIConstants.getServiceId());
}
try{
return (RemoteJourneyAPI) 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 RemoteJourneyAPI 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{
RemoteJourneyAPI ret = (RemoteJourneyAPI) registry.lookup(serviceDescriptor.getServiceId());
return ret;
}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);
}
}