Пример #1
0
 /**
  * Creates a new reflection class instance from the passed PHP reflection class.
  *
  * @param \ReflectionClass $reflectionClass     The PHP reflection class to load the data from
  * @param array            $annotationsToIgnore An array with annotations names we want to ignore when loaded
  * @param array            $annotationAliases   An array with annotation aliases used when create annotation instances
  *
  * @return \AppserverIo\Lang\Reflection\ReflectionClass The instance
  */
 public static function fromPhpReflectionClass(\ReflectionClass $reflectionClass, array $annotationsToIgnore = array(), array $annotationAliases = array())
 {
     // initialize the array with the annotations we want to ignore
     $annotationsToIgnore = array_merge($annotationsToIgnore, array('author', 'package', 'license', 'copyright', 'param', 'return', 'throws', 'see', 'link'));
     // initialize the array with the aliases for the enterprise bean annotations
     $annotationAliases = array_merge(array(PersistenceUnit::ANNOTATION => PersistenceUnit::__getClass(), MessageDriven::ANNOTATION => MessageDriven::__getClass(), PostConstruct::ANNOTATION => PostConstruct::__getClass(), PreDestroy::ANNOTATION => PreDestroy::__getClass(), PostDetach::ANNOTATION => PostDetach::__getClass(), PreAttach::ANNOTATION => PreAttach::__getClass(), Schedule::ANNOTATION => Schedule::__getClass(), Singleton::ANNOTATION => Singleton::__getClass(), Startup::ANNOTATION => Startup::__getClass(), Stateful::ANNOTATION => Stateful::__getClass(), Stateless::ANNOTATION => Stateless::__getClass(), Timeout::ANNOTATION => Timeout::__getClass(), EnterpriseBean::ANNOTATION => EnterpriseBean::__getClass(), Resource::ANNOTATION => Resource::__getClass()));
     // create a new timed object instance
     return new TimedObject($reflectionClass->getName(), $annotationsToIgnore, $annotationAliases);
 }
 /**
  * Tests that initialization from a reflection class without @Stateful
  * annotation won't work.
  *
  * @return void
  */
 public function testFromInvalidReflectionClass()
 {
     // initialize the annotation aliases
     $aliases = array(Stateful::ANNOTATION => Stateful::__getClass());
     // create the reflection class
     $reflectionClass = new ReflectionClass('\\stdClass', array(), $aliases);
     // check that the descriptor has not been initialized
     $this->assertNull($this->descriptor->fromReflectionClass($reflectionClass));
 }
Пример #3
0
 /**
  * Returns a reflection class instance for the passed class name.
  *
  * @param string $className The class name to return the reflection instance for
  *
  * @return \AppserverIo\Lang\Reflection\ReflectionClass The reflection instance
  */
 public function newReflectionClass($className)
 {
     // initialize the array with the annotations we want to ignore
     $annotationsToIgnore = array('author', 'package', 'license', 'copyright', 'param', 'return', 'throws', 'see', 'link');
     // initialize the array with the aliases for the enterprise bean annotations
     $annotationAliases = array(Route::ANNOTATION => Route::__getClass(), Resource::ANNOTATION => Resource::__getClass(), Timeout::ANNOTATION => Timeout::__getClass(), Stateless::ANNOTATION => Stateless::__getClass(), Stateful::ANNOTATION => Stateful::__getClass(), Startup::ANNOTATION => Startup::__getClass(), Singleton::ANNOTATION => Singleton::__getClass(), Schedule::ANNOTATION => Schedule::__getClass(), PreAttach::ANNOTATION => PreAttach::__getClass(), PostDetach::ANNOTATION => PostDetach::__getClass(), PreDestroy::ANNOTATION => PreDestroy::__getClass(), PostConstruct::ANNOTATION => PostConstruct::__getClass(), MessageDriven::ANNOTATION => MessageDriven::__getClass(), EnterpriseBean::ANNOTATION => EnterpriseBean::__getClass(), PersistenceUnit::ANNOTATION => PersistenceUnit::__getClass());
     // return the reflection class instance
     return new ReflectionClass($className, $annotationsToIgnore, $annotationAliases);
 }