/**
  * Tries to get class uri via reflection
  *
  * @param lang.XPClass class The class to return the URI for
  * @return string
  */
 private function uriFor(XPClass $class)
 {
     try {
         $Urimethod = $class->getClassLoader()->getClass()->getMethod('classURI');
         $Urimethod->setAccessible(TRUE);
         return $Urimethod->invoke($class->getClassLoader(), $class->getName());
     } catch (Exception $ignored) {
         return $class->getClassName();
     }
 }
예제 #2
0
 /**
  * Main
  *
  * @param  string[] $args
  * @return int
  */
 public static function main(array $args)
 {
     $command = null;
     if (empty($args)) {
         $class = new XPClass(self::class);
         $source = $class->getClassLoader();
         $markdown = $class->getComment();
     } else {
         if ('@' === $args[0][0]) {
             $resource = substr($args[0], 1);
             if (null === ($source = ClassLoader::getDefault()->findResource($resource))) {
                 Console::$err->writeLine('No help topic named ', $resource);
                 return 2;
             }
             $markdown = $source->getResource($resource);
         } else {
             $class = $args[0];
             if (null === ($source = ClassLoader::getDefault()->findClass($class))) {
                 Console::$err->writeLine('No class named ', $class);
                 return 2;
             }
             $markdown = $source->loadClass($class)->getComment();
         }
     }
     self::render(Console::$out, $markdown, $source);
     return 1;
 }
 /**
  * Get instance for class
  *
  * @param   lang.XPClass class
  * @return  remote.server.BeanContainer
  */
 public static function forClass(XPClass $class)
 {
     $bc = new self();
     $bc->instancePool = new Vector();
     $bc->poolClass = $class;
     // Fetch class' classloader to check for resources configured
     // for the bean.
     $cl = $class->getClassLoader();
     // Try loading the well known resources, and remember if it exists
     $bc->configuration['log.ini'] = $cl->providesResource('etc/log.ini');
     $bc->configuration['database.ini'] = $cl->providesResource('etc/log.ini');
     $bc->configuration['cl'] = $cl;
     return $bc;
 }