/**
  * Loads the container instances from the META-INF/containers.xml configuration file of the
  * passed web application path and add/merge them to/with the system configuration.
  *
  * @param \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface         $containerNode       The container node used for property replacement
  * @param \AppserverIo\Appserver\Core\Interfaces\SystemConfigurationInterface $systemConfiguration The system configuration to add/merge the found containers to/with
  * @param string                                                              $webappPath          The path to the web application to search for a META-INF/containers.xml file
  *
  * @return void
  */
 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));
         }
     }
 }