Examples of AsyncInvocationMap


Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

      {
         throw new IllegalArgumentException("ID must be specified");
      }

      // Put a flag in the cancel map, will be cleared when the invocation passes through
      final AsyncInvocationMap map = this.getCurrentAsyncInvocations();
      map.put(id, true);
   }
View Full Code Here

Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

      if (ejbContainer instanceof ServiceContainer || ejbContainer instanceof MessagingContainer)
      {
         return invocation.invokeNext();
      }
      final SessionSpecContainer sessionContainer = (SessionSpecContainer) EJBContainer.getEJBContainer(advisor);
      final AsyncInvocationMap currentInvocations = sessionContainer.getCurrentAsyncInvocations();

      // Put the current ID into the Map
      if (id != null)
      {
         currentInvocations.put(id, false);
      }

      // Mark the Thread
      CurrentAsyncInvocation.markCurrentInvocationOnThread(id);

      // Now invoke
      Object returnValue;
      try
      {
         returnValue = invocation.invokeNext();

         // If this is a Future
         if (returnValue instanceof Future)
         {
            // Cast
            final Future<?> future = (Future<?>) returnValue;

            // If not Serializable
            if (!(returnValue instanceof Serializable))
            {
               // Make it so
               returnValue = new SerializableFuture<Object>(future.get());
            }
         }

         return returnValue;
      }
      finally
      {
         // Remove the invocation from the Map of those currently-executed
         if (id != null)
         {
            currentInvocations.remove(id);
         }

         // Unmark the Thread
         CurrentAsyncInvocation.unmarkCurrentInvocationFromThread();
      }
View Full Code Here

Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

    * @see org.jboss.ejb3.context.spi.SessionContext#wasCancelCalled()
    */
   public boolean wasCancelCalled()
   {
      // Obtain the Map of current invocations
      final AsyncInvocationMap map = this.getContainer().getCurrentAsyncInvocations();

      // Get the current invocation in play
      final AsyncInvocationId id = CurrentAsyncInvocation.getCurrentAsyncInvocationId();
     
      // No async invocation in play
      if (id == null)
      {
         return false;
      }

      // Obtain if the current invocation has been cancelled
      final Boolean wasCancelled = map.get(id);

      // Return
      return wasCancelled == null ? false : wasCancelled.booleanValue();
   }
View Full Code Here

Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

      if (ejbContainer instanceof ServiceContainer || ejbContainer instanceof MessagingContainer)
      {
         return invocation.invokeNext();
      }
      final SessionSpecContainer sessionContainer = (SessionSpecContainer) EJBContainer.getEJBContainer(advisor);
      final AsyncInvocationMap currentInvocations = sessionContainer.getCurrentAsyncInvocations();

      // Put the current ID into the Map
      if (id != null)
      {
         currentInvocations.put(id, false);
      }

      // Mark the Thread
      CurrentAsyncInvocation.markCurrentInvocationOnThread(id);

      // Now invoke
      Object returnValue;
      try
      {
         returnValue = invocation.invokeNext();

         // If this is a Future
         if (returnValue instanceof Future)
         {
            // Cast
            final Future<?> future = (Future<?>) returnValue;

            // If not Serializable
            if (!(returnValue instanceof Serializable))
            {
               // Make it so
               returnValue = new SerializableFuture<Object>(future.get());
            }
         }

         return returnValue;
      }
      catch(final Throwable t)
      {
         // Only propagate this back if the return type is not void, else swallow the exception
         final MethodInvocation mi = (MethodInvocation) invocation;
         final Method m = mi.getActualMethod();
         final Class<?> returnType = m.getReturnType();
         if (void.class.equals(returnType))
         {
            log.debug("Received Throwable on @Asynchronous invocation " + m + ", not returning to the client:", t);
            return null;
         }
         throw t;
      }
      finally
      {
         // Remove the invocation from the Map of those currently-executed
         if (id != null)
         {
            currentInvocations.remove(id);
         }

         // Unmark the Thread
         CurrentAsyncInvocation.unmarkCurrentInvocationFromThread();
      }
View Full Code Here

Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

      {
         throw new IllegalArgumentException("ID must be specified");
      }

      // Put a flag in the cancel map, will be cleared when the invocation passes through
      final AsyncInvocationMap map = this.getCurrentAsyncInvocations();
      return map.put(id, true) != null;
   }
View Full Code Here

Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

      if (ejbContainer instanceof ServiceContainer || ejbContainer instanceof MessagingContainer)
      {
         return invocation.invokeNext();
      }
      final SessionSpecContainer sessionContainer = (SessionSpecContainer) EJBContainer.getEJBContainer(advisor);
      final AsyncInvocationMap currentInvocations = sessionContainer.getCurrentAsyncInvocations();

      // Put the current ID into the Map
      if (id != null)
      {
         currentInvocations.put(id, false);
      }

      // Mark the Thread
      CurrentAsyncInvocation.markCurrentInvocationOnThread(id);

      // Now invoke
      Object returnValue;
      try
      {
         returnValue = invocation.invokeNext();

         // If this is a Future
         if (returnValue instanceof Future)
         {
            // Cast
            final Future<?> future = (Future<?>) returnValue;

            // If not Serializable
            if (!(returnValue instanceof Serializable))
            {
               // Make it so
               returnValue = new SerializableFuture<Object>(future.get());
            }
         }

         return returnValue;
      }
      finally
      {
         // Remove the invocation from the Map of those currently-executed
         if (id != null)
         {
            currentInvocations.remove(id);
         }

         // Unmark the Thread
         CurrentAsyncInvocation.unmarkCurrentInvocationFromThread();
      }
View Full Code Here

Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

      {
         throw new IllegalArgumentException("ID must be specified");
      }

      // Put a flag in the cancel map, will be cleared when the invocation passes through
      final AsyncInvocationMap map = this.getCurrentAsyncInvocations();
      return map.put(id, true) != null;
   }
View Full Code Here

Examples of org.jboss.ejb3.async.spi.AsyncInvocationMap

    * @see org.jboss.ejb3.context.spi.SessionContext#wasCancelCalled()
    */
   public boolean wasCancelCalled()
   {
      // Obtain the Map of current invocations
      final AsyncInvocationMap map = this.getContainer().getCurrentAsyncInvocations();

      // Get the current invocation in play
      final AsyncInvocationId id = CurrentAsyncInvocation.getCurrentAsyncInvocationId();
     
      // No async invocation in play
      if (id == null)
      {
         return false;
      }

      // Obtain if the current invocation has been cancelled
      final Boolean wasCancelled = map.get(id);

      // Return
      return wasCancelled == null ? false : wasCancelled.booleanValue();
   }
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.