當前位置: 首頁>>代碼示例>>Java>>正文


Java ApplicationException.rollback方法代碼示例

本文整理匯總了Java中javax.ejb.ApplicationException.rollback方法的典型用法代碼示例。如果您正苦於以下問題:Java ApplicationException.rollback方法的具體用法?Java ApplicationException.rollback怎麽用?Java ApplicationException.rollback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ejb.ApplicationException的用法示例。


在下文中一共展示了ApplicationException.rollback方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: needsRollback

import javax.ejb.ApplicationException; //導入方法依賴的package包/類
/**
 * Determines whether it is necessary to rollback the current transaction
 * when the specified exception occurred during the method invocation.
 *
 * @param exception the exception that occurred during the method
 *        invocation.
 * @return {@code true} if the interceptor should rollback the current
 *         transaction, {@code false} if the interceptor should commit the
 *         current transaction.
 */
private boolean needsRollback(
    Exception exception)
{
    boolean rollback = exception instanceof RuntimeException;

    for (Class<?> clazz = exception.getClass(); clazz != null; clazz = clazz
        .getSuperclass())
    {
        ApplicationException ae = clazz
            .getAnnotation(ApplicationException.class);
        if (ae != null)
        {
            if (ae.inherited())
            {
                return ae.rollback();
            }
            else
            {
                break;
            }
        }
    }

    return rollback;
}
 
開發者ID:arkhipov,項目名稱:transaction-cdi,代碼行數:36,代碼來源:TransactionalInterceptor.java

示例2: invoke

import javax.ejb.ApplicationException; //導入方法依賴的package包/類
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);
    }
}
 
開發者ID:michaelyaakoby,項目名稱:testfun,代碼行數:28,代碼來源:TransactionUtils.java

示例3: hasRollbackAnnotation

import javax.ejb.ApplicationException; //導入方法依賴的package包/類
private static boolean hasRollbackAnnotation(Exception ex) {
    ApplicationException annotation = ex.getClass().getAnnotation(
            ApplicationException.class);
    return annotation != null && annotation.rollback();
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:6,代碼來源:TransactionInvocationHandlers.java

示例4: rollbackOn

import javax.ejb.ApplicationException; //導入方法依賴的package包/類
@Override
public boolean rollbackOn(Throwable ex) {
	ApplicationException ann = ex.getClass().getAnnotation(ApplicationException.class);
	return (ann != null ? ann.rollback() : super.rollbackOn(ex));
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:6,代碼來源:Ejb3TransactionAnnotationParser.java


注:本文中的javax.ejb.ApplicationException.rollback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。