public void execute() { if(!canceled) { transactionalAction = null; switch (op) { case suspend: suspended = true; transaction = tx; // put a barrier in the event queue manager for this activity, to // freeze the event routing on this activity at that level event.getLocalActivityContext().getEventQueueManager().createBarrier(tx); // init queue to store events about to be routed (after this one), // which may have passed the barrier barriedEvents = new LinkedList<EventContext>(); // set state as suspended suspended = true; // schedule task scheduledFuture = sleeContainer.getNonClusteredScheduler().schedule(new SuspensionTimerTask(),timeout,TimeUnit.MILLISECONDS); break; case resume: resume(); break; default: throw new SLEEException("unxpected op type when executing event context state change"); } } }
@Override public void suspend() throws TransactionRequiredLocalException, SLEEException { final SleeTransactionManager txManager = sleeContainer .getTransactionManager(); txManager.mandateTransaction(); try { final SleeTransaction tx = txManager.getTransaction(); final ActivityEventQueueManager aeqm = activityContext .getLocalActivityContext().getEventQueueManager(); aeqm.createBarrier(tx); final TransactionalAction action = new TransactionalAction() { public void execute() { aeqm.removeBarrier(tx); } }; final TransactionContext tc = tx.getTransactionContext(); tc.getAfterCommitActions().add(action); tc.getAfterRollbackActions().add(action); } catch (Throwable e) { throw new SLEEException(e.getMessage(), e); } } }
aeqm.createBarrier(barrierTx); TransactionalAction action = new TransactionalAction() { public void execute() {
final ActivityEventQueueManager eventQueue = ac .getLocalActivityContext().getEventQueueManager(); eventQueue.createBarrier(tx); TransactionalAction action = new TransactionalAction() { public void execute() {
aeqm.createBarrier(barrierTx); TransactionalAction action = new TransactionalAction() { public void execute() {
aeqm.createBarrier(barrierTx); TransactionalAction action = new TransactionalAction() { public void execute() {