/**
  * Responsible for invoking the timeout method on the target object.
  *
  * The timerservice implementation invokes this method as a callback when a timeout occurs for the
  * passed timer. The timerservice implementation will be responsible for passing the correct
  * timeout method corresponding to the <code>timer</code> on which the timeout has occurred.
  *
  * @param \AppserverIo\Psr\EnterpriseBeans\TimerInterface $timer         The timer that is passed to timeout
  * @param \AppserverIo\Lang\Reflection\MethodInterface    $timeoutMethod The timeout method
  *
  * @return void
  */
 public function callTimeout(TimerInterface $timer, MethodInterface $timeoutMethod = null)
 {
     // synchronize the application instance and register the class loaders
     $application = $this->getApplication();
     $application->registerClassLoaders();
     // initialize the initial context instance
     $initialContext = new InitialContext();
     $initialContext->injectApplication($application);
     // lookup the enterprise bean using the initial context
     $instance = $initialContext->lookup($this->getTimedObjectId());
     // check if the timeout method has been passed
     if ($timeoutMethod != null) {
         // if yes, invoke it on the proxy
         $callback = array($instance, $timeoutMethod->getMethodName());
         call_user_func_array($callback, array($timer));
         return;
     }
     // check if we've a default timeout method
     if ($this->defaultTimeoutMethod != null) {
         // if yes, invoke it on the proxy
         $callback = array($instance, $this->defaultTimeoutMethod->getMethodName());
         call_user_func_array($callback, array($timer));
         return;
     }
 }
 /**
  * Creates and initializes a beans injection target configuration instance from the passed
  * reflection method instance.
  *
  * @param \AppserverIo\Lang\Reflection\MethodInterface $reflectionMethod The reflection method with the beans injection target configuration
  *
  * @return \AppserverIo\Psr\EnterpriseBeans\Description\InjectionTargetDescriptorInterface|null The initialized descriptor instance
  */
 public function fromReflectionMethod(MethodInterface $reflectionMethod)
 {
     // initialize the injection target from the passed method
     $this->setTargetClass($reflectionMethod->getClassName());
     $this->setTargetMethod($reflectionMethod->getMethodName());
     // return the instance
     return $this;
 }
 /**
  * Initializes the action configuration instance from the passed reflection method instance.
  *
  * @param \AppserverIo\Lang\Reflection\MethodInterface $reflectionMethod The reflection method with the action configuration
  *
  * @return \AppserverIo\Routlt\Description\ActionDescriptorInterface The initialized descriptor
  */
 public function fromReflectionMethod(MethodInterface $reflectionMethod)
 {
     // add the annotation alias to the reflection method
     $reflectionMethod->addAnnotationAlias(Action::ANNOTATION, Action::__getClass());
     // query if we've a method with a @Action annotation
     if ($reflectionMethod->hasAnnotation(Action::ANNOTATION) === false && $reflectionMethod->getMethodName() !== 'perform') {
         // if not, do nothing
         return;
         // query whether we've the default perform() method WITHOUT an @Action annotation
     } elseif ($reflectionMethod->hasAnnotation(Action::ANNOTATION) === false && $reflectionMethod->getMethodName() === 'perform') {
         // create an annotation instance manually
         $reflectionAnnotation = new ReflectionAnnotation(Action::__getClass());
     } else {
         // create a new annotation instance by default
         $reflectionAnnotation = $this->newAnnotationInstance($reflectionMethod);
     }
     // load method name
     $this->setMethodName($reflectionMethod->getMethodName());
     // initialize the annotation instance
     $annotationInstance = $reflectionAnnotation->newInstance($reflectionAnnotation->getAnnotationName(), $reflectionAnnotation->getValues());
     // load the default name to register in naming directory
     if (($nameAttribute = $annotationInstance->getName()) || $nameAttribute === '') {
         $this->setName($nameAttribute);
     } else {
         // if @Annotation(name=****) is NOT SET, we use the method name by default
         $this->setName('/' . lcfirst(str_replace('Action', '', $reflectionMethod->getMethodName())));
     }
     // initialize the array for the annotated request methods
     $annotatedRequestMethods = array();
     // parse the method for annotated request methods
     foreach ($this->getRequestMethods() as $requestMethod) {
         // prepare the annotation name, e. g. POST -> Post
         $annotationName = ucfirst(strtolower($requestMethod));
         // query whether the reflection method has been annotated
         if ($reflectionMethod->hasAnnotation($annotationName)) {
             array_push($annotatedRequestMethods, $requestMethod);
         }
     }
     // query whether at least one annotated request method has been found
     if (sizeof($annotatedRequestMethods) > 0) {
         // if yes, override the default request methods
         $this->setRequestMethods($annotatedRequestMethods);
     }
     // initialize the restrictions for the route placeholders
     if (is_array($restrictions = $annotationInstance->getRestrictions())) {
         foreach ($restrictions as $restriction) {
             list($name, $value) = $restriction;
             $this->restrictions[$name] = $value;
         }
     }
     // initialize the defaults for the route placeholders
     if (is_array($defaults = $annotationInstance->getDefaults())) {
         foreach ($defaults as $default) {
             list($name, $value) = $default;
             $this->defaults[$name] = $value;
         }
     }
     // return the instance
     return $this;
 }