예제 #1
0
 /**
  * Deploy
  *
  * @param   remote.server.deploy.Deployable deployment
  */
 public function deployBean($deployment)
 {
     if ($deployment instanceof IncompleteDeployment) {
         throw new DeployException('Incomplete deployment originating from ' . $deployment->origin, $deployment->cause);
     }
     $this->cat && $this->cat->info($this->getClassName(), 'Begin deployment of', $deployment);
     // Register beans classloader. This classloader must be put at the beginning
     // to prevent loading of the home interface not implmenenting BeanInterface
     $cl = $deployment->getClassLoader();
     ClassLoader::getDefault()->registerLoader($cl, TRUE);
     $impl = $cl->loadClass($deployment->getImplementation());
     $interface = $cl->loadClass($deployment->getInterface());
     $directoryName = $deployment->getDirectoryName();
     // Fetch naming directory
     $directory = NamingDirectory::getInstance();
     // Create beanContainer
     // TBI: Check which kind of bean container has to be created
     $beanContainer = StatelessSessionBeanContainer::forClass($impl);
     $this->cat && $beanContainer->setTrace($this->cat);
     // Create invocation handler
     $invocationHandler = new ContainerInvocationHandler();
     $invocationHandler->setContainer($beanContainer);
     // Now bind into directory
     $directory->bind($directoryName, Proxy::newProxyInstance($cl, array($interface), $invocationHandler));
     $this->cat && $this->cat->info($this->getClassName(), 'End deployment of', $impl->getName(), 'with ND entry', $directoryName);
     return $beanContainer;
 }
 /**
  * Returns a value for the given serialized string
  *
  * @param   server.protocol.Serializer serializer
  * @param   remote.protocol.SerializedData serialized
  * @param   [:var] context default array()
  * @return  var
  */
 public function valueOf($serializer, $serialized, $context = array())
 {
     $oid = $serialized->consumeSize();
     $serialized->consume('{');
     $interface = $serializer->valueOf($serialized, $context);
     $serialized->consume('}');
     return Proxy::newProxyInstance(ClassLoader::getDefault(), array(XPClass::forName($serializer->packageMapping($interface))), RemoteInvocationHandler::newInstance((int) $oid, $context['handler']));
 }
예제 #3
0
 /**
  * Runs the server. Loads the listener using XPClass::forName()
  * so that the class is loaded within the thread's process space
  * and will be recompiled whenever the thread is restarted.
  *
  * @throws  lang.XPException in case initializing the server fails
  * @throws  lang.SystemException in case setuid fails
  */
 public function run()
 {
     try {
         with($class = XPClass::forName('peer.ftp.server.FtpProtocol'), $cl = ClassLoader::getDefault());
         // Add listener
         $this->server->setProtocol($proto = $class->newInstance($storage = Proxy::newProxyInstance($cl, array(XPClass::forName('peer.ftp.server.storage.Storage')), $this->storageHandler), Proxy::newProxyInstance($cl, array(XPClass::forName('security.auth.Authenticator')), $this->authenticatorHandler)));
         // Copy interceptors to connection listener
         $proto->interceptors = $this->interceptors;
         // Enable debugging
         if ($this->cat) {
             $proto->setTrace($this->cat);
             $this->server instanceof Traceable && $this->server->setTrace($this->cat);
         }
         // Try to start the server
         $this->server->init();
     } catch (Throwable $e) {
         $this->server->shutdown();
         throw $e;
     }
     // Check if we should run child processes
     // with another uid/pid
     if (isset($this->processGroup)) {
         $group = posix_getgrnam($this->processGroup);
         $this->cat && $this->cat->debugf('Setting group to: %s (GID: %d)', $group['name'], $group['uid']);
         if (!posix_setgid($group['gid'])) {
             throw new SystemException('Could not set GID');
         }
     }
     if (isset($this->processOwner)) {
         $user = posix_getpwnam($this->processOwner);
         $this->cat && $this->cat->debugf('Setting user to: %s (UID: %d)', $user['name'], $user['uid']);
         if (!posix_setuid($user['uid'])) {
             throw new SystemException('Could not set UID');
         }
     }
     $this->server->service();
 }
예제 #4
0
 /**
  * Helper method which returns a proxy instance for a given list of
  * interfaces, using the default classloader and the handler defined
  * in setUp()
  *
  * @param   lang.XPClass[] interfaces
  * @return  lang.reflect.Proxy
  */
 protected function proxyInstanceFor($interfaces)
 {
     return Proxy::newProxyInstance(ClassLoader::getDefault(), $interfaces, $this->handler);
 }
 protected function getNonOwnerProxy(PersonBean $person)
 {
     return Proxy::newProxyInstance(new NonOwnerInvocationHandler($person));
 }