javax.enterprise.concurrent.LastExecution Java Examples

The following examples show how to use javax.enterprise.concurrent.LastExecution. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConcurrentTaskScheduler.java    From spring-analysis-note with MIT License 6 votes vote down vote up
public ScheduledFuture<?> schedule(Runnable task, final Trigger trigger) {
	ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) scheduledExecutor;
	return executor.schedule(task, new javax.enterprise.concurrent.Trigger() {
		@Override
		@Nullable
		public Date getNextRunTime(@Nullable LastExecution le, Date taskScheduledTime) {
			return (trigger.nextExecutionTime(le != null ?
					new SimpleTriggerContext(le.getScheduledStart(), le.getRunStart(), le.getRunEnd()) :
					new SimpleTriggerContext()));
		}
		@Override
		public boolean skipRun(LastExecution lastExecution, Date scheduledRunTime) {
			return false;
		}
	});
}
 
Example #2
Source File: ConcurrentTaskScheduler.java    From java-technology-stack with MIT License 6 votes vote down vote up
public ScheduledFuture<?> schedule(Runnable task, final Trigger trigger) {
	ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) scheduledExecutor;
	return executor.schedule(task, new javax.enterprise.concurrent.Trigger() {
		@Override
		@Nullable
		public Date getNextRunTime(@Nullable LastExecution le, Date taskScheduledTime) {
			return (trigger.nextExecutionTime(le != null ?
					new SimpleTriggerContext(le.getScheduledStart(), le.getRunStart(), le.getRunEnd()) :
					new SimpleTriggerContext()));
		}
		@Override
		public boolean skipRun(LastExecution lastExecution, Date scheduledRunTime) {
			return false;
		}
	});
}
 
Example #3
Source File: ConcurrentTaskScheduler.java    From audit4j-core with Apache License 2.0 6 votes vote down vote up
/**
 * Schedule.
 * 
 * @param task
 *            the task
 * @param trigger
 *            the trigger
 * @return the scheduled future
 */
public ScheduledFuture<?> schedule(Runnable task, final Trigger trigger) {
    ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) scheduledExecutor;
    return executor.schedule(task, new javax.enterprise.concurrent.Trigger() {
        @Override
        public Date getNextRunTime(LastExecution le, Date taskScheduledTime) {
            return trigger.nextExecutionTime(le != null ? new SimpleTriggerContext(le.getScheduledStart(), le
                    .getRunStart(), le.getRunEnd()) : new SimpleTriggerContext());
        }

        @Override
        public boolean skipRun(LastExecution lastExecution, Date scheduledRunTime) {
            return false;
        }
    });
}
 
Example #4
Source File: ConcurrentTaskScheduler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
public ScheduledFuture<?> schedule(Runnable task, final Trigger trigger) {
	ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) scheduledExecutor;
	return executor.schedule(task, new javax.enterprise.concurrent.Trigger() {
		@Override
		public Date getNextRunTime(LastExecution le, Date taskScheduledTime) {
			return (trigger.nextExecutionTime(le != null ?
					new SimpleTriggerContext(le.getScheduledStart(), le.getRunStart(), le.getRunEnd()) :
					new SimpleTriggerContext()));
		}
		@Override
		public boolean skipRun(LastExecution lastExecution, Date scheduledRunTime) {
			return false;
		}
	});
}
 
Example #5
Source File: GameRound.java    From liberty-bikes with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) {
    // If there are any clients still connected to this game, keep sending heartbeats
    if (clients.size() == 0) {
        // Ensure that game state is closed off so that no other players
        // can quick join while a round is marked for deletion
        log("No clients remaining.  Cancelling heartbeat.");
        endGame();
        return null;
    }
    return Date.from(Instant.now().plusSeconds(HEARTBEAT_INTERVAL_SEC));
}
 
Example #6
Source File: ConcurrentTaskScheduler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public ScheduledFuture<?> schedule(Runnable task, final Trigger trigger) {
	ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) scheduledExecutor;
	return executor.schedule(task, new javax.enterprise.concurrent.Trigger() {
		@Override
		public Date getNextRunTime(LastExecution le, Date taskScheduledTime) {
			return trigger.nextExecutionTime(le != null ?
					new SimpleTriggerContext(le.getScheduledStart(), le.getRunStart(), le.getRunEnd()) :
					new SimpleTriggerContext());
		}
		@Override
		public boolean skipRun(LastExecution lastExecution, Date scheduledRunTime) {
			return false;
		}
	});
}
 
Example #7
Source File: GameRound.java    From liberty-bikes with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) {
    return clients.size() == 0;
}
 
Example #8
Source File: TriggerTask.java    From tomee with Apache License 2.0 4 votes vote down vote up
public LastExecution getLastExecution() {
    return lastExecution;
}