AppserverIo\Appserver\PersistenceContainer\BeanManager::registerBeans PHP Метод

registerBeans() публичный Метод

Registers the message beans at startup.
public registerBeans ( AppserverIo\Psr\Application\ApplicationInterface $application ) : void
$application AppserverIo\Psr\Application\ApplicationInterface The application instance
Результат void
    public function registerBeans(ApplicationInterface $application)
    {
        // query whether or not the web application folder exists
        if (is_dir($this->getWebappPath()) === false) {
            return;
        }
        // initialize the directory parser and parse the web application's base directory for annotated beans
        $directoryParser = new DirectoryParser();
        $directoryParser->injectBeanContext($this);
        $directoryParser->parse();
        // initialize the deployment descriptor parser and parse the web application's deployment descriptor for beans
        $deploymentDescriptorParser = new DeploymentDescriptorParser();
        $deploymentDescriptorParser->injectBeanContext($this);
        $deploymentDescriptorParser->parse();
        // load the object manager
        /** @var \AppserverIo\Appserver\DependencyInjectionContainer\Interfaces\ObjectManagerInterface $objectManager */
        $objectManager = $this->getApplication()->search('ObjectManagerInterface');
        // register the beans found by annotations and the XML configuration
        /** \AppserverIo\Psr\Deployment\DescriptorInterface $objectDescriptor */
        foreach ($objectManager->getObjectDescriptors() as $descriptor) {
            // check if we've found a bean descriptor and register the bean
            if ($descriptor instanceof BeanDescriptorInterface) {
                $this->registerBean($descriptor);
            }
            // if we found a singleton session bean with a startup callback
            if ($descriptor instanceof SingletonSessionBeanDescriptorInterface && $descriptor->isInitOnStartup()) {
                $this->getApplication()->search($descriptor->getName(), array(null, array($application)));
            }
        }
    }