use of jp.ossc.nimbus.service.aop.InvocationContext in project nimbus by nimbus-org.
the class DefaultAsynchCallInterceptorService method invokeInternal.
protected Object invokeInternal(Object inputObj, jp.ossc.nimbus.service.aspect.interfaces.InterceptorChain interceptChain, jp.ossc.nimbus.service.aop.InterceptorChain chain) throws Throwable {
Object ret = null;
Object input = inputObj;
if (chain != null) {
input = ((MethodInvocationContext) input).getParameters()[0];
}
if (input instanceof ObjectMessage) {
ObjectMessage msg = (ObjectMessage) input;
FacadeValue in = null;
if (isIgnoreRedelivery) {
try {
if (msg.getJMSRedelivered()) {
return ret;
}
} catch (JMSException e) {
throw new InterceptorException("getJMSRedelivered JMSException", e);
}
}
if (redeliveryInterval > 0) {
try {
if (msg.getJMSRedelivered()) {
Thread.sleep(redeliveryInterval);
}
} catch (InterruptedException e) {
} catch (JMSException e) {
throw new InterceptorException("getJMSRedelivered JMSException", e);
}
}
try {
in = (FacadeValue) msg.getObject();
} catch (JMSException e) {
throw new InterceptorException("getObject JMSException", e);
}
try {
if (interceptChain != null) {
ret = interceptChain.invokeChain(in);
} else {
final MethodInvocationContext context = (MethodInvocationContext) inputObj;
context.setParameters(new Object[] { in });
ret = chain.invokeNext(context);
}
} catch (TargetUncheckedException e) {
Throwable th = e.getCause();
if (th instanceof RuntimeException) {
if (queueSessionFactory != null) {
try {
Queue replyQueue = (Queue) msg.getJMSReplyTo();
if (replyQueue == null) {
throw e;
}
} catch (JMSException e2) {
throw new InterceptorException("Unexpected Exception", e2);
}
}
ret = th;
} else {
throw new InterceptorException("Unexpected Exception", th);
}
} catch (TargetCheckedException e) {
// ここに飛んでくることはない。
// コマンド層でキャッチされ処理済みのはず。
e.printStackTrace();
}
if (queueSessionFactory != null) {
try {
Queue replyQueue = (Queue) msg.getJMSReplyTo();
if (replyQueue != null) {
QueueTransanctionResource resource = null;
try {
resource = (QueueTransanctionResource) queueSessionFactory.makeResource(null);
QueueSession session = (QueueSession) resource.getObject();
QueueSender sender = session.createSender(replyQueue);
sender.send(session.createObjectMessage((Serializable) ret), deliveryMode, priority, timeToLive);
} finally {
if (resource != null) {
resource.close();
}
}
}
} catch (Exception e) {
throw new InterceptorException("Unexpected Exception", e);
}
}
} else {
if (interceptChain != null) {
ret = interceptChain.invokeChain(input);
} else {
ret = chain.invokeNext((InvocationContext) inputObj);
}
}
return ret;
}
use of jp.ossc.nimbus.service.aop.InvocationContext in project nimbus by nimbus-org.
the class ThreadContextImportInterceptorService method invokeInternal.
protected Object invokeInternal(Object inputObj, jp.ossc.nimbus.service.aspect.interfaces.InterceptorChain interceptChain, jp.ossc.nimbus.service.aop.InterceptorChain chain) throws Throwable {
Object input = inputObj;
if (chain != null) {
input = ((MethodInvocationContext) input).getParameters()[0];
}
FacadeValue in = (FacadeValue) input;
if (threadContextServiceName != null) {
final Context context = (Context) ServiceManagerFactory.getServiceObject(threadContextServiceName);
if (headerKeys == null) {
final Iterator keys = in.getHederKeys().iterator();
while (keys.hasNext()) {
final String key = (String) keys.next();
context.put(key, in.getHeader(key));
}
} else {
for (int i = 0; i < headerKeys.length; i++) {
final String key = headerKeys[i];
context.put(key, in.getHeader(key));
}
}
}
if (interceptChain != null) {
return interceptChain.invokeChain(inputObj);
} else {
return chain.invokeNext((InvocationContext) inputObj);
}
}
use of jp.ossc.nimbus.service.aop.InvocationContext in project nimbus by nimbus-org.
the class AOPInterceptorAdaptorInterceptorService method invokeChain.
public Object invokeChain(Object inputObj, InterceptorChain interceptChain) throws InterceptorException, TargetCheckedException, TargetUncheckedException {
InterceptorChainInvokerAccessImpl invoker = (InterceptorChainInvokerAccessImpl) interceptChain;
InvocationContext context = new DefaultMethodInvocationContext(invoker.mCallBackObject, invoker.mCallBackmethod, new Object[] { inputObj });
context.setAttribute(CHAIN_ATTRIBUTE_NAME, interceptChain);
try {
return chain.invokeNext(context);
} catch (TargetUncheckedException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (TargetCheckedException e) {
throw e;
} catch (InterceptorException e) {
throw e;
} catch (Exception e) {
throw new InterceptorException(e);
} catch (Throwable th) {
throw (Error) th;
}
}
Aggregations