Examples of Callable


Examples of java.util.concurrent.Callable

   @Override
   public NotifyingFuture<V> removeAsync(final Object key) {
      assertRemoteCacheManagerIsStarted();
      final NotifyingFutureImpl<V> result = new NotifyingFutureImpl<V>();
      Future future = executorService.submit(new Callable() {
         @Override
         public Object call() throws Exception {
            V toReturn = remove(key);
            result.notifyFutureCompletion();
            return toReturn;
View Full Code Here

Examples of java.util.concurrent.Callable

   @Override
   public NotifyingFuture<V> replaceAsync(final K key,final V value,final long lifespan,final TimeUnit lifespanUnit,final long maxIdle,final TimeUnit maxIdleUnit) {
      assertRemoteCacheManagerIsStarted();
      final NotifyingFutureImpl<V> result = new NotifyingFutureImpl<V>();
      Future future = executorService.submit(new Callable() {
         @Override
         public Object call() throws Exception {
            V v = replace(key, value, lifespan, lifespanUnit, maxIdle, maxIdleUnit);
            result.notifyFutureCompletion();
            return v;
View Full Code Here

Examples of java.util.concurrent.Callable

   public void testNodeJoiningDuringPutIfAbsent() throws Exception {
      Future[] futures = new Future[NUM_WRITERS];
      for (int i = 0; i < NUM_WRITERS; i++) {
         final int finalI = i;
         futures[i] = fork(new Callable() {
            @Override
            public Object call() throws Exception {
               for (int j = 0; j < NUM_KEYS; j++) {
                  Cache<Object, Object> cache = cache(finalI % NUM_ORIGINATORS);
                  cache.putIfAbsent("key_" + finalI + "_" + j, "value_" + finalI + "_" + j);
View Full Code Here

Examples of java.util.concurrent.Callable

   public void testNodeLeavingDuringPutIfAbsent() throws Exception {
      Future[] futures = new Future[NUM_WRITERS];
      for (int i = 0; i < NUM_WRITERS; i++) {
         final int finalI = i;
         futures[i] = fork(new Callable() {
            @Override
            public Object call() throws Exception {
               for (int j = 0; j < NUM_KEYS; j++) {
                  Cache<Object, Object> cache = cache(finalI % NUM_ORIGINATORS);
                  putRetryOnSuspect(cache, "key_" + finalI + "_" + j, "value_" + finalI + "_" + j);
View Full Code Here

Examples of java.util.concurrent.Callable

  public void testNotIterableCallable() throws IOException {
    MustacheFactory mf = createMustacheFactory();
    Mustache m = mf.compile(new StringReader("{{^value}}test{{/value}}"), "testNotIterableCallable");
    StringWriter sw = new StringWriter();
    m.execute(sw, new Object() {
      Callable value = new Callable() {
        @Override
        public Object call() throws Exception {
          return null;
        }
      };
View Full Code Here

Examples of java.util.concurrent.Callable

   }

   @Override
   protected Callable<?> createPushStateTask()
   {
      return new Callable()
      {
         public Object call() throws Exception
         {
            final boolean debugEnabled = log.isDebugEnabled();
View Full Code Here

Examples of org.apache.harmony.pack200.NewAttributeBands.Callable

        MockNewAttributeBands newAttributeBands = new MockNewAttributeBands(1,
                null, null, new AttributeDefinition(35,
                        AttributeDefinitionBands.CONTEXT_CLASS, name, layout));
        List layoutElements = newAttributeBands.getLayoutElements();
        assertEquals(3, layoutElements.size());
        Callable firstCallable = (Callable) layoutElements.get(0);
        Callable secondCallable = (Callable) layoutElements.get(1);
        Callable thirdCallable = (Callable) layoutElements.get(2);
        List firstBody = firstCallable.getBody();
        assertEquals(1, firstBody.size());
        Replication rep = (Replication) firstBody.get(0);
        List repBody = rep.getLayoutElements();
        assertEquals(1, repBody.size());
View Full Code Here

Examples of org.drools.runtime.pipeline.Callable

public class MvelExpressionTest extends TestCase {
    public void testExpression() {
        MockClass mock = new MockClass();
              
        Callable callable = new CallableImpl();
        Action action = PipelineFactory.newMvelAction( "this.setValues( [0, 1, 2, 3, 4] ) " );
        callable.setReceiver( action );
        Expression expr = PipelineFactory.newMvelExpression( "this.values" );
        action.setReceiver( expr );
        expr.setReceiver( callable );         
       
        assertNull( mock.getValues() );
        List<Integer> list = ( List<Integer> ) callable.call( mock, new BasePipelineContext( Thread.currentThread().getContextClassLoader() ) );

       
        System.out.println( list.get( 0 ));
        assertEquals( 5, list.size());
        assertEquals( 0,list.get( 0 ).intValue() );
View Full Code Here

Examples of org.mozilla.javascript.Callable

    static int taskId = 0;

    private static Runnable runnableInNewThread(final Scriptable scope, Object[] args, String name) {
    if(args.length == 0 || !(args[0] instanceof Callable))
      throw ScriptRuntime.constructError("TypeError", "The first parameter of " + name + " must be a function");
    final Callable function = (Callable) args[0];
    TimerTask timeoutTask;
    final int thisTaskId = taskId++;
    final Object user = UserSecurity.currentUser();
    IndividualRequest request = Client.getCurrentObjectResponse();
    final Client session = request == null ? null : Client.getCurrentObjectResponse().getConnection();

    return new Runnable(){

      public void run() {
        try{
          if(session != null)
            session.adoptThread(Thread.currentThread());
          UserSecurity.registerThisThread(user);
          Transaction.startTransaction();
          function.call(PersevereContextFactory.getContext(), scope, null, new Object[]{});
          Transaction.currentTransaction().commit();
        }catch(Throwable e){
          if(e instanceof RhinoException)
            log.warn(((RhinoException)e).details() + '\n' + ((RhinoException)e).getScriptStackTrace());
          else
View Full Code Here

Examples of org.mule.api.lifecycle.Callable

        ChainedThreadingProfile threadingProfile = (ChainedThreadingProfile) muleContext.getDefaultServiceThreadingProfile();
        threadingProfile.setMaxThreadsActive(1);
        threadingProfile.setThreadWaitTimeout(200);
        threadingProfile.setPoolExhaustedAction(ThreadingProfile.WHEN_EXHAUSTED_WAIT);
        service.setThreadingProfile(threadingProfile);
        final SimpleCallableJavaComponent component = new SimpleCallableJavaComponent(new Callable()
        {

            public Object onCall(MuleEventContext eventContext) throws Exception
            {
                latch.countDown();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.