Java Code Examples for javax.ejb.ApplicationException#rollback()

The following examples show how to use javax.ejb.ApplicationException#rollback() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransactionUtils.java    From testfun with Apache License 2.0 5 votes vote down vote up
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    boolean newTransaction = beginTransaction();

    try {
        return method.invoke(delegate, args);

    } catch (Throwable throwable) {

        if (throwable instanceof InvocationTargetException) {
            InvocationTargetException invocationTargetException = (InvocationTargetException) throwable;

            ApplicationException applicationException = invocationTargetException.getTargetException().getClass().getAnnotation(ApplicationException.class);

            if (applicationException == null || applicationException.rollback()) {
                rollbackTransaction();
            }

        } else {
            rollbackTransaction();
        }

        throw throwable.getCause();

    } finally {
        endTransaction(newTransaction);
    }
}
 
Example 2
Source File: Ejb3TransactionAnnotationParser.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public boolean rollbackOn(Throwable ex) {
	ApplicationException ann = ex.getClass().getAnnotation(ApplicationException.class);
	return (ann != null ? ann.rollback() : super.rollbackOn(ex));
}
 
Example 3
Source File: Ejb3TransactionAnnotationParser.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public boolean rollbackOn(Throwable ex) {
	ApplicationException ann = ex.getClass().getAnnotation(ApplicationException.class);
	return (ann != null ? ann.rollback() : super.rollbackOn(ex));
}
 
Example 4
Source File: Ejb3TransactionAnnotationParser.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean rollbackOn(Throwable ex) {
	ApplicationException ann = ex.getClass().getAnnotation(ApplicationException.class);
	return (ann != null ? ann.rollback() : super.rollbackOn(ex));
}
 
Example 5
Source File: Ejb3TransactionAnnotationParser.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public boolean rollbackOn(Throwable ex) {
	ApplicationException ann = ex.getClass().getAnnotation(ApplicationException.class);
	return (ann != null ? ann.rollback() : super.rollbackOn(ex));
}
 
Example 6
Source File: TransactionInvocationHandlers.java    From development with Apache License 2.0 4 votes vote down vote up
private static boolean hasRollbackAnnotation(Exception ex) {
    ApplicationException annotation = ex.getClass().getAnnotation(
            ApplicationException.class);
    return annotation != null && annotation.rollback();
}