本文整理了Java中javax.transaction.Transactional.dontRollbackOn()
方法的一些代码示例,展示了Transactional.dontRollbackOn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transactional.dontRollbackOn()
方法的具体详情如下:
包路径:javax.transaction.Transactional
类名称:Transactional
方法名:dontRollbackOn
暂无
代码示例来源:origin: com.expanset.hk2/hk2-persistence
protected boolean needRollback(Transactional ann, Throwable e)
throws Exception {
assert ann != null;
assert e != null;
if(transactionManager.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
return true;
}
if(ann.dontRollbackOn() != null) {
for(Class<?> dontRollback : ann.dontRollbackOn()) {
if(dontRollback.isAssignableFrom(e.getClass())) {
return false;
}
}
}
if(ann.rollbackOn() != null) {
for(Class<?> rollback : ann.rollbackOn()) {
if(rollback.isAssignableFrom(e.getClass())) {
return true;
}
}
}
if(ann.rollbackOn() == null || ann.rollbackOn().length == 0) {
return true;
}
return false;
}
代码示例来源:origin: org.jboss.narayana.jts/narayana-jts-idlj
protected void handleException(InvocationContext ic, Exception e, Transaction tx) throws Exception {
Transactional transactional = getTransactional(ic);
for (Class<?> dontRollbackOnClass : transactional.dontRollbackOn()) {
if (dontRollbackOnClass.isAssignableFrom(e.getClass())) {
throw e;
}
}
for (Class<?> rollbackOnClass : transactional.rollbackOn()) {
if (rollbackOnClass.isAssignableFrom(e.getClass())) {
tx.setRollbackOnly();
throw e;
}
}
if (e instanceof RuntimeException) {
tx.setRollbackOnly();
throw e;
}
throw e;
}
代码示例来源:origin: org.jboss.narayana.jta/cdi
protected void handleException(InvocationContext ic, Exception e, Transaction tx) throws Exception {
Transactional transactional = getTransactional(ic);
for (Class<?> dontRollbackOnClass : transactional.dontRollbackOn()) {
if (dontRollbackOnClass.isAssignableFrom(e.getClass())) {
throw e;
}
}
for (Class<?> rollbackOnClass : transactional.rollbackOn()) {
if (rollbackOnClass.isAssignableFrom(e.getClass())) {
tx.setRollbackOnly();
throw e;
}
}
if (e instanceof RuntimeException) {
tx.setRollbackOnly();
throw e;
}
throw e;
}
代码示例来源:origin: jbosstm/narayana
protected void handleException(InvocationContext ic, Exception e, Transaction tx) throws Exception {
Transactional transactional = getTransactional(ic);
for (Class<?> dontRollbackOnClass : transactional.dontRollbackOn()) {
if (dontRollbackOnClass.isAssignableFrom(e.getClass())) {
throw e;
}
}
for (Class<?> rollbackOnClass : transactional.rollbackOn()) {
if (rollbackOnClass.isAssignableFrom(e.getClass())) {
tx.setRollbackOnly();
throw e;
}
}
if (e instanceof RuntimeException) {
tx.setRollbackOnly();
throw e;
}
throw e;
}
代码示例来源:origin: jbosstm/narayana
protected void handleException(InvocationContext ic, Exception e, Transaction tx) throws Exception {
Transactional transactional = getTransactional(ic);
for (Class<?> dontRollbackOnClass : transactional.dontRollbackOn()) {
if (dontRollbackOnClass.isAssignableFrom(e.getClass())) {
throw e;
}
}
for (Class<?> rollbackOnClass : transactional.rollbackOn()) {
if (rollbackOnClass.isAssignableFrom(e.getClass())) {
tx.setRollbackOnly();
throw e;
}
}
if (e instanceof RuntimeException) {
tx.setRollbackOnly();
throw e;
}
throw e;
}
代码示例来源:origin: org.apache.aries.transaction/org.apache.aries.transaction.blueprint
private boolean parseTxData(Class<?> c) {
boolean shouldAssignInterceptor = false;
Transactional classAnnotation = c.getAnnotation(Transactional.class);
TxType defaultType = getType(classAnnotation);
if (defaultType != null) {
shouldAssignInterceptor = true;
}
for (Method m : c.getDeclaredMethods()) {
try {
Transactional methodAnnotation = m.getAnnotation(Transactional.class);
TxType t = getType(methodAnnotation);
if (t != null) {
TransactionalAnnotationAttributes txData = new TransactionalAnnotationAttributes(t,
methodAnnotation.dontRollbackOn(), methodAnnotation.rollbackOn());
assertAllowedModifier(m);
txMap.put(m, txData);
shouldAssignInterceptor = true;
} else if (defaultType != null){
txMap.put(m, new TransactionalAnnotationAttributes(defaultType, classAnnotation.dontRollbackOn(),
classAnnotation.rollbackOn()));
}
} catch(IllegalStateException e) {
LOG.warn("Invalid transaction annoation found", e);
}
}
return shouldAssignInterceptor;
}
代码示例来源:origin: org.glassfish.main.web/weld-integration
if (transactionalAnnotation != null) { //if at method level
rollbackOn = transactionalAnnotation.rollbackOn();
dontRollbackOn = transactionalAnnotation.dontRollbackOn();
} else { //if not, at class level
Class<?> targetClass = ctx.getTarget().getClass();
if (transactionalAnnotation != null) {
rollbackOn = transactionalAnnotation.rollbackOn();
dontRollbackOn = transactionalAnnotation.dontRollbackOn();
代码示例来源:origin: org.seedstack.seed/seed-core
private TransactionMetadata readTransactionMetadata(MethodInvocation methodInvocation) {
Method method = methodInvocation.getMethod();
TransactionMetadata defaults = defaultTransactionMetadata();
TransactionMetadata target = defaultTransactionMetadata();
for (TransactionMetadataResolver transactionMetadataResolver : transactionMetadataResolvers) {
target.mergeFrom(transactionMetadataResolver.resolve(methodInvocation, defaults));
}
Optional<Transactional> nativeTransactional = TransactionalResolver.INSTANCE.apply(method);
if (nativeTransactional.isPresent()) {
target.mergeFrom(nativeTransactional.get());
} else if (TransactionPlugin.JTA_12_OPTIONAL.isPresent()) {
Optional<javax.transaction.Transactional> transactionalOptional = JtaTransactionalResolver.INSTANCE
.apply(method);
if (transactionalOptional.isPresent()) {
javax.transaction.Transactional transactional = transactionalOptional.get();
target.setPropagation(Propagation.valueOf(transactional.value().name()));
if (transactional.rollbackOn().length > 0) {
target.setRollbackOn(asExceptions(transactional.rollbackOn()));
}
if (transactional.dontRollbackOn().length > 0) {
target.setNoRollbackFor(asExceptions(transactional.dontRollbackOn()));
}
}
}
return target;
}
代码示例来源:origin: apache/meecrowave
doRollback = new ExceptionPriotiryRules(tx.rollbackOn(), tx.dontRollbackOn()).accept(error, method.getExceptionTypes());
rollback.putIfAbsent(method, doRollback);
if (doRollback && isTransactionActive(state.current)) {
代码示例来源:origin: org.apache.tomee/openejb-core
doRollback = new ExceptionPriotiryRules(tx.rollbackOn(), tx.dontRollbackOn()).accept(error, method.getExceptionTypes());
rollback.putIfAbsent(method, doRollback);
if (doRollback && policy != null && policy.isTransactionActive()) {
内容来源于网络,如有侵权,请联系作者删除!