コード例 #1
0
ファイル: FtpThread.class.php プロジェクト: xp-framework/ftp
 /**
  * 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 = \lang\XPClass::forName('peer.ftp.server.FtpProtocol'), $cl = \lang\ClassLoader::getDefault());
         // Add listener
         $this->server->setProtocol($proto = $class->newInstance($storage = Proxy::newProxyInstance($cl, [\lang\XPClass::forName('peer.ftp.server.storage.Storage')], $this->storageHandler), Proxy::newProxyInstance($cl, [\lang\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 (\lang\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 \lang\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 \lang\SystemException('Could not set UID');
         }
     }
     $this->server->service();
 }
コード例 #2
0
ファイル: ProxyTest.class.php プロジェクト: johannes85/core
 public function nullInterfaces7()
 {
     Proxy::getProxyClass(ClassLoader::getDefault(), null);
 }
コード例 #3
0
 public function proxyInstance()
 {
     $c = Proxy::getProxyClass(\lang\ClassLoader::getDefault(), array(\lang\XPClass::forName('util.log.Traceable')));
     $this->assertClass($c->getClassLoader(), 'lang.DynamicClassLoader');
 }