List of usage examples for org.springframework.transaction.support TransactionCallbackWithoutResult TransactionCallbackWithoutResult
TransactionCallbackWithoutResult
From source file:com.alibaba.otter.manager.biz.config.canal.impl.CanalServiceImpl.java
/** * //from w w w . j a va2 s .c o m */ public void remove(final Long canalId) { Assert.assertNotNull(canalId); transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { try { Canal canal = findById(canalId); canalDao.delete(canalId); arbitrateViewService.removeCanal(canal.getName()); // canal? } catch (Exception e) { logger.error("ERROR ## remove canal(" + canalId + ") has an exception!"); throw new ManagerException(e); } } }); }
From source file:com.zonekey.ssm.common.log.appender.JdbcLogWriter.java
/** * Buffer???./* w w w.j a v a 2 s. c o m*/ */ @SuppressWarnings("unchecked") public void updateBatch() { try { // ?, ?jdbc??. int i = 0; Map[] paramMapArray = new HashMap[eventsBuffer.size()]; for (LoggingEvent event : eventsBuffer) { paramMapArray[i++] = parseEvent(event); } final SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(paramMapArray); // ??,?. transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { try { jdbcTemplate.batchUpdate(getActualSql(), batchParams); if (logger.isDebugEnabled()) { for (LoggingEvent event : eventsBuffer) { logger.debug("saved event: {}", new LoggingEventWrapper(event).convertToString()); } } } catch (DataAccessException e) { status.setRollbackOnly(); handleDataAccessException(e, eventsBuffer); } } }); // ?Buffer eventsBuffer.clear(); } catch (Exception e) { logger.error("????.", e); } }
From source file:jp.go.aist.six.util.core.persist.castor.CastorDatastore.java
public <K, T extends Persistable<K>> void update(final Class<T> type, final T object) { _executeTx("update", type, object, new TransactionCallbackWithoutResult() { @Override/*from w w w .j a va2 s . c o m*/ public void doInTransactionWithoutResult(final TransactionStatus status) { getDao(type).update(object); } }); }
From source file:com.mothsoft.alexis.engine.textual.TopicDocumentMatcherImpl.java
private void bulkUpdateDocumentState(final DocumentState queryState, final DocumentState nextState) { this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override//from w ww . j a v a2 s .com protected void doInTransactionWithoutResult(TransactionStatus txStatus) { TopicDocumentMatcherImpl.this.documentDao.bulkUpdateDocumentState(queryState, nextState); } }); }
From source file:com.thoughtworks.go.server.service.UserService.java
public void disable(final List<String> usersToBeDisabled, LocalizedOperationResult result) { synchronized (disableUserMutex) { if (willDisableAllAdmins(usersToBeDisabled)) { result.badRequest("There must be atleast one admin user enabled!"); return; }/* ww w . j a v a 2 s . com*/ transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { userDao.disableUsers(usersToBeDisabled); } }); } }
From source file:com.hypersocket.permissions.PermissionServiceImpl.java
@PostConstruct private void postConstruct() { TransactionTemplate tmpl = new TransactionTemplate(txManager); tmpl.execute(new TransactionCallbackWithoutResult() { @Override//from w w w . jav a 2 s . co m protected void doInTransactionWithoutResult(TransactionStatus status) { PermissionCategory cat = registerPermissionCategory(RESOURCE_BUNDLE, "category.permissions"); registerPermission(SystemPermission.SYSTEM_ADMINISTRATION, cat); registerPermission(SystemPermission.SYSTEM, cat); } }); cacheManager = CacheManager.newInstance(); permissionsCache = new Cache("permissionsCache", 5000, false, false, 60 * 60, 60 * 60); cacheManager.addCache(permissionsCache); roleCache = new Cache("roleCache", 5000, false, false, 60 * 60, 60 * 60); cacheManager.addCache(roleCache); realmService.registerRealmListener(new RealmAdapter() { @Override public boolean hasCreatedDefaultResources(Realm realm) { return repository.getRoleByName(ROLE_ADMINISTRATOR, realm) != null; } @Override public void onCreateRealm(Realm realm) { if (log.isInfoEnabled()) { log.info("Creating Administrator role for realm " + realm.getName()); } repository.createRole(ROLE_ADMINISTRATOR, realm, false, false, true, true); if (log.isInfoEnabled()) { log.info("Creating Everyone role for realm " + realm.getName()); } Set<Permission> perms = new HashSet<Permission>(); perms.add(getPermission(AuthenticationPermission.LOGON.getResourceKey())); perms.add(getPermission(ProfilePermission.READ.getResourceKey())); perms.add(getPermission(ProfilePermission.UPDATE.getResourceKey())); perms.add(getPermission(PasswordPermission.CHANGE.getResourceKey())); repository.createRole(ROLE_EVERYONE, realm, false, true, false, true, perms); } }); eventService.registerEvent(RoleEvent.class, RESOURCE_BUNDLE); eventService.registerEvent(RoleCreatedEvent.class, RESOURCE_BUNDLE); eventService.registerEvent(RoleUpdatedEvent.class, RESOURCE_BUNDLE); eventService.registerEvent(RoleDeletedEvent.class, RESOURCE_BUNDLE); }
From source file:ch.tatool.app.service.impl.DataServiceImpl.java
/** Finishes a module session. */ public void finishSession(final ModuleSession moduleSession) { final ModuleImpl moduleImpl = (ModuleImpl) moduleSession.getModule(); moduleImpl.getTransactionTemplate().execute(new TransactionCallbackWithoutResult() { public void doInTransactionWithoutResult(TransactionStatus status) { moduleSession.setEndTime(new Date()); moduleImpl.getSessionDAO().saveSession(moduleImpl, moduleSession); }//from ww w .j ava 2s . co m }); }
From source file:org.pentaho.custom.authentication.provider.userroledao.hibernate.UserRoleDaoTransactionDecorator.java
public void deleteUser(final IUser userToDelete) throws NotFoundException, UncategorizedUserRoleDaoException { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { userRoleDao.deleteUser(userToDelete); }/*from w ww. ja v a 2 s.c o m*/ }); }
From source file:org.springside.examples.showcase.log.appender.JdbcLogWriter.java
/** * Buffer???./* w w w . j ava 2 s. c o m*/ */ @SuppressWarnings("unchecked") public void updateBatch() { try { //?, ?jdbc??. int i = 0; Map[] paramMapArray = new HashMap[eventsBuffer.size()]; for (LoggingEvent event : eventsBuffer) { paramMapArray[i++] = parseEvent(event); } final SqlParameterSource[] batchParams = SqlParameterSourceUtils.createBatch(paramMapArray); //??,?. transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { try { jdbcTemplate.batchUpdate(getActualSql(), batchParams); if (logger.isDebugEnabled()) { for (LoggingEvent event : eventsBuffer) { logger.debug("saved event: {}", new LoggingEventWrapper(event).convertToString()); } } } catch (DataAccessException e) { status.setRollbackOnly(); handleDataAccessException(e, eventsBuffer); } } }); //?Buffer eventsBuffer.clear(); } catch (Exception e) { logger.error("????.", e); } }
From source file:org.cleverbus.core.common.asynch.repair.RepairMessageServiceDbImpl.java
/** * Updates bulk of messages in DB.//from ww w .j a va2 s . com * * @param messages the messages for update */ private void updateMessagesInDB(final List<Message> messages) { final Date currDate = new Date(); transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { for (final Message msg : messages) { // checks if failed count exceeds limit for failing if (msg.getFailedCount() >= countPartlyFailsBeforeFailed) { Log.warn("The message " + msg.toHumanString() + " was in PROCESSING state and exceeded " + "max. count of failures. Message is redirected to processing of failed message."); // redirect to "FAILED" route producerTemplate.send(AsynchConstants.URI_ERROR_FATAL, ExchangePattern.InOnly, new Processor() { @Override public void process(Exchange exchange) throws Exception { IntegrationException ex = new IntegrationException(InternalErrorEnum.E116); exchange.setProperty(Exchange.EXCEPTION_CAUGHT, ex); exchange.getIn().setHeader(AsynchConstants.MSG_HEADER, msg); } }); } else { msg.setLastUpdateTimestamp(currDate); msg.setState(MsgStateEnum.PARTLY_FAILED); // note: increase count of failures because if message stays in PROCESSING state it's almost sure // because of any error msg.setFailedCount(msg.getFailedCount() + 1); messageDao.update(msg); Log.warn("The message " + msg.toHumanString() + " was in PROCESSING state " + "and changed to PARTLY_FAILED.", msg.getMsgId(), msg.getCorrelationId()); } } } }); }