public function loadContainerInstance(ContainerNodeInterface $containerNode, SystemConfigurationInterface $systemConfiguration, $webappPath)
{
// load the service to validate the files
/** @var \AppserverIo\Appserver\Core\Api\ConfigurationService $configurationService */
$configurationService = $this->newService('AppserverIo\\Appserver\\Core\\Api\\ConfigurationService');
// iterate through all server configurations (servers.xml), validate and merge them
foreach ($this->globDir(AppEnvironmentHelper::getEnvironmentAwareGlobPattern($webappPath, 'META-INF/containers')) as $containersConfigurationFile) {
try {
// validate the application specific container configurations
$configurationService->validateFile($containersConfigurationFile, null);
// create a new containers node instance
$containersNodeInstance = new ContainersNode();
$containersNodeInstance->initFromFile($containersConfigurationFile);
// load the system properties
$properties = $this->getSystemProperties($containerNode);
// prepare the sytsem properties
$this->prepareSystemProperties($properties, $webappPath);
/** @var \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $containerNodeInstance */
foreach ($containersNodeInstance->getContainers() as $containerNodeInstance) {
// replace the properties for the found container node instance
$containerNodeInstance->replaceProperties($properties);
// query whether we've to merge or append the server node instance
if ($container = $systemConfiguration->getContainer($containerNodeInstance->getName())) {
$container->merge($containerNodeInstance);
} else {
$systemConfiguration->attachContainer($containerNodeInstance);
}
}
} 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 server configuration will be missing
$systemLogger->critical(sprintf('Will skip app specific server configuration because of invalid file %s', $containersConfigurationFile));
}
}
}