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