/** * Tests if the merge method fails with an exception if the class * name doesn't match when try to merge to descriptor instances. * * @return void * @expectedException AppserverIo\Psr\EnterpriseBeans\EnterpriseBeansException */ public function testMergeWithException() { // initialize the configuration $node = new SessionNode(); $node->initFromFile(__DIR__ . '/_files/dd-sessionbean.xml'); // initialize the descriptor from the nodes data $this->descriptor->fromConfiguration($node); // initialize the descriptor to merge $descriptorToMerge = $this->getMockForAbstractClass('AppserverIo\\Description\\BeanDescriptor'); // initialize the configuration of the descriptor to be merged $nodeToMerge = new SessionNode(); $nodeToMerge->initFromFile(__DIR__ . '/_files/dd-sessionbean-to-merge-with-exception.xml'); $descriptorToMerge->fromConfiguration($nodeToMerge); // merge the descriptors $this->descriptor->merge($descriptorToMerge); }
/** * Initializes a bean descriptor instance from the passed configuration node. * * @param \AppserverIo\Description\Configuration\ConfigurationInterface $configuration The configuration node with the bean configuration * * @return \AppserverIo\Psr\EnterpriseBeans\Description\MessageDrivenBeanDescriptorInterface|null The initialized descriptor instance */ public function fromConfiguration(ConfigurationInterface $configuration) { // query whether or not we've a message driven bean configuration if (!$configuration instanceof MessageDrivenConfigurationInterface) { return; } // initialize the descriptor instance parent::fromConfiguration($configuration); // return the instance return $this; }
/** * Initializes a bean descriptor instance from the passed configuration node. * * @param \AppserverIo\Description\Configuration\ConfigurationInterface $configuration The configuration node with the bean description * * @return void */ public function fromConfiguration(ConfigurationInterface $configuration) { // query whether or not we've a session bean configuration if (!$configuration instanceof SessionConfigurationInterface) { return; } // initialize the bean descriptor parent::fromConfiguration($configuration); // query for the session type and set it if ($sessionType = (string) $configuration->getSessionType()) { $this->setSessionType($sessionType); } // query for the name of the local business interface and set it if ($local = (string) $configuration->getLocal()) { $this->setLocal($local); } else { $this->setLocal(sprintf('%sLocal', rtrim($this->getName(), 'Bean'))); } // query for the name of the remote business interface and set it if ($remote = (string) $configuration->getRemote()) { $this->setRemote($remote); } else { $this->setRemote(sprintf('%sRemote', rtrim($this->getName(), 'Bean'))); } // initialize the post construct callback methods if ($postConstructNode = $configuration->getPostConstruct()) { foreach ($postConstructNode->getLifecycleCallbackMethods() as $postConstructCallback) { $this->addPostConstructCallback(DescriptorUtil::trim((string) $postConstructCallback)); } } // initialize the pre destroy callback methods if ($preDestroyNode = $configuration->getPreDestroy()) { foreach ($preDestroyNode->getLifecycleCallbackMethods() as $preDestroyCallback) { $this->addPreDestroyCallback(DescriptorUtil::trim((string) $preDestroyCallback)); } } }