/** * @param task * @param delay * @param timeUnit * @return * @throws NamingException */ public Future<?> schedule(TestRunnable task, long delay, TimeUnit timeUnit) throws NamingException { final Principal principal = ejbContext.getCallerPrincipal(); logger.debugf("Principal: %s", principal); task.setExpectedPrincipal(principal); return executorService.schedule(task, delay, timeUnit); }
@Override public void init() throws ServletException { executorService.scheduleWithFixedDelay( new Runnable() { @Override public void run() { number.set((int) (Math.random() * 100)); } }, 0, 3, TimeUnit.SECONDS); executorService.schedule( new Callable<Void>() { @Override public Void call() throws Exception { return null; } }, new Trigger() { @Override public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { // TODO Auto-generated method stub return false; } @Override public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { // TODO Auto-generated method stub return null; } }); }