Example usage for javax.ejb TransactionAttributeType NOT_SUPPORTED

List of usage examples for javax.ejb TransactionAttributeType NOT_SUPPORTED

Introduction

In this page you can find the example usage for javax.ejb TransactionAttributeType NOT_SUPPORTED.

Prototype

TransactionAttributeType NOT_SUPPORTED

To view the source code for javax.ejb TransactionAttributeType NOT_SUPPORTED.

Click Source Link

Document

The container invokes an enterprise bean method whose transaction attribute NOT_SUPPORTED with an unspecified transaction context.

Usage

From source file:edu.harvard.iq.dvn.core.study.StudyFileServiceBean.java

@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public List<Long> getOrderedFileIdsByStudyVersion(Long svId) {
    List<FileIdCategory> fileIdCatList = new ArrayList();
    String queryString = "SELECT f.id, f.category FROM FileMetadata f WHERE f.studyVersion_id = " + svId
            + " ORDER BY f.category, f.label";
    Query query = em.createNativeQuery(queryString);

    for (Object result : query.getResultList()) {
        Object[] resultArray = (Object[]) result;
        FileIdCategory idCat = new FileIdCategory();
        idCat.setId(new Long((Integer) resultArray[0]));
        idCat.setCategory((String) resultArray[1]);
        fileIdCatList.add(idCat);/*from  w  ww. j ava 2  s. c o m*/
    }

    Collections.sort(fileIdCatList);

    List<Long> fileIdList = new ArrayList<Long>();
    for (FileIdCategory idCat : fileIdCatList) {
        fileIdList.add(idCat.getId());
    }

    return fileIdList;
}

From source file:edu.harvard.iq.dvn.core.index.IndexServiceBean.java

@Timeout
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void handleTimeout(javax.ejb.Timer timer) {
    System.out.println("in handleTimeout, timer = " + timer.getInfo());

    try {//  w  w w .j a  v  a2  s. c om
        // read-only mode check:
        boolean readOnly = vdcNetworkService.defaultTransactionReadOnly();

        if (timer.getInfo().equals(INDEX_TIMER)) {
            if (readOnly) {
                logger.log(Level.ALL, "Network is in read-only mode; skipping scheduled index job.");
            } else {
                logger.log(Level.INFO, "Index update");
                indexBatch();
            }
        } else if (timer.getInfo().equals(INDEX_NOTIFICATION_TIMER)) {
            if (readOnly) {
                logger.log(Level.ALL, "Network is in read-only mode; skipping scheduled index notification.");
            } else {
                logger.log(Level.INFO, "Index notify");
                indexProblemNotify();
            }
        } else if (timer.getInfo().equals(COLLECTION_INDEX_TIMER)) {
            if (readOnly) {
                logger.log(Level.ALL,
                        "Network is in read-only mode; skipping scheduled collection reindexing.");
            } else {
                logger.log(Level.INFO, "Collection ReIndex");
                updateStudiesInCollections();
            }
        }
    } catch (Throwable e) {
        mailService.sendIndexUpdateErrorNotification(vdcNetworkService.find().getSystemEmail(),
                vdcNetworkService.find().getName());
        e.printStackTrace();
    }
}

From source file:com.flexive.ejb.beans.FxTimerServiceBean.java

/**
* {@inheritDoc}/*from  w  w w.  jav  a 2 s . c  o  m*/
* @since 3.1.2
*/
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void scheduleScript(FxScriptSchedule scriptSchedule) throws FxApplicationException {
    FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptManagement);
    FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptExecution);
    FxQuartz.scheduleScript(scriptSchedule);
}

From source file:com.hiperium.bo.control.impl.TaskBOImpl.java

/**
 * //from  www.ja  v  a 2s  . c om
 * @param task
 */
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
private void createSingleTimer(Task task) {
    this.log.debug("createSingleTimer - START");
    this.timerService.createSingleActionTimer(task.getExecutionDate(), new TimerConfig(task.getId(), true));
    this.log.debug("createSingleTimer - END");
}

From source file:com.flexive.ejb.beans.FxTimerServiceBean.java

/**
 * {@inheritDoc}//from   w  w  w  . j  a  va 2 s .c om
 * @since 3.1.2
 */
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void updateScriptSchedule(FxScriptSchedule scriptSchedule) throws FxApplicationException {
    FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptManagement);
    FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptExecution);
    FxQuartz.updateScriptSchedule(scriptSchedule);
}

From source file:com.hiperium.bo.control.impl.TaskBOImpl.java

/**
 * //from w  w  w . j  a va2 s.  c  o  m
 * @param task
 * @throws InformationException 
 */
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
private void createCalendarTimer(Task task) throws InformationException {
    this.log.debug("createCalendarTimer - START");
    ScheduleExpression expression = new ScheduleExpression();
    // TODO: Create CRON TASK based on task.getCronTask() parameter.
    this.timerService.createCalendarTimer(expression, new TimerConfig(task.getId(), true));
    this.log.debug("createCalendarTimer - END");
}

From source file:com.flexive.ejb.beans.FxTimerServiceBean.java

/**
 * {@inheritDoc}/*from  w w  w  .  j  a  v a 2s .c  om*/
 * @since 3.1.2
 */
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public boolean deleteScriptSchedule(FxScriptSchedule scriptSchedule) throws FxApplicationException {
    FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptManagement);
    FxPermissionUtils.checkRole(FxContext.getUserTicket(), Role.ScriptExecution);
    return FxQuartz.deleteScriptSchedule(scriptSchedule);
}

From source file:com.hiperium.bo.control.impl.TaskBOImpl.java

/**
 * /*from  w  ww  . j a v a 2s  .  c  om*/
 * @param task
 */
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
private void createIntervalTimer(Task task) {
    this.log.debug("createIntervalTimer - START: " + task.getExecutionDate());
    Long interval = 0L;
    switch (task.getFrequency()) {
    case EVERY_MIMUTE:
        this.log.debug("createIntervalTimer - EVERY_MIMUTE");
        interval = 60000L;
        break;
    case QUARTER_HOUR:
        this.log.debug("createIntervalTimer - QUARTER_HOUR");
        interval = 900000L;
        break;
    case HALF_HOUR:
        this.log.debug("createIntervalTimer - HALF_HOUR");
        interval = 1800000L;
        break;
    case HOURLY:
        this.log.debug("createIntervalTimer - HOURLY");
        interval = 3600000L;
        break;
    case DAILY:
        this.log.debug("createIntervalTimer - DAILY");
        interval = 86400000L;
        break;
    default:
        break;
    }
    this.log.debug("Interval in milliseconds: " + interval);
    this.timerService.createIntervalTimer(task.getExecutionDate(), interval,
            new TimerConfig(task.getId(), true));
    this.log.debug("createIntervalTimer - END");
}

From source file:com.flexive.ejb.beans.FxTimerServiceBean.java

/**
* {@inheritDoc}//from   w  ww .  j  a v  a 2  s  . c om
* @since 3.1.2
*/
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void parseCronString(String cronString) throws FxInvalidParameterException {
    FxQuartz.parseCronString(cronString);
}

From source file:edu.harvard.iq.dvn.core.harvest.HarvesterServiceBean.java

/**
 * This method is called whenever an EJB Timer goes off.
 * Check to see if this is a Harvest Timer, and if it is
 * Run the harvest for the given (scheduled) dataverse
 * @param timer//from w ww .  j av  a2s.  c o m
 */
@Timeout
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void handleTimeout(javax.ejb.Timer timer) {
    // We have to put all the code in a try/catch block because
    // if an exception is thrown from this method, Glassfish will automatically
    // call the method a second time. (The minimum number of re-tries for a Timer method is 1)

    if (timer.getInfo() instanceof HarvestTimerInfo) {
        HarvestTimerInfo info = (HarvestTimerInfo) timer.getInfo();
        try {
            // First, check if we are in read-only mode: 

            if (vdcNetworkService.defaultTransactionReadOnly()) {
                logger.log(Level.ALL, "Network is in read-only mode.");
                return;

            }

            // Proceeding with the scheduled harvest: 

            logger.log(Level.INFO, "DO HARVESTING of dataverse " + info.getHarvestingDataverseId());
            doHarvesting(info.getHarvestingDataverseId());

        } catch (Throwable e) {
            harvestingDataverseService.setHarvestResult(info.getHarvestingDataverseId(),
                    HarvestingDataverse.HARVEST_RESULT_FAILED);
            mailService.sendHarvestErrorNotification(vdcNetworkService.find().getSystemEmail(),
                    vdcNetworkService.find().getName());
            logException(e, logger);
        }
    }
}