コード例 #1
0
 public function runImpl()
 {
     Log::writeInfo("Called invocation task task: " . $this->rai, $target = 'file');
     if ($this->rai == null) {
         Log::writeInfo("Something is null in InvocationActionTask...");
         return;
     }
     try {
         $path_to_hosted = PathBuilder::getHostedService($this->rai->getAppVersionId(), $this->rai->getRelativePath());
         $parser = HostedServiceParser::getInstance()->parseModelRAI($path_to_hosted, $this->rai->getId());
         if ($parser->isError()) {
             Log::writeError($parser->getError()['msg']);
             return ResponderProcessor::sendResult($this->rai->getId(), $parser->getError());
         }
         $runtime = ['path' => $path_to_hosted, 'endpointURL' => Config::$CORE['hosted_service']['endpoint_url'], 'serverRootURL' => Config::$CORE['hosted_service']['server_root_url'], 'serverPort' => Config::$CORE['hosted_service']['server_port'], 'serverName' => Config::$CORE['hosted_service']['server_name'], 'codeFormatType' => Config::$CORE['hosted_service']['code_format_type'], "generationMode" => Config::$CORE['hosted_service']['generation_mode'], 'randomUUID' => mt_rand(100000000, PHP_INT_MAX)];
         $xml_manager = new XmlManager();
         $invocation_result = new InvocationResult();
         $invocation_result->setArguments(["xml" => $xml_manager->buildXml($parser->getParsedData(), $runtime), "config" => $parser->getConfigListAsArray()]);
         //            $xml = $xml_manager->buildXml( $hosted_parser->getParsedData(), $runtime );
         //            file_put_contents("../repo/e3bd3a54-9a07-6160-ff70-a824a9610800/servercode/services/E3BD3A54-9A07-6160-FF70-A824A9610800.xml", $xml);
         //            echo $xml; return;
         ResponderProcessor::sendResult($this->rai->getId(), $invocation_result);
     } catch (Exception $e) {
         Log::writeError($e->getMessage());
     }
 }
コード例 #2
0
 public function runImpl()
 {
     Log::writeInfo("Called invocation task: " . $this->rsi, $target = 'file');
     if ($this->rsi == null) {
         Log::writeInfo("Something is null in InvocationActionTask...");
         return;
     }
     try {
         if (GlobalState::$TYPE == 'CLOUD') {
             $xml_path = realpath(PathBuilder::getHostedService($this->rsi->getAppVersionId(), $this->rsi->getRelativePath()) . DS . "..") . DS . $this->rsi->getAppVersionId() . ".xml";
             HostedModelHolder::setXMLModel(file_get_contents($xml_path));
             // load xml from file to holder
         }
         $this->initSdk();
         $instance_class_name = $this->rsi->getClassName();
         $arguments = $this->rsi->getArguments();
         $hosted_mapper = new HostedMapper();
         $hosted_mapper->prepareArguments($arguments, $this->rsi->getMethod());
         if ($hosted_mapper->isError()) {
             Log::writeError($hosted_mapper->getError()['msg']);
             return ResponderProcessor::sendResult($this->rsi->getId(), $hosted_mapper->getError());
         }
         $reflection_method = new ReflectionMethod($this->rsi->getClassName(), $this->rsi->getMethod());
         $hosted_instance = new $instance_class_name();
         $this->setConfiguration($hosted_instance, $this->rsi->getConfiguration());
         $result = $reflection_method->invokeArgs($hosted_instance, $arguments);
         $invocation_result = new InvocationResult();
         $hosted_mapper->prepareResult($result);
         $invocation_result->setArguments($result);
         ResponderProcessor::sendResult($this->rsi->getId(), $invocation_result);
     } catch (Exception $e) {
         Log::writeError($e->getMessage());
     }
 }
コード例 #3
0
 protected function RequestServiceInvocation($msg)
 {
     /// invoke hosted servise action
     $rsi = new RequestServiceInvocation($msg);
     Log::writeInfo("Received RSI:" . $rsi, $target = 'file');
     if (GlobalState::$TYPE == 'CLOUD' && time() * 1000 - $rsi->getTimestamp() > $this->timeout) {
         Log::writeError("RSI ignored by timeout" . $rsi, $target = 'file');
         return;
     }
     if (GlobalState::$TYPE === 'CLOUD') {
         Config::$RELATIVE_PATH = $msg['relativePath'];
         Config::$TASK_APPLICATION_ID = $msg['applicationId'];
         //ClassManager::analyze( PathBuilder::getClasses() );
         ClassManager::analyze(PathBuilder::getHostedService($rsi->getAppVersionId(), $rsi->getRelativePath()));
     }
     $executor = $this->executor_holder->getCodeExecutor($rsi->getApplicationId(), $rsi->getAppVersionId());
     $executor->invokeService($rsi);
 }