/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/data_source/GenericDataSource.inc
ViewVC logotype

Diff of /nfo/php/libs/com.newsblob.phphtmllib/widgets/data_source/GenericDataSource.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by joko, Sun Mar 2 01:05:13 2003 UTC revision 1.3 by joko, Mon Mar 3 21:24:18 2003 UTC
# Line 17  Line 17 
17   * $Id$   * $Id$
18   *   *
19   * $Log$   * $Log$
20     * Revision 1.3  2003/03/03 21:24:18  joko
21     * now based on DesignPattern::RemoteProxy
22     *
23   * Revision 1.2  2003/03/02 01:05:13  joko   * Revision 1.2  2003/03/02 01:05:13  joko
24   * - purged old code   * - purged old code
25   *   *
# Line 144  Line 147 
147   */   */
148    
149    
150  class GenericDataSource extends MemoryDataSource {  //loadModule('DesignPattern::Proxy');
151    loadModule('DesignPattern::RemoteProxy');
152    
153    //class GenericDataSource extends MemoryDataSource {
154    //class GenericDataSource extends DesignPattern_Proxy {
155    class GenericDataSource extends DesignPattern_RemoteProxy {
156    
157          /**          /**
158           * This var holds the locator metadata hash           * This var holds the locator metadata hash
# Line 165  class GenericDataSource extends MemoryDa Line 173  class GenericDataSource extends MemoryDa
173    
174    
175          /**          /**
          * This var holds the Handler object  
          * that is used to do the work.  
          * It acts as a dispatcher combining result caching.  
          * It is assumed that this provides 4 methods:  
          * queryData() - execute a query against a data storage  
          * querySchema() - execute a query against underlying storage metadata  
          * sendCommand() - send a command against an arbitrary execution engine  
          * ... or others! (these are just proposals for convenience)  
          *  
          */  
         var $_handler = NULL;  
   
   
         /**  
          * This var holds options fed to the Proxy object  
          * These are built from locator metadata (_locator) and query arguments (_query)  
          * It's a simple structured hash:  
          *  $proxy_options = array(  
          *    method => '<remote-method-name>',  
          *    args => array('list', 'of', 'arguments')  
          *  );  
          *  
          */  
         var $_handler_options = NULL;  
   
   
         /**  
176           * this holds the query result from the           * this holds the query result from the
177           * Data::Driver::Proxy->queryXyz() call           * Data::Driver::Proxy->queryXyz() call
178           *           *
179           */           */
180          var $_result = NULL;          var $_result = NULL;
181    
         /**  
          * This holds some information about the tracing level.  
          *  
          */  
         var $_debug = array(  
           notice => 0,  
           trace => 0,  
           payload => 0,  
         );  
182    
183    
184          /**          /**
# Line 245  class GenericDataSource extends MemoryDa Line 217  class GenericDataSource extends MemoryDa
217      }      }
218    
219          /**          /**
      * Directly inject a Data::Driver::Proxy instance to use.  
      *  
      * @param Data::Driver::Proxy object - &$proxy  
      *  
      */  
     function set_handler( &$proxy ) {  
         $this->_handler = &$proxy;  
     }  
   
         /**  
220       * Issue remote/proxy call       * Issue remote/proxy call
221       * Stolen from Application_AbstractBackend::_remote_method (RefactoringProposal?)       * Stolen from Application_AbstractBackend::_remote_method (RefactoringProposal?)
222       * Tweaked a bit: proxy package now taken from $this->_handler_name       * Tweaked a bit: proxy package now taken from $this->_handler_name
# Line 266  class GenericDataSource extends MemoryDa Line 228  class GenericDataSource extends MemoryDa
228       * @param string - $proxy_name (namespaced classname - perl syntax - e.g.: Data::Driver::Proxy)       * @param string - $proxy_name (namespaced classname - perl syntax - e.g.: Data::Driver::Proxy)
229       *       *
230       */       */
231      function do_handler_call() {      function call_handler() {
232    
233    
234        // 1. read args        // 1. read args
# Line 293  class GenericDataSource extends MemoryDa Line 255  class GenericDataSource extends MemoryDa
255          if (sizeof($query) == 1) {          if (sizeof($query) == 1) {
256            $query = $query[0];            $query = $query[0];
257          }          }
258    
259          //  !!! use DesignPattern::Proxy here !!!
260          // $proxy = new DesignPattern_Proxy($proxy_name, ...)
261          // or:
262          // $proxy = mkObject('DesignPattern::Proxy');
263          // $this->set_handler( $proxy );
264          // or:
265          // $proxy = mkObject('DesignPattern::Proxy');
266          // $proxy->
267          // $this->set_handler( $proxy );
268          
269          $this->set_component_name( $proxy_name );
270          $this->set_component_options( $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
271          
272          $this->create_handler();
273                
274          /*
275        // --------------------   clone this & modify  ----------        // --------------------   clone this & modify  ----------
276        $proxy = mkObject($proxy_name, $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );        $proxy = mkObject($proxy_name, $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) );
277        $this->set_handler( $proxy );        $this->set_handler( $proxy );
# Line 302  class GenericDataSource extends MemoryDa Line 280  class GenericDataSource extends MemoryDa
280        //$this->_result = $resultHandle->getAttributes();        //$this->_result = $resultHandle->getAttributes();
281        //$this->_result = $this->_handler->getAttributes();        //$this->_result = $this->_handler->getAttributes();
282        // --------------------   clone this & modify  ----------        // --------------------   clone this & modify  ----------
283          */
284        
285      }      }
286    
# Line 364  class GenericDataSource extends MemoryDa Line 343  class GenericDataSource extends MemoryDa
343    
344        // do remote call here and get result        // do remote call here and get result
345        // FIXME: handle synchronous/asynchronous mode here!!!        // FIXME: handle synchronous/asynchronous mode here!!!
346          $this->do_handler_call($method, $args);          $this->call_handler($method, $args);
347          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result          // TODO: ... = $this->poll_handler_result  and  $this->get_handler_result
348          $this->_result = $this->_handler->getAttributes();          $this->_result = $this->_handler->getAttributes();
349    
# Line 385  class GenericDataSource extends MemoryDa Line 364  class GenericDataSource extends MemoryDa
364    
365    function do_query_schema() {    function do_query_schema() {
366      user_error("FIXME: do_query_schema");      user_error("FIXME: do_query_schema");
367      // $this->do_handler_call( ... );      // $this->call_handler( ... );
368    }    }
369                    
370    function get_header() {    function get_header() {

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed