Package java.util.concurrent

Examples of java.util.concurrent.Callable


    * @return new instance of Callable<?> whose call() method either throws an exception or returns null if the task
    *         was successfull.
    */
   protected Callable<?> createPushStateTask()
   {
      return new Callable()
      {
         public Object call() throws Exception
         {
            final boolean debugEnabled = log.isDebugEnabled();

View Full Code Here


      }

      @Override
      protected Callable<?> createPushStateTask()
      {
         return new Callable()
         {
            public Object call() throws Exception
            {
               numberCreatedTasks++;
               try
View Full Code Here

    *
    * @return new instance of Callable<?> whose call() method either throws an exception or returns null if the task was
    *         successfull.
    */
   protected Callable<?> createPushStateTask() {
      return new Callable() {
         public Object call() throws Exception {
            final boolean debugEnabled = log.isDebugEnabled();

            if (debugEnabled) log.debug("start pushing in-memory state to cache cacheLoader");
            pushState(cache);
View Full Code Here

    *
    * @return new instance of Callable<?> whose call() method either throws an exception or returns null if the task was
    *         successfull.
    */
   protected Callable<?> createPushStateTask() {
      return new Callable() {
         public Object call() throws Exception {
            final boolean debugEnabled = log.isDebugEnabled();

            if (debugEnabled) log.debug("start pushing in-memory state to cache cacheLoader");
            pushState(cache);
View Full Code Here

    *
    * @return new instance of Callable<?> whose call() method either throws an exception or returns null if the task was
    *         successfull.
    */
   protected Callable<?> createPushStateTask() {
      return new Callable() {
         public Object call() throws Exception {
            final boolean debugEnabled = log.isDebugEnabled();

            if (debugEnabled) log.debug("start pushing in-memory state to cache cacheLoader");
            pushState(cache);
View Full Code Here

   
    // helper method to apply migration on the migration stage. typical migration failures will throw an
    // InvalidRequestException. atypical failures will throw a RuntimeException.
    private static void applyMigrationOnStage(final Migration m) throws InvalidRequestException
    {
        Future f = StageManager.getStage(Stage.MIGRATION).submit(new Callable()
        {
            public Object call() throws Exception
            {
                m.apply();
                m.announce();
View Full Code Here

  {
    Collection<Class<?>> classes = new ArrayList<Class<?>>(Arrays.asList(Callable.class));
    TestListener tl = new TestListener();
    TestCallable tc = new TestCallable();
   
    Callable o = (Callable) InterfaceProxyGenerator.getProxyInstance(testBundle,
        null, classes, tc, tl);
   
    assertCalled(tl, false, false, false);
   
    assertNull(null, o.call());
   
    assertCalled(tl, true, true, false);
   
    assertEquals(Callable.class.getMethod("call"),
        tl.getLastMethod());

    tl.clear();
    assertCalled(tl, false, false, false);
   
    tc.setReturn(new Callable<Object>() {

      public Object call() throws Exception {
        throw new RuntimeException();
      }
    });
    try {
      o.call();
      fail("Should throw an exception");
    } catch (RuntimeException re) {
      assertCalled(tl, true, false, true);
      assertSame(re, tl.getLastThrowable());
    }
   
    tl.clear();
    assertCalled(tl, false, false, false);
   
    tc.setReturn(new Callable<Object>() {

    
      public Object call() throws Exception {
        try {
          throw new RuntimeException();
        } catch (RuntimeException re) {
          return new Object();
        }
      }
    });
   
   
    try {
      assertNotNull(o.call());
    } finally {
      assertCalled(tl, true, true, false);
    }
  }
View Full Code Here

  protected Object getProxyInstance(Class<?> proxyClass) {
    try {
      if(proxyClass.getName().equals(ProxyTestClassAbstract.class.getName())) {
        Collection<Class<?>> coll = new ArrayList<Class<?>>();
        coll.add(proxyClass);
        return new AsmProxyManager().createNewProxy(null, coll, new Callable() {
          public Object call() throws Exception {
            return null;
          }}, null);
      }
      return proxyClass.newInstance();
View Full Code Here

   
    Skeleton.getSkeleton(b).setReturnValue(new MethodCall(
        ClassLoaderProxy.class, "getClassLoader"), weavingLoader);
   
    Object toCall = new AsmProxyManager().createDelegatingProxy(b, Arrays.asList(
        getProxyClass(ProxyTestClassAbstract.class), Callable.class), new Callable() {

          public Object call() throws Exception {
            return weavingLoader.loadClass(ProxyTestClassChildOfAbstract.class.getName()).newInstance();
          }
     
View Full Code Here

  @Test
  public void testFinalClass() throws Exception
  {
    try {
      InterfaceProxyGenerator.getProxyInstance(null, FINAL_CLASS, Collections.EMPTY_SET,
          new Callable() {
        public Object call() throws Exception {
          return null;
        }} , null).getClass();
    } catch (FinalModifierException e) {
      assertTrue("Should have found final class", e.isFinalClass());
View Full Code Here

TOP

Related Classes of java.util.concurrent.Callable

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.