List of usage examples for org.springframework.transaction.support DefaultTransactionDefinition setTimeout
public final void setTimeout(int timeout)
From source file:jp.terasoluna.fw.batch.util.BatchUtil.java
/** * ?TransactionDefinition??/*w w w . ja va2 s.co m*/ * @param propagationBehavior ??(@see TransactionDefinition) TransactionDefinition.PROPAGATION_REQUIRED * @param isolationLevel (@see TransactionDefinition) TransactionDefinition.ISOLATION_DEFAULT * @param timeout () TransactionDefinition.TIMEOUT_DEFAULT (??) * @param readOnly false * @return */ public static TransactionDefinition getTransactionDefinition(int propagationBehavior, int isolationLevel, int timeout, boolean readOnly) { DefaultTransactionDefinition td = new DefaultTransactionDefinition(); td.setPropagationBehavior(propagationBehavior); td.setIsolationLevel(isolationLevel); td.setTimeout(timeout); td.setReadOnly(readOnly); return td; }
From source file:com.github.akiraly.db4j.CommonDbConfig.java
@Bean public TransactionTemplate transactionTemplate(PlatformTransactionManager transactionManager) { DefaultTransactionDefinition td = new DefaultTransactionDefinition(); td.setTimeout(30); return new TransactionTemplate(transactionManager, td); }
From source file:nl.nn.adapterframework.receivers.PullingListenerContainer.java
public void configure() { if (receiver.getNumThreadsPolling() > 0 && receiver.getNumThreadsPolling() < receiver.getNumThreads()) { pollToken = new Semaphore(receiver.getNumThreadsPolling()); }//from ww w .java 2s . c o m processToken = new Semaphore(receiver.getNumThreads()); maxThreadCount = receiver.getNumThreads(); if (receiver.isTransacted()) { DefaultTransactionDefinition txDef = new DefaultTransactionDefinition( TransactionDefinition.PROPAGATION_REQUIRES_NEW); if (receiver.getTransactionTimeout() > 0) { txDef.setTimeout(receiver.getTransactionTimeout()); } txNew = txDef; } }
From source file:org.compass.spring.transaction.SpringSyncTransaction.java
public void begin(PlatformTransactionManager transactionManager, InternalCompassSession session, boolean commitBeforeCompletion) { this.session = session; this.transactionManager = transactionManager; // the factory called begin, so we are in charge, if we were not, than // it would not call begin (we are in charge of the COMPASS transaction, // the spring one is handled later) controllingNewTransaction = true;/*from ww w .ja v a 2 s . co m*/ if (transactionManager != null) { DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(); transactionDefinition.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRED); int timeout = session.getSettings().getSettingAsInt(CompassEnvironment.Transaction.TRANSACTION_TIMEOUT, -1); if (timeout != -1) { transactionDefinition.setTimeout(timeout); } transactionDefinition.setReadOnly(session.isReadOnly()); status = transactionManager.getTransaction(transactionDefinition); } session.getSearchEngine().begin(); SpringTransactionSynchronization sync; if (transactionManager != null) { if (log.isDebugEnabled()) { if (status.isNewTransaction()) { log.debug("Beginning new Spring transaction, and a new compass transaction on thread [" + Thread.currentThread().getName() + "]"); } else { log.debug("Joining Spring transaction, and starting a new compass transaction on thread [" + Thread.currentThread().getName() + "]"); } } sync = new SpringTransactionSynchronization(session, status.isNewTransaction(), commitBeforeCompletion, transactionFactory); } else { if (log.isDebugEnabled()) { log.debug("Joining Spring transaction, and starting a new compass transaction on thread [" + Thread.currentThread().getName() + "]"); } sync = new SpringTransactionSynchronization(session, false, commitBeforeCompletion, transactionFactory); } TransactionSynchronizationManager.registerSynchronization(sync); setBegun(true); }
From source file:org.kuali.kfs.sys.context.KualiTestBase.java
private void configure(ConfigureContext contextConfiguration) throws Exception { if (configurationFailure != null) { throw configurationFailure; }/*from w w w . ja v a 2s . c o m*/ if (!springContextInitialized) { try { KFSTestStartup.initializeKfsTestContext(); springContextInitialized = true; } catch (RuntimeException e) { configurationFailure = e; throw e; } } if (!batchScheduleInitialized && contextConfiguration.initializeBatchSchedule()) { SpringContext.getBean(SchedulerService.class).initialize(); batchScheduleInitialized = true; } if (!contextConfiguration.shouldCommitTransactions()) { LOG.info("Starting test transaction that will be rolled back"); DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition(); defaultTransactionDefinition.setTimeout(3600); // defaultTransactionDefinition.setReadOnly(true); transactionStatus = getTransactionManager().getTransaction(defaultTransactionDefinition); transactionStatus.setRollbackOnly(); } else { LOG.info("Test transaction not used"); LOG.info("Starting transaction which will COMMIT at the end of the test"); DefaultTransactionDefinition defaultTransactionDefinition = new DefaultTransactionDefinition(); defaultTransactionDefinition.setTimeout(3600); transactionStatus = getTransactionManager().getTransaction(defaultTransactionDefinition); // transactionStatus = null; } UserNameFixture sessionUser = contextConfiguration.session(); if (sessionUser != UserNameFixture.NO_SESSION) { GlobalVariables.setUserSession(new UserSession(sessionUser.toString())); } }