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.portalkit.services.subscription.generated.RemoteSubscriptionServiceStub Maven / Gradle / Ivy
package net.anotheria.portalkit.services.subscription.generated;
//BEGIN GENERATED CODE
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;
@SuppressWarnings("PMD")
public class RemoteSubscriptionServiceStub implements net.anotheria.portalkit.services.subscription.SubscriptionService{
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 getActiveSubscriptionForAccountFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideFailingStrategy;
private FailingStrategy getSubscriptionForAccountFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideFailingStrategy;
private FailingStrategy getSubscriptionsFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy deleteSubscriptionsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideFailingStrategy;
private FailingStrategy deleteTransactionsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideFailingStrategy;
private FailingStrategy getTransactionsFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy addSubscriptionFailingStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription = clazzWideFailingStrategy;
private FailingStrategy updateSubscriptionFailingStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription = clazzWideFailingStrategy;
private FailingStrategy addTransactionFailingStrategy_netanotheriaportalkitservicessubscriptionTransactiontransaction = clazzWideFailingStrategy;
private FailingStrategy addTransactionLogEntryFailingStrategy_netanotheriaportalkitservicessubscriptionTransactionLogEntrytoAdd = clazzWideFailingStrategy;
private FailingStrategy getTransactionLogEntriesFailingStrategy_netanotheriaportalkitservicescommonAccountIdowner = clazzWideFailingStrategy;
private FailingStrategy getTransactionLogEntriesFailingStrategy = clazzWideFailingStrategy;
private FailingStrategy getTransactionLogEntriesByMessageMaskFailingStrategy_javalangStringmessageMask = clazzWideFailingStrategy;
private FailingStrategy deleteTransactionLogsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideFailingStrategy;
private FailingStrategy saveCancellationFailingStrategy_netanotheriaportalkitservicessubscriptionCancellationcancellation = clazzWideFailingStrategy;
private FailingStrategy deleteCancellationFailingStrategy_javalangStringaccountId = clazzWideFailingStrategy;
private FailingStrategy getCancellationByIdFailingStrategy_javalangStringaccountId = clazzWideFailingStrategy;
private FailingStrategy getCancellationsFailingStrategy = clazzWideFailingStrategy;
// Failing end
// CONCURRENCY CONTROL
// Class wide concurrency control strategy
private ConcurrencyControlStrategy clazzWideCCStrategy = Defaults.getDefaultConcurrencyControlStrategy();
private ConcurrencyControlStrategy getActiveSubscriptionForAccountCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideCCStrategy;
private ConcurrencyControlStrategy getSubscriptionForAccountCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideCCStrategy;
private ConcurrencyControlStrategy getSubscriptionsCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy deleteSubscriptionsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideCCStrategy;
private ConcurrencyControlStrategy deleteTransactionsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideCCStrategy;
private ConcurrencyControlStrategy getTransactionsCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy addSubscriptionCCStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription = clazzWideCCStrategy;
private ConcurrencyControlStrategy updateSubscriptionCCStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription = clazzWideCCStrategy;
private ConcurrencyControlStrategy addTransactionCCStrategy_netanotheriaportalkitservicessubscriptionTransactiontransaction = clazzWideCCStrategy;
private ConcurrencyControlStrategy addTransactionLogEntryCCStrategy_netanotheriaportalkitservicessubscriptionTransactionLogEntrytoAdd = clazzWideCCStrategy;
private ConcurrencyControlStrategy getTransactionLogEntriesCCStrategy_netanotheriaportalkitservicescommonAccountIdowner = clazzWideCCStrategy;
private ConcurrencyControlStrategy getTransactionLogEntriesCCStrategy = clazzWideCCStrategy;
private ConcurrencyControlStrategy getTransactionLogEntriesByMessageMaskCCStrategy_javalangStringmessageMask = clazzWideCCStrategy;
private ConcurrencyControlStrategy deleteTransactionLogsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId = clazzWideCCStrategy;
private ConcurrencyControlStrategy saveCancellationCCStrategy_netanotheriaportalkitservicessubscriptionCancellationcancellation = clazzWideCCStrategy;
private ConcurrencyControlStrategy deleteCancellationCCStrategy_javalangStringaccountId = clazzWideCCStrategy;
private ConcurrencyControlStrategy getCancellationByIdCCStrategy_javalangStringaccountId = clazzWideCCStrategy;
private ConcurrencyControlStrategy getCancellationsCCStrategy = clazzWideCCStrategy;
// CONCURRENCY CONTROL end
public RemoteSubscriptionServiceStub(){
discoveryMode = DiscoveryMode.AUTO;
}
private ServiceDescriptor manuallySetDescriptor;
private RemoteSubscriptionService manuallySetTarget;
public RemoteSubscriptionServiceStub(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 net.anotheria.portalkit.services.subscription.Subscription getActiveSubscriptionForAccount(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getActiveSubscriptionForAccount(accountId, (ClientSideCallContext)null);
} //...public net.anotheria.portalkit.services.subscription.Subscription getActiveSubscriptionForAccount(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private net.anotheria.portalkit.services.subscription.Subscription getActiveSubscriptionForAccount(net.anotheria.portalkit.services.common.AccountId accountId, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getActiveSubscriptionForAccount");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getActiveSubscriptionForAccountCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(accountId);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.portalkit.services.subscription.Subscription) 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
accountId = (net.anotheria.portalkit.services.common.AccountId) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getActiveSubscriptionForAccount(accountId, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.portalkit.services.subscription.Subscription) __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
getActiveSubscriptionForAccountCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.portalkit.services.subscription.Subscription) 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.
getActiveSubscriptionForAccountFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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.portalkit.services.subscription.Subscription) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getActiveSubscriptionForAccountFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getActiveSubscriptionForAccount(accountId, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getActiveSubscriptionForAccount(accountId, 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.portalkit.services.subscription.Subscription getSubscriptionForAccount(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getSubscriptionForAccount(accountId, (ClientSideCallContext)null);
} //...public net.anotheria.portalkit.services.subscription.Subscription getSubscriptionForAccount(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private net.anotheria.portalkit.services.subscription.Subscription getSubscriptionForAccount(net.anotheria.portalkit.services.common.AccountId accountId, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getSubscriptionForAccount");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getSubscriptionForAccountCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(accountId);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.portalkit.services.subscription.Subscription) 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
accountId = (net.anotheria.portalkit.services.common.AccountId) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getSubscriptionForAccount(accountId, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.portalkit.services.subscription.Subscription) __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
getSubscriptionForAccountCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.portalkit.services.subscription.Subscription) 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.
getSubscriptionForAccountFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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.portalkit.services.subscription.Subscription) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getSubscriptionForAccountFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getSubscriptionForAccount(accountId, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getSubscriptionForAccount(accountId, 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 getSubscriptions() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getSubscriptions((ClientSideCallContext)null);
} //...public java.util.List getSubscriptions() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private java.util.List getSubscriptions(org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getSubscriptions");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getSubscriptionsCCStrategy.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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()).getSubscriptions( __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
getSubscriptionsCCStrategy.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
getSubscriptionsFailingStrategy.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 = getSubscriptionsFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getSubscriptions(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getSubscriptions(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 deleteSubscriptions(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
deleteSubscriptions(accountId, (ClientSideCallContext)null);
} //...public void deleteSubscriptions(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void deleteSubscriptions(net.anotheria.portalkit.services.common.AccountId accountId, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("deleteSubscriptions");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
deleteSubscriptionsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(accountId);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
accountId = (net.anotheria.portalkit.services.common.AccountId) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).deleteSubscriptions(accountId, __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
deleteSubscriptionsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
deleteSubscriptionsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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 = deleteSubscriptionsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
deleteSubscriptions(accountId, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
deleteSubscriptions(accountId, 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 deleteTransactions(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
deleteTransactions(accountId, (ClientSideCallContext)null);
} //...public void deleteTransactions(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void deleteTransactions(net.anotheria.portalkit.services.common.AccountId accountId, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("deleteTransactions");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
deleteTransactionsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(accountId);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
accountId = (net.anotheria.portalkit.services.common.AccountId) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).deleteTransactions(accountId, __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
deleteTransactionsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
deleteTransactionsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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 = deleteTransactionsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
deleteTransactions(accountId, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
deleteTransactions(accountId, 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 getTransactions() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getTransactions((ClientSideCallContext)null);
} //...public java.util.List getTransactions() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private java.util.List getTransactions(org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getTransactions");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getTransactionsCCStrategy.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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()).getTransactions( __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
getTransactionsCCStrategy.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
getTransactionsFailingStrategy.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 = getTransactionsFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getTransactions(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getTransactions(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 addSubscription(net.anotheria.portalkit.services.subscription.Subscription subscription) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
addSubscription(subscription, (ClientSideCallContext)null);
} //...public void addSubscription(net.anotheria.portalkit.services.subscription.Subscription subscription) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void addSubscription(net.anotheria.portalkit.services.subscription.Subscription subscription, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("addSubscription");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
addSubscriptionCCStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(subscription);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
subscription = (net.anotheria.portalkit.services.subscription.Subscription) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).addSubscription(subscription, __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
addSubscriptionCCStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
addSubscriptionFailingStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.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 = addSubscriptionFailingStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
addSubscription(subscription, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
addSubscription(subscription, 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 updateSubscription(net.anotheria.portalkit.services.subscription.Subscription subscription) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
updateSubscription(subscription, (ClientSideCallContext)null);
} //...public void updateSubscription(net.anotheria.portalkit.services.subscription.Subscription subscription) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void updateSubscription(net.anotheria.portalkit.services.subscription.Subscription subscription, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("updateSubscription");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
updateSubscriptionCCStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(subscription);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
subscription = (net.anotheria.portalkit.services.subscription.Subscription) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).updateSubscription(subscription, __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
updateSubscriptionCCStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
updateSubscriptionFailingStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.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 = updateSubscriptionFailingStrategy_netanotheriaportalkitservicessubscriptionSubscriptionsubscription.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
updateSubscription(subscription, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
updateSubscription(subscription, 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 addTransaction(net.anotheria.portalkit.services.subscription.Transaction transaction) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
addTransaction(transaction, (ClientSideCallContext)null);
} //...public void addTransaction(net.anotheria.portalkit.services.subscription.Transaction transaction) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void addTransaction(net.anotheria.portalkit.services.subscription.Transaction transaction, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("addTransaction");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
addTransactionCCStrategy_netanotheriaportalkitservicessubscriptionTransactiontransaction.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(transaction);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
transaction = (net.anotheria.portalkit.services.subscription.Transaction) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).addTransaction(transaction, __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
addTransactionCCStrategy_netanotheriaportalkitservicessubscriptionTransactiontransaction.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
addTransactionFailingStrategy_netanotheriaportalkitservicessubscriptionTransactiontransaction.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 = addTransactionFailingStrategy_netanotheriaportalkitservicessubscriptionTransactiontransaction.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
addTransaction(transaction, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
addTransaction(transaction, 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 addTransactionLogEntry(net.anotheria.portalkit.services.subscription.TransactionLogEntry toAdd) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
addTransactionLogEntry(toAdd, (ClientSideCallContext)null);
} //...public void addTransactionLogEntry(net.anotheria.portalkit.services.subscription.TransactionLogEntry toAdd) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void addTransactionLogEntry(net.anotheria.portalkit.services.subscription.TransactionLogEntry toAdd, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("addTransactionLogEntry");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
addTransactionLogEntryCCStrategy_netanotheriaportalkitservicessubscriptionTransactionLogEntrytoAdd.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(toAdd);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
toAdd = (net.anotheria.portalkit.services.subscription.TransactionLogEntry) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).addTransactionLogEntry(toAdd, __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
addTransactionLogEntryCCStrategy_netanotheriaportalkitservicessubscriptionTransactionLogEntrytoAdd.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
addTransactionLogEntryFailingStrategy_netanotheriaportalkitservicessubscriptionTransactionLogEntrytoAdd.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 = addTransactionLogEntryFailingStrategy_netanotheriaportalkitservicessubscriptionTransactionLogEntrytoAdd.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
addTransactionLogEntry(toAdd, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
addTransactionLogEntry(toAdd, 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 getTransactionLogEntries(net.anotheria.portalkit.services.common.AccountId owner) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getTransactionLogEntries(owner, (ClientSideCallContext)null);
} //...public java.util.List getTransactionLogEntries(net.anotheria.portalkit.services.common.AccountId owner) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private java.util.List getTransactionLogEntries(net.anotheria.portalkit.services.common.AccountId owner, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getTransactionLogEntries");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getTransactionLogEntriesCCStrategy_netanotheriaportalkitservicescommonAccountIdowner.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(owner);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
owner = (net.anotheria.portalkit.services.common.AccountId) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getTransactionLogEntries(owner, __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
getTransactionLogEntriesCCStrategy_netanotheriaportalkitservicescommonAccountIdowner.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
getTransactionLogEntriesFailingStrategy_netanotheriaportalkitservicescommonAccountIdowner.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 = getTransactionLogEntriesFailingStrategy_netanotheriaportalkitservicescommonAccountIdowner.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getTransactionLogEntries(owner, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getTransactionLogEntries(owner, 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 getTransactionLogEntries() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getTransactionLogEntries((ClientSideCallContext)null);
} //...public java.util.List getTransactionLogEntries() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private java.util.List getTransactionLogEntries(org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getTransactionLogEntries");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getTransactionLogEntriesCCStrategy.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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()).getTransactionLogEntries( __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
getTransactionLogEntriesCCStrategy.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
getTransactionLogEntriesFailingStrategy.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 = getTransactionLogEntriesFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getTransactionLogEntries(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getTransactionLogEntries(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 getTransactionLogEntriesByMessageMask(java.lang.String messageMask) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getTransactionLogEntriesByMessageMask(messageMask, (ClientSideCallContext)null);
} //...public java.util.List getTransactionLogEntriesByMessageMask(java.lang.String messageMask) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private java.util.List getTransactionLogEntriesByMessageMask(java.lang.String messageMask, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getTransactionLogEntriesByMessageMask");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getTransactionLogEntriesByMessageMaskCCStrategy_javalangStringmessageMask.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(messageMask);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
messageMask = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getTransactionLogEntriesByMessageMask(messageMask, __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
getTransactionLogEntriesByMessageMaskCCStrategy_javalangStringmessageMask.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
getTransactionLogEntriesByMessageMaskFailingStrategy_javalangStringmessageMask.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 = getTransactionLogEntriesByMessageMaskFailingStrategy_javalangStringmessageMask.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getTransactionLogEntriesByMessageMask(messageMask, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getTransactionLogEntriesByMessageMask(messageMask, 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 deleteTransactionLogs(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
deleteTransactionLogs(accountId, (ClientSideCallContext)null);
} //...public void deleteTransactionLogs(net.anotheria.portalkit.services.common.AccountId accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void deleteTransactionLogs(net.anotheria.portalkit.services.common.AccountId accountId, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("deleteTransactionLogs");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
deleteTransactionLogsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(accountId);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
accountId = (net.anotheria.portalkit.services.common.AccountId) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).deleteTransactionLogs(accountId, __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
deleteTransactionLogsCCStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
deleteTransactionLogsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.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 = deleteTransactionLogsFailingStrategy_netanotheriaportalkitservicescommonAccountIdaccountId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
deleteTransactionLogs(accountId, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
deleteTransactionLogs(accountId, 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 saveCancellation(net.anotheria.portalkit.services.subscription.Cancellation cancellation) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
saveCancellation(cancellation, (ClientSideCallContext)null);
} //...public void saveCancellation(net.anotheria.portalkit.services.subscription.Cancellation cancellation) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void saveCancellation(net.anotheria.portalkit.services.subscription.Cancellation cancellation, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("saveCancellation");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
saveCancellationCCStrategy_netanotheriaportalkitservicessubscriptionCancellationcancellation.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(cancellation);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
cancellation = (net.anotheria.portalkit.services.subscription.Cancellation) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).saveCancellation(cancellation, __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
saveCancellationCCStrategy_netanotheriaportalkitservicessubscriptionCancellationcancellation.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
saveCancellationFailingStrategy_netanotheriaportalkitservicessubscriptionCancellationcancellation.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 = saveCancellationFailingStrategy_netanotheriaportalkitservicessubscriptionCancellationcancellation.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
saveCancellation(cancellation, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
saveCancellation(cancellation, 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 deleteCancellation(java.lang.String accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
deleteCancellation(accountId, (ClientSideCallContext)null);
} //...public void deleteCancellation(java.lang.String accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private void deleteCancellation(java.lang.String accountId, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("deleteCancellation");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
deleteCancellationCCStrategy_javalangStringaccountId.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(accountId);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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
accountId = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).deleteCancellation(accountId, __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
deleteCancellationCCStrategy_javalangStringaccountId.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
deleteCancellationFailingStrategy_javalangStringaccountId.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 = deleteCancellationFailingStrategy_javalangStringaccountId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
deleteCancellation(accountId, diMeCallContext.increaseCallCount());
return;
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
deleteCancellation(accountId, 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.portalkit.services.subscription.Cancellation getCancellationById(java.lang.String accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getCancellationById(accountId, (ClientSideCallContext)null);
} //...public net.anotheria.portalkit.services.subscription.Cancellation getCancellationById(java.lang.String accountId) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private net.anotheria.portalkit.services.subscription.Cancellation getCancellationById(java.lang.String accountId, org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getCancellationById");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getCancellationByIdCCStrategy_javalangStringaccountId.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeParameters.add(accountId);
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.portalkit.services.subscription.Cancellation) 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
accountId = (java.lang.String) diMeParameters.get(0);
if (!abortAndFail){
__fromServerSide = getDelegate(diMeCallContext.getServiceId()).getCancellationById(accountId, __transportableCallContext);
__transportableCallContext.putAll(((HashMap)__fromServerSide.get(1)));
return (net.anotheria.portalkit.services.subscription.Cancellation) __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
getCancellationByIdCCStrategy_javalangStringaccountId.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) interceptorResponse.getException();
throw new RuntimeException("Interceptor exception",interceptorResponse.getException());
case RETURN:
return (net.anotheria.portalkit.services.subscription.Cancellation) 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.
getCancellationByIdFailingStrategy_javalangStringaccountId.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.portalkit.services.subscription.Cancellation) __fromServerSide.get(0);
} //...finally
// Failing
if (exceptionInMethod!=null || diMeForceFailing || abortAndFail){
FailDecision failDecision = getCancellationByIdFailingStrategy_javalangStringaccountId.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getCancellationById(accountId, diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getCancellationById(accountId, 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 getCancellations() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
return getCancellations((ClientSideCallContext)null);
} //...public java.util.List getCancellations() throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException
private java.util.List getCancellations(org.distributeme.core.ClientSideCallContext diMeCallContext) throws net.anotheria.portalkit.services.subscription.SubscriptionServiceException{
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("getCancellations");
if (discoveryMode == DiscoveryMode.MANUAL) {
diMeCallContext.setServiceId(manuallySetDescriptor.getServiceId());
}
if (discoveryMode==DiscoveryMode.AUTO && diMeCallContext.getServiceId()==null)
diMeCallContext.setServiceId(SubscriptionServiceConstants.getServiceId());
HashMap __transportableCallContext = diMeCallContext.getTransportableCallContext();
// Initialize interceptors
List diMeInterceptors = InterceptorRegistry.getInstance().getClientSideRequestInterceptors();
InterceptionContext diMeInterceptionContext = new InterceptionContext();
// Concurrency control, client side - start
getCancellationsCCStrategy.notifyClientSideCallStarted(diMeCallContext);
try{
ArrayList diMeParameters = new ArrayList();
diMeCallContext.setParameters(diMeParameters);
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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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()).getCancellations( __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
getCancellationsCCStrategy.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.portalkit.services.subscription.SubscriptionServiceException)
throw (net.anotheria.portalkit.services.subscription.SubscriptionServiceException) 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.
getCancellationsFailingStrategy.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 = getCancellationsFailingStrategy.callFailed(diMeCallContext);
if (failDecision.getTargetService()!=null)
diMeCallContext.setServiceId(failDecision.getTargetService());
switch(failDecision.getReaction()){
case RETRY:
return getCancellations(diMeCallContext.increaseCallCount());
case RETRYONCE:
// Only retry if its the first call
if (!diMeCallContext.isFirstCall())
break;
return getCancellations(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);
}
// according to findbugs this method is never used, so we remove it for now reduce warnings.
//private void notifyDelegateFailed(){
//notifyDelegateFailed(SubscriptionServiceConstants.getServiceId());
//}
private void notifyDelegateFailed(String serviceId){
if (discoveryMode==DiscoveryMode.MANUAL){
manuallySetTarget = null;
return;
}
if (serviceId!=null)
delegates.remove(serviceId);
} //...notifyDelegateFailed
private RemoteSubscriptionService getDelegate() throws NoConnectionToServerException{
if (discoveryMode==DiscoveryMode.MANUAL){
if (manuallySetTarget!=null)
return manuallySetTarget;
manuallySetTarget = lookup(manuallySetDescriptor);
return manuallySetTarget;
} //...if (mode==MANUAL)
return getDelegate(SubscriptionServiceConstants.getServiceId());
}
private RemoteSubscriptionService 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();
RemoteSubscriptionService delegate = delegates.get(serviceId);
if (delegate==null){
try{
delegate = lookup(serviceId);
RemoteSubscriptionService 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 RemoteSubscriptionService 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 "+SubscriptionServiceConstants.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 "+SubscriptionServiceConstants.getServiceId());
}
try{
return (RemoteSubscriptionService) 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 RemoteSubscriptionService 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{
RemoteSubscriptionService ret = (RemoteSubscriptionService) 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);
}
}