Changeset 507

Show
Ignore:
Timestamp:
04/14/07 10:38:47 (1 year ago)
Author:
schst
Message:

Added phing tasks to generate JSON-RPC proxies during build, added ability to set the service-URL in the config. This needs to be reviewed!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/config/php/config-dist.php

    r239 r507  
    77    /** 
    88     * this method should return the path to the lib directory 
    9      *  
     9     * 
    1010     * By default its /path/to/stubbles/lib. 
    1111     * 
     
    1616        return realpath(dirname(__FILE__) . '/../../lib'); 
    1717    } 
    18      
     18 
     19    /** 
     20     * this method should return the path to the source directory 
     21     * 
     22     * By default its /path/to/stubbles/src/main/php. 
     23     * 
     24     * @return  string 
     25     */ 
     26    public static function getSourcePath() 
     27    { 
     28        return realpath(dirname(__FILE__) . '/../../src/main/php'); 
     29    } 
     30 
    1931    /** 
    2032     * this method should return the path to the log directory 
    21      *  
     33     * 
    2234     * By default its /path/to/stubbles/log. 
    2335     * 
     
    2840        return realpath(dirname(__FILE__) . '/../../log'); 
    2941    } 
    30      
     42 
    3143    /** 
    3244     * this method should return the path to the cache directory 
     
    3850        return realpath(dirname(__FILE__) . '/../../cache'); 
    3951    } 
    40      
     52 
    4153    /** 
    4254     * this method should return the path to the config directory 
     
    4860        return realpath(dirname(__FILE__) . '/../'); 
    4961    } 
    50      
     62 
    5163    /** 
    5264     * switch to use star files or not 
  • trunk/config/php/config.php

    r239 r507  
    77    /** 
    88     * this method should return the path to the lib directory 
    9      *  
     9     * 
    1010     * By default its /path/to/stubbles/lib. 
    1111     * 
     
    1616        return realpath(dirname(__FILE__) . '/../../lib'); 
    1717    } 
    18      
     18 
     19    /** 
     20     * this method should return the path to the source directory 
     21     * 
     22     * By default its /path/to/stubbles/src/main/php. 
     23     * 
     24     * @return  string 
     25     */ 
     26    public static function getSourcePath() 
     27    { 
     28        return realpath(dirname(__FILE__) . '/../../src/main/php'); 
     29    } 
     30 
    1931    /** 
    2032     * this method should return the path to the log directory 
    21      *  
     33     * 
    2234     * By default its /path/to/stubbles/log. 
    2335     * 
     
    2840        return realpath(dirname(__FILE__) . '/../../log'); 
    2941    } 
    30      
     42 
    3143    /** 
    3244     * this method should return the path to the cache directory 
     
    3850        return realpath(dirname(__FILE__) . '/../../cache'); 
    3951    } 
    40      
     52 
    4153    /** 
    4254     * this method should return the path to the config directory 
     
    4860        return realpath(dirname(__FILE__) . '/../'); 
    4961    } 
    50      
     62 
    5163    /** 
    5264     * switch to use star files or not 
  • trunk/config/xml/json-rpc-service.xml

    r504 r507  
    33    xmlns:xj="http://xjconf.net/XJConf" 
    44    xmlns="http://stubbles.net/service/json-rpc"> 
     5  <service-url>http://localhost/?processor=jsonrpc</service-url> 
    56  <services> 
    67    <service name="BuddyQuoteService" className="_test.service.BuddyQuoteService"/> 
  • trunk/docroot/jsonrpclab

    • Property svn:ignore changed from
      yui
      to
      yui
      generated-scripts
  • trunk/src/main/php/net/stubbles/service/jsonrpc/util/stubJsonRpcProxyGenerator.php

    r499 r507  
    77 * @subpackage  service_jsonrpc 
    88 */ 
    9 stubClassLoader::load('net.stubbles.service.annotations.stubWebMethodAnnotation'); 
     9stubClassLoader::load('net.stubbles.service.annotations.stubWebMethodAnnotation', 
     10                      'net.stubbles.reflection.reflection'); 
    1011 
    1112/** 
     
    1920{ 
    2021    /** 
     22     * URL of the service 
     23     * 
     24     * @var string 
     25     */ 
     26    protected $serviceURL; 
     27 
     28    /** 
     29     * Create a new generator 
     30     * 
     31     * @param string $serviceURL 
     32     */ 
     33    public function __construct($serviceURL) { 
     34        $this->serviceURL = $serviceURL; 
     35    } 
     36 
     37    /** 
    2138     * Generate JS proxy for a specified class 
    2239     * 
     
    2643     * @return string 
    2744     */ 
    28     static public function generateJavascriptProxy($className, $jsClass = null, $jsCode = '') { 
     45    public function generateJavascriptProxy($className, $jsClass = null, $jsCode = '') { 
    2946 
    3047        $clazz = new stubReflectionClass($className); 
     
    3350        } 
    3451 
    35         $serviceUrl = $_SERVER['PHP_SELF'] . '?processor=jsonrpc'; 
    36  
    3752        $jsCode .= "function {$jsClass}(clientObj) {\n"; 
    38         $jsCode .= " this.dispatcher = new stubbles.json.rpc.Client(clientObj, '{$serviceUrl}');\n"; 
     53        $jsCode .= " this.dispatcher = new stubbles.json.rpc.Client(clientObj, '{$this->serviceURL}');\n"; 
    3954        $jsCode .= "}\n"; 
    4055 
  • trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php

    r506 r507  
    1111                      'net.stubbles.util.validators.stubRegexValidator', 
    1212                      'net.stubbles.util.validators.stubPassThruValidator', 
     13                      'net.stubbles.reflection.reflection', 
    1314                      'net.stubbles.service.annotations.stubWebMethodAnnotation'); 
    1415 
     
    8889     * @param array        restrict to classes 
    8990     * @todo  restrict to classes 
     91     * @todo  Improve service URL detection 
    9092     */ 
    9193    public function generateProxies($class = null) { 
    9294        stubClassLoader::load('net.stubbles.service.jsonrpc.util.stubJsonRpcProxyGenerator'); 
     95        $generator = new stubJsonRpcProxyGenerator($_SERVER['PHP_SELF'] . '?processor=jsonrpc'); 
    9396        $jsCode = ''; 
    9497        foreach ($this->classMap as $jsClass => $serviceConfig) { 
    95             $jsCode = stubJsonRpcProxyGenerator::generateJavascriptProxy($serviceConfig['className'], $jsClass, $jsCode); 
     98            $jsCode = $generator->generateJavascriptProxy($serviceConfig['className'], $jsClass, $jsCode); 
    9699        } 
    97100        $this->response->write($jsCode); 
  • trunk/src/main/resources/xjconf/json-rpc-service.xml

    r504 r507  
    33  <namespace uri="http://stubbles.net/service/json-rpc"> 
    44    <tag name="services" type="array" /> 
     5    <tag name="service-url" type="string" /> 
    56    <tag name="service" type="array" keyAttribute="name"> 
    67      <attribute name="name" type="string" required="true"/>