/[cvs]/nfo/php/libs/org.netfrag.glib/DataSource/Generic.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/DataSource/Generic.php

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

revision 1.1 by joko, Wed Mar 5 12:04:00 2003 UTC revision 1.3 by joko, Sun Mar 9 15:50:36 2003 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /**  /**
3   * This file contains the GenericDataSource child class   * This file contains the GenericDataSource child class
  * that may use arbitrary code modules as database handlers.  
  * It's aims are to get together:  
  *   o phpHtmlLibs "source-handlers"  
  *   o PEAR's database handlers  
  *   o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)  
4   *   *
5   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
6   * @package phpHtmlLib   * @package org.netfrag.glib
7   * @module GenericDataSource   * @name DataSource::Generic
8   *   *
9   */   */
10    
# Line 17  Line 12 
12   * $Id$   * $Id$
13   *   *
14   * $Log$   * $Log$
15     * Revision 1.3  2003/03/09 15:50:36  joko
16     * + additional metadata for Autodia
17     *
18     * Revision 1.2  2003/03/05 17:28:43  joko
19     * updated docu (phpDocumentor testing....)
20     *
21   * Revision 1.1  2003/03/05 12:04:00  joko   * Revision 1.1  2003/03/05 12:04:00  joko
22   * + initial commit, from GenericDataSource   * + initial commit, from GenericDataSource
23   *   *
# Line 71  Line 72 
72    // require_once("PEAR.php");   // FIXME: what about PEAR::XML::RPC?    // require_once("PEAR.php");   // FIXME: what about PEAR::XML::RPC?
73    // require_once("DB.php");    // require_once("DB.php");
74    
75    
76    loadModule('DesignPattern::Proxy');
77    loadModule('DesignPattern::TransparentProxy');
78    loadModule('DesignPattern::RemoteProxy');
79    
80    //class GenericDataSource extends MemoryDataSource {
81    //class GenericDataSource extends DesignPattern_Proxy {
82    //class GenericDataSource extends DesignPattern_RemoteProxy {
83    //class GenericDataSource extends DesignPattern_TransparentProxy {
84    
85    //class GenericDataSource extends MemoryDataSource {
86    //loadModule("DataSource::Proxy::Memory");
87    //class GenericDataSource extends DataSource_Proxy_Memory {
88    //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
89    //class DataSource_GenericDataSource extends DesignPattern_Proxy {
90    //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {
91    
92    // now independent!!! new class-inheritance-tree possible now!
93    // solved by having an Adapter *and* a Proxy here!
94    //class GenericDataSource {
95    
96    loadModule('DesignPattern::AdapterProxy');
97    
98    
99    
100  /**  /**
101   * This GenericDataSource child class is *completely* independent   * This GenericDataSource child class is *completely* independent
102   * of a specific storage implementation and intended to be a wrapper   * of a specific storage implementation and intended to be a wrapper
103   * class on the way from phpHtmlLib to Xyz.   * class on the way from phpHtmlLib to Xyz. <br>
104   *    ("Yyz" gets represented by Data::Storage by now.....)   *    ("Yyz" gets represented by Data::Storage by now.....)
105   *   *
106   * GenericDataSource interacts with an intermediate "proxy" object   * GenericDataSource interacts with an intermediate "proxy" object
107   * (e.g. Data::Driver::Proxy) when doing queries.   * (e.g. Data::Driver::Proxy) when doing queries. <br>
108     * <pre>
109   *    Don't mix this up with a persistent database handle which gets   *    Don't mix this up with a persistent database handle which gets
110   *    reused each and every time for different queries.   *    reused each and every time for different queries.
111   *    Here *is* a new instance of Data::Driver::Proxy for *each* query.   *    Here *is* a new instance of Data::Driver::Proxy for *each* query.
112     * </pre>
113   *   *
114   * But the point is: Caching! The actual *data* isn't read redundant!   * But the point is: Caching! The actual *data* isn't read redundant!
115   *   *
116     * <pre>
117     * --- snipped into here from above ---
118     * that may use arbitrary code modules as database handlers.
119     * It's aims are to get together:
120     *   o phpHtmlLibs "source-handlers"
121     *   o PEAR's database handlers
122     *   o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server)
123     * --- snipped into here from above ---
124     * </pre>
125     *
126   *   *
127   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------
128   *   *
# Line 95  Line 133 
133   * One worker already implemented is Data::Driver::RPC::Remote, which   * One worker already implemented is Data::Driver::RPC::Remote, which
134   * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.   * talks to a RPC::XML server (todo: talk SOAP!) using PEAR::XML::RPC.
135   *   *
136     * <pre>
137   * ---  refactored here, but: redundant somehow  ---   * ---  refactored here, but: redundant somehow  ---
138   * Data::Driver::Proxy uses a PEAR XML::RPC object to actually   * Data::Driver::Proxy uses a PEAR XML::RPC object to actually
139   * talk HTTP and serialize data chunks to and from XML,   * talk HTTP and serialize data chunks to and from XML,
# Line 102  Line 141 
141   * It "proxies" arbitrary data chunks a) inside a native php4 session,   * It "proxies" arbitrary data chunks a) inside a native php4 session,
142   * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.   * b) by talking to a rdbms (single proxy-table) or c) [TODO] using PEAR::Cache.
143   * ---  refactored here, but: redundant somehow  ---   * ---  refactored here, but: redundant somehow  ---
144     * </pre>
145   *   *
146   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------   * !!!!!!  refactor this to Data::Driver::Proxy  !!!!!!     <-----------------
147   *   *
148   *   *
149   * How to use?   * <b>How to use?</b>
150   *   *
151   * Pass an array holding "locator metadata" to the constructor.   * Pass an array holding "locator metadata" to the constructor.
152   * GenericDataSource takes care of the rest.   * GenericDataSource takes care of the rest.
# Line 114  Line 154 
154   * Pass an array to the constructor: (e.g.)   * Pass an array to the constructor: (e.g.)
155   *   *
156   *  1. doing rpc-calls....   *  1. doing rpc-calls....
157     *    <code>
158   *    $locator = array(   *    $locator = array(
159   *      type => 'rpc',   *      type => 'rpc',
160   *      metadata => array( Host => 'localhost', Port => '8765' ),   *      metadata => array( Host => 'localhost', Port => '8765' ),
161   *    );   *    );
162   *    $source = new GenericDataSource($locator);   *    $source = ne w GenericDataSource($locator);
163   *    $this->set_data_source( &$source );   *    $this->set_data_source( &$source );
164     *    </code>
165   *   *
166   *  2. [proposal] common datahandles....   *  2. [proposal] common datahandles....
167     *    <code>
168   *    $locator = array(   *    $locator = array(
169   *      type => 'mysql',   *      type => 'mysql',
170   *      dsn => 'known dsn markup',   *      dsn => 'known dsn markup',
171   *    );   *    );
172   *    $source = new GenericDataSource($locator);   *    $source = ne w GenericDataSource($locator);
173   *    $this->set_data_source( &$source );   *    $this->set_data_source( &$source );
174     *    </code>
175   *   *
176     * @link http://www.netfrag.org/~joko/
177   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
178     *
179     * @link http://www.netfrag.org/~jonen/
180   * @author Sebastian Utz <seut@tunemedia.de>   * @author Sebastian Utz <seut@tunemedia.de>
181     *
182   * @copyright (c) 2003 - All Rights reserved.   * @copyright (c) 2003 - All Rights reserved.
  * @license GNU LGPL (GNU Lesser General Public License)  
183   *   *
184   * @author-url http://www.netfrag.org/~joko/   * @link http://www.gnu.org/licenses/lgpl.txt
185   * @author-url http://www.netfrag.org/~jonen/   * @license GNU LGPL (GNU Lesser General Public License)
  * @license-url http://www.gnu.org/licenses/lgpl.txt  
186   *   *
  * @package phpHtmlLib  
  * @module GenericDataSource  
187   *   *
188   */   * @package org.netfrag.glib
189     * @subpackage DataSource
190  /**   * @name DataSource::Generic
  * Todo:  
191   *   *
192     * @todo
193     * <ul>
194   *  o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles   *  o mungle this to be able to be wrapped around phpHtmlLib's own storage-handles
195   *  o implement another Data::Driver::Proxy container   *  o implement another Data::Driver::Proxy container
196     * </ul>
197   *   *
  */  
   
198    
199  //              !!!!!!!!          THIS IS THE PROBLEM          !!!!!!!!  //              !!!!!!!!          THIS IS THE PROBLEM          !!!!!!!!
200  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!
# Line 169  Line 213 
213  //          o clean implementation using a DesignPattern::AdapterProxy  //          o clean implementation using a DesignPattern::AdapterProxy
214  //  //
215    
216  loadModule('DesignPattern::Proxy');  */
 loadModule('DesignPattern::TransparentProxy');  
 loadModule('DesignPattern::RemoteProxy');  
   
 //class GenericDataSource extends MemoryDataSource {  
 //class GenericDataSource extends DesignPattern_Proxy {  
 //class GenericDataSource extends DesignPattern_RemoteProxy {  
 //class GenericDataSource extends DesignPattern_TransparentProxy {  
   
 //class GenericDataSource extends MemoryDataSource {  
 //loadModule("DataSource::Proxy::Memory");  
 //class GenericDataSource extends DataSource_Proxy_Memory {  
 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {  
 //class DataSource_GenericDataSource extends DesignPattern_Proxy {  
 //class DataSource_GenericDataSource extends DataSource_Proxy_Memory {  
   
 // now independent!!! new class-inheritance-tree possible now!  
 // solved by having an Adapter *and* a Proxy here!  
 //class GenericDataSource {  
   
 loadModule('DesignPattern::AdapterProxy');  
217  class DataSource_Generic extends DesignPattern_AdapterProxy {  class DataSource_Generic extends DesignPattern_AdapterProxy {
218    
219  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!  //    !!!!!!!!   here is it where we have to break inheritance again   !!!!!!!!
# Line 305  class DataSource_Generic extends DesignP Line 329  class DataSource_Generic extends DesignP
329                  //$this->_locator->_datasource_type = $query[datasource];                  //$this->_locator->_datasource_type = $query[datasource];
330                  //$locator[_datasource_type] = $query[datasource];                  //$locator[_datasource_type] = $query[datasource];
331                                    
332          /**
333           * <!-- Autodia -->
334           * can do: (this is metadata supplied for Autodia, don't delete!)
335           *  $this->_locator = new DataSource_Locator()
336           *
337           */
338    
339                  // build master locator                  // build master locator
340                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );                  $this->_locator = php::mkComponent('DataSource::Locator', $locator, array( datasource_type => $query[datasource] ) );
341                  //exit;                  //exit;
# Line 351  class DataSource_Generic extends DesignP Line 382  class DataSource_Generic extends DesignP
382  //exit;  //exit;
383    
384    
385        /**
386         * <!-- Autodia -->
387         * can do: (this is metadata supplied for Autodia, don't delete!)
388         *  $proxy = new DesignPattern_RemoteProxy()
389         *
390         */
391    
392    
393      // --- Proxy selector/dispatcher ...      // --- Proxy selector/dispatcher ...
394            
395      switch ($this->_locator->_datasource_type) {      switch ($this->_locator->_datasource_type) {
# Line 446  class DataSource_Generic extends DesignP Line 485  class DataSource_Generic extends DesignP
485        // $this->create_handler();        // $this->create_handler();
486    
487    
488          /**
489           * <!-- Autodia -->
490           * can do: (this is metadata supplied for Autodia, don't delete!)
491           *  $adapter = new DataSource_Adapter_phpHtmlLib_DataListSource()
492           *
493           */
494    
495        // V1:        // V1:
496        //$this->create_adapter($adapter_module, $this->function, $this->arguments);        //$this->create_adapter($adapter_module, $this->function, $this->arguments);
497    

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

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