Example usage for javax.management.timer Timer addNotification

List of usage examples for javax.management.timer Timer addNotification

Introduction

In this page you can find the example usage for javax.management.timer Timer addNotification.

Prototype






public synchronized Integer addNotification(String type, String message, Object userData, Date date)
        throws java.lang.IllegalArgumentException 

Source Link

Document

Creates a new timer notification with the specified type, message and userData and inserts it into the list of notifications with a given date and a null period and number of occurrences.

Usage

From source file:org.accada.epcis.repository.query.QuerySubscriptionScheduled.java

/**
 * Starts a Timer to get this query executed in specific time intervals.
 * /*from  w ww.  j av  a 2  s.  c o m*/
 * @throws ImplementationException
 *             If the next scheduled date cannot be evaluated.
 */
private void startThread() throws ImplementationExceptionResponse {
    Timer nextAction = new Timer();
    nextAction.addNotificationListener(this, null, nextAction);

    Date nextSchedule = schedule.nextScheduledTime().getTime();
    nextAction.addNotification("SubscriptionSchedule", "Please do the query", null, nextSchedule);
    nextAction.start();
}

From source file:org.accada.epcis.repository.query.QuerySubscriptionScheduled.java

/**
 * Determines the next scheduled execution time for this subscribed query.
 * /*www.j a  va  2s.  co  m*/
 * @param timer
 *            The Timer to set the next scheduled time.
 * @throws IllegalArgumentException
 */
protected void setNextScheduledExecutionTime(final Timer timer) throws IllegalArgumentException {
    try {
        Date nextSchedule = schedule.nextScheduledTime().getTime();
        LOG.debug("Next scheduled time for the subscribed query is '" + nextSchedule + "'.");
        timer.addNotification("SubscriptionSchedule", "Please do the query", timer, nextSchedule);
    } catch (ImplementationExceptionResponse e) {
        String msg = "The next scheduled date for the subscribed query with ID '" + getSubscriptionID()
                + "' cannot be evaluated: " + e.getMessage();
        LOG.error(msg, e);
    }
}