/** * Executes the passed applications provisioning workflow. * * * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance * @param \AppserverIo\Appserver\Core\Api\Node\ProvisionNode $provisionNode The file with the provisioning information * @param \SplFileInfo $webappPath The path to the webapp folder * * @return void */ protected function executeProvision(ApplicationInterface $application, ProvisionNode $provisionNode, \SplFileInfo $webappPath) { // load the steps from the configuration $stepNodes = $provisionNode->getInstallation()->getSteps(); if (!is_array($stepNodes)) { return; } // execute all steps found in the configuration foreach ($stepNodes as $stepNode) { try { // create a new reflection class of the step $reflectionClass = new \ReflectionClass($stepNode->getType()); $step = $reflectionClass->newInstance(); // try to inject the datasource node if available if ($datasourceNode = $provisionNode->getDatasource()) { $step->injectDataSourceNode($datasourceNode); } // inject all other information $step->injectStepNode($stepNode); $step->injectApplication($application); $step->injectService($this->getService()); $step->injectWebappPath($webappPath->getPathname()); $step->injectInitialContext($this->getInitialContext()); $step->injectPhpExecutable($this->getAbsolutPathToPhpExecutable()); // execute the step finally $step->start(PTHREADS_INHERIT_NONE | PTHREADS_INHERIT_CONSTANTS); $step->join(); } catch (\Exception $e) { $this->getInitialContext()->getSystemLogger()->error($e->__toString()); } } }
/** * 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\ProvisionNode $provisionNode The node with the installation steps we want to merge * * @return void */ public function merge(ProvisionNode $provisionNode) { // inject the datasource node if available if ($datasource = $provisionNode->getDatasource()) { $this->injectDatasource($datasource); } // load the steps of this instance $localSteps = $this->getInstallation()->getSteps(); // merge it with the ones found in the passed provisioning node foreach ($provisionNode->getInstallation()->getSteps() as $stepToMerge) { foreach ($localSteps as $key => $step) { if ($step->getType() === $stepToMerge->getType()) { $localSteps[$key] = $stepToMerge; } else { $localSteps[$stepToMerge->getUuid()] = $stepToMerge; } } } // set the installation steps $this->getInstallation()->setSteps($localSteps); }