Package org.jboss.errai.bus.client.api

Examples of org.jboss.errai.bus.client.api.AsyncTask


      throw new RuntimeException(e);
    }
  }

  public AsyncTask scheduleRepeating(TimeUnit unit, int interval, Runnable task) {
    AsyncTask t = service.scheduleRepeating(task, unit, 0, interval);

    if (task instanceof HasAsyncTaskRef) {
      ((HasAsyncTaskRef) task).setAsyncTask(t);
    }
View Full Code Here


    return t;
  }

  public AsyncTask schedule(TimeUnit unit, int interval, Runnable task) {
    AsyncTask t = service.schedule(task, unit, interval);

    if (task instanceof HasAsyncTaskRef) {
      ((HasAsyncTaskRef) task).setAsyncTask(t);
    }
View Full Code Here

      public void run() {
        task.run();
      }
    };

    AsyncTask asyncTask = createAsyncTask(task, timer);
    timer.scheduleRepeating((int) unit.convert(interval, TimeUnit.MILLISECONDS));
    return asyncTask;
  }
View Full Code Here

      public void run() {
        task.run();
      }
    };

    AsyncTask asyncTask = createAsyncTask(task, timer);
    timer.schedule((int) unit.convert(interval, TimeUnit.MILLISECONDS));
    return asyncTask;
  }
View Full Code Here

    timer.schedule((int) unit.convert(interval, TimeUnit.MILLISECONDS));
    return asyncTask;
  }

  private static AsyncTask createAsyncTask(final Runnable task, final Timer timer) {
    AsyncTask asyncTask = new AsyncTask() {
      boolean cancelled = false;

      public boolean cancel(boolean interrupt) {
        timer.cancel();
        return cancelled = true;
View Full Code Here

      }

      if (autoStartStop) startIfTasks();
    }

    return new AsyncTask() {
      private boolean finished = false;

      public boolean cancel(boolean mayInterruptIfRunning) {
        task.cancel(mayInterruptIfRunning);
        return finished = true;
View Full Code Here

    String commandType = message.getCommandType();
    String taskName = getTaskName(commandType);

    if (StartMatcher.matcher(commandType).matches()) {
      AsyncTask task = ctx.getAttribute(AsyncTask.class, taskName);

      // there's no task running in this context.
      if (task == null) {
        ResourceProvider<Double> randomNumberProvider = new ResourceProvider<Double>() {
          public Double get() {
            return Math.random();
          }
        };

        task = MessageBuilder.createConversation(message)
            .subjectProvided()
            .withProvided("Data", randomNumberProvider)
            .noErrorHandling()
            .replyRepeating(TimeUnit.MILLISECONDS, 50);

        System.out.println("New task started: " + taskName);
        ctx.setAttribute(taskName, task);
      }
      else {
        System.out.println("Task already started: " + taskName);
      }
    }
    else if (StopMatcher.matcher(commandType).matches()) {
      AsyncTask task = ctx.getAttribute(AsyncTask.class, taskName);

      if (task == null) {
        System.out.println("Nothing to stop: " + taskName);
      }
      else {
        System.out.println("Stopping: " + taskName);
        task.cancel(true);
        ctx.removeAttribute(taskName);
      }
    }
  }
View Full Code Here

            public void run() {
                task.run();
            }
        };

        AsyncTask asyncTask = createAsyncTask(task, timer);
        timer.scheduleRepeating((int) unit.convert(interval, TimeUnit.MILLISECONDS));
        return asyncTask;
    }
View Full Code Here

            public void run() {
                task.run();
            }
        };

        AsyncTask asyncTask = createAsyncTask(task, timer);
        timer.schedule((int) unit.convert(interval, TimeUnit.MILLISECONDS));
        return asyncTask;
    }
View Full Code Here

        timer.schedule((int) unit.convert(interval, TimeUnit.MILLISECONDS));
        return asyncTask;
    }

    private static AsyncTask createAsyncTask(final Runnable task, final Timer timer) {
        AsyncTask asyncTask = new AsyncTask() {
            boolean cancelled = false;
            public boolean cancel(boolean interrupt) {
                timer.cancel();
                return cancelled = true;
            }
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.client.api.AsyncTask

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.