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.shared.api.generated.RemoteAdditionalFunctionalityAPIStub Maven / Gradle / Ivy
package net.anotheria.moskito.webui.shared.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 RemoteAdditionalFunctionalityAPIStub implements net.anotheria.moskito.webui.shared.api.AdditionalFunctionalityAPI{
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 getPluginsFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy removePluginFailingStrategy_javalangStringpluginName = clazzWideFailingStrategy;
private FailingStrategy forceIntervalUpdateFailingStrategy_javalangStringintervalName = clazzWideFailingStrategy;
private FailingStrategy getMBeansFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getIntervalInfosFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getConfigurationAsStringFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getIntervalUpdateTimestampFailingStrategy_javalangStringintervalName = clazzWideFailingStrategy;
private FailingStrategy getConfigurationFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getActiveErrorCatchersFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getCaughtErrorsByExceptionNameFailingStrategy_javalangStringexceptionName = 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 getPluginsCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy removePluginCCStrategy_javalangStringpluginName = clazzWideCCStrategy;
private ConcurrencyControlStrategy forceIntervalUpdateCCStrategy_javalangStringintervalName = clazzWideCCStrategy;
private ConcurrencyControlStrategy getMBeansCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getIntervalInfosCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getConfigurationAsStringCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getIntervalUpdateTimestampCCStrategy_javalangStringintervalName = clazzWideCCStrategy;
private ConcurrencyControlStrategy getConfigurationCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getActiveErrorCatchersCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getCaughtErrorsByExceptionNameCCStrategy_javalangStringexceptionName = clazzWideCCStrategy;
private ConcurrencyControlStrategy initCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy deInitCCStrategy = clazzWideCCStrategy;
// CONCURRENCY CONTROL end
public RemoteAdditionalFunctionalityAPIStub(){
discoveryMode = DiscoveryMode.AUTO;
}
private ServiceDescriptor manuallySetDescriptor;
private RemoteAdditionalFunctionalityAPI manuallySetTarget;
public RemoteAdditionalFunctionalityAPIStub(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 getPlugins() throws net.anotheria.anoplass.api.APIException{
return getPlugins((ClientSideCallContext)null);
} //...public java.util.List getPlugins() throws net.anotheria.anoplass.api.APIException
private java.util.List getPlugins(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("getPlugins");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getPluginsCCStrategy.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()).getPlugins( __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
getPluginsCCStrategy.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.
getPluginsFailingStrategy.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 = getPluginsFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getPlugins(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getPlugins(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 removePlugin(java.lang.String pluginName) throws net.anotheria.anoplass.api.APIException{
removePlugin(pluginName, (ClientSideCallContext)null);
} //...public void removePlugin(java.lang.String pluginName) throws net.anotheria.anoplass.api.APIException
private void removePlugin(java.lang.String pluginName, 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("removePlugin");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
removePluginCCStrategy_javalangStringpluginName.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(pluginName);
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
pluginName = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).removePlugin(pluginName, __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
removePluginCCStrategy_javalangStringpluginName.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.
removePluginFailingStrategy_javalangStringpluginName.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 = removePluginFailingStrategy_javalangStringpluginName.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
removePlugin(pluginName, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
removePlugin(pluginName, 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 forceIntervalUpdate(java.lang.String intervalName) throws net.anotheria.anoplass.api.APIException{
forceIntervalUpdate(intervalName, (ClientSideCallContext)null);
} //...public void forceIntervalUpdate(java.lang.String intervalName) throws net.anotheria.anoplass.api.APIException
private void forceIntervalUpdate(java.lang.String intervalName, 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("forceIntervalUpdate");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
forceIntervalUpdateCCStrategy_javalangStringintervalName.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(intervalName);
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
intervalName = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).forceIntervalUpdate(intervalName, __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
forceIntervalUpdateCCStrategy_javalangStringintervalName.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.
forceIntervalUpdateFailingStrategy_javalangStringintervalName.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 = forceIntervalUpdateFailingStrategy_javalangStringintervalName.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
forceIntervalUpdate(intervalName, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
forceIntervalUpdate(intervalName, 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 java.util.List getMBeans() throws net.anotheria.anoplass.api.APIException{
return getMBeans((ClientSideCallContext)null);
} //...public java.util.List getMBeans() throws net.anotheria.anoplass.api.APIException
private java.util.List getMBeans(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("getMBeans");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getMBeansCCStrategy.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()).getMBeans( __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
getMBeansCCStrategy.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.
getMBeansFailingStrategy.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 = getMBeansFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getMBeans(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getMBeans(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 getIntervalInfos() throws net.anotheria.anoplass.api.APIException{
return getIntervalInfos((ClientSideCallContext)null);
} //...public java.util.List getIntervalInfos() throws net.anotheria.anoplass.api.APIException
private java.util.List getIntervalInfos(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("getIntervalInfos");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getIntervalInfosCCStrategy.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()).getIntervalInfos( __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
getIntervalInfosCCStrategy.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.
getIntervalInfosFailingStrategy.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 = getIntervalInfosFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getIntervalInfos(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getIntervalInfos(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.lang.String getConfigurationAsString() throws net.anotheria.anoplass.api.APIException{
return getConfigurationAsString((ClientSideCallContext)null);
} //...public java.lang.String getConfigurationAsString() throws net.anotheria.anoplass.api.APIException
private java.lang.String getConfigurationAsString(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("getConfigurationAsString");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getConfigurationAsStringCCStrategy.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.lang.String) 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()).getConfigurationAsString( __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
getConfigurationAsStringCCStrategy.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.lang.String) 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.
getConfigurationAsStringFailingStrategy.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.lang.String) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getConfigurationAsStringFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getConfigurationAsString(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getConfigurationAsString(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.lang.Long getIntervalUpdateTimestamp(java.lang.String intervalName) throws net.anotheria.anoplass.api.APIException{
return getIntervalUpdateTimestamp(intervalName, (ClientSideCallContext)null);
} //...public java.lang.Long getIntervalUpdateTimestamp(java.lang.String intervalName) throws net.anotheria.anoplass.api.APIException
private java.lang.Long getIntervalUpdateTimestamp(java.lang.String intervalName, 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("getIntervalUpdateTimestamp");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getIntervalUpdateTimestampCCStrategy_javalangStringintervalName.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(intervalName);
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.lang.Long) 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
intervalName = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getIntervalUpdateTimestamp(intervalName, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (java.lang.Long) __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
getIntervalUpdateTimestampCCStrategy_javalangStringintervalName.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.lang.Long) 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.
getIntervalUpdateTimestampFailingStrategy_javalangStringintervalName.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.lang.Long) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getIntervalUpdateTimestampFailingStrategy_javalangStringintervalName.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getIntervalUpdateTimestamp(intervalName, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getIntervalUpdateTimestamp(intervalName, 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.core.config.MoskitoConfiguration getConfiguration() throws net.anotheria.anoplass.api.APIException{
return getConfiguration((ClientSideCallContext)null);
} //...public net.anotheria.moskito.core.config.MoskitoConfiguration getConfiguration() throws net.anotheria.anoplass.api.APIException
private net.anotheria.moskito.core.config.MoskitoConfiguration getConfiguration(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("getConfiguration");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getConfigurationCCStrategy.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 (net.anotheria.moskito.core.config.MoskitoConfiguration) 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()).getConfiguration( __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.moskito.core.config.MoskitoConfiguration) __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
getConfigurationCCStrategy.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.core.config.MoskitoConfiguration) 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.
getConfigurationFailingStrategy.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.core.config.MoskitoConfiguration) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getConfigurationFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getConfiguration(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getConfiguration(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 getActiveErrorCatchers() throws net.anotheria.anoplass.api.APIException{
return getActiveErrorCatchers((ClientSideCallContext)null);
} //...public java.util.List getActiveErrorCatchers() throws net.anotheria.anoplass.api.APIException
private java.util.List getActiveErrorCatchers(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("getActiveErrorCatchers");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getActiveErrorCatchersCCStrategy.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()).getActiveErrorCatchers( __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
getActiveErrorCatchersCCStrategy.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.
getActiveErrorCatchersFailingStrategy.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 = getActiveErrorCatchersFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getActiveErrorCatchers(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getActiveErrorCatchers(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 getCaughtErrorsByExceptionName(java.lang.String exceptionName) throws net.anotheria.anoplass.api.APIException{
return getCaughtErrorsByExceptionName(exceptionName, (ClientSideCallContext)null);
} //...public java.util.List getCaughtErrorsByExceptionName(java.lang.String exceptionName) throws net.anotheria.anoplass.api.APIException
private java.util.List getCaughtErrorsByExceptionName(java.lang.String exceptionName, 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("getCaughtErrorsByExceptionName");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(AdditionalFunctionalityAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getCaughtErrorsByExceptionNameCCStrategy_javalangStringexceptionName.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(exceptionName);
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
exceptionName = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getCaughtErrorsByExceptionName(exceptionName, __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
getCaughtErrorsByExceptionNameCCStrategy_javalangStringexceptionName.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.
getCaughtErrorsByExceptionNameFailingStrategy_javalangStringexceptionName.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 = getCaughtErrorsByExceptionNameFailingStrategy_javalangStringexceptionName.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getCaughtErrorsByExceptionName(exceptionName, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getCaughtErrorsByExceptionName(exceptionName, 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 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(AdditionalFunctionalityAPIConstants.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(AdditionalFunctionalityAPIConstants.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(AdditionalFunctionalityAPIConstants.getServiceId());
//}
private void notifyDelegateFailed(String serviceId){
if (discoveryMode==DiscoveryMode.MANUAL){
manuallySetTarget = null;
return;
}
if (serviceId!=null)
delegates.remove(serviceId);
} //...notifyDelegateFailed
private RemoteAdditionalFunctionalityAPI getDelegate() throws NoConnectionToServerException{
if (discoveryMode==DiscoveryMode.MANUAL){
if (manuallySetTarget!=null)
return manuallySetTarget;
manuallySetTarget = lookup(manuallySetDescriptor);
return manuallySetTarget;
} //...if (mode==MANUAL)
return getDelegate(AdditionalFunctionalityAPIConstants.getServiceId());
}
private RemoteAdditionalFunctionalityAPI 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();
RemoteAdditionalFunctionalityAPI delegate = delegates.get(serviceId);
if (delegate==null){
try{
delegate = lookup(serviceId);
RemoteAdditionalFunctionalityAPI 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 RemoteAdditionalFunctionalityAPI 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 "+AdditionalFunctionalityAPIConstants.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 "+AdditionalFunctionalityAPIConstants.getServiceId());
}
try{
return (RemoteAdditionalFunctionalityAPI) 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 RemoteAdditionalFunctionalityAPI 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{
RemoteAdditionalFunctionalityAPI ret = (RemoteAdditionalFunctionalityAPI) 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);
}
}