/** * Prepares the application with the specific data found in the * passed context node. * * @param \AppserverIo\Appserver\Core\Interfaces\ContainerInterface $container The container instance bind the application to * @param \AppserverIo\Appserver\Core\Api\Node\ContextNode $context The application configuration * * @return void */ public function prepare(ContainerInterface $container, ContextNode $context) { // load the unique application name + the naming directory $uniqueName = $this->getUniqueName(); $namingDirectory = $this->getNamingDirectory(); // create subdirectories for the application and the logger $namingDirectory->createSubdirectory(sprintf('php:global/%s', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/log/%s', $uniqueName)); // create the applications 'env' + 'env/persistence' directory the beans + persistence units will be bound to $namingDirectory->createSubdirectory(sprintf('php:env/%s', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/%s/env', $uniqueName)); $namingDirectory->createSubdirectory(sprintf('php:global/%s/env/persistence', $uniqueName)); // bind the directory containing the applications $namingDirectory->bind(sprintf('php:env/%s/appBase', $uniqueName), $container->getAppBase()); // prepare the application specific directories $webappPath = sprintf('%s/%s', $this->getAppBase(), $this->getName()); $tmpDirectory = sprintf('%s/%s', $container->getTmpDir(), $this->getName()); $cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($context->getParam(DirectoryKeys::CACHE), '/')); $sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($context->getParam(DirectoryKeys::SESSION), '/')); // prepare the application specific environment variables $namingDirectory->bind(sprintf('php:env/%s/webappPath', $uniqueName), $webappPath); $namingDirectory->bind(sprintf('php:env/%s/tmpDirectory', $uniqueName), $tmpDirectory); $namingDirectory->bind(sprintf('php:env/%s/cacheDirectory', $uniqueName), $cacheDirectory); $namingDirectory->bind(sprintf('php:env/%s/sessionDirectory', $uniqueName), $sessionDirectory); // bind the interface as reference to the application $namingDirectory->bind(sprintf('php:global/%s/env/ApplicationInterface', $uniqueName), $this); }
/** * Prepares the application with the specific data found in the * passed context node. * * @param \AppserverIo\Appserver\Core\Api\Node\ContextNode $context The application configuration * * @return void */ public function prepare(ContextNode $context) { // load application name + naming directory $applicationName = $context->getName(); $namingDirectory = $this->getNamingDirectory(); // bind the application (which is also a naming directory) $namingDirectory->createSubdirectory(sprintf('php:global/%s', $applicationName)); // create the applications 'env' + 'env/persistence' directory the beans + persistence units will be bound to $namingDirectory->createSubdirectory(sprintf('php:global/%s/env', $this->getName())); $namingDirectory->createSubdirectory(sprintf('php:global/%s/env/persistence', $this->getName())); // prepare the application specific directories $webappPath = sprintf('%s/%s', $namingDirectory->search('php:env/appBase'), $applicationName); $tmpDirectory = sprintf('%s/%s', $namingDirectory->search('php:env/tmpDirectory'), $applicationName); $cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($context->getParam(DirectoryKeys::CACHE), '/')); $sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($context->getParam(DirectoryKeys::SESSION), '/')); // prepare the application specific environment variables $namingDirectory->createSubdirectory(sprintf('php:env/%s', $applicationName)); $namingDirectory->bind(sprintf('php:env/%s/webappPath', $applicationName), $webappPath); $namingDirectory->bind(sprintf('php:env/%s/tmpDirectory', $applicationName), $tmpDirectory); $namingDirectory->bind(sprintf('php:env/%s/cacheDirectory', $applicationName), $cacheDirectory); $namingDirectory->bind(sprintf('php:env/%s/sessionDirectory', $applicationName), $sessionDirectory); // bind the interface as reference to the application $namingDirectory->bind(sprintf('php:global/%s/env/ApplicationInterface', $this->getName()), $this); }