msg.setBodyWithFault(cause); } catch (IllegalAccessException e) { throw new InvocationRuntimeException(e);
/** * Performs the invocation on the target component instance. If a target classloader is configured for the interceptor, it will be set as the TCCL. * * @param msg the messaging containing the invocation data * @param instance the target component instance * @return the response message */ private Message invoke(Message msg, Object instance) { try { Object body = msg.getBody(); if (targetTCCLClassLoader == null) { msg.setBody(invoker.invoke(instance, body)); } else { ClassLoader old = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(targetTCCLClassLoader); msg.setBody(invoker.invoke(instance, body)); } finally { Thread.currentThread().setContextClassLoader(old); } } } catch (InvocationTargetException e) { msg.setBodyWithFault(e.getCause()); } catch (IllegalAccessException e) { throw new InvocationRuntimeException(e); } return msg; }
public Message invoke(Message msg) { WorkContext workContext = msg.getWorkContext(); try { SecuritySubject subject = workContext.getSubject(); if (subject == null) { msg.setBodyWithFault(new ServiceRuntimeException("Subject not authenticated")); return msg; } authorizationService.checkRoles(subject, roles); return next.invoke(msg); } catch (AuthorizationException e) { msg.setBodyWithFault(new ServiceRuntimeException(e)); return msg; } }
response.setBodyWithFault(fault); } catch (InstantiationException e) { throw new AssertionError();
throw e; //retry ret.setBodyWithFault(e.getDetail()); Object result = sender.sendReceive(message); if (result instanceof Throwable) { ret.setBodyWithFault(result); } else { ret.setBody(result);
private Message transformOutput(Message ret) { // FIXME For exception transformation, if it is checked convert as application fault Object body = ret.getBody(); // TODO handle null types if (body != null) { try { Object transformed = outTransformer.transform(body, outLoader); if (ret.isFault()) { ret.setBodyWithFault(transformed); } else { ret.setBody(transformed); } } catch (ClassCastException e) { // an unexpected type was returned by the target service or an interceptor later in the chain. This is an error in the extension or // interceptor and not user code since errors should be trapped and returned in the format expected by the transformer if (body instanceof Throwable) { throw new ServiceRuntimeException("Unexpected exception returned", (Throwable) body); } else { throw new ServiceRuntimeException("Unexpected type returned: " + body.getClass()); } } catch (TransformationException e) { throw new ServiceRuntimeException(e); } } return ret; }