[jboss-user] [EJB3] - Re: Why application exceptions are wrapped in EJBException on AS 6.1?
spangaer
do-not-reply at jboss.com
Fri Mar 23 07:15:54 EDT 2012
spangaer [https://community.jboss.org/people/spangaer] created the discussion
"Re: Why application exceptions are wrapped in EJBException on AS 6.1?"
To view the discussion, visit: https://community.jboss.org/message/725880#725880
--------------------------------------------------------------
Ive put in in jboss\server\default\lib in a jar. And my a small modification to respect inheritence.
public class BMTTxInterceptorFactoryCustom extends BMTTxInterceptorFactory {
@SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(BMTTxInterceptorFactoryCustom.class);
public Object createPerJoinpoint(Advisor advisor, Joinpoint jp) {
// We have to do this until AOP supports matching based on annotation attributes
TransactionManagementType type = TxUtil.getTransactionManagementType(advisor);
if (type != TransactionManagementType.BEAN)
return new NullInterceptor();
TransactionManager tm = TxUtil.getTransactionManager();
boolean stateful = advisor.resolveAnnotation(Stateful.class) != null;
// Both MessageDriven and Stateless are stateless
if (stateful)
return new StatefulBMTInterceptor(tm);
else
return new StatelessBMTInterceptor(tm) {
@SuppressWarnings("unused")
protected void handleException(Invocation invocation, Exception ex) throws Exception {
if (ex == null) {
return;
}
ApplicationException ae = (ApplicationException) invocation.getAdvisor()
.resolveAnnotation(ApplicationException.class);
// it's an application exception, so just throw it back as-is
if (ae != null || ex.getClass().isAnnotationPresent(ApplicationException.class)
|| isApplicationExceptionPresentInParent(ex.getClass().getSuperclass())) {
throw ex;
}
if (ex instanceof EJBException) {
throw (EJBException) ex;
} else {
throw new EJBException(ex);
}
}
};
}
private boolean isApplicationExceptionPresentInParent(Class<?> parent) {
if (Object.class.equals(parent))
return false;
ApplicationException anot = parent.getAnnotation(ApplicationException.class);
if (anot != null)
return anot.inherited();
else
return isApplicationExceptionPresentInParent(parent.getSuperclass());
}
}
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/725880#725880]
Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120323/fef252ac/attachment.html
More information about the jboss-user
mailing list