/** * @return ServerModule */ public function handleRequest() { $useZend = false; // zend is slow! $result = $this; // zend is slow! if ($useZend) { $this->_handleZend(); return $result; } $rpc = $this->getRpc(); $rpcRequest = $rpc->getRequest(); $rpcResponse = $rpc->getResponse(); try { $class = $rpc->getRouterServiceQualifiedName(); $method = $rpc->getRouterServiceMethodName(); $params = $rpc->getRouterServiceMethodParams(); if (!is_array($params)) { $params = array(); } $classExists = RpcUtil::classExists($class, true, false); if (!$classExists) { $e = $this->newModuleException(); $e->setMessage($e::ERROR_SERVERMODULE_SERVICECLASS_NOT_EXIST); $e->setMethodInfo($this, __METHOD__, __LINE__); $e->setDebugData(array('className' => $class, 'methodName' => $method)); throw $e; } $reflectionClass = new \ReflectionClass($class); if (!$reflectionClass->isInstantiable() || $reflectionClass->isAbstract()) { $e = $this->newModuleException(); $e->setMessage($e::ERROR_SERVERMODULE_SERVICECLASS_NOT_INVOCABLE); $e->setMethodInfo($this, __METHOD__, __LINE__); $e->setDebugData(array('className' => $class, 'methodName' => $method)); throw $e; } if (!$reflectionClass->hasMethod((string) $method)) { $e = $this->newModuleException(); $e->setMessage($e::ERROR_SERVERMODULE_SERVICEMETHOD_NOT_EXISTS); $e->setMethodInfo($this, __METHOD__, __LINE__); $e->setDebugData(array('className' => $class, 'methodName' => $method)); throw $e; } $reflectionMethod = $reflectionClass->getMethod($method); if (!$reflectionMethod->isPublic() || $reflectionMethod->isAbstract() || $reflectionMethod->isStatic()) { $e = $this->newModuleException(); $e->setMessage($e::ERROR_SERVERMODULE_SERVICEMETHOD_NOT_INVOCABLE); $e->setMethodInfo($this, __METHOD__, __LINE__); $e->setDebugData(array('className' => $class, 'methodName' => $method)); throw $e; } $className = $reflectionClass->getName(); $serviceInstance = $this->_newServiceInstance($className); $this->_invokeServiceMethod($reflectionMethod, $serviceInstance, $params); } catch (\Exception $e) { $rpcResponse->setException($e); } return $result; }
/** * @return DispatcherZmq * @throws DispatcherZmqException */ protected function _requireZmq() { $result = $this; if (!RpcUtil::classExists('\\ZMQSocket', true, false)) { $e = $this->newException(); $e->setMessage($e::ERROR_ZMQ_EXTENSION_NOT_FOUND); $e->setMethodInfo($this, __METHOD__, __LINE__); throw $e; } return $result; }