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.threshold.api.generated.RemoteThresholdAPIStub Maven / Gradle / Ivy
package net.anotheria.moskito.webui.threshold.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 RemoteThresholdAPIStub implements net.anotheria.moskito.webui.threshold.api.ThresholdAPI{
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 getAlertsFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy createThresholdFailingStrategy_netanotheriamoskitowebuithresholdapiThresholdPOpo = clazzWideFailingStrategy;
private FailingStrategy getThresholdStatusesFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getThresholdStatusesFailingStrategy_javalangStringnames = clazzWideFailingStrategy;
private FailingStrategy getThresholdDefinitionsFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy removeThresholdFailingStrategy_javalangStringid = clazzWideFailingStrategy;
private FailingStrategy updateThresholdFailingStrategy_javalangStringthresholdId_netanotheriamoskitowebuithresholdapiThresholdPOpo = clazzWideFailingStrategy;
private FailingStrategy getWorstStatusFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getThresholdDefinitionFailingStrategy_javalangStringid = clazzWideFailingStrategy;
private FailingStrategy getWorstStatusFailingStrategy_javautilListthresholdNames = clazzWideFailingStrategy;
private FailingStrategy getGuardsForThresholdFailingStrategy_javalangStringthresholdId = clazzWideFailingStrategy;
private FailingStrategy getThresholdIdsTiedToASpecificProducerFailingStrategy_javalangStringproducerId = 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 getAlertsCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy createThresholdCCStrategy_netanotheriamoskitowebuithresholdapiThresholdPOpo = clazzWideCCStrategy;
private ConcurrencyControlStrategy getThresholdStatusesCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getThresholdStatusesCCStrategy_javalangStringnames = clazzWideCCStrategy;
private ConcurrencyControlStrategy getThresholdDefinitionsCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy removeThresholdCCStrategy_javalangStringid = clazzWideCCStrategy;
private ConcurrencyControlStrategy updateThresholdCCStrategy_javalangStringthresholdId_netanotheriamoskitowebuithresholdapiThresholdPOpo = clazzWideCCStrategy;
private ConcurrencyControlStrategy getWorstStatusCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getThresholdDefinitionCCStrategy_javalangStringid = clazzWideCCStrategy;
private ConcurrencyControlStrategy getWorstStatusCCStrategy_javautilListthresholdNames = clazzWideCCStrategy;
private ConcurrencyControlStrategy getGuardsForThresholdCCStrategy_javalangStringthresholdId = clazzWideCCStrategy;
private ConcurrencyControlStrategy getThresholdIdsTiedToASpecificProducerCCStrategy_javalangStringproducerId = clazzWideCCStrategy;
private ConcurrencyControlStrategy initCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy deInitCCStrategy = clazzWideCCStrategy;
// CONCURRENCY CONTROL end
public RemoteThresholdAPIStub(){
discoveryMode = DiscoveryMode.AUTO;
}
private ServiceDescriptor manuallySetDescriptor;
private RemoteThresholdAPI manuallySetTarget;
public RemoteThresholdAPIStub(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 getAlerts() throws net.anotheria.anoplass.api.APIException{
return getAlerts((ClientSideCallContext)null);
} //...public java.util.List getAlerts() throws net.anotheria.anoplass.api.APIException
private java.util.List getAlerts(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("getAlerts");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getAlertsCCStrategy.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()).getAlerts( __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
getAlertsCCStrategy.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.
getAlertsFailingStrategy.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 = getAlertsFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getAlerts(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getAlerts(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 createThreshold(net.anotheria.moskito.webui.threshold.api.ThresholdPO po) throws net.anotheria.anoplass.api.APIException{
createThreshold(po, (ClientSideCallContext)null);
} //...public void createThreshold(net.anotheria.moskito.webui.threshold.api.ThresholdPO po) throws net.anotheria.anoplass.api.APIException
private void createThreshold(net.anotheria.moskito.webui.threshold.api.ThresholdPO po, 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("createThreshold");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
createThresholdCCStrategy_netanotheriamoskitowebuithresholdapiThresholdPOpo.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(po);
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
po = (net.anotheria.moskito.webui.threshold.api.ThresholdPO) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).createThreshold(po, __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
createThresholdCCStrategy_netanotheriamoskitowebuithresholdapiThresholdPOpo.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.
createThresholdFailingStrategy_netanotheriamoskitowebuithresholdapiThresholdPOpo.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 = createThresholdFailingStrategy_netanotheriamoskitowebuithresholdapiThresholdPOpo.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
createThreshold(po, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
createThreshold(po, 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 getThresholdStatuses() throws net.anotheria.anoplass.api.APIException{
return getThresholdStatuses((ClientSideCallContext)null);
} //...public java.util.List getThresholdStatuses() throws net.anotheria.anoplass.api.APIException
private java.util.List getThresholdStatuses(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("getThresholdStatuses");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getThresholdStatusesCCStrategy.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()).getThresholdStatuses( __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
getThresholdStatusesCCStrategy.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.
getThresholdStatusesFailingStrategy.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 = getThresholdStatusesFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getThresholdStatuses(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getThresholdStatuses(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 getThresholdStatuses(java.lang.String[] names) throws net.anotheria.anoplass.api.APIException{
return getThresholdStatuses(names, (ClientSideCallContext)null);
} //...public java.util.List getThresholdStatuses(java.lang.String[] names) throws net.anotheria.anoplass.api.APIException
private java.util.List getThresholdStatuses(java.lang.String[] names, 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("getThresholdStatuses");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getThresholdStatusesCCStrategy_javalangStringnames.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(names);
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
names = (java.lang.String[]) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getThresholdStatuses(names, __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
getThresholdStatusesCCStrategy_javalangStringnames.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.
getThresholdStatusesFailingStrategy_javalangStringnames.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 = getThresholdStatusesFailingStrategy_javalangStringnames.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getThresholdStatuses(names, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getThresholdStatuses(names, 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 getThresholdDefinitions() throws net.anotheria.anoplass.api.APIException{
return getThresholdDefinitions((ClientSideCallContext)null);
} //...public java.util.List getThresholdDefinitions() throws net.anotheria.anoplass.api.APIException
private java.util.List getThresholdDefinitions(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("getThresholdDefinitions");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getThresholdDefinitionsCCStrategy.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()).getThresholdDefinitions( __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
getThresholdDefinitionsCCStrategy.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.
getThresholdDefinitionsFailingStrategy.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 = getThresholdDefinitionsFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getThresholdDefinitions(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getThresholdDefinitions(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 removeThreshold(java.lang.String id) throws net.anotheria.anoplass.api.APIException{
removeThreshold(id, (ClientSideCallContext)null);
} //...public void removeThreshold(java.lang.String id) throws net.anotheria.anoplass.api.APIException
private void removeThreshold(java.lang.String id, 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("removeThreshold");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
removeThresholdCCStrategy_javalangStringid.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(id);
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
id = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).removeThreshold(id, __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
removeThresholdCCStrategy_javalangStringid.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.
removeThresholdFailingStrategy_javalangStringid.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 = removeThresholdFailingStrategy_javalangStringid.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
removeThreshold(id, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
removeThreshold(id, 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 updateThreshold(java.lang.String thresholdId, net.anotheria.moskito.webui.threshold.api.ThresholdPO po) throws net.anotheria.anoplass.api.APIException{
updateThreshold(thresholdId, po, (ClientSideCallContext)null);
} //...public void updateThreshold(java.lang.String thresholdId, net.anotheria.moskito.webui.threshold.api.ThresholdPO po) throws net.anotheria.anoplass.api.APIException
private void updateThreshold(java.lang.String thresholdId, net.anotheria.moskito.webui.threshold.api.ThresholdPO po, 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("updateThreshold");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
updateThresholdCCStrategy_javalangStringthresholdId_netanotheriamoskitowebuithresholdapiThresholdPOpo.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(thresholdId);
diMeParameters.add(po);
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
thresholdId = (java.lang.String) diMeParameters.get(0);
po = (net.anotheria.moskito.webui.threshold.api.ThresholdPO) diMeParameters.get(1);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).updateThreshold(thresholdId, po, __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
updateThresholdCCStrategy_javalangStringthresholdId_netanotheriamoskitowebuithresholdapiThresholdPOpo.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.
updateThresholdFailingStrategy_javalangStringthresholdId_netanotheriamoskitowebuithresholdapiThresholdPOpo.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 = updateThresholdFailingStrategy_javalangStringthresholdId_netanotheriamoskitowebuithresholdapiThresholdPOpo.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
updateThreshold(thresholdId, po, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
updateThreshold(thresholdId, po, 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 net.anotheria.moskito.core.threshold.ThresholdStatus getWorstStatus() throws net.anotheria.anoplass.api.APIException{
return getWorstStatus((ClientSideCallContext)null);
} //...public net.anotheria.moskito.core.threshold.ThresholdStatus getWorstStatus() throws net.anotheria.anoplass.api.APIException
private net.anotheria.moskito.core.threshold.ThresholdStatus getWorstStatus(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("getWorstStatus");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getWorstStatusCCStrategy.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.threshold.ThresholdStatus) 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()).getWorstStatus( __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.moskito.core.threshold.ThresholdStatus) __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
getWorstStatusCCStrategy.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.threshold.ThresholdStatus) 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.
getWorstStatusFailingStrategy.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.threshold.ThresholdStatus) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getWorstStatusFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getWorstStatus(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getWorstStatus(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.threshold.api.ThresholdDefinitionAO getThresholdDefinition(java.lang.String id) throws net.anotheria.anoplass.api.APIException{
return getThresholdDefinition(id, (ClientSideCallContext)null);
} //...public net.anotheria.moskito.webui.threshold.api.ThresholdDefinitionAO getThresholdDefinition(java.lang.String id) throws net.anotheria.anoplass.api.APIException
private net.anotheria.moskito.webui.threshold.api.ThresholdDefinitionAO getThresholdDefinition(java.lang.String id, 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("getThresholdDefinition");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getThresholdDefinitionCCStrategy_javalangStringid.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(id);
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.threshold.api.ThresholdDefinitionAO) 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
id = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getThresholdDefinition(id, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.moskito.webui.threshold.api.ThresholdDefinitionAO) __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
getThresholdDefinitionCCStrategy_javalangStringid.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.threshold.api.ThresholdDefinitionAO) 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.
getThresholdDefinitionFailingStrategy_javalangStringid.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.threshold.api.ThresholdDefinitionAO) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getThresholdDefinitionFailingStrategy_javalangStringid.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getThresholdDefinition(id, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getThresholdDefinition(id, 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.threshold.ThresholdStatus getWorstStatus(java.util.List thresholdNames) throws net.anotheria.anoplass.api.APIException{
return getWorstStatus(thresholdNames, (ClientSideCallContext)null);
} //...public net.anotheria.moskito.core.threshold.ThresholdStatus getWorstStatus(java.util.List thresholdNames) throws net.anotheria.anoplass.api.APIException
private net.anotheria.moskito.core.threshold.ThresholdStatus getWorstStatus(java.util.List thresholdNames, 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("getWorstStatus");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getWorstStatusCCStrategy_javautilListthresholdNames.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(thresholdNames);
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.threshold.ThresholdStatus) 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
thresholdNames = (java.util.List) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getWorstStatus(thresholdNames, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.moskito.core.threshold.ThresholdStatus) __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
getWorstStatusCCStrategy_javautilListthresholdNames.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.threshold.ThresholdStatus) 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.
getWorstStatusFailingStrategy_javautilListthresholdNames.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.threshold.ThresholdStatus) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getWorstStatusFailingStrategy_javautilListthresholdNames.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getWorstStatus(thresholdNames, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getWorstStatus(thresholdNames, 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 getGuardsForThreshold(java.lang.String thresholdId) throws net.anotheria.anoplass.api.APIException{
return getGuardsForThreshold(thresholdId, (ClientSideCallContext)null);
} //...public java.util.List getGuardsForThreshold(java.lang.String thresholdId) throws net.anotheria.anoplass.api.APIException
private java.util.List getGuardsForThreshold(java.lang.String thresholdId, 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("getGuardsForThreshold");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getGuardsForThresholdCCStrategy_javalangStringthresholdId.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(thresholdId);
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
thresholdId = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getGuardsForThreshold(thresholdId, __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
getGuardsForThresholdCCStrategy_javalangStringthresholdId.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.
getGuardsForThresholdFailingStrategy_javalangStringthresholdId.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 = getGuardsForThresholdFailingStrategy_javalangStringthresholdId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getGuardsForThreshold(thresholdId, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getGuardsForThreshold(thresholdId, 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 getThresholdIdsTiedToASpecificProducer(java.lang.String producerId) throws net.anotheria.anoplass.api.APIException{
return getThresholdIdsTiedToASpecificProducer(producerId, (ClientSideCallContext)null);
} //...public java.util.List getThresholdIdsTiedToASpecificProducer(java.lang.String producerId) throws net.anotheria.anoplass.api.APIException
private java.util.List getThresholdIdsTiedToASpecificProducer(java.lang.String producerId, 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("getThresholdIdsTiedToASpecificProducer");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(ThresholdAPIConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getThresholdIdsTiedToASpecificProducerCCStrategy_javalangStringproducerId.notifyClientSideCallStarted(diMeCallContext);
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(producerId);
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
producerId = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getThresholdIdsTiedToASpecificProducer(producerId, __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
getThresholdIdsTiedToASpecificProducerCCStrategy_javalangStringproducerId.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.
getThresholdIdsTiedToASpecificProducerFailingStrategy_javalangStringproducerId.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 = getThresholdIdsTiedToASpecificProducerFailingStrategy_javalangStringproducerId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getThresholdIdsTiedToASpecificProducer(producerId, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getThresholdIdsTiedToASpecificProducer(producerId, 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(ThresholdAPIConstants.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(ThresholdAPIConstants.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(ThresholdAPIConstants.getServiceId());
//}
private void notifyDelegateFailed(String serviceId){
if (discoveryMode==DiscoveryMode.MANUAL){
manuallySetTarget = null;
return;
}
if (serviceId!=null)
delegates.remove(serviceId);
} //...notifyDelegateFailed
private RemoteThresholdAPI getDelegate() throws NoConnectionToServerException{
if (discoveryMode==DiscoveryMode.MANUAL){
if (manuallySetTarget!=null)
return manuallySetTarget;
manuallySetTarget = lookup(manuallySetDescriptor);
return manuallySetTarget;
} //...if (mode==MANUAL)
return getDelegate(ThresholdAPIConstants.getServiceId());
}
private RemoteThresholdAPI 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();
RemoteThresholdAPI delegate = delegates.get(serviceId);
if (delegate==null){
try{
delegate = lookup(serviceId);
RemoteThresholdAPI 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 RemoteThresholdAPI 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 "+ThresholdAPIConstants.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 "+ThresholdAPIConstants.getServiceId());
}
try{
return (RemoteThresholdAPI) 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 RemoteThresholdAPI 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{
RemoteThresholdAPI ret = (RemoteThresholdAPI) 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);
}
}