1 |
<?php |
<?php |
|
|
|
2 |
/** |
/** |
3 |
|
* This file contains the DesignPattern::RemoteProxy class |
4 |
|
* |
5 |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
|
* @package org.netfrag.glib |
7 |
|
* @name DesignPattern::RemoteProxy |
8 |
|
* @filesource |
9 |
|
* |
10 |
|
* |
11 |
|
* <b>Cvs-Log:</b> |
12 |
|
* |
13 |
|
* <pre> |
14 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
15 |
* $Id$ |
* $Id$ |
16 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
17 |
* $Log$ |
* $Log$ |
18 |
|
* Revision 1.5 2003/03/05 17:02:22 joko |
19 |
|
* updated docu (phpDocumentor testing....) |
20 |
|
* |
21 |
|
* Revision 1.4 2003/03/05 16:32:19 joko |
22 |
|
* updated docu (phpDocumentor testing....) |
23 |
|
* |
24 |
|
* Revision 1.3 2003/03/05 16:10:17 joko |
25 |
|
* updated docu (phpDocumentor testing....) |
26 |
|
* |
27 |
|
* Revision 1.2 2003/03/05 12:14:02 joko |
28 |
|
* renamed method |
29 |
|
* constructor argument expansion |
30 |
|
* |
31 |
* Revision 1.1 2003/03/03 22:06:46 joko |
* Revision 1.1 2003/03/03 22:06:46 joko |
32 |
* refactored from Data::Driver::Proxy |
* refactored from Data::Driver::Proxy |
33 |
* |
* |
115 |
* Revision 1.1 2002/10/09 00:51:39 cvsjoko |
* Revision 1.1 2002/10/09 00:51:39 cvsjoko |
116 |
* + new |
* + new |
117 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
118 |
|
* </pre> |
119 |
|
* |
120 |
*/ |
*/ |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
/** |
/** |
126 |
|
* Load required modules: |
127 |
* |
* |
128 |
|
*/ |
129 |
|
loadModule('DesignPattern::Proxy'); |
130 |
|
|
131 |
|
|
132 |
|
/** |
133 |
* Data::Driver::Proxy -- Multiple stage data fetching and caching |
* Data::Driver::Proxy -- Multiple stage data fetching and caching |
134 |
* |
* |
135 |
* |
* |
144 |
* |
* |
145 |
* Multiple stage data fetching and caching: |
* Multiple stage data fetching and caching: |
146 |
* |
* |
147 |
|
* <pre> |
148 |
|
* |
149 |
* DATA, ... |
* DATA, ... |
150 |
* ... also refered to as data, should be handled as |
* ... also refered to as data, should be handled as |
151 |
* something called data. |
* something called data. |
188 |
* o Data::Driver::PEAR::DB |
* o Data::Driver::PEAR::DB |
189 |
* x Data::Driver::PEAR::Tree (via Data::Lift) |
* x Data::Driver::PEAR::Tree (via Data::Lift) |
190 |
* |
* |
191 |
*/ |
* </pre> |
|
|
|
|
/** |
|
|
* Todo: |
|
|
* x extend options to en-/disable caching via a) session and/or b) database |
|
|
* o make feature available via runtime setter-method to these options |
|
|
* o use PEAR::Cache for caching purposes!!! |
|
|
* o refactor database access: use PEAR for this! no more 'connectdb' here!!! |
|
|
* o make database connection more flexible to make possible |
|
|
* to have different (probably named) proxy databases (besides a "main database") |
|
|
* o rename this to Data::Proxy? or split into Data::Query, Data::Result and Data::Wrapper? |
|
192 |
* |
* |
193 |
*/ |
* |
194 |
|
* An attempt to implement some software design patterns |
195 |
/** |
* --- RemoteProxyPattern |
196 |
* Load required modules: |
* |
197 |
|
* @link http://c2.com/cgi-bin/wiki?ProxyPattern |
198 |
|
* |
199 |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
200 |
|
* @link http://www.netfrag.org/~joko/ |
201 |
|
* |
202 |
|
* @copyright (c) 2003 - All Rights reserved. |
203 |
|
* @license GNU LGPL (GNU Lesser General Public License) |
204 |
|
* @link http://www.gnu.org/licenses/lgpl.txt |
205 |
|
* |
206 |
|
* @package org.netfrag.glib |
207 |
|
* @name DesignPattern::RemoteProxy |
208 |
|
* |
209 |
|
* |
210 |
|
* @todo |
211 |
|
* <pre> |
212 |
|
* x extend options to en-/disable caching via a) session and/or b) database |
213 |
|
* o make feature available via runtime setter-method to these options |
214 |
|
* o use PEAR::Cache for caching purposes!!! |
215 |
|
* o refactor database access: use PEAR for this! no more 'connectdb' here!!! |
216 |
|
* o make database connection more flexible to make possible |
217 |
|
* to have different (probably named) proxy databases (besides a "main database") |
218 |
|
* o rename this to Data::Proxy? or split into Data::Query, Data::Result and Data::Wrapper? |
219 |
|
* </pre> |
220 |
* |
* |
221 |
*/ |
*/ |
|
loadModule('DesignPattern::Proxy'); |
|
|
|
|
222 |
class DesignPattern_RemoteProxy extends DesignPattern_Proxy { |
class DesignPattern_RemoteProxy extends DesignPattern_Proxy { |
223 |
|
|
224 |
var $objectId; |
var $objectId; |
232 |
logp(get_class($this) . "->new()", PEAR_LOG_INFO); |
logp(get_class($this) . "->new()", PEAR_LOG_INFO); |
233 |
global $proxy; |
global $proxy; |
234 |
|
|
235 |
|
// 2003-03-05 - modified constructor |
236 |
|
// expand objectId |
237 |
|
if (is_array($objectId)) { |
238 |
|
$options = $objectId[1]; |
239 |
|
$objectId = $objectId[0]; |
240 |
|
} |
241 |
|
|
242 |
// trace |
// trace |
243 |
//print Dumper($objectId, $options); |
//print Dumper($objectId, $options); |
244 |
|
|
247 |
$this->_init_caching(); |
$this->_init_caching(); |
248 |
$this->_init_load(); |
$this->_init_load(); |
249 |
|
|
250 |
|
//print Dumper($this); |
251 |
|
|
252 |
} |
} |
253 |
|
|
254 |
function _init_meta_options( $objectId="", $options = array() ) { |
function _init_meta_options( $objectId="", $options = array() ) { |
273 |
|
|
274 |
if ($this->meta[remote]) { |
if ($this->meta[remote]) { |
275 |
//$this->backend = mkObject('Data::Driver::RPC::Remote', $this->meta[rpcinfo]); |
//$this->backend = mkObject('Data::Driver::RPC::Remote', $this->meta[rpcinfo]); |
276 |
$this->backend = mkObject('DataSource::Proxy::XMLRPC', $this->meta[rpcinfo]); |
$this->backend = php::mkComponent('DataSource::Proxy::XMLRPC', $this->meta[rpcinfo]); |
277 |
} |
} |
278 |
} |
} |
279 |
|
|
331 |
} |
} |
332 |
*/ |
*/ |
333 |
|
|
334 |
function getAttributes() { |
function getResult() { |
335 |
if (!$this->meta[decoded]) { |
if (!$this->meta[decoded]) { |
336 |
$this->_decode(); |
$this->_decode(); |
337 |
$this->_saveState(); |
$this->_saveState(); |