/**
  * Creates and initializes a beans reference configuration instance from the passed
  * reflection property instance.
  *
  * @param \AppserverIo\Lang\Reflection\PropertyInterface $reflectionProperty The reflection property with the beans reference configuration
  *
  * @return \AppserverIo\Psr\EnterpriseBeans\Description\EpbReferenceDescriptorInterface|null The initialized descriptor instance
  */
 public function fromReflectionProperty(PropertyInterface $reflectionProperty)
 {
     // if we found a @EnterpriseBean annotation, load the annotation instance
     if ($reflectionProperty->hasAnnotation(EnterpriseBean::ANNOTATION) === false) {
         // if not, do nothing
         return;
     }
     // initialize the annotation instance
     $annotation = $reflectionProperty->getAnnotation(EnterpriseBean::ANNOTATION);
     // load the annotation instance
     $annotationInstance = $annotation->newInstance($annotation->getAnnotationName(), $annotation->getValues());
     // load the reference name defined as @EnterpriseBean(name=****)
     if ($name = $annotationInstance->getName()) {
         $this->setName(sprintf('%s/%s', EpbReferenceDescriptor::REF_DIRECTORY, $name));
     } else {
         // use the property name
         $this->setName(sprintf('%s/%s', EpbReferenceDescriptor::REF_DIRECTORY, ucfirst($reflectionProperty->getPropertyName())));
     }
     // register the bean with the name defined as @EnterpriseBean(beanName=****)
     if ($beanNameAttribute = $annotationInstance->getBeanName()) {
         $this->setBeanName($beanNameAttribute);
     } else {
         $this->setBeanName(ucfirst(str_replace(EpbReferenceDescriptor::REF_DIRECTORY . '/', '', $this->getName())));
     }
     // register the bean with the interface defined as @EnterpriseBean(beanInterface=****)
     if ($beanInterfaceAttribute = $annotationInstance->getBeanInterface()) {
         $this->setBeanInterface($beanInterfaceAttribute);
     } else {
         // use the property name as local business interface
         $this->setBeanInterface(sprintf('%sLocal', ucfirst($this->getBeanName())));
     }
     // register the bean with the lookup name defined as @EnterpriseBean(lookup=****)
     if ($lookupAttribute = $annotationInstance->getLookup()) {
         $this->setLookup($lookupAttribute);
     }
     // register the bean with the interface defined as @EnterpriseBean(description=****)
     if ($descriptionAttribute = $annotationInstance->getDescription()) {
         $this->setDescription($descriptionAttribute);
     }
     // load the injection target data
     $this->setInjectionTarget(InjectionTargetDescriptor::newDescriptorInstance()->fromReflectionProperty($reflectionProperty));
     // return the instance
     return $this;
 }
 /**
  * Creates and initializes a beans reference configuration instance from the passed
  * reflection property instance.
  *
  * @param \AppserverIo\Lang\Reflection\PropertyInterface $reflectionProperty The reflection property with the beans reference configuration
  *
  * @return \AppserverIo\Psr\EnterpriseBeans\Description\PersistenceUnitReferenceDescriptorInterface|null The initialized descriptor instance
  */
 public function fromReflectionProperty(PropertyInterface $reflectionProperty)
 {
     // if we found a @PersistenceUnit annotation, load the annotation instance
     if ($reflectionProperty->hasAnnotation(PersistenceUnit::ANNOTATION) === false) {
         // if not, do nothing
         return;
     }
     // initialize the annotation instance
     $annotation = $reflectionProperty->getAnnotation(PersistenceUnit::ANNOTATION);
     // load the annotation instance
     $annotationInstance = $annotation->newInstance($annotation->getAnnotationName(), $annotation->getValues());
     // load the reference name defined as @PersistenceUnit(name=****)
     if ($name = $annotationInstance->getName()) {
         $this->setName(sprintf('%s/%s', PersistenceUnitReferenceDescriptor::REF_DIRECTORY, $name));
     } else {
         $this->setName(sprintf('%s/%s', PersistenceUnitReferenceDescriptor::REF_DIRECTORY, ucfirst($reflectionProperty->getPropertyName())));
     }
     // load the resource type defined as @PersistenceUnit(unitName=****)
     if ($unitName = $annotationInstance->getUnitName()) {
         $this->setUnitName($unitName);
     } else {
         $this->setUnitName(ucfirst($reflectionProperty->getPropertyName()));
     }
     // load the injection target data
     $this->setInjectionTarget(InjectionTargetDescriptor::newDescriptorInstance()->fromReflectionProperty($reflectionProperty));
     // return the instance
     return $this;
 }
 /**
  * Creates and initializes a beans injection target configuration instance from the passed
  * reflection property instance.
  *
  * @param \AppserverIo\Lang\Reflection\PropertyInterface $reflectionProperty The reflection property with the beans injection target configuration
  *
  * @return \AppserverIo\Psr\EnterpriseBeans\Description\InjectionTargetDescriptorInterface|null The initialized descriptor instance
  */
 public function fromReflectionProperty(PropertyInterface $reflectionProperty)
 {
     // initialize the injection target from the passed property
     $this->setTargetClass($reflectionProperty->getClassName());
     $this->setTargetProperty($reflectionProperty->getPropertyName());
     // return the instance
     return $this;
 }
Esempio n. 4
0
 /**
  * Initializes and returns an array with annotation instances from the doc comment
  * found in the passed reflection property instance.
  *
  * @param \AppserverIo\Lang\Reflection\PropertyInterface $reflectionProperty The reflection property to load the doc comment from
  *
  * @return array The array with the ReflectionAnnotation instances loaded from the passed reflection property
  * @see \AppserverIo\Lang\Reflection\ReflectionAnnotation::fromDocComment()
  */
 public static function fromReflectionProperty(PropertyInterface $reflectionProperty)
 {
     // load the reflection method data we need to initialize the annotations
     $aliases = $reflectionProperty->getAnnotationAliases();
     $ignore = $reflectionProperty->getAnnotationsToIgnore();
     $docComment = $reflectionProperty->toPhpReflectionProperty()->getDocComment();
     // load and return the annotations found in the doc comment
     return ReflectionAnnotation::fromDocComment($docComment, $ignore, $aliases);
 }