/** * 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); }