Package javax.ejb

Examples of javax.ejb.AccessTimeout


    * @return Returns the access timeout value for the <code>invocation</code>.
    *       Returns null if no access timeout is specified
    */
   private AccessTimeout getAccessTimeout(Invocation invocation)
   {
      AccessTimeout timeout = (AccessTimeout) invocation.resolveAnnotation(AccessTimeout.class);
      if(timeout == null)
         timeout = (AccessTimeout) invocation.resolveClassAnnotation(AccessTimeout.class);
      return timeout;
   }
View Full Code Here


   public Object invoke(Invocation invocation) throws Throwable
   {
      Lock lock = getLock(invocation);
      long time = DEFAULT_MAX_TIMEOUT_VALUE;
      TimeUnit unit = DEFAULT_MAX_TIMEOUT_UNIT;
      AccessTimeout timeout = getAccessTimeout(invocation);
      if(timeout != null)
      {
         if (timeout.value() < 0)
         {
            // for any negative value of timeout, we just default to max timeout val and max timeout unit.
            // violation of spec! But we don't want to wait indefinitely.
            logger.info("Ignoring a negative @AccessTimeout value: " + timeout.value() + " and timeout unit: "
                  + timeout.unit().name() + ". Will default to timeout value: " + DEFAULT_MAX_TIMEOUT_VALUE
                  + " and timeout unit: " + DEFAULT_MAX_TIMEOUT_UNIT.name());
         }
         else
         {
            time = timeout.value();
            unit = timeout.unit();
         }
      }
      boolean success = lock.tryLock(time, unit);
      if(!success)
      {
View Full Code Here

         throw new IllegalArgumentException("Invocation context: " + invocationContext + " cannot be processed because it's not applicable for a method invocation");
      }
      // get the Lock applicable for this method
      Lock lock = getLock(lockableComponent, invokedMethod);
      // the default access timeout (will be used in the absence of any explicit access timeout value for the invoked method)
      AccessTimeout defaultAccessTimeout = lockableComponent.getDefaultAccessTimeout();
      // set to the default values
      long time = defaultAccessTimeout.value();
      TimeUnit unit = defaultAccessTimeout.unit();

      AccessTimeout accessTimeoutOnMethod = lockableComponent.getAccessTimeout(invokedMethod);
      if (accessTimeoutOnMethod != null)
      {
         if (accessTimeoutOnMethod.value() < 0)
         {
            // for any negative value of timeout, we just default to max timeout val and max timeout unit.
            // violation of spec! But we don't want to wait indefinitely.
            logger.debug("Ignoring a negative @AccessTimeout value: " + accessTimeoutOnMethod.value() + " and timeout unit: "
                    + accessTimeoutOnMethod.unit().name() + ". Will default to timeout value: " + defaultAccessTimeout.value()
                    + " and timeout unit: " + defaultAccessTimeout.unit().name());
         }
         else
         {
            // use the explicit access timeout values specified on the method
            time = accessTimeoutOnMethod.value();
            unit = accessTimeoutOnMethod.unit();
         }
      }
      // try getting the lock
      boolean success = lock.tryLock(time, unit);
      if (!success)
View Full Code Here

    if (lockAttribute != null) {
      _lockType = lockAttribute.value();
    }

    AccessTimeout accessTimeoutAttribute
      = getAnnotation(AccessTimeout.class,
                      apiMethod, apiClass,
                      implementationMethod, implementationClass);

    if (accessTimeoutAttribute != null) {
      _lockTimeout = accessTimeoutAttribute.timeout();
      _lockTimeoutUnit = accessTimeoutAttribute.unit();
    }
  }
View Full Code Here

    // Finally, the top level class annotation takes effect.
    else {
      lockType = _classLockType;
    }

    AccessTimeout accessTimeout = null;

    AccessTimeout methodLevelAccessTimeout = method
        .getAnnotation(AccessTimeout.class);

    AccessTimeout declaringClassAccessTimeout = (declaringType != null) ? declaringType
        .getAnnotation(AccessTimeout.class)
        : null;

    // The method-level annotation takes precedence.
    if (methodLevelAccessTimeout != null) {
View Full Code Here

TOP

Related Classes of javax.ejb.AccessTimeout

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.