/** * Convert's the passed container node into a DTO. * * @param \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $containerNode The container node to convert * * @return \AppserverIo\Apps\Api\TransferObject\ContainerOverviewData The DTO */ public function toContainerOverviewData(ContainerNodeInterface $containerNode) { $overviewData = new ContainerOverviewData(); $overviewData->setId($containerNode->getPrimaryKey()); $overviewData->setName($containerNode->getName()); return $overviewData; }
/** * Factory method to create a new container instance. * * @param \AppserverIo\Appserver\Core\Interfaces\ApplicationServerInterface $applicationServer The application instance to register the class loader with * @param \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $configuration The class loader configuration * * @return void */ public static function factory(ApplicationServerInterface $applicationServer, ContainerNodeInterface $configuration) { // create a new reflection class instance $reflectionClass = new \ReflectionClass($configuration->getType()); // initialize the container configuration with the base directory and pass it to the thread $params = array($applicationServer->getInitialContext(), $applicationServer->getNamingDirectory(), $configuration); // create and append the thread instance to the internal array return $reflectionClass->newInstanceArgs($params); }
/** * Factory method to create a new container instance. * * @param \AppserverIo\Appserver\Core\Interfaces\ApplicationServerInterface $applicationServer The application instance to register the class loader with * @param \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $configuration The class loader configuration * @param integer $runlevel The runlevel the container has been started in * * @return void */ public static function factory(ApplicationServerInterface $applicationServer, ContainerNodeInterface $configuration, $runlevel = ApplicationServerInterface::NETWORK) { // create a new reflection class instance $reflectionClass = new \ReflectionClass($configuration->getType()); // initialize the container configuration with the base directory and pass it to the thread $params = array($applicationServer->getInitialContext(), $applicationServer->getNamingDirectory(), $configuration, $applicationServer->runlevelToString($runlevel)); // create, initialize and return the container instance return $reflectionClass->newInstanceArgs($params); }
/** *This method merges the passed container node into this one. * * @param \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $containerNode The container node to merge * * @return void */ public function merge(ContainerNodeInterface $containerNode) { // iterate over this container server nodes /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNode */ foreach ($this->getServers() as $serverNode) { // try to match with the server names of the passed container /** @var \AppserverIo\Appserver\Core\Api\Node\ServerNodeInterface $serverNodeToMerge */ foreach ($containerNode->getServers() as $serverNodeToMerge) { if (fnmatch($serverNodeToMerge->getName(), $serverNode->getName())) { $serverNode->merge($serverNodeToMerge); } else { $this->attachServer($serverNode); } } } }
/** * Returns the container's webapps directory. * * @param \AppserverIo\Appserver\Core\Api\Node\ContainerInterface $containerNode The container to return the temporary directory for * @param string $relativePathToAppend A relative path to append * * @return string The web application directory */ public function getWebappsDir(ContainerNodeInterface $containerNode, $relativePathToAppend = '') { return $this->getService()->realpath($this->getService()->makePathAbsolute($containerNode->getHost()->getAppBase() . $this->getService()->makePathAbsolute($relativePathToAppend))); }
/** * Attaches the passed container node. * * @param \AppserverIo\Appserver\Core\Api\Node\ContainerNodeInterface $container The container node to attach * * @return void */ public function attachContainer(ContainerNodeInterface $container) { $this->containers[$container->getPrimaryKey()] = $container; }