Changeset 1647 for trunk/src/main/php/net/stubbles/service/jsonrpc
- Timestamp:
- 06/23/08 23:34:06 (5 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessor.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcAbstractGenerateSubProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcGenerateProxiesSubProcessor.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcGenerateSmdSubProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcGetSubProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcPostSubProcessor.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcSubProcessor.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessor.php
r1544 r1647 22 22 { 23 23 /** 24 * registry key for the service config file25 */26 const KEY_SERVICE_FILE = 'net.stubbles.service.jsonrpc.configfile';27 /**28 24 * configuration file with list of client classes 29 25 * … … 37 33 protected function doConstruct() 38 34 { 39 $this->configFile = stubConfig::getConfigPath() . DIRECTORY_SEPARATOR . stubRegistry::getConfig(self::KEY_SERVICE_FILE, 'json-rpc-service.ini');35 $this->configFile = stubConfig::getConfigPath() . DIRECTORY_SEPARATOR . 'json-rpc-service.ini'; 40 36 } 41 37 … … 54 50 55 51 $subProcessor = new $nqClassName(); 56 $subProcessor->process($this->request, $this->session, $this->response, $this->loadClassMap()); 52 $config = $this->loadConfig(); 53 $subProcessor->process($this->request, $this->session, $this->response, $config['classmap'], $config['config']); 57 54 } 58 55 … … 63 60 * @throws stubFileNotFoundException 64 61 */ 65 protected function loadC lassMap()62 protected function loadConfig() 66 63 { 67 64 if (file_exists($this->configFile) === false || is_readable($this->configFile) === false) { … … 70 67 } 71 68 72 return parse_ini_file($this->configFile );69 return parse_ini_file($this->configFile, true); 73 70 } 74 71 trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcAbstractGenerateSubProcessor.php
r1547 r1647 21 21 abstract class stubJsonRpcAbstractGenerateSubProcessor extends stubBaseObject implements stubJsonRpcSubProcessor 22 22 { 23 /** 24 * default javascript namespace 25 * 26 * @var string 27 */ 28 protected $jsNamespace = 'stubbles.json.proxy'; 29 23 30 /** 24 31 * helper method to detect the service url trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcGenerateProxiesSubProcessor.php
r1547 r1647 23 23 { 24 24 /** 25 * default javascript namespace26 *27 * @var string28 */29 protected $jsNamespace = 'stubbles.json.proxy';30 31 /**32 25 * does the processing of the subtask 33 26 * … … 36 29 * @param stubResponse $response the current response 37 30 * @param array<string,array<string,string>> $classMap list of available webservice classes 31 * @param array<string,string> $config json-rpc config 38 32 */ 39 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap )33 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap, array $config) 40 34 { 35 if (isset($config['namespace']) === false) { 36 $config['namespace'] = $this->jsNamespace; 37 } 38 41 39 $classes = $request->getValidatedValue(new stubRegexValidator('/^[A-Za-z,0-9_\.]+$/'), '__generateProxy'); 42 40 if ('__all' !== $classes) { … … 44 42 } 45 43 46 $response->write($ this->jsNamespace. " = {};\n\n");44 $response->write($config['namespace'] . " = {};\n\n"); 47 45 $generator = $this->getProxyGenerator(); 48 46 foreach ($classMap as $jsClass => $fqClassName) { 49 47 if (is_array($classes) === false || in_array($jsClass, $classes) === true) { 50 48 try { 51 $response->write($generator->generateJavascriptProxy($fqClassName, $jsClass ));49 $response->write($generator->generateJavascriptProxy($fqClassName, $jsClass, $config['namespace'])); 52 50 } catch (Exception $e) { 53 51 $this->handleException($e, $response, 'Generation of proxy for ' . $fqClassName . ' failed.'); trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcGenerateSmdSubProcessor.php
r1547 r1647 26 26 * @param stubResponse $response the current response 27 27 * @param array<string,array<string,string>> $classMap list of available webservice classes 28 * @param array<string,string> $config json-rpc config 28 29 */ 29 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap )30 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap, array $config) 30 31 { 32 if (isset($config['namespace']) === false) { 33 $config['namespace'] = $this->jsNamespace; 34 } 35 31 36 $class = $request->getValidatedValue(new stubRegexValidator('/^[A-Za-z0-9_\.]+$/'), '__smd'); 32 37 $generator = $this->getSmdGenerator($this->getServiceURL($request) . '&__class=' . $class); 33 38 // get rid of namespace for class matching 34 $class = preg_replace('/ stubbles\.json\.proxy\./', '', $class);39 $class = preg_replace('/' . preg_quote($config['namespace']) . '\./', '', $class); 35 40 try { 36 41 $response->write($generator->generateSmd($classMap[$class], $class)); trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcGetSubProcessor.php
r1547 r1647 47 47 * @param stubResponse $response the current response 48 48 * @param array<string,array<string,string>> $classMap list of available webservice classes 49 * @param array<string,string> $config json-rpc config 49 50 */ 50 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap )51 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap, array $config) 51 52 { 52 53 $requestId = $request->getValidatedValue(new stubRegexValidator(self::ID_PATTERN), 'id'); trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcPostSubProcessor.php
r1547 r1647 29 29 * @param stubResponse $response the current response 30 30 * @param array<string,array<string,string>> $classMap list of available webservice classes 31 * @param array<string,string> $config json-rpc config 31 32 */ 32 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap )33 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap, array $config) 33 34 { 34 35 $requestJsonObj = $request->getValidatedRawData(new stubPassThruValidator()); trunk/src/main/php/net/stubbles/service/jsonrpc/subprocessors/stubJsonRpcSubProcessor.php
r1434 r1647 26 26 * @param stubResponse $response the current response 27 27 * @param array<string,array<string,string>> $classMap list of available webservice classes 28 * @param array<string,string> $config json-rpc config 28 29 */ 29 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap );30 public function process(stubRequest $request, stubSession $session, stubResponse $response, array $classMap, array $config); 30 31 } 31 32 ?>
