/** * Register the bean described by the passed descriptor. * * @param \AppserverIo\Psr\EnterpriseBeans\Description\BeanDescriptorInterface $descriptor The bean descriptor * * @return void */ protected function registerBean(BeanDescriptorInterface $descriptor) { try { // load the application instance $application = $this->getApplication(); // register the bean with the default name/short class name $application->getNamingDirectory()->bind(sprintf('php:global/%s/%s', $application->getName(), $descriptor->getName()), array(&$this, 'lookup'), array($descriptor->getClassName())); // register the EPB references foreach ($descriptor->getEpbReferences() as $epbReference) { $this->registerEpbReference($epbReference); } // register the resource references foreach ($descriptor->getResReferences() as $resReference) { $this->registerResReference($resReference); } // register the persistence unit references foreach ($descriptor->getPersistenceUnitReferences() as $persistenceUnitReference) { $this->registerPersistenceUnitReference($persistenceUnitReference); } } catch (\Exception $e) { // log the exception $this->getApplication()->getInitialContext()->getSystemLogger()->critical($e->__toString()); } }
/** * Merges the passed configuration into this one. Configuration values * of the passed configuration will overwrite the this one. * * @param \AppserverIo\Psr\EnterpriseBeans\Description\BeanDescriptorInterface $beanDescriptor The configuration to merge * * @return void */ public function merge(BeanDescriptorInterface $beanDescriptor) { // check if the classes are equal if ($this->getClassName() !== $beanDescriptor->getClassName()) { throw new EnterpriseBeansException(sprintf('You try to merge a bean configuration for % with %s', $beanDescriptor->getClassName(), $this->getClassName())); } // merge the name if ($name = $beanDescriptor->getName()) { $this->setName($name); } // merge the EPB references foreach ($beanDescriptor->getEpbReferences() as $epbReference) { $this->addEpbReference($epbReference); } // merge the resource references foreach ($beanDescriptor->getResReferences() as $resReference) { $this->addResReference($resReference); } // merge the persistence unit references foreach ($beanDescriptor->getPersistenceUnitReferences() as $persistenceUnitReference) { $this->addPersistenceUnitReference($persistenceUnitReference); } }