Changeset 588

Show
Ignore:
Timestamp:
04/20/07 15:19:36 (1 year ago)
Author:
schst
Message:

JsonRpcProcessor? can now display error message using firebug, if a class is not available

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config/xml/json-rpc-service.xml

    r517 r588  
    44    xmlns="http://stubbles.net/service/json-rpc"> 
    55  <service-url>http://localhost/?processor=jsonrpc</service-url> 
     6  <use-firebug>true</use-firebug> 
    67  <services> 
    78    <service name="BuddyQuoteService" className="_test.service.BuddyQuoteService"/> 
  • trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php

    r580 r588  
    5252 
    5353    /** 
     54     * Configuration of the service 
     55     * 
     56     * @var array 
     57     */ 
     58    protected $serviceConfig = array(); 
     59 
     60    /** 
    5461     * The class used in the service 
    5562     * 
     
    7178     */ 
    7279    public function doProcess() { 
    73  
    7480        $xjconf = new stubXJConfFacade(new XJConfFacade(array('__default' => stubXJConfLoader::getInstance()))); 
    7581        $xjconf->addDefinitions(stubFactory::getResourceURIs('xjconf/json-rpc-service.xml')); 
     
    7783        $xjconf->parse($configFile); 
    7884        $this->classMap = $xjconf->getConfigValue('services'); 
     85        $this->serviceConfig['use-firebug'] = $xjconf->getConfigValue('use-firebug'); 
    7986 
    8087        if ($this->request->hasValue('__generateProxy', stubRequest::SOURCE_PARAM)) { 
     
    114121                continue; 
    115122            } 
    116             $jsCode = $generator->generateJavascriptProxy($serviceConfig['className'], $jsClass, $jsCode); 
     123            try { 
     124                $jsCode = $generator->generateJavascriptProxy($serviceConfig['className'], $jsClass, $jsCode); 
     125            } catch (stubClassNotFoundException $e) { 
     126                if ($this->serviceConfig['use-firebug'] === true) { 
     127                    $jsCode = $jsCode . "console.error('Class {$serviceConfig['className']} does not exist, generation of proxy failed.');\n"; 
     128                } 
     129            } 
    117130        } 
    118131        $this->response->write($jsCode); 
  • trunk/src/main/resources/xjconf/json-rpc-service.xml

    r507 r588  
    44    <tag name="services" type="array" /> 
    55    <tag name="service-url" type="string" /> 
     6    <tag name="use-firebug" type="boolean" /> 
    67    <tag name="service" type="array" keyAttribute="name"> 
    78      <attribute name="name" type="string" required="true"/>