예제 #1
0
 /**
  * We process the timer here.
  *
  * @return void
  */
 public function run()
 {
     try {
         // register the default autoloader
         require SERVER_AUTOLOADER;
         // register shutdown handler
         register_shutdown_function(array(&$this, "shutdown"));
         // we need to register the class loaders again
         $application = $this->application;
         $application->registerClassLoaders();
         // load application and message instance
         $message = $this->message;
         // load class name and session ID from remote method
         $queueProxy = $message->getDestination();
         $sessionId = $message->getSessionId();
         // lookup the queue and process the message
         if ($queue = $application->search('QueueContextInterface')->locate($queueProxy)) {
             // the queues receiver type
             $queueType = $queue->getType();
             // create an intial context instance
             $initialContext = new InitialContext();
             $initialContext->injectApplication($application);
             // lookup the bean instance
             $instance = $initialContext->lookup($queueType);
             // inject the application to the receiver and process the message
             $instance->onMessage($message, $sessionId);
         }
         // mark the job finished
         $this->finished = true;
     } catch (\Exception $e) {
         $application->getInitialContext()->getSystemLogger()->error($e->__toString());
     }
 }
예제 #2
0
 /**
  * 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;
     }
 }