List of usage examples for org.springframework.transaction.interceptor DefaultTransactionAttribute DefaultTransactionAttribute
public DefaultTransactionAttribute()
From source file:org.jboss.arquillian.transaction.spring.provider.AbstractSpringTransactionProvider.java
/** * <p>Creates new transaction definition.</p> * * @return the transaction definition/*from w w w . j a v a 2 s.c o m*/ */ private DefaultTransactionAttribute createTransactionDefinition() { return new DefaultTransactionAttribute(); }
From source file:py.una.pol.karaku.test.cucumber.TransactionalTestCucumberExecutionListener.java
/** * If the test method of the supplied {@link TestContext test context} is * configured to run within a transaction, this method will run * {@link BeforeTransaction @BeforeTransaction methods} and start a new * transaction.// www.j a v a 2s . c o m * <p> * Note that if a {@link BeforeTransaction @BeforeTransaction method} * fails, remaining {@link BeforeTransaction @BeforeTransaction * methods} will not be invoked, and a transaction will not be started. * * @see org.springframework.transaction.annotation.Transactional */ @SuppressWarnings("serial") @Override public void beforeTestClass(TestContext testContext) throws Exception { TransactionDefinition transactionDefinition = new DefaultTransactionAttribute(); if (transactionDefinition != null) { PlatformTransactionManager tm = testContext.getApplicationContext() .getBean(PlatformTransactionManager.class); TransactionContext txContext = new TransactionContext(tm, transactionDefinition); startNewTransaction(testContext, txContext); this.transactionContextCache.put(testContext.getTestClass(), txContext); } }
From source file:ome.services.sharing.ShareRestrictionTransactionAttributeSource.java
public TransactionAttribute getTransactionAttribute(Method method, Class targetClass) { try {/*from w ww. j av a 2 s . c o m*/ Principal principal = current.getLast(); String uuid = principal.getName(); EventContext ec = cache.getSessionContext(uuid); Long shareId = ec.getCurrentShareId(); if (ec.getCurrentShareId() != null) { log.debug("Returning readOnly tx for shared " + shareId); DefaultTransactionAttribute ta = new DefaultTransactionAttribute(); ta.setReadOnly(true); return ta; } } catch (SessionException se) { // No worries. It's not our job to enforce anything. return null; } catch (NoSuchElementException nse) { // No one is logged in so there can't be a share active! return null; } return null; }
From source file:org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.java
@SuppressWarnings("serial") private void configureTaskletStep(TaskletStep ts) { configureAbstractStep(ts);//w ww . j av a 2s .c o m if (listeners != null) { List<ChunkListener> newListeners = new ArrayList<ChunkListener>(); for (StepListener listener : listeners) { if (listener instanceof ChunkListener) { newListeners.add((ChunkListener) listener); } } ts.setChunkListeners(newListeners.toArray(new ChunkListener[0])); } if (tasklet != null) { ts.setTasklet(tasklet); } if (taskExecutor != null) { TaskExecutorRepeatTemplate repeatTemplate = new TaskExecutorRepeatTemplate(); repeatTemplate.setTaskExecutor(taskExecutor); if (throttleLimit != null) { repeatTemplate.setThrottleLimit(throttleLimit); } ts.setStepOperations(repeatTemplate); } if (transactionManager != null) { ts.setTransactionManager(transactionManager); } if (transactionTimeout != null || propagation != null || isolation != null || noRollbackExceptionClasses != null) { DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); if (propagation != null) { attribute.setPropagationBehavior(propagation.value()); } if (isolation != null) { attribute.setIsolationLevel(isolation.value()); } if (transactionTimeout != null) { attribute.setTimeout(transactionTimeout); } Collection<Class<? extends Throwable>> exceptions = noRollbackExceptionClasses == null ? new HashSet<Class<? extends Throwable>>() : noRollbackExceptionClasses; final BinaryExceptionClassifier classifier = new BinaryExceptionClassifier(exceptions, false); ts.setTransactionAttribute(new DefaultTransactionAttribute(attribute) { @Override public boolean rollbackOn(Throwable ex) { return classifier.classify(ex); } }); } }
From source file:org.springframework.batch.core.step.factory.SimpleStepFactoryBean.java
/** * Getter for the {@link TransactionAttribute} for subclasses only. * @return the transactionAttribute/*w w w.java 2 s .com*/ */ @SuppressWarnings("serial") protected TransactionAttribute getTransactionAttribute() { DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); attribute.setPropagationBehavior(propagation.value()); attribute.setIsolationLevel(isolation.value()); attribute.setTimeout(transactionTimeout); return new DefaultTransactionAttribute(attribute) { /** * Ignore the default behaviour and rollback on all exceptions that bubble up to the tasklet level. The * tasklet has to deal with the rollback rules internally. */ @Override public boolean rollbackOn(Throwable ex) { return true; } }; }
From source file:org.springframework.batch.core.step.item.SimpleStepFactoryBean.java
/** * Getter for the {@link TransactionAttribute} for subclasses only. * @return the transactionAttribute/*from w ww.jav a2 s .c o m*/ */ @SuppressWarnings("serial") protected TransactionAttribute getTransactionAttribute() { DefaultTransactionAttribute attribute = new DefaultTransactionAttribute(); attribute.setPropagationBehavior(propagation.value()); attribute.setIsolationLevel(isolation.value()); attribute.setTimeout(transactionTimeout); return new DefaultTransactionAttribute(attribute) { /** * Ignore the default behaviour and rollback on all exceptions that * bubble up to the tasklet level. The tasklet has to deal with the * rollback rules internally. */ @Override public boolean rollbackOn(Throwable ex) { return true; } }; }