Package javax.enterprise.concurrent

Examples of javax.enterprise.concurrent.ManagedScheduledExecutorService


        assertTrue(future.isCancelled());
    }

    @Test
    public void triggerRunnableSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final CountDownLatch counter = new CountDownLatch(5);
        final FutureAwareCallable callable = new FutureAwareCallable(counter);

        final ScheduledFuture<?> future = es.schedule(Runnable.class.cast(callable),
            new Trigger() {
                @Override
                public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) {
                    if (lastExecutionInfo == null) {
                        return new Date();
View Full Code Here


        assertTrue(cancelled);
    }

    @Test
    public void simpleSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final long start = System.currentTimeMillis();
        final ScheduledFuture<Long> future = es.schedule(new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                Thread.sleep(4000);
                return System.currentTimeMillis();
            }
View Full Code Here

        SystemInstance.reset();
    }

    @Test
    public void triggerCallableSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final CountDownLatch counter = new CountDownLatch(5);
        final FutureAwareCallable callable = new FutureAwareCallable(counter);

        final Future<Long> future = es.schedule((Callable<Long>) callable,
            new Trigger() {
                @Override
                public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) {
                    if (lastExecutionInfo == null) {
                        return new Date();
View Full Code Here

        assertTrue(future.isCancelled());
    }

    @Test
    public void triggerRunnableSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final CountDownLatch counter = new CountDownLatch(5);
        final FutureAwareCallable callable = new FutureAwareCallable(counter);

        final ScheduledFuture<?> future = es.schedule(Runnable.class.cast(callable),
            new Trigger() {
                @Override
                public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) {
                    if (lastExecutionInfo == null) {
                        return new Date();
View Full Code Here

        assertTrue(cancelled);
    }

    @Test
    public void simpleSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final long start = System.currentTimeMillis();
        final ScheduledFuture<Long> future = es.schedule(new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                Thread.sleep(4000);
                return System.currentTimeMillis();
            }
View Full Code Here

   * Separated into an inner class in order to avoid a hard dependency on the JSR-236 API.
   */
  private class EnterpriseConcurrentTriggerScheduler {

    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());
View Full Code Here

        SystemInstance.reset();
    }

    @Test
    public void triggerCallableSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final AtomicInteger counter = new AtomicInteger(0);
        final FutureAwareCallable callable = new FutureAwareCallable(counter);

        final Future<Integer> future = es.schedule((Callable<Integer>) callable,
                new Trigger() {
                    @Override
                    public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) {
                        if (lastExecutionInfo == null) {
                            return new Date();
View Full Code Here

        assertTrue(future.isCancelled());
    }

    @Test
    public void triggerRunnableSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final AtomicInteger counter = new AtomicInteger(0);
        final FutureAwareCallable callable = new FutureAwareCallable(counter);

        final ScheduledFuture<?> future = es.schedule(Runnable.class.cast(callable),
                new Trigger() {
                    @Override
                    public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) {
                        if (lastExecutionInfo == null) {
                            return new Date();
View Full Code Here

        assertTrue(future.isCancelled());
    }

    @Test
    public void simpleSchedule() throws Exception {
        final ManagedScheduledExecutorService es = new ManagedScheduledExecutorServiceImplFactory().create();
        final long start = System.currentTimeMillis();
        final ScheduledFuture<Long> future = es.schedule(new Callable<Long>() {
            @Override
            public Long call() throws Exception {
                Thread.sleep(4000);
                return System.currentTimeMillis();
            }
View Full Code Here

TOP

Related Classes of javax.enterprise.concurrent.ManagedScheduledExecutorService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.