List of usage examples for javax.management.timer Timer stop
public synchronized void stop()
From source file:org.accada.epcis.repository.query.QuerySubscriptionScheduled.java
/** * This method is handles a notification when the Timer for the schedule * times out.//from ww w .ja v a 2 s.co m * * @see javax.management.NotificationListener#handleNotification(javax.management.Notification, * java.lang.Object) * @param pNotification * The Notification. * @param pHandback * A Timer stating the time when the Notification should be * invoked. */ public void handleNotification(final Notification pNotification, final Object pHandback) { if (pHandback == null) { LOG.error("The timer stating the next scheduled query execution time is null!"); return; } Timer timer = (Timer) pHandback; if (!doItAgain.booleanValue()) { timer.stop(); } else { // execute the query and determine next scheduled execution time executeQuery(); setNextScheduledExecutionTime(timer); } }
From source file:org.accada.epcis.repository.query.QuerySubscriptionTriggered.java
/** * {@inheritDoc} First checks on the trigger condition: if fulfilled then * execute Query.//from w w w. jav a2 s . c om * * @see org.accada.epcis.repository.query.QuerySubscriptionScheduled#handleNotification(javax.management.Notification, * java.lang.Object) */ @Override public void handleNotification(final Notification pNotification, final Object pHandback) { if (pHandback == null) { LOG.error("The timer stating the next scheduled query execution time is null!"); return; } Timer timer = (Timer) pHandback; if (!doItAgain.booleanValue()) { timer.stop(); } else { try { LOG.debug("Checking trigger condition ..."); String queryName = "SimpleEventQuery"; QueryParams params = new QueryParams(); // add MATCH_anyEPC query param QueryParam param = new QueryParam(); param.setName("MATCH_anyEPC"); ArrayOfString strings = new ArrayOfString(); strings.getString().add(trigger); param.setValue(strings); params.getParam().add(param); // add GE_recordTime query param param = new QueryParam(); param.setName("GE_recordTime"); param.setValue(initialRecordTime); params.getParam().add(param); // send the query Poll poll = new Poll(); poll.setParams(params); poll.setQueryName(queryName); QueryResults results = executePoll(poll); if (results.getResultsBody().getEventList() != null) { LOG.debug("Trigger condition fulfilled!"); LOG.debug("Executing subscribed query associated with trigger event ..."); super.executeQuery(); LOG.debug("Triggered query successfully executed!"); } } catch (Exception e) { String msg = "An error occurred while checking trigger condition for query with subscriptionID '" + subscriptionID + "': " + e.getMessage(); LOG.error(msg, e); } // determine next scheduled execution time setNextScheduledExecutionTime(timer); } }
From source file:org.fosstrak.epcis.repository.query.QuerySubscriptionTriggered.java
/** * {@inheritDoc} First checks on the trigger condition: if fulfilled then * execute Query.// w ww .j av a 2s. c o m * * @see org.fosstrak.epcis.repository.query.QuerySubscriptionScheduled#handleNotification(javax.management.Notification, * java.lang.Object) */ @Override public void handleNotification(final Notification pNotification, final Object pHandback) { if (pHandback == null) { LOG.error("The timer stating the next scheduled query execution time is null!"); return; } Timer timer = (Timer) pHandback; if (!doItAgain.booleanValue()) { timer.stop(); } else { try { LOG.debug("Checking trigger condition ..."); String queryName = "SimpleEventQuery"; QueryParams params = new QueryParams(); // add MATCH_anyEPC query param QueryParam param = new QueryParam(); param.setName("MATCH_anyEPC"); ArrayOfString strings = new ArrayOfString(); strings.getString().add(trigger); param.setValue(strings); params.getParam().add(param); // add GE_recordTime query param param = new QueryParam(); param.setName("GE_recordTime"); param.setValue(initialRecordTime); params.getParam().add(param); // send the query Poll poll = new Poll(); poll.setParams(params); poll.setQueryName(queryName); QueryResults results = executePoll(poll); if (results != null && results.getResultsBody() != null && results.getResultsBody().getEventList() != null) { LOG.debug("Trigger condition fulfilled!"); LOG.debug("Executing subscribed query associated with trigger event ..."); super.executeQuery(); LOG.debug("Triggered query successfully executed!"); } } catch (Exception e) { String msg = "An error occurred while checking trigger condition for query with subscriptionID '" + subscriptionID + "': " + e.getMessage(); LOG.error(msg, e); } // determine next scheduled execution time setNextScheduledExecutionTime(timer); } }