Changeset 921
- Timestamp:
- 09/16/07 14:31:26 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/examples/docroot/json-rpc/index.php
r866 r921 84 84 A: <input type="text" id="a" size="3"/> B: <input type="text" id="b" size="3"/><br/> 85 85 <input type="button" onclick="math.add(document.getElementById('a').value, document.getElementById('b').value);" value="A+B"/> 86 <p> 87 SMD for this service:<br/> 88 <iframe height="50" width="100%" src="<?php echo dirname($_SERVER['PHP_SELF']);?>/jsonrpc.php?processor=jsonrpc&__smd=MathService"></iframe> 89 </p> 86 90 </fieldset> 87 91 … … 96 100 <input type="button" onclick="nameServ.getName();" value="Get Name"/> 97 101 <input type="button" onclick="nameServ.setName(document.getElementById('name').value);" value="Set Name"/> 102 <p> 103 SMD for this service:<br/> 104 <iframe height="50" width="100%" src="<?php echo dirname($_SERVER['PHP_SELF']);?>/jsonrpc.php?processor=jsonrpc&__smd=NameService"></iframe> 105 </p> 98 106 </fieldset> 99 107 trunk/src/main/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessor.php
r888 r921 86 86 $this->generateProxies(explode(',', $classes)); 87 87 } 88 } elseif ($this->request->hasValue('__smd')) { 89 $smdClassvalidator = new stubRegexValidator('^[A-Za-z0-9_\.]+$'); 90 $class = $this->request->getValidatedValue($smdClassvalidator, '__smd', stubRequest::SOURCE_PARAM); 91 $this->generateSmd($class); 92 } elseif ($this->request->getMethod() === 'post') { 88 93 } elseif ($this->request->getMethod() === 'post') { 89 94 $this->processPostRequest(); … … 172 177 } 173 178 } 179 180 /** 181 * Generate and send SMD for the specified class 182 * 183 * @param string $class 184 */ 185 public function generateSmd($class) 186 { 187 stubClassLoader::load('net.stubbles.service.jsonrpc.util.stubSmdGenerator'); 188 $tmp = parse_url($this->request->getURI()); 189 $serviceUrl = '//' . $tmp['path']; 190 if ($this->request->hasValue('processor')) { 191 $processor = $this->request->getValidatedValue(new stubPassThruValidator(), 'processor', stubRequest::SOURCE_PARAM); 192 $serviceUrl .= '?processor='.$processor; 193 } 194 195 $generator = new stubSmdGenerator($serviceUrl); 196 try { 197 $classInfo = $this->classMap[$class]; 198 $this->response->write($generator->generateSmd($classInfo['className'], $class)); 199 } catch (Exception $e) { 200 if ($this->serviceConfig['use-firebug'] === true) { 201 $this->response->write("console.error('Generation of SMD for {$serviceConfig['className']} failed.');\n"); 202 $this->response->write($this->convertStringToFirebug($e->__toString())); 203 } 204 } 205 } 206 174 207 175 208 /** … … 301 334 throw new stubException('Invalid amount of parameters passed.'); 302 335 } 303 336 304 337 $binder = stubRegistry::get('net.stubbles.ioc.stubBinder'); 305 338 if (($binder instanceof stubBinder) === false) { 306 339 throw new stubRuntimeException('No instance of net.stubbles.ioc.stubBinder in registry.'); 307 340 } 308 341 309 342 $instance = $binder->getInjector()->getInstance($class->getName()); 310 343 return $method->invokeArgs($instance, $params);
