Changeset 504
- Timestamp:
- 04/14/07 00:22:52 (1 year ago)
- Files:
-
- trunk/config/xml/json-rpc-service.xml (added)
- trunk/docroot/jsonrpclab/testBuddyQuoteService.php (modified) (2 diffs)
- trunk/src/main/php/_test/service/BuddyQuoteService.php (moved) (moved from trunk/src/main/php/_test/BuddyQuoteService.php)
- trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php (modified) (4 diffs)
- trunk/src/main/resources/xjconf/json-rpc-service.xml (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docroot/jsonrpclab/testBuddyQuoteService.php
r499 r504 20 20 21 21 var bq = new BuddyQuoteService(callbackObj); 22 23 var MathCallbackObj = { 24 callback__add: function(id, result, error) { 25 alert(result); 26 } 27 }; 28 var math = new MathService(MathCallbackObj); 22 29 </script> 23 30 … … 29 36 </fieldset> 30 37 38 <fieldset> 39 <legend>Second JSON-RPC example</legend> 40 A: <input type="text" id="a" size="3"/> B: <input type="text" id="b" size="3"/><br/> 41 <input type="button" onclick="math.add(document.getElementById('a').value, document.getElementById('b').value);" value="A+B"/> 42 </fieldset> 31 43 32 44 </head> trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php
r499 r504 44 44 * 45 45 * @var array 46 * @todo read this from a configuration file 47 */ 48 protected $classMap = array( 49 'BuddyQuoteService' => '_test.BuddyQuoteService' 50 ); 46 */ 47 protected $classMap = array(); 51 48 52 49 /** … … 72 69 */ 73 70 public function doProcess() { 71 72 $xjconf = new stubXJConfFacade(array('__default' => stubXJConfLoader::getInstance())); 73 $xjconf->parseAndAddDefinitions(stubFactory::getResourceURIs('xjconf/json-rpc-service.xml')); 74 $configFile = stubConfig::getConfigPath() . '/xml/json-rpc-service.xml'; 75 $xjconf->parse($configFile); 76 $this->classMap = $xjconf->getConfigValue('services'); 74 77 75 78 if ($this->request->hasValue('__generateProxy', stubRequest::SOURCE_PARAM)) { … … 92 95 stubClassLoader::load('net.stubbles.service.jsonrpc.util.stubJsonRpcProxyGenerator'); 93 96 $jsCode = ''; 94 foreach ($this->classMap as $jsClass => $ fqClass) {95 $jsCode = stubJsonRpcProxyGenerator::generateJavascriptProxy($ fqClass, $jsClass, $jsCode);97 foreach ($this->classMap as $jsClass => $serviceConfig) { 98 $jsCode = stubJsonRpcProxyGenerator::generateJavascriptProxy($serviceConfig['className'], $jsClass, $jsCode); 96 99 } 97 100 $this->response->write($jsCode); … … 194 197 throw new Exception('Unknown class ' . $class . '.'); 195 198 } 196 $fqClass = $this->classMap[$class] ;199 $fqClass = $this->classMap[$class]['className']; 197 200 $classObj = new stubReflectionClass($fqClass); 198 201 return $classObj;
