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 |
|
* |
9 |
|
* |
10 |
|
* <b>Cvs-Log:</b> |
11 |
|
* |
12 |
|
* <pre> |
13 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
14 |
* $Id$ |
* $Id$ |
15 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
16 |
* $Log$ |
* $Log$ |
17 |
|
* Revision 1.8 2003/03/10 22:31:56 joko |
18 |
|
* + fixed metadata for phpDocumentor |
19 |
|
* |
20 |
|
* Revision 1.7 2003/03/09 15:51:44 joko |
21 |
|
* + additional metadata for Autodia |
22 |
|
* |
23 |
|
* Revision 1.6 2003/03/05 17:28:43 joko |
24 |
|
* updated docu (phpDocumentor testing....) |
25 |
|
* |
26 |
|
* Revision 1.5 2003/03/05 17:02:22 joko |
27 |
|
* updated docu (phpDocumentor testing....) |
28 |
|
* |
29 |
|
* Revision 1.4 2003/03/05 16:32:19 joko |
30 |
|
* updated docu (phpDocumentor testing....) |
31 |
|
* |
32 |
|
* Revision 1.3 2003/03/05 16:10:17 joko |
33 |
|
* updated docu (phpDocumentor testing....) |
34 |
|
* |
35 |
|
* Revision 1.2 2003/03/05 12:14:02 joko |
36 |
|
* renamed method |
37 |
|
* constructor argument expansion |
38 |
|
* |
39 |
* Revision 1.1 2003/03/03 22:06:46 joko |
* Revision 1.1 2003/03/03 22:06:46 joko |
40 |
* refactored from Data::Driver::Proxy |
* refactored from Data::Driver::Proxy |
41 |
* |
* |
123 |
* Revision 1.1 2002/10/09 00:51:39 cvsjoko |
* Revision 1.1 2002/10/09 00:51:39 cvsjoko |
124 |
* + new |
* + new |
125 |
* ------------------------------------------------------------------------- |
* ------------------------------------------------------------------------- |
126 |
|
* </pre> |
127 |
|
* |
128 |
*/ |
*/ |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
/** |
/** |
134 |
|
* Load required modules: |
135 |
* |
* |
136 |
* Data::Driver::Proxy -- Multiple stage data fetching and caching |
*/ |
137 |
|
loadModule('DesignPattern::Proxy'); |
138 |
|
|
139 |
|
|
140 |
|
/** |
141 |
|
* DesignPattern::RemoteProxy -- Multiple stage data fetching and caching |
142 |
* |
* |
143 |
* |
* |
144 |
* This class (Data::Driver::Proxy) provides an abstract framework |
* This class (DesignPattern::RemoteProxy) provides an abstract framework |
145 |
* for loading/saving arbitrary data from/to data storages interfaced |
* for loading/saving arbitrary data from/to data storages interfaced |
146 |
* by storage *proxy*-drivers. |
* by storage *proxy*-drivers. |
147 |
* Don't mix these up with the concrete storage *handle*-drivers |
* Don't mix these up with the concrete storage *handle*-drivers |
150 |
* providing a more highlevel, consistent API making |
* providing a more highlevel, consistent API making |
151 |
* it easier for Data::Driver::Proxy to do its main work: |
* it easier for Data::Driver::Proxy to do its main work: |
152 |
* |
* |
153 |
|
* quote from: http://home.earthlink.net/~huston2/dp/proxy.html |
154 |
|
* "A remote proxy provides a local representative for an |
155 |
|
* object that resides in a different address space. This is |
156 |
|
* what the "stub" code in RPC and CORBA provides." |
157 |
|
* |
158 |
|
* |
159 |
* Multiple stage data fetching and caching: |
* Multiple stage data fetching and caching: |
160 |
* |
* |
161 |
|
* <pre> |
162 |
|
* |
163 |
* DATA, ... |
* DATA, ... |
164 |
* ... also refered to as data, should be handled as |
* ... also refered to as data, should be handled as |
165 |
* something called data. |
* something called data. |
202 |
* o Data::Driver::PEAR::DB |
* o Data::Driver::PEAR::DB |
203 |
* x Data::Driver::PEAR::Tree (via Data::Lift) |
* x Data::Driver::PEAR::Tree (via Data::Lift) |
204 |
* |
* |
205 |
*/ |
* </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? |
|
206 |
* |
* |
207 |
*/ |
* |
208 |
|
* An attempt to implement some software design patterns |
209 |
/** |
* --- RemoteProxyPattern |
210 |
* Load required modules: |
* |
211 |
|
* @link http://www.agcs.com/supportv2/techpapers/patterns/papers/tutnotes/sld017.htm |
212 |
|
* @link http://home.earthlink.net/~huston2/dp/proxy.html |
213 |
|
* @link http://wiki.cs.uiuc.edu/PatternStories/RemoteObject |
214 |
|
* @link http://c2.com/cgi-bin/wiki?ProxyPattern |
215 |
|
* @link http://c2.com/cgi-bin/wiki?LazyProxies |
216 |
|
* |
217 |
|
* @author Andreas Motl <andreas.motl@ilo.de> |
218 |
|
* @link http://www.netfrag.org/~joko/ |
219 |
|
* |
220 |
|
* @copyright (c) 2003 - All Rights reserved. |
221 |
|
* @license GNU LGPL (GNU Lesser General Public License) |
222 |
|
* @link http://www.gnu.org/licenses/lgpl.txt |
223 |
|
* |
224 |
|
* @package org.netfrag.glib |
225 |
|
* @subpackage DesignPattern |
226 |
|
* @name DesignPattern::RemoteProxy |
227 |
|
* |
228 |
|
* |
229 |
|
* @todo extend options to en-/disable caching via a) session and/or b) database |
230 |
|
* make feature available via runtime setter-method to these options |
231 |
|
* @todo PEAR::Cache for caching purposes!!! |
232 |
|
* @todo refactor database access: use PEAR for this! no more 'connectdb' here!!! |
233 |
|
* @todo make database connection more flexible to make possible |
234 |
|
* to have different (probably named) proxy databases (besides a "main database") |
235 |
|
* @todo rename this to Data::Proxy? or split into Data::Query, Data::Result and Data::Wrapper? |
236 |
|
* @todo refactor this to a "RemoteObject" class!!! (inheriting from DesignPattern::RemoteObject) |
237 |
|
* @todo rename this to "DesignPattern::LazyRemoteProxy"??? |
238 |
* |
* |
239 |
*/ |
*/ |
|
loadModule('DesignPattern::Proxy'); |
|
|
|
|
240 |
class DesignPattern_RemoteProxy extends DesignPattern_Proxy { |
class DesignPattern_RemoteProxy extends DesignPattern_Proxy { |
241 |
|
|
242 |
var $objectId; |
var $objectId; |
250 |
logp(get_class($this) . "->new()", PEAR_LOG_INFO); |
logp(get_class($this) . "->new()", PEAR_LOG_INFO); |
251 |
global $proxy; |
global $proxy; |
252 |
|
|
253 |
|
// 2003-03-05 - modified constructor |
254 |
|
// expand objectId |
255 |
|
if (is_array($objectId)) { |
256 |
|
$options = $objectId[1]; |
257 |
|
$objectId = $objectId[0]; |
258 |
|
} |
259 |
|
|
260 |
// trace |
// trace |
261 |
//print Dumper($objectId, $options); |
//print Dumper($objectId, $options); |
262 |
|
|
265 |
$this->_init_caching(); |
$this->_init_caching(); |
266 |
$this->_init_load(); |
$this->_init_load(); |
267 |
|
|
268 |
|
//print Dumper($this); |
269 |
|
|
270 |
} |
} |
271 |
|
|
272 |
function _init_meta_options( $objectId="", $options = array() ) { |
function _init_meta_options( $objectId="", $options = array() ) { |
289 |
session_register_safe("proxy"); |
session_register_safe("proxy"); |
290 |
} |
} |
291 |
|
|
292 |
|
/** |
293 |
|
* <!-- Autodia --> |
294 |
|
* can do: (this is metadata supplied for Autodia, don't delete!) |
295 |
|
* $this->backend = new DataSource_Proxy_XMLRPC() |
296 |
|
* |
297 |
|
*/ |
298 |
|
|
299 |
if ($this->meta[remote]) { |
if ($this->meta[remote]) { |
300 |
//$this->backend = mkObject('Data::Driver::RPC::Remote', $this->meta[rpcinfo]); |
//$this->backend = mkObject('Data::Driver::RPC::Remote', $this->meta[rpcinfo]); |
301 |
$this->backend = mkObject('DataSource::Proxy::XMLRPC', $this->meta[rpcinfo]); |
$this->backend = php::mkComponent('DataSource::Proxy::XMLRPC', $this->meta[rpcinfo]); |
302 |
} |
} |
303 |
} |
} |
304 |
|
|
356 |
} |
} |
357 |
*/ |
*/ |
358 |
|
|
359 |
function getAttributes() { |
function getResult() { |
360 |
if (!$this->meta[decoded]) { |
if (!$this->meta[decoded]) { |
361 |
$this->_decode(); |
$this->_decode(); |
362 |
$this->_saveState(); |
$this->_saveState(); |