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

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

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