Package org.jboss.aspects.asynchronous.aspects

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


    BusinessModelWithCleanup bm1 = new BusinessModelWithCleanup();

    BusinessModelWithCleanup bm2 = new BusinessModelWithCleanup();

    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)bm1;

    AsynchronousFacade asynchronousFacade2 = (AsynchronousFacade)bm2;

    asynchronousFacade1.setTimeout(100);

    bm1.processBusinessModel2(200);

    bm2.processBusinessModel2(200);

    assertEquals(

      "Method did not timeout !",

      TIMEOUT,

      asynchronousFacade1.getResponseCode());

    assertEquals(

      "Method is not successfull !",

      OK,

      asynchronousFacade2.getResponseCode());

    assertEquals("Cleanup method not called", true, bm1.bCleanupCalled);

    assertEquals("Cleanup method called", false, bm2.bCleanupCalled);
View Full Code Here


    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

    BusinessModel bm1 = new BusinessModel();

    bm1.processBusinessModel2(-1);

    AsynchronousFacade asynchronousFacade = (AsynchronousFacade)bm1;

    assertEquals(

      "EXCEPTIONCAUGHT error not returned !",

      EXCEPTIONCAUGHT,

      asynchronousFacade.getResponseCode());

  }
View Full Code Here

    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

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

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

      "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

      "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

      "bm2 is not an instance of AsynchronousFacade",

      bm2 instanceof AsynchronousFacade);

    AsynchronousFacade asynchronousFacade1 = (AsynchronousFacade)bm1;

    AsynchronousFacade asynchronousFacade2 = (AsynchronousFacade)bm2;

    asynchronousFacade1.setId("OK");

    asynchronousFacade2.setId("KO");

    assertNotSame(

      "same instances(ID) of AsynchronousFacade",

      asynchronousFacade1.getId(),

      asynchronousFacade2.getId());

  }
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.