本文整理匯總了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;
}
示例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);
}
}
示例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();
}
示例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));
}