/** * Creates and initializes a beans reference configuration instance from the passed * configuration node. * * @param \AppserverIo\Configuration\Interfaces\NodeInterface $configuration The configuration node with the beans reference configuration * * @return \AppserverIo\Psr\EnterpriseBeans\Description\EpbReferenceDescriptorInterface|null The initialized descriptor instance */ public function fromConfiguration(EpbRefConfigurationInterface $configuration) { // query for the reference name if ($name = (string) $configuration->getEpbRefName()) { $this->setName(sprintf('%s/%s', EpbReferenceDescriptor::REF_DIRECTORY, $name)); } // query for the bean name and set it if ($beanName = (string) $configuration->getEpbLink()) { $this->setBeanName($beanName); } // query for the lookup name and set it if ($lookup = (string) $configuration->getLookupName()) { $this->setLookup($lookup); } // query for the bean interface and set it if ($beanInterface = (string) $configuration->getLocal()) { $this->setBeanInterface($beanInterface); } elseif ($beanInterface = (string) $configuration->getRemote()) { $this->setBeanInterface($beanInterface); } else { // use the bean name as local interface $this->setBeanInterface(sprintf('%sLocal', str_replace('Bean', '', $this->getBeanName()))); } // query for the description and set it if ($description = (string) $configuration->getDescription()) { $this->setDescription($description); } // query for the injection target if ($injectionTarget = $configuration->getInjectionTarget()) { $this->setInjectionTarget(InjectionTargetDescriptor::newDescriptorInstance()->fromConfiguration($injectionTarget)); } // return the instance return $this; }
/** * Creates and initializes a beans reference configuration instance from the passed * configuration node. * * @param \AppserverIo\Description\Configuration\ResRefConfigurationInterface $configuration The configuration node with the beans reference configuration * * @return \AppserverIo\Psr\EnterpriseBeans\Description\EpbReferenceDescriptorInterface|null The initialized descriptor instance */ public function fromConfiguration(ResRefConfigurationInterface $configuration) { // query for the reference name if ($name = (string) $configuration->getResRefName()) { $this->setName(sprintf('%s/%s', ResReferenceDescriptor::REF_DIRECTORY, $name)); } // query for the reference type if ($type = (string) $configuration->getResRefType()) { $this->setType($type); } // query for the description and set it if ($description = (string) $configuration->getDescription()) { $this->setDescription($description); } // query for the lookup name and set it if ($lookup = (string) $configuration->getLookupName()) { $this->setLookup($lookup); } // query for the injection target if ($injectionTarget = $configuration->getInjectionTarget()) { $this->setInjectionTarget(InjectionTargetDescriptor::newDescriptorInstance()->fromConfiguration($injectionTarget)); } // return the instance return $this; }
/** * Creates and initializes a beans reference configuration instance from the passed * configuration node. * * @param \AppserverIo\Description\Configuration\PersistenceUnitRefConfigurationInterface $configuration The configuration node with the beans reference configuration * * @return \AppserverIo\Psr\EnterpriseBeans\Description\EpbReferenceDescriptorInterface|null The initialized descriptor instance */ public function fromConfiguration(PersistenceUnitRefConfigurationInterface $configuration) { // query for the reference name if ($name = (string) $configuration->getPersistenceUnitRefName()) { $this->setName(sprintf('%s/%s', PersistenceUnitReferenceDescriptor::REF_DIRECTORY, $name)); } // query for the reference type if ($unitName = (string) $configuration->getPersistenceUnitName()) { $this->setUnitName($unitName); } // query for the injection target if ($injectionTarget = $configuration->getInjectionTarget()) { $this->setInjectionTarget(InjectionTargetDescriptor::newDescriptorInstance()->fromConfiguration($injectionTarget)); } // return the instance return $this; }
/** * Tests if the merge method, based on a TargetInjectionDescriptor initialized from * a method works successfully. * * @return void */ public function testMergeSuccessfulWithMethod() { // initialize a new descriptor from one of our properties $descriptor = InjectionTargetDescriptor::newDescriptorInstance(); $descriptor->fromReflectionMethod(new ReflectionMethod(__CLASS__, 'injectDummyResource')); // initialize a descriptor from another method $this->descriptor->fromReflectionMethod(new ReflectionMethod(__CLASS__, 'injectDummyEnterpriseBean')); $this->descriptor->merge($descriptor); // check the descriptor values $this->assertSame(__CLASS__, $this->descriptor->getTargetClass()); $this->assertSame('injectDummyResource', $this->descriptor->getTargetMethod()); $this->assertNull($this->descriptor->getTargetProperty()); }