Package org.jboss.aspects.asynchronous.aspects

Examples of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade


    assertEquals("Cleanup method called", false, bm2.bCleanupCalled);
  }
  public static void testIsDone() {
    BusinessModel bm1 = new BusinessModel(200);
    bm1.processBusinessModel();
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    long t0 = System.currentTimeMillis();
    assertFalse("isDone returns TRUE  !", asynchronousFacade.isDone());
    long t1 = System.currentTimeMillis();
    assertTrue(
      "isDone is a blocking call " + (t1 - t0) + " ms.",
      (t1 - t0) < 20);
    assertEquals(
      "Method is not succesfull !",
      OK,
      asynchronousFacade.getResponseCode());
    assertTrue("isDone returns FALSE  !", asynchronousFacade.isDone());
  }
View Full Code Here


    assertTrue("isDone returns FALSE  !", asynchronousFacade.isDone());
  }
  public static void testExceptionRaisedInMethodCall() {
    BusinessModel bm1 = new BusinessModel();
    long value = bm1.processBusinessModel2(-1);
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    assertEquals(
      "EXCEPTIONCAUGHT error not returned !",
      EXCEPTIONCAUGHT,
      asynchronousFacade.getResponseCode());
  }
View Full Code Here

      bm1.processBusinessModel();

    }
    BusinessModel bm1 = new BusinessModel(200);
    bm1.processBusinessModel();
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;
    assertEquals(
      "Pool size not full !",
      CAN_NOT_PROCESS,
      asynchronousFacade.getResponseCode());
  }
View Full Code Here

        + (tt1 - tt0)
        + " (ms).Average time "
        + time
        + " (ms).");
    BusinessModel bm = new BusinessModel(10);
    AsynchronousFacade Fbm = (AsynchronousFacade)bm;
    long total = 0;
    int iOk = 0;
    int nb1 = 200;
    int nb2 = 5;
    AsynchronousTask[] Tbm = new AsynchronousTask[nb2];
    for (int j = 0; j < nb1; j++) {
      long t0 = System.currentTimeMillis();
      for (int i = 0; i < nb2; i++) {
        bm.processBusinessModel();
        Tbm[i] = Fbm.getAsynchronousTask();
      }
      long t1 = System.currentTimeMillis();
      total += (t1 - t0);
      for (int i = 0; i < nb2; i++) {
        int ok = Fbm.getResponseCode(Tbm[i]);
        if (ok == OK)
          iOk++;
      }
    }
    System.out.println(
View Full Code Here

  public static void testResponseTimeReturned() {
    BusinessModel bm1 = new BusinessModel(200);
    int ERROR = 20;
    long t0 = System.currentTimeMillis();
    bm1.processBusinessModel();
    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)bm1;
    assertEquals(
      "Method is not succesfull !",
      OK,
      asynchronousFacade1.getResponseCode());
    long t1 = System.currentTimeMillis();
    long startingTime =
      asynchronousFacade1.getThreadManagerResponse().getStartingTime();
    long endingTime =
      asynchronousFacade1.getThreadManagerResponse().getEndingTime();
    assertTrue(
      "starting time issue ? " + (startingTime - t0),
      (startingTime - t0) < ERROR);
    assertTrue(
      "ending time issue ? " + (t1 - endingTime),
View Full Code Here

      "not an instance of AsynchronousFacade",
      object instanceof AsynchronousFacade);
    assertTrue(
      "static method not an asynchronous call:" + (t1 - t0) + " ms.",
      (t1 - t0) < 100);
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)object;
    AsynchronousTask asynchronousTask1 =
      asynchronousFacade.getAsynchronousTask();
    assertEquals(
      "Method does not return the right value !",
      200,
      ((Long)asynchronousFacade.getReturnValue(asynchronousTask1))
        .longValue());
  }
View Full Code Here

    System.out.println(System.currentTimeMillis()-t0);
    long t1 = System.currentTimeMillis();
    assertTrue(
      "static method not an asynchronous call:" + (t1 - t0) + " ms.",
      (t1 - t0) < 160);
    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)object1;
    assertEquals(
      "Method did not timeout !",
      TIMEOUT,
      asynchronousFacade1.getResponseCode());
    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)object2;
    AsynchronousTask asynchronousTask2 =
      asynchronousFacade.getAsynchronousTask();
    assertEquals(
      "Method does not return the right value !",
      150,
      ((Long)asynchronousFacade.getReturnValue(asynchronousTask2))
        .longValue());
  }
View Full Code Here

   public AsynchronousAspect() {}

   public Object execute(MethodInvocation invocation) throws Throwable
   {
      AsynchronousFacade asynchronousResult = null;
      if (invocation.getTargetObject() != null)
         asynchronousResult = (AsynchronousFacade) invocation.getTargetObject();
      else
      {
         Object[] tObject = invocation.getArguments();
         for (int i = 0; i < tObject.length; i++)
         {
            Object object = tObject[i];
            if (object instanceof AsynchronousFacade)
            {
               asynchronousResult = (AsynchronousFacade) object;
               break;
            }
         }
         if (asynchronousResult == null)
            asynchronousResult = new AsynchronousFacadeImpl();
      }
      Asynchronous asynchronous = (Asynchronous) AnnotationElement.getAnyAnnotation(invocation.getMethod(), Asynchronous.class);
      if (asynchronous!=null)
      {
        if (asynchronousResult.getTimeout() == 0)
         asynchronousResult.setTimeout(asynchronous.timeout());

        if ((asynchronousResult.getId()!=null) && (asynchronousResult.getId().equals("None"))
                                                &&
                       (asynchronous.id()!=null)&&(asynchronous.id().length()!=0) )
         asynchronousResult.setId(asynchronous.id());
    }
     
      asynchronousResult.setAsynchronousTask(ThreadManagerFactory.getThreadManager().process(ThreadManagerFactory.createNewThreadManagerRequest(asynchronousResult.getId(),
      new InvokeTaskInputParameters((MethodInvocation) invocation.copy()),
      asynchronousInvokeTask,
      asynchronousResult.getTimeout())));
      Class<?> returnType = invocation.getActualMethod().getReturnType();
      return Utils.returnInitObject(returnType);
   }
View Full Code Here

TOP

Related Classes of org.jboss.aspects.asynchronous.aspects.AsynchronousFacade

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.