org.springframework.transaction.annotation.Propagation#REQUIRES_NEW源码实例Demo

下面列出了org.springframework.transaction.annotation.Propagation#REQUIRES_NEW 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: herd   文件: EmrServiceImpl.java
/**
 * {@inheritDoc}
 * <p/>
 * This implementation starts a new transaction.
 */
@NamespacePermission(fields = "#request?.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public EmrMasterSecurityGroup addSecurityGroupsToClusterMaster(EmrMasterSecurityGroupAddRequest request) throws Exception
{
    return addSecurityGroupsToClusterMasterImpl(request);
}
 
源代码2 项目: projectforge-webapp   文件: BaseDao.java
/**
 * 
 * @param obj
 * @return the generated identifier.
 * @throws AccessException
 */
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW, isolation = Isolation.REPEATABLE_READ)
public Serializable save(final O obj) throws AccessException
{
  Validate.notNull(obj);
  if (avoidNullIdCheckBeforeSave == false) {
    Validate.isTrue(obj.getId() == null);
  }
  checkLoggedInUserInsertAccess(obj);
  accessChecker.checkRestrictedOrDemoUser();
  return internalSave(obj);
}
 
源代码3 项目: herd   文件: BusinessObjectDataServiceImpl.java
@NamespacePermission(fields = "#request.namespace", permissions = NamespacePermissionEnum.READ)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public BusinessObjectDataDdl generateBusinessObjectDataDdl(BusinessObjectDataDdlRequest request)
{
    return generateBusinessObjectDataDdlImpl(request, false);
}
 
源代码4 项目: TeamDojo   文件: CustomAuditEventRepository.java
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
    if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
        !Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {

        PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
        persistentAuditEvent.setPrincipal(event.getPrincipal());
        persistentAuditEvent.setAuditEventType(event.getType());
        persistentAuditEvent.setAuditEventDate(event.getTimestamp());
        Map<String, String> eventData = auditEventConverter.convertDataToStrings(event.getData());
        persistentAuditEvent.setData(truncate(eventData));
        persistenceAuditEventRepository.save(persistentAuditEvent);
    }
}
 
/**
 * {@inheritDoc}
 * <p/>
 * This implementation starts a new transaction.
 */
@PublishNotificationMessages
@NamespacePermission(fields = "#businessObjectDataStorageUnitKey.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public BusinessObjectDataStorageUnitStatusUpdateResponse updateBusinessObjectDataStorageUnitStatus(
    BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey, BusinessObjectDataStorageUnitStatusUpdateRequest request)
{
    return updateBusinessObjectDataStorageUnitStatusImpl(businessObjectDataStorageUnitKey, request);
}
 
源代码6 项目: olat   文件: NotificationEventDao.java
@Retryable
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateEvents(List<NotificationEvent> events, NotificationEvent.Status status) {
    for (NotificationEvent event : events) {
        event = genericDao.findById(event.getId());
        event.setStatus(status);
        event.getSubscription().setLastNotifiedDate(new Date());
        updateEvent(event);
    }
}
 
源代码7 项目: syncope   文件: JPAUserDAO.java
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
@Override
public Collection<ExternalResource> findAllResources(final User user) {
    Set<ExternalResource> result = new HashSet<>();
    result.addAll(user.getResources());
    findAllGroups(user).forEach(group -> result.addAll(group.getResources()));

    return result;
}
 
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void add(AuditEvent event) {
    if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
        !Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {

        PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
        persistentAuditEvent.setPrincipal(event.getPrincipal());
        persistentAuditEvent.setAuditEventType(event.getType());
        persistentAuditEvent.setAuditEventDate(event.getTimestamp());
        Map<String, String> eventData = auditEventConverter.convertDataToStrings(event.getData());
        persistentAuditEvent.setData(truncate(eventData));
        persistenceAuditEventRepository.save(persistentAuditEvent);
    }
}
 
源代码9 项目: projectforge-webapp   文件: UserDao.java
/**
 * Ohne Zugangsbegrenzung. Wird bei Anmeldung benötigt.
 * @param username
 * @param encryptedPassword
 * @return
 */
@SuppressWarnings("unchecked")
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW)
public PFUserDO authenticateUser(final String username, final String password)
{
  Validate.notNull(username);
  Validate.notNull(password);

  PFUserDO user = getUser(username, password, true);
  if (user != null) {
    final int loginFailures = user.getLoginFailures();
    final Timestamp lastLogin = user.getLastLogin();
    user.setLastLogin(new Timestamp(new Date().getTime()));
    user.setLoginFailures(0);
    user.setMinorChange(true); // Avoid re-indexing of all dependent objects.
    internalUpdate(user, false);
    if (user.hasSystemAccess() == false) {
      log.warn("Deleted/deactivated user tried to login: " + user);
      return null;
    }
    final PFUserDO contextUser = new PFUserDO();
    contextUser.copyValuesFrom(user);
    contextUser.setLoginFailures(loginFailures); // Restore loginFailures for current user session.
    contextUser.setLastLogin(lastLogin); // Restore lastLogin for current user session.
    contextUser.setPassword(null);
    return contextUser;
  }
  final List<PFUserDO> list = getHibernateTemplate().find("from PFUserDO u where u.username = ?", username);
  if (list != null && list.isEmpty() == false && list.get(0) != null) {
    user = list.get(0);
    user.setLoginFailures(user.getLoginFailures() + 1);
    internalUpdate(user);
  }
  return null;
}
 
源代码10 项目: onetwo   文件: DbmSendMessageRepository.java
@Override
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void batchUpdateToSent(Collection<SendMessageContext<?>> ctxs) {
	List<SendMessageEntity> messages = ctxs.stream().map(ctx -> {
		SendMessageEntity e = ctx.getMessageEntity();
		e.setState(SendStates.SENT);
		return e;
	}).collect(Collectors.toList());
	getBaseEntityManager().getSessionFactory().getSession().batchUpdate(messages);
}
 
/**
 * {@inheritDoc}
 * <p/>
 * This implementation starts a new transaction.
 */
@NamespacePermission(fields = "#businessObjectDataKey?.namespace", permissions = NamespacePermissionEnum.READ)
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public BusinessObjectDataAttributeKeys getBusinessObjectDataAttributes(BusinessObjectDataKey businessObjectDataKey)
{
    return getBusinessObjectDataAttributesImpl(businessObjectDataKey);
}
 
源代码12 项目: c2mon   文件: RuleTagConfigTransactedImpl.java
@Override
@Transactional(value = "cacheTransactionManager", propagation=Propagation.REQUIRES_NEW, isolation = Isolation.READ_COMMITTED)
public void doRemoveRuleTag(final Long id, final ConfigurationElementReport elementReport) {
  LOGGER.trace("Removing RuleTag " + id);
  try {
    RuleTag ruleTag = tagCache.get(id);
    Collection<Long> ruleIds = ruleTag.getCopyRuleIds();  
    if (!ruleIds.isEmpty()) {
      LOGGER.debug("Removing rules dependent on RuleTag " + id);
      for (Long ruleId : ruleIds) { //concurrent modifcation as a rule is removed from the list during the remove call!
        if (tagLocationService.isInTagCache(ruleId)) { //may already have been removed if a previous rule in the list was used in this rule!
          ConfigurationElementReport newReport = new ConfigurationElementReport(Action.REMOVE, Entity.RULETAG, ruleId);
          elementReport.addSubReport(newReport);
          ruleTagConfigHandler.removeRuleTag(ruleId, newReport); //call config handler bean so transaction annotation is noticed
        }         
      }                
    }
    tagCache.acquireWriteLockOnKey(id);      
    Collection<Long> ruleInputTagIds = Collections.EMPTY_LIST;
    try {
      ruleInputTagIds = ruleTag.getCopyRuleInputTagIds();                
      Collection<Long> alarmIds = ruleTag.getCopyAlarmIds();                  
      if (!alarmIds.isEmpty()) {
        LOGGER.debug("Removing Alarms dependent on RuleTag " + id);
        for (Long alarmId : alarmIds) { //need copy as modified concurrently by remove alarm
          ConfigurationElementReport alarmReport = new ConfigurationElementReport(Action.REMOVE, Entity.ALARM, alarmId);
          elementReport.addSubReport(alarmReport);
          alarmConfigHandler.removeAlarm(alarmId, alarmReport);
        }        
      }
      for (Long inputTagId : ruleInputTagIds) {
        tagConfigGateway.removeRuleFromTag(inputTagId, id); //allowed to lock tag below the rule...
      }

      for (ConfigurationEventListener listener : configurationEventListeners) {
        listener.onConfigurationEvent(ruleTag, Action.REMOVE);
      }

      configurableDAO.deleteItem(ruleTag.getId());                                           
    }
    catch (RuntimeException rEx) {
      String errMessage = "Exception caught when removing rule tag with id " + id;
      LOGGER.error(errMessage, rEx); 
      throw new UnexpectedRollbackException(errMessage, rEx);   
    } finally {
      if (tagCache.isWriteLockedByCurrentThread(id)) {
        tagCache.releaseWriteLockOnKey(id);
      }        
    }
  } catch (CacheElementNotFoundException e) {
    LOGGER.debug("Attempting to remove a non-existent RuleTag - no action taken.");
    elementReport.setWarning("Attempting to removed a non-existent RuleTag");      
  }       
}
 
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Modifying
@Query("update Check c set c.lastSentEmail = current_timestamp, currentErrorCount = 0 where c.id = ?1")
void emailSent(int checkId);
 
源代码14 项目: redisson   文件: TransactionalBean2.java
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void testInNewTransaction() {
    RTransaction transaction = transactionManager.getCurrentTransaction();
    transaction.getMap("tr2").put("2", "4");
}
 
源代码15 项目: zstack   文件: SimpleQueryImpl.java
@Override
@Transactional(readOnly=true, propagation=Propagation.REQUIRES_NEW)
public T find() {
    return _find();
}
 
源代码16 项目: zstack   文件: SimpleQueryImpl.java
@Override
@Transactional(readOnly=true, propagation=Propagation.REQUIRES_NEW)
public <K> List<K> listValue() {
    return _listValue();
}
 
源代码17 项目: transaction-test   文件: User2ServiceImpl.java
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void addRequiresNewException(User2 user){
	user2Mapper.insert(user);
	throw new RuntimeException();
}
 
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Modifying
@Query("update Check c set c.currentErrorCount = 0 where c.id = ?1")
void clearErrorCount(int checkId);
 
源代码19 项目: c2mon   文件: SubEquipmentConfigTransactedImpl.java
@Override
@Transactional(value = "cacheTransactionManager", propagation = Propagation.REQUIRES_NEW)
public List<ProcessChange> doUpdateAbstractEquipment(final SubEquipment subEquipment, Properties properties) throws IllegalAccessException {
  return super.updateAbstractEquipment(subEquipment, properties);
}
 
源代码20 项目: DataHubSystem   文件: SynchronizerService.java
/**
 * Saves the given synchronizer's configuration back in the databse.
 * This method is intended to be used by Synchronizers themselves, this
 * method does no tests at all to avoid deadlocks.
 * <p>
 * This method is unsafe and you should probably be using
 * {@link #saveSynchronizerConf(SynchronizerConf)} instead.
 * @param s to save.
 */
@Override
@Transactional (propagation = Propagation.REQUIRES_NEW)
public void saveSynchronizer (Synchronizer s)
{
   this.synchronizerDao.update (s.getSynchronizerConf ());
}