getWebappPath() public method

Returns the path to the web application.
public getWebappPath ( ) : string
return string
Ejemplo n.º 1
0
 /**
  * This method merges the installation steps of the passed provisioning node into the steps of
  * this instance. If a installation node with the same type already exists, the one of this
  * instance will be overwritten.
  *
  * @param \AppserverIo\Appserver\Core\Api\Node\ContextNode $contextNode The node with the installation steps we want to merge
  *
  * @return void
  */
 public function merge(ContextNode $contextNode)
 {
     // merge the application type
     if ($type = $contextNode->getType()) {
         $this->setType($type);
     }
     // merge the application factory class name
     if ($factory = $contextNode->getFactory()) {
         $this->setFactory($factory);
     }
     // merge the application webapp path
     if ($webappPath = $contextNode->getWebappPath()) {
         $this->setWebappPath($webappPath);
     }
     // load the params defined in this context
     $localParams = $this->getParams();
     // merge them with the passed ones
     foreach ($contextNode->getParams() as $paramToMerge) {
         $isMerged = false;
         /** @var \AppserverIo\Appserver\Core\Api\Node\ParamNode $param */
         foreach ($localParams as $key => $param) {
             if ($param->getName() == $paramToMerge->getName()) {
                 $localParams[$key] = $paramToMerge;
                 $isMerged = true;
             }
         }
         if ($isMerged === false) {
             $localParams[$paramToMerge->getUuid()] = $paramToMerge;
         }
     }
     // set the params back to the context
     $this->setParams($localParams);
     // load the managers defined of this context
     $localManagers = $this->getManagers();
     // merge them with the passed ones
     /**  @var \AppserverIo\Appserver\Core\Api\Node\ManagerNode $managerToMerge */
     foreach ($contextNode->getManagers() as $managerToMerge) {
         $isMerged = false;
         /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNode $manager */
         foreach ($localManagers as $key => $manager) {
             if ($manager->getName() === $managerToMerge->getName()) {
                 $manager->merge($managerToMerge);
                 $localManagers[$key] = $manager;
                 $isMerged = true;
             }
         }
         if ($isMerged === false) {
             $localManagers[$managerToMerge->getUuid()] = $managerToMerge;
         }
     }
     // set the managers back to the context
     $this->setManagers($localManagers);
     // load the class loaders of this context
     $localClassLoaders = $this->getClassLoaders();
     // merge them with the passed ones
     /** @var \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNode $classLoaderToMerge */
     foreach ($contextNode->getClassLoaders() as $classLoaderToMerge) {
         $isMerged = false;
         /** @var \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNode $classLoader */
         foreach ($localClassLoaders as $key => $classLoader) {
             if ($classLoader->getName() === $classLoaderToMerge->getName()) {
                 $localClassLoaders[$key] = $classLoaderToMerge;
                 $isMerged = true;
             }
         }
         if ($isMerged === false) {
             $localClassLoaders[$classLoaderToMerge->getUuid()] = $classLoaderToMerge;
         }
     }
     // set the class loaders back to the context
     $this->setClassLoaders($localClassLoaders);
     // load the loggers of this context
     $localLoggers = $this->getLoggers();
     // merge them with the passed ones (DO override already registered loggers)
     /** @var \AppserverIo\Appserver\Core\Api\Node\LoggerNode $loggerToMerge */
     foreach ($contextNode->getLoggers() as $loggerToMerge) {
         $localLoggers[$loggerToMerge->getName()] = $loggerToMerge;
     }
     // set the loggers back to the context
     $this->setLoggers($localLoggers);
 }
Ejemplo n.º 2
0
 /**
  * Visitor method that registers the application in the container.
  *
  * @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 static function visit(ContainerInterface $container, ContextNode $context)
 {
     // load the applications base directory
     $webappPath = $context->getWebappPath();
     // declare META-INF and WEB-INF directory
     $webInfDir = $webappPath . DIRECTORY_SEPARATOR . 'WEB-INF';
     $metaInfDir = $webappPath . DIRECTORY_SEPARATOR . 'META-INF';
     // check if we've a directory containing a valid application,
     // at least a WEB-INF or META-INF folder has to be available
     if (!is_dir($webInfDir) && !is_dir($metaInfDir)) {
         return;
     }
     // load the naming directory + initial context
     $initialContext = $container->getInitialContext();
     $namingDirectory = $container->getNamingDirectory();
     // load the application service
     $appService = $container->newService('AppserverIo\\Appserver\\Core\\Api\\AppService');
     // load the application type
     $contextType = $context->getType();
     $containerName = $container->getName();
     $environmentName = $context->getEnvironmentName();
     $applicationName = $context->getName();
     $containerRunlevel = $container->getRunlevel();
     // create a new application instance
     /** @var \AppserverIo\Appserver\Application\Application $application */
     $application = new $contextType();
     // initialize the storage for managers, virtual hosts an class loaders
     $loggers = new GenericStackable();
     $managers = new GenericStackable();
     $provisioners = new GenericStackable();
     $classLoaders = new GenericStackable();
     // initialize the generic instances and information
     $application->injectLoggers($loggers);
     $application->injectManagers($managers);
     $application->injectName($applicationName);
     $application->injectEnvironmentName($environmentName);
     $application->injectProvisioners($provisioners);
     $application->injectClassLoaders($classLoaders);
     $application->injectContainerName($containerName);
     $application->injectInitialContext($initialContext);
     $application->injectNamingDirectory($namingDirectory);
     $application->injectContainerRunlevel($containerRunlevel);
     // prepare the application instance
     $application->prepare($container, $context);
     // create the applications temporary folders and cleans the folders up
     /** @var \AppserverIo\Appserver\Core\Api\AppService $appService */
     PermissionHelper::sudo(array($appService, 'createTmpFolders'), array($application));
     $appService->cleanUpFolders($application);
     // add the configured loggers
     /** @var \AppserverIo\Appserver\Core\Api\Node\LoggerNode $loggerNode */
     foreach ($context->getLoggers() as $loggerNode) {
         $application->addLogger(LoggerFactory::factory($loggerNode), $loggerNode);
     }
     // add the configured class loaders
     /** @var \AppserverIo\Appserver\Core\Api\Node\ClassLoaderNode $classLoader */
     foreach ($context->getClassLoaders() as $classLoader) {
         /** @var \AppserverIo\Appserver\Core\Interfaces\ClassLoaderFactoryInterface $classLoaderFactory */
         if ($classLoaderFactory = $classLoader->getFactory()) {
             // use the factory if available
             $classLoaderFactory::visit($application, $classLoader);
         } else {
             // if not, try to instanciate the class loader directly
             $classLoaderType = $classLoader->getType();
             $application->addClassLoader(new $classLoaderType($classLoader), $classLoader);
         }
     }
     // add the configured managers
     /** @var \AppserverIo\Appserver\Core\Api\Node\ManagerNode $manager */
     foreach ($context->getManagers() as $manager) {
         /** @var \AppserverIo\Appserver\Core\Interfaces\ManagerFactoryInterface $managerFactory */
         if ($managerFactory = $manager->getFactory()) {
             // use the factory if available
             $managerFactory::visit($application, $manager);
         } else {
             // if not, try to instanciate the manager directly
             $managerType = $manager->getType();
             $application->addManager(new $managerType($manager), $manager);
         }
     }
     // add the configured provisioners
     /** @var \AppserverIo\Appserver\Core\Api\Node\ProvisionerNode $provisioner */
     foreach ($context->getProvisioners() as $provisioner) {
         /** @var \AppserverIo\Appserver\Provisioning\StandardProvisionerFactory $provisionerFactory */
         if ($provisionerFactory = $provisioner->getFactory()) {
             // use the factory if available
             $provisionerFactory::visit($application, $provisioner);
         } else {
             // if not, try to instanciate the provisioner directly
             $provisionerType = $provisioner->getType();
             $application->addProvisioner(new $provisionerType($provisioner), $provisioner);
         }
     }
     // add the application to the container
     $container->addApplication($application);
 }