Returns the containers configuration node.
public getContainerNode ( ) : |
||
리턴 | The configuration node |
/** * Initializes the available application contexts and returns them. * * @param \AppserverIo\Appserver\Core\Interfaces\ContainerInterface $container The container we want to add the applications to * * @return ContextNode[] The array with the application contexts */ public function loadContextInstancesByContainer(ContainerInterface $container) { // initialize the array for the context instances $contextInstances = array(); // iterate over all applications and create the context configuration foreach (glob($container->getAppBase() . '/*', GLOB_ONLYDIR) as $webappPath) { $context = $this->loadContextInstance($container->getContainerNode(), $webappPath); $contextInstances[$context->getName()] = $context; } // return the array with the context instances return $contextInstances; }
/** * Initializes the available application contexts and returns them. * * @param \AppserverIo\Appserver\Core\Interfaces\ContainerInterface $container The container we want to add the applications to * * @return array The array with the application contexts */ public function loadContextInstancesByWorkingDir(ContainerInterface $container) { // initialize the array for the context instances $contextInstances = array(); // attach the context to the context instances $context = $this->loadContextInstance($container->getContainerNode(), getcwd()); $contextInstances[$context->getName()] = $context; // return the array with the context instances return $contextInstances; }
/** * Initializes the available application contexts and returns them. * * @param \AppserverIo\Appserver\Core\Interfaces\ContainerInterface $container The container we want to add the applications to * * @return array The array with the application contexts */ public function loadContextInstancesByContainer(ContainerInterface $container) { try { // initialize the array for the context instances $contextInstances = array(); // validate the base context file /** @var AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */ $configurationService = $this->newService('AppserverIo\\Appserver\\Core\\Api\\ConfigurationService'); $configurationService->validateFile($baseContextPath = $this->getConfdDir('context.xml'), null); //load it as default if validation succeeds $baseContext = new ContextNode(); $baseContext->initFromFile($baseContextPath); } catch (ConfigurationException $ce) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($ce->__toString()); // additionally log a message that DS will be missing $systemLogger->critical(sprintf('Problems validating base context file %s, this might affect app configurations badly.', $baseContextPath)); } // iterate over all applications and create the context configuration foreach (glob($container->getAppBase() . '/*', GLOB_ONLYDIR) as $webappPath) { // prepare the context path $contextPath = basename($webappPath); // start with a fresh clone of the base context configuration $context = clone $baseContext; // try to load a context configuration (from appserver.xml) for the context path if ($contextToMerge = $container->getContainerNode()->getHost()->getContext($contextPath)) { $context->merge($contextToMerge); } // iterate through all context configurations (context.xml), validate and merge them foreach ($this->globDir($webappPath . '/META-INF/context.xml') as $contextFile) { try { // validate the application specific context $configurationService->validateFile($contextFile, null); // create a new context node instance $contextInstance = new ContextNode(); $contextInstance->initFromFile($contextFile); // merge it into the default configuration $context->merge($contextInstance); } catch (ConfigurationException $ce) { // load the logger and log the XML validation errors $systemLogger = $this->getInitialContext()->getSystemLogger(); $systemLogger->error($ce->__toString()); // additionally log a message that DS will be missing $systemLogger->critical(sprintf('Will skip app specific context file %s, configuration might be faulty.', $contextFile)); } } // set the real context name $context->setName($contextPath); // attach the context to the context instance $contextInstances[$contextPath] = $context; } // return the array with the context instances return $contextInstances; }