Changeset 518

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

Load missing interface, avoid direct access to $_SERVER

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/processors/stubJsonRpcProcessor.php

    r517 r518  
    1212                      'net.stubbles.util.validators.stubPassThruValidator', 
    1313                      'net.stubbles.reflection.reflection', 
    14                       'net.stubbles.service.annotations.stubWebMethodAnnotation'); 
     14                      'net.stubbles.service.annotations.stubWebMethodAnnotation', 
     15                      'net.stubbles.service.stubStatefulService'); 
    1516 
    1617/** 
     
    7879            $this->generateProxies(); 
    7980        } elseif ($this->request->getMethod() === 'get') { 
    80             $this->doGET(); 
     81            $this->processGetRequest(); 
    8182        } else { 
    82             $this->doPOST(); 
     83            $this->processPostRequest(); 
    8384        } 
    8485    } 
     
    8990     * @param array        restrict to classes 
    9091     * @todo  restrict to classes 
    91      * @todo  Improve service URL detection 
    92      */ 
    93     public function generateProxies($class = null) { 
     92     */ 
     93    public function generateProxies($classes = null) { 
    9494        stubClassLoader::load('net.stubbles.service.jsonrpc.util.stubJsonRpcProxyGenerator'); 
    95         $generator = new stubJsonRpcProxyGenerator($_SERVER['PHP_SELF'] . '?processor=jsonrpc'); 
     95 
     96        $tmp = parse_url($this->request->getURI()); 
     97        $serviceUrl = '//' . $tmp['path']; 
     98        if ($this->request->hasValue('processor')) { 
     99            $processor = $this->request->getValidatedValue(new stubPassThruValidator(), 'processor', stubRequest::SOURCE_PARAM); 
     100            $serviceUrl .= '?processor='.$processor; 
     101        } 
     102 
     103        $generator = new stubJsonRpcProxyGenerator($serviceUrl); 
    96104        $jsCode = ''; 
    97105        foreach ($this->classMap as $jsClass => $serviceConfig) { 
     
    104112     * Handle a JSON-RPC POST request 
    105113     */ 
    106     public function doPOST() { 
     114    public function processPostRequest() { 
    107115        $requestJsonObj  = $this->request->getValidatedRawData(new stubPassThruValidator()); 
    108116        $phpJsonObj      = json_decode($requestJsonObj); 
     
    174182     * &id=186252 
    175183     */ 
    176     public function doGET() { 
     184    public function processGetRequest() { 
    177185        try { 
    178186            $idPattern = new stubRegexValidator(self::ID_PATTERN);