本文整理匯總了Java中org.springframework.transaction.annotation.Isolation類的典型用法代碼示例。如果您正苦於以下問題:Java Isolation類的具體用法?Java Isolation怎麽用?Java Isolation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Isolation類屬於org.springframework.transaction.annotation包,在下文中一共展示了Isolation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: upload
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
/**
* 執行數據上報
*
* @author gaoxianglong
* @throws Exception
*/
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.DEFAULT)
public void upload(String taskId, Map<String, CountDownLatch> countDownLatchMap,
Map<String, List<ResultBean>> resultMap) throws Exception {
CountDownLatch latch = countDownLatchMap.get(taskId);
try {
/* 等待指定場景的壓測數據 */
latch.await();
List<ResultBean> results = resultMap.get(taskId);
/* 統計壓測結果 */
ReportPO reportPO = ResultStatistics.result(results);
if (null != reportPO) {
/* 新增壓測結果信息 */
reportDao.insertReport(reportPO);
/* 更改場景狀態為未開始 */
reportDao.updateScene(reportPO.getSceneId(), 0);
log.info("senceId為[" + reportPO.getSceneId() + "]的壓測結果已經收集完成並成功上報");
}
} finally {
/* 資源回收 */
countDownLatchMap.remove(taskId);
resultMap.remove(taskId);
}
}
示例2: onlineByDeploy
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Override
@Transactional(value = "transactionManager", isolation = Isolation.READ_COMMITTED, readOnly = false)
public List<Server> onlineByDeploy(Integer appId, String appInsId, int pid, Date date) throws Exception {
//用appId和appInsId查找server列表, 不用pid,為了減少時間,避開注冊中心的berkeley異步注冊時間
List<Server> servers = serverDao.getServersByApp(appId, appInsId, null);
if (servers != null && !servers.isEmpty()) {
List<Integer> serverIds = new ArrayList<Integer>();
List<Integer> ifaceIds = new ArrayList<Integer>();
List<IfaceServer> ifaceServerList = new ArrayList<IfaceServer>();
for (Server server : servers) {
ifaceIds.add(server.getInterfaceId());
serverIds.add(server.getId());
ifaceServerList.add(getIfaceServer(server));
}
logger.info("deploy.online.serverIds: {}", serverIds);
serverDao.updateServerToOnline(serverIds);
interfaceDataVersionDao.update(ifaceIds, date);
logger.info("online ifaceAlias list:" + aliasVersionService.updateByServerList(ifaceServerList, date));
List<IfaceServer> relaAliasServerList = aliasVersionService.getRelaIfaceServerList(ifaceServerList);
logger.info("自動部署調用: 上線服務端成功, appId:{}, appInsId:{}, serverIds: {}", appId, appInsId, serverIds.toString());
mergeServers(servers, relaAliasServerList);
return servers;
}
return null;
}
示例3: offlineByDeploy
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Override
@Transactional(value = "transactionManager", isolation = Isolation.READ_COMMITTED, readOnly = false)
public List<Server> offlineByDeploy(Integer appId, String appInsId, int pid, Date date) throws Exception {
List<Server> servers = serverDao.getServersByApp(appId, appInsId, pid);
if (servers != null && !servers.isEmpty()) {
List<Integer> serverIds = new ArrayList<Integer>();
List<Integer> ifaceIds = new ArrayList<Integer>();
List<IfaceServer> ifaceServerList = new ArrayList<IfaceServer>();
for (Server server : servers) {
ifaceIds.add(server.getInterfaceId());
serverIds.add(server.getId());
ifaceServerList.add(getIfaceServer(server));
}
logger.info("deploy.offline.serverIds: {}", serverIds);
serverDao.updateServerToOffline(serverIds);
interfaceDataVersionDao.update(ifaceIds, date);
logger.info("offline ifaceAlias list:" + aliasVersionService.updateByServerList(ifaceServerList, date));
List<IfaceServer> relaAliasServerList = aliasVersionService.getRelaIfaceServerList(ifaceServerList);
logger.info("自動部署調用: 下線服務端成功, appId:{}, appInsId:{}, serverIds: {}", appId, appInsId, serverIds.toString());
mergeServers(servers, relaAliasServerList);
return servers;
}
return null;
}
示例4: modifyPw
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Transactional(isolation = Isolation.READ_COMMITTED)
public int modifyPw(String oldPass, String newPass) {
int result;
if (checkPass(oldPass)) {
try {
infoMapper.updataPass(newPass);
result = MODIFYPASSSUC;
} catch (Exception e) {
LOGGER.error(e.getMessage());
result = SySTEMERROE;
}
} else {
result = PASSERROE;
}
return result;
}
示例5: modifyPw
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Override
@Transactional(isolation = Isolation.READ_COMMITTED)
public int modifyPw(String oldPass,String newPass) {
int result;
if (checkPass(oldPass)){
try {
infoMapper.updataPass(newPass);
result=MODIFYPASSSUC;
} catch (Exception e) {
LOGGER.error(e.getMessage());
result=SySTEMERROE;
}
}else {
result=PASSERROE;
}
return result;
}
示例6: mergeSequences
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Transactional(propagation = MANDATORY, isolation = Isolation.SERIALIZABLE)
public Sequence mergeSequences(List<Sequence> sequences) {
Sequence main = sequences.get(0);
if (sequences.size() != 1) {
sequences.forEach(s -> entityManager.refresh(s));
List<BookSequence> bookSequences = sequences.stream().
flatMap(s -> s.getBookSequences().stream()).collect(Collectors.toList());
bookSequences.forEach(bs -> bs.setSequence(main));
main.setBookSequences(bookSequences);
sequenceRepository.save(main);
sequences.stream().skip(1).forEach(s -> {
s.setBookSequences(new ArrayList<>());
sequenceRepository.delete(s);
});
}
return main;
}
示例7: likeInterpretation
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Transactional( isolation = Isolation.REPEATABLE_READ )
public boolean likeInterpretation( int id )
{
Interpretation interpretation = getInterpretation( id );
if ( interpretation == null )
{
return false;
}
User user = currentUserService.getCurrentUser();
if ( user == null )
{
return false;
}
return interpretation.like( user );
}
示例8: unlikeInterpretation
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Transactional( isolation = Isolation.REPEATABLE_READ )
public boolean unlikeInterpretation( int id )
{
Interpretation interpretation = getInterpretation( id );
if ( interpretation == null )
{
return false;
}
User user = currentUserService.getCurrentUser();
if ( user == null )
{
return false;
}
return interpretation.unlike( user );
}
示例9: findEntityByOid
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(
propagation=Propagation.REQUIRES_NEW,
isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
public DefaultResult<E> findEntityByOid(E object) throws ServiceException, Exception {
if (object==null || !(object instanceof BaseEntity) ) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
DefaultResult<E> result=new DefaultResult<E>();
try {
E entityObject=this.findByOid(object);
if (entityObject!=null && !StringUtils.isBlank( ((BaseEntity<String>)entityObject).getOid() ) ) {
result.setValue(entityObject);
}
} catch (Exception e) {
e.printStackTrace();
}
if (result.getValue() == null) {
result.setSystemMessage(new SystemMessage(SysMessageUtil.get(GreenStepSysMsgConstants.SEARCH_NO_DATA)));
}
return result;
}
示例10: deletePaasUser
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, rollbackForClassName = { "BusinessException" })
public void deletePaasUser(int paasUserId) throws BusinessException {
log.debug("find user");
PaasUser paasUser = paasUserRepository.findOne(paasUserId);
if (paasUser == null) {
String message = "PaasUser[" + paasUserId + "] does not exist";
log.error(message);
throw new PaasUserNotFoundException(message);
}
log.debug("find user envs");
if (environmentRepository.countActiveByOwner(paasUser) > 0) {
throw new BusinessException("You cannot delete user id=" + paasUserId + " until active environments exists");
}
List<Environment> userRemovedEnvs = environmentRepository.findAllByOwner(paasUser);
environmentRepository.delete(userRemovedEnvs);
paasUserRepository.delete(paasUser);
}
示例11: makeDatabaseSnapshot
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
/**
* make an hsql database snapshot (txt file)
* SCRIPT native query is used
* doc : http://www.hsqldb.org/doc/2.0/guide/management-chapt.html#N144AE
* @param deleteIfExists
* @return
* @throws Exception
*/
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public DbSnapshot makeDatabaseSnapshot(boolean deleteIfExists) throws Exception {
File snapshotfile = new File(giveMeSnapshotName());
if (snapshotfile.exists() && deleteIfExists) {
snapshotfile.delete();
}
if (snapshotfile.exists()) {
throw new Exception("unable to snapshot : file already exists " + snapshotfile.getAbsolutePath());
}
// String exportFileAbsolutePath = snapshotfile.getAbsolutePath();
// String hsqldbExport = "SCRIPT " + exportFileAbsolutePath.replaceAll("\\\\","/");
String hsqldbExport = "SCRIPT '" + snapshotfile.getName() + "'";
logger.info("export query :{}", hsqldbExport);
Query nativeQuery = em.createNativeQuery(hsqldbExport);
nativeQuery.executeUpdate();
return new DbSnapshot(snapshotfile);
}
示例12: countByUK
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
@SuppressWarnings("unchecked")
public int countByUK(T object) throws ServiceException, Exception {
if (object==null || !(object instanceof BaseValueObj) ) {
throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.OBJ_NULL));
}
int count=0;
Class<E> entityObjectClass=GenericsUtils.getSuperClassGenricType(getClass(), 1);
E entityObject=entityObjectClass.newInstance();
try {
this.doMapper(object, entityObject, this.getMapperIdVo2Po());
count=this.getBaseDataAccessObject().countByUK(entityObject);
} catch (Exception e) {
e.printStackTrace();
}
return count;
}
示例13: update
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
@Override
public Environment update(EnvironmentDetailsDto environmentDetailsDto) {
try {
MDC.put(LOG_KEY_ENVUID, environmentDetailsDto.getUid());
MDC.put(LOG_KEY_ENVNAME, environmentDetailsDto.getLabel());
log.debug("updateEnvironment: uid={}", new Object[]{environmentDetailsDto.getUid()});
Environment environment = environmentRepository.findByUid(environmentDetailsDto.getUid());
assertHasWritePermissionFor(environment);
environment.setComment(environmentDetailsDto.getComment());
return environment;
} finally {
MDC.remove(LOG_KEY_ENVNAME);
MDC.remove(LOG_KEY_ENVUID);
}
}
示例14: deleteEnvironment
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@Override
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT)
public void deleteEnvironment(String uid) throws EnvironmentNotFoundException {
try {
MDC.put(LOG_KEY_ENVUID, uid);
log.debug("deleteEnvironment: uid={}", new Object[]{uid});
Environment environment = environmentRepository.findByUid(uid);
assertHasWritePermissionFor(environment);
MDC.put(LOG_KEY_ENVNAME, environment.getLabel());
if (environment.isRemoved() || environment.isRemoving()) {
log.info("Environment '" + environment.getUID() + "' is already deleted or deletion is in progress (ignoring call)");
} else {
managePaasActivation.delete(environment.getTechnicalDeploymentInstance().getId());
// TODO status should be set by managePaasActivation
environment.setStatus(EnvironmentStatus.REMOVING);
}
} finally {
MDC.remove(LOG_KEY_ENVNAME);
MDC.remove(LOG_KEY_ENVUID);
}
}
示例15: findListVOByParams
import org.springframework.transaction.annotation.Isolation; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@ServiceMethodAuthority(type={ServiceMethodType.SELECT})
@Transactional(
propagation=Propagation.REQUIRES_NEW,
isolation=Isolation.READ_COMMITTED, timeout=25, readOnly=true)
public List<T> findListVOByParams(Map<String, Object> params) throws ServiceException, Exception {
List<T> returnList = null;
List<E> searchList = findListByParams(params, null);
if (searchList==null || searchList.size()<1) {
return returnList;
}
returnList=new ArrayList<T>();
for (E entity : searchList) {
Class<T> objectClass=GenericsUtils.getSuperClassGenricType(getClass(), 0);
T obj=objectClass.newInstance();
this.doMapper(entity, obj, this.getMapperIdPo2Vo());
returnList.add(obj);
}
return returnList;
}