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

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

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