List of usage examples for javax.ejb TransactionAttributeType REQUIRES_NEW
TransactionAttributeType REQUIRES_NEW
To view the source code for javax.ejb TransactionAttributeType REQUIRES_NEW.
Click Source Link
REQUIRES_NEW
with a new transaction context. From source file:com.encens.khipus.service.production.RawMaterialPayRollServiceBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void createAll(RawMaterialPayRoll rawMaterialPayRoll) throws EntryDuplicatedException, RawMaterialPayRollException { try {/*from w w w .ja v a 2 s . c om*/ //validate(rawMaterialPayRoll); //Object args = preCreate(rawMaterialPayRoll); //processCreate(rawMaterialPayRoll); //postCreate(rawMaterialPayRoll, args); //getEntityManager().merge(rawMaterialPayRoll); //getEntityManager().flush(); validate(rawMaterialPayRoll); Object args = preCreate(rawMaterialPayRoll); processCreate(rawMaterialPayRoll); postCreate(rawMaterialPayRoll, args); getEntityManager().flush(); } catch (PersistenceException e) { //TODO when hibernate will fix this http://opensource.atlassian.com/projects/hibernate/browse/EJB-382, we have to restore EntityExistsException here. log.debug("Persistence error..", e); log.info("PersistenceException caught"); //log.error(e); //throw new EntryDuplicatedException(e); } }
From source file:dk.dma.msinm.legacy.msi.service.LegacyMsiImportService.java
/** * Import all MSI warnings/*from w w w. ja v a2 s .c om*/ * @return the imported/updated MSI warnings */ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public List<LegacyMessage> importAllMsiWarnings() { // Check if the integration is active if (!settings.getBoolean(LEGACY_MSI_ACTIVE)) { return new ArrayList<>(); } // Import the legacy MSI from the last registered update time until now // Note that at most LIMIT messages are processed Date lastRegisteredUpdateDate = settings.getDate(LEGACY_MSI_LAST_UPDATE); Date now = new Date(); List<LegacyMessage> result = new ArrayList<>(); Date lastUpdate = importMsi(result, allLegacyMsiSql, "all", lastRegisteredUpdateDate, now); // And register the last update time if (lastUpdate != null) { settings.updateSetting(new SettingsEntity(LEGACY_MSI_LAST_UPDATE.getSettingName(), String.valueOf(lastUpdate.getTime()))); } return result; }
From source file:be.fedict.trust.service.dao.bean.CertificateAuthorityDAOBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void updateRevokedCertificates(Set<X509CRLEntry> revokedCertificates, BigInteger crlNumber, X500Principal crlIssuer) { LOG.debug("Update " + revokedCertificates.size() + " revoked certificates (crlNumber=" + crlNumber + ")"); for (X509CRLEntry revokedCertificate : revokedCertificates) { X500Principal certificateIssuer = revokedCertificate.getCertificateIssuer(); String issuerName;/* www .j a v a2 s . c o m*/ if (null == certificateIssuer) { issuerName = crlIssuer.toString(); } else { issuerName = certificateIssuer.toString(); } BigInteger serialNumber = revokedCertificate.getSerialNumber(); Date revocationDate = revokedCertificate.getRevocationDate(); // lookup RevokedCertificateEntity revokedCertificateEntity = this.entityManager.find( RevokedCertificateEntity.class, new RevokedCertificatePK(issuerName, serialNumber.toString())); if (null != revokedCertificateEntity) { // already exists, update revocationDate and crl number revokedCertificateEntity.setRevocationDate(revocationDate); revokedCertificateEntity.setCrlNumber(crlNumber); } else { // don't exist yet, add this.entityManager .persist(new RevokedCertificateEntity(issuerName, serialNumber, revocationDate, crlNumber)); } } }
From source file:org.rhq.enterprise.server.cloud.PartitionEventManagerBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @RequiredPermission(Permission.MANAGE_INVENTORY) public void createPartitionEvent(Subject subject, PartitionEvent partitionEvent) { entityManager.persist(partitionEvent); }
From source file:org.rhq.enterprise.server.cloud.StatusManagerBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void updateByResource(Subject subject, int resourceId) { log.debug("About to mark status by resource"); /* //from www .j a v a2 s . com * the old alert definition is needed to know which caches to remove stale entries from; the updated / new * alert definition is needed to know which caches need to be reloaded to get the new conditions; by the time * this method is called, we only have the updated alert definition, thus it's not possible to intelligently * know which of the two caches to reload; so, we need to reload them both to be sure the system is consistent */ markGlobalCache(); // use local references to execute in the same transaction Query updateAgentQuery = entityManager.createNamedQuery(Agent.QUERY_UPDATE_STATUS_BY_RESOURCE); updateAgentQuery.setParameter("resourceId", resourceId); int agentsUpdated = updateAgentQuery.executeUpdate(); /* * this is informational debugging only - do NOT change the status bits here */ if (log.isDebugEnabled()) { Agent agent = agentManager.getAgentByResourceId(LookupUtil.getSubjectManager().getOverlord(), resourceId); log.debug("Marking status, agent[id=" + agent.getId() + ", status=" + agent.getStatus() + "] for resource[id=" + resourceId + "]"); log.debug("Agents updated: " + agentsUpdated); } }
From source file:pl.psnc.synat.wrdz.mdz.integrity.IntegrityProcessorBean.java
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public IntegrityProcessingResult processOne() { DigitalObject object = getNextObject(); if (object == null) { return IntegrityProcessingResult.FINISHED; }//www. j a va 2 s . co m HttpClient client = httpsClientHelper.getHttpsClient(WrdzModule.MDZ); HttpGet get = new HttpGet(configuration.getZmdObjectUrl(object.getIdentifier())); HttpResponse response = null; try { synchronized (this) { response = client.execute(get); if (response.getStatusLine().getStatusCode() == HttpStatus.SC_ACCEPTED) { waitingForIdentifier = object.getIdentifier(); return IntegrityProcessingResult.PAUSED; } } if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { boolean corrupted = false; File file = storeTemporarily(response.getEntity()); try { corrupted = integrityVerifier.isCorrupted(object.getIdentifier(), file); } finally { if (!file.delete()) { logger.warn("Could not delete temporary file: " + file.getAbsolutePath()); } } if (corrupted) { messenger.notifyObjectCorrupted(object.getIdentifier()); } object.setVerifiedOn(new Date()); object.setCorrect(!corrupted); return IntegrityProcessingResult.PROCESSED; } else { throw new WrdzRuntimeException("Unexpected response: " + response.getStatusLine()); } } catch (IOException e) { throw new WrdzRuntimeException("Could not fetch object from ZMD", e); } finally { if (response != null) { EntityUtils.consumeQuietly(response.getEntity()); } } }
From source file:org.rhq.enterprise.server.measurement.AvailabilityManagerBean.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) @TransactionTimeout(6 * 60 * 60)//from ww w .ja v a 2 s . c om public int purgeAvailabilities(long oldest) { try { Query purgeQuery = entityManager.createNativeQuery(Availability.NATIVE_QUERY_PURGE); purgeQuery.setParameter(1, oldest); long startTime = System.currentTimeMillis(); int deleted = purgeQuery.executeUpdate(); MeasurementMonitor.getMBean().incrementPurgeTime(System.currentTimeMillis() - startTime); MeasurementMonitor.getMBean().setPurgedAvailabilities(deleted); return deleted; } catch (Exception e) { throw new RuntimeException("Failed to purge availabilities older than [" + oldest + "]", e); } }
From source file:be.fedict.eid.pkira.blm.model.contracts.ContractRepositoryBean.java
/** * {@inheritDoc}// w w w . ja va2s .c o m */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void removeCertificate(Certificate certificate) { certificate = entityManager.getReference(Certificate.class, certificate.getId()); entityManager.remove(certificate); }
From source file:org.meveo.service.job.JobInstanceService.java
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void startTimers(Job job) { // job.cleanAllTimers(); @SuppressWarnings("unchecked") List<JobInstance> jobInstances = getEntityManager() .createQuery("from JobInstance ji JOIN FETCH ji.followingJob where ji.jobTemplate=:jobName") .setParameter("jobName", job.getClass().getSimpleName()).getResultList(); if (jobInstances != null) { int started = 0; for (JobInstance jobInstance : jobInstances) { if (jobInstance.isActive() && jobInstance.getTimerEntity() != null) { jobTimers.put(jobInstance.getId(), job.createTimer(jobInstance.getTimerEntity().getScheduleExpression(), jobInstance)); started++;/* ww w . java 2 s.co m*/ } } log.debug("Found {} job instances for {}, started {}", jobInstances.size(), job.getClass().getSimpleName(), started); } }
From source file:be.fedict.eid.pkira.blm.model.contracts.ContractRepositoryBean.java
@Override @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void updateContract(AbstractContract contract) { entityManager.merge(contract); }