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 |
|
|
12 |
* $Id$ |
* $Id$ |
13 |
* |
* |
14 |
* $Log$ |
* $Log$ |
15 |
|
* Revision 1.2 2003/03/05 17:28:43 joko |
16 |
|
* updated docu (phpDocumentor testing....) |
17 |
|
* |
18 |
* Revision 1.1 2003/03/05 12:04:00 joko |
* Revision 1.1 2003/03/05 12:04:00 joko |
19 |
* + initial commit, from GenericDataSource |
* + initial commit, from GenericDataSource |
20 |
* |
* |
69 |
// require_once("PEAR.php"); // FIXME: what about PEAR::XML::RPC? |
// require_once("PEAR.php"); // FIXME: what about PEAR::XML::RPC? |
70 |
// require_once("DB.php"); |
// require_once("DB.php"); |
71 |
|
|
72 |
|
|
73 |
|
loadModule('DesignPattern::Proxy'); |
74 |
|
loadModule('DesignPattern::TransparentProxy'); |
75 |
|
loadModule('DesignPattern::RemoteProxy'); |
76 |
|
|
77 |
|
//class GenericDataSource extends MemoryDataSource { |
78 |
|
//class GenericDataSource extends DesignPattern_Proxy { |
79 |
|
//class GenericDataSource extends DesignPattern_RemoteProxy { |
80 |
|
//class GenericDataSource extends DesignPattern_TransparentProxy { |
81 |
|
|
82 |
|
//class GenericDataSource extends MemoryDataSource { |
83 |
|
//loadModule("DataSource::Proxy::Memory"); |
84 |
|
//class GenericDataSource extends DataSource_Proxy_Memory { |
85 |
|
//class DataSource_GenericDataSource extends DataSource_Proxy_Memory { |
86 |
|
//class DataSource_GenericDataSource extends DesignPattern_Proxy { |
87 |
|
//class DataSource_GenericDataSource extends DataSource_Proxy_Memory { |
88 |
|
|
89 |
|
// now independent!!! new class-inheritance-tree possible now! |
90 |
|
// solved by having an Adapter *and* a Proxy here! |
91 |
|
//class GenericDataSource { |
92 |
|
|
93 |
|
loadModule('DesignPattern::AdapterProxy'); |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
/** |
/** |
98 |
* This GenericDataSource child class is *completely* independent |
* This GenericDataSource child class is *completely* independent |
99 |
* of a specific storage implementation and intended to be a wrapper |
* of a specific storage implementation and intended to be a wrapper |
100 |
* class on the way from phpHtmlLib to Xyz. |
* class on the way from phpHtmlLib to Xyz. <br> |
101 |
* ("Yyz" gets represented by Data::Storage by now.....) |
* ("Yyz" gets represented by Data::Storage by now.....) |
102 |
* |
* |
103 |
* GenericDataSource interacts with an intermediate "proxy" object |
* GenericDataSource interacts with an intermediate "proxy" object |
104 |
* (e.g. Data::Driver::Proxy) when doing queries. |
* (e.g. Data::Driver::Proxy) when doing queries. <br> |
105 |
|
* <pre> |
106 |
* Don't mix this up with a persistent database handle which gets |
* Don't mix this up with a persistent database handle which gets |
107 |
* reused each and every time for different queries. |
* reused each and every time for different queries. |
108 |
* Here *is* a new instance of Data::Driver::Proxy for *each* query. |
* Here *is* a new instance of Data::Driver::Proxy for *each* query. |
109 |
|
* </pre> |
110 |
* |
* |
111 |
* But the point is: Caching! The actual *data* isn't read redundant! |
* But the point is: Caching! The actual *data* isn't read redundant! |
112 |
* |
* |
113 |
|
* <pre> |
114 |
|
* --- snipped into here from above --- |
115 |
|
* that may use arbitrary code modules as database handlers. |
116 |
|
* It's aims are to get together: |
117 |
|
* o phpHtmlLibs "source-handlers" |
118 |
|
* o PEAR's database handlers |
119 |
|
* o custom ones (e.g. Data::Driver::Proxy object, which talks to a remote rpc server) |
120 |
|
* --- snipped into here from above --- |
121 |
|
* </pre> |
122 |
|
* |
123 |
* |
* |
124 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
125 |
* |
* |
130 |
* One worker already implemented is Data::Driver::RPC::Remote, which |
* One worker already implemented is Data::Driver::RPC::Remote, which |
131 |
* 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. |
132 |
* |
* |
133 |
|
* <pre> |
134 |
* --- refactored here, but: redundant somehow --- |
* --- refactored here, but: redundant somehow --- |
135 |
* Data::Driver::Proxy uses a PEAR XML::RPC object to actually |
* Data::Driver::Proxy uses a PEAR XML::RPC object to actually |
136 |
* talk HTTP and serialize data chunks to and from XML, |
* talk HTTP and serialize data chunks to and from XML, |
138 |
* It "proxies" arbitrary data chunks a) inside a native php4 session, |
* It "proxies" arbitrary data chunks a) inside a native php4 session, |
139 |
* 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. |
140 |
* --- refactored here, but: redundant somehow --- |
* --- refactored here, but: redundant somehow --- |
141 |
|
* </pre> |
142 |
* |
* |
143 |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
* !!!!!! refactor this to Data::Driver::Proxy !!!!!! <----------------- |
144 |
* |
* |
145 |
* |
* |
146 |
* How to use? |
* <b>How to use?</b> |
147 |
* |
* |
148 |
* Pass an array holding "locator metadata" to the constructor. |
* Pass an array holding "locator metadata" to the constructor. |
149 |
* GenericDataSource takes care of the rest. |
* GenericDataSource takes care of the rest. |
151 |
* Pass an array to the constructor: (e.g.) |
* Pass an array to the constructor: (e.g.) |
152 |
* |
* |
153 |
* 1. doing rpc-calls.... |
* 1. doing rpc-calls.... |
154 |
|
* <code> |
155 |
* $locator = array( |
* $locator = array( |
156 |
* type => 'rpc', |
* type => 'rpc', |
157 |
* metadata => array( Host => 'localhost', Port => '8765' ), |
* metadata => array( Host => 'localhost', Port => '8765' ), |
158 |
* ); |
* ); |
159 |
* $source = new GenericDataSource($locator); |
* $source = new GenericDataSource($locator); |
160 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
161 |
|
* </code> |
162 |
* |
* |
163 |
* 2. [proposal] common datahandles.... |
* 2. [proposal] common datahandles.... |
164 |
|
* <code> |
165 |
* $locator = array( |
* $locator = array( |
166 |
* type => 'mysql', |
* type => 'mysql', |
167 |
* dsn => 'known dsn markup', |
* dsn => 'known dsn markup', |
168 |
* ); |
* ); |
169 |
* $source = new GenericDataSource($locator); |
* $source = new GenericDataSource($locator); |
170 |
* $this->set_data_source( &$source ); |
* $this->set_data_source( &$source ); |
171 |
|
* </code> |
172 |
* |
* |
173 |
|
* @link http://www.netfrag.org/~joko/ |
174 |
* @author Andreas Motl <andreas.motl@ilo.de> |
* @author Andreas Motl <andreas.motl@ilo.de> |
175 |
|
* |
176 |
|
* @link http://www.netfrag.org/~jonen/ |
177 |
* @author Sebastian Utz <seut@tunemedia.de> |
* @author Sebastian Utz <seut@tunemedia.de> |
178 |
|
* |
179 |
* @copyright (c) 2003 - All Rights reserved. |
* @copyright (c) 2003 - All Rights reserved. |
180 |
|
* |
181 |
|
* @link http://www.gnu.org/licenses/lgpl.txt |
182 |
* @license GNU LGPL (GNU Lesser General Public License) |
* @license GNU LGPL (GNU Lesser General Public License) |
183 |
* |
* |
|
* @author-url http://www.netfrag.org/~joko/ |
|
|
* @author-url http://www.netfrag.org/~jonen/ |
|
|
* @license-url http://www.gnu.org/licenses/lgpl.txt |
|
184 |
* |
* |
185 |
* @package phpHtmlLib |
* @package org.netfrag.glib |
186 |
* @module GenericDataSource |
* @subpackage DataSource |
187 |
* |
* @name DataSource::Generic |
|
*/ |
|
|
|
|
|
/** |
|
|
* Todo: |
|
188 |
* |
* |
189 |
|
* @todo |
190 |
|
* <ul> |
191 |
* 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 |
192 |
* o implement another Data::Driver::Proxy container |
* o implement another Data::Driver::Proxy container |
193 |
|
* </ul> |
194 |
* |
* |
|
*/ |
|
|
|
|
195 |
|
|
196 |
// !!!!!!!! THIS IS THE PROBLEM !!!!!!!! |
// !!!!!!!! THIS IS THE PROBLEM !!!!!!!! |
197 |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
210 |
// o clean implementation using a DesignPattern::AdapterProxy |
// o clean implementation using a DesignPattern::AdapterProxy |
211 |
// |
// |
212 |
|
|
213 |
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'); |
|
214 |
class DataSource_Generic extends DesignPattern_AdapterProxy { |
class DataSource_Generic extends DesignPattern_AdapterProxy { |
215 |
|
|
216 |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |
// !!!!!!!! here is it where we have to break inheritance again !!!!!!!! |