/[cvs]/nfo/php/libs/org.netfrag.glib/DesignPattern/RemoteProxy.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/DesignPattern/RemoteProxy.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by joko, Wed Mar 5 16:32:19 2003 UTC revision 1.11 by joko, Fri Mar 28 06:44:51 2003 UTC
# Line 5  Line 5 
5   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
6   * @package org.netfrag.glib   * @package org.netfrag.glib
7   * @name DesignPattern::RemoteProxy   * @name DesignPattern::RemoteProxy
  * @filesource  
8   *   *
9   *   *
10     */
11    
12    
13    /**
14   * <b>Cvs-Log:</b>   * <b>Cvs-Log:</b>
15   *   *
16   * <pre>   * <pre>
# Line 15  Line 18 
18   *    $Id$   *    $Id$
19   * -------------------------------------------------------------------------   * -------------------------------------------------------------------------
20   *    $Log$   *    $Log$
21     *    Revision 1.11  2003/03/28 06:44:51  joko
22     *    VERBOSE mode
23     *
24     *    Revision 1.10  2003/03/28 03:05:54  joko
25     *    more fancy debugging-output
26     *
27     *    Revision 1.9  2003/03/10 23:05:25  joko
28     *    + fixed metadata for phpDocumentor
29     *
30     *    Revision 1.8  2003/03/10 22:31:56  joko
31     *    + fixed metadata for phpDocumentor
32     *
33     *    Revision 1.7  2003/03/09 15:51:44  joko
34     *    + additional metadata for Autodia
35     *
36     *    Revision 1.6  2003/03/05 17:28:43  joko
37     *    updated docu (phpDocumentor testing....)
38     *
39     *    Revision 1.5  2003/03/05 17:02:22  joko
40     *    updated docu (phpDocumentor testing....)
41     *
42   *    Revision 1.4  2003/03/05 16:32:19  joko   *    Revision 1.4  2003/03/05 16:32:19  joko
43   *    updated docu (phpDocumentor testing....)   *    updated docu (phpDocumentor testing....)
44   *   *
# Line 127  loadModule('DesignPattern::Proxy'); Line 151  loadModule('DesignPattern::Proxy');
151    
152    
153  /**  /**
154   * Data::Driver::Proxy  --  Multiple stage data fetching and caching   * DesignPattern::RemoteProxy  --  Multiple stage data fetching and caching
155   *   *
156   *   *
157   * This class (Data::Driver::Proxy) provides an abstract framework   * This class (DesignPattern::RemoteProxy) provides an abstract framework
158   * for loading/saving arbitrary data from/to data storages interfaced   * for loading/saving arbitrary data from/to data storages interfaced
159   * by storage *proxy*-drivers.   * by storage *proxy*-drivers.
160   * Don't mix these up with the concrete storage *handle*-drivers   * Don't mix these up with the concrete storage *handle*-drivers
# Line 139  loadModule('DesignPattern::Proxy'); Line 163  loadModule('DesignPattern::Proxy');
163   * providing a more highlevel, consistent API making   * providing a more highlevel, consistent API making
164   * it easier for Data::Driver::Proxy to do its main work:   * it easier for Data::Driver::Proxy to do its main work:
165   *   *
166     * quote from: http://home.earthlink.net/~huston2/dp/proxy.html
167     * "A remote proxy provides a local representative for an
168     * object that resides in a different address space. This is
169     * what the "stub" code in RPC and CORBA provides."
170     *
171     *
172   * Multiple stage data fetching and caching:   * Multiple stage data fetching and caching:
173   *   *
174   * <pre>   * <pre>
# Line 191  loadModule('DesignPattern::Proxy'); Line 221  loadModule('DesignPattern::Proxy');
221   * An attempt to implement some software design patterns   * An attempt to implement some software design patterns
222   * --- RemoteProxyPattern   * --- RemoteProxyPattern
223   *   *
224     * @link http://www.agcs.com/supportv2/techpapers/patterns/papers/tutnotes/sld017.htm
225     * @link http://home.earthlink.net/~huston2/dp/proxy.html
226     * @link http://wiki.cs.uiuc.edu/PatternStories/RemoteObject
227   * @link http://c2.com/cgi-bin/wiki?ProxyPattern   * @link http://c2.com/cgi-bin/wiki?ProxyPattern
228     * @link http://c2.com/cgi-bin/wiki?LazyProxies
229   *   *
230   * @author Andreas Motl <andreas.motl@ilo.de>   * @author Andreas Motl <andreas.motl@ilo.de>
231   * @link http://www.netfrag.org/~joko/   * @link http://www.netfrag.org/~joko/
# Line 201  loadModule('DesignPattern::Proxy'); Line 235  loadModule('DesignPattern::Proxy');
235   * @link http://www.gnu.org/licenses/lgpl.txt   * @link http://www.gnu.org/licenses/lgpl.txt
236   *   *
237   * @package org.netfrag.glib   * @package org.netfrag.glib
238     * @subpackage DesignPattern
239   * @name DesignPattern::RemoteProxy   * @name DesignPattern::RemoteProxy
240   *   *
241   *   *
242   * @todo   * @todo extend options to en-/disable caching via a) session and/or b) database
243   * <pre>   *           make feature available via runtime setter-method to these options
244   *  x extend options to en-/disable caching via a) session and/or b) database   * @todo PEAR::Cache for caching purposes!!!
245   *    o make feature available via runtime setter-method to these options   * @todo refactor database access: use PEAR for this! no more 'connectdb' here!!!
246   *  o use PEAR::Cache for caching purposes!!!   * @todo make database connection more flexible to make possible
247   *  o refactor database access: use PEAR for this! no more 'connectdb' here!!!   *           to have different (probably named) proxy databases (besides a "main database")
248   *  o make database connection more flexible to make possible   * @todo rename this to Data::Proxy? or split into Data::Query, Data::Result and Data::Wrapper?
249   *      to have different (probably named) proxy databases (besides a "main database")   * @todo refactor this to a "RemoteObject" class!!! (inheriting from DesignPattern::RemoteObject)
250   *  o rename this to Data::Proxy? or split into Data::Query, Data::Result and Data::Wrapper?   * @todo rename this to "DesignPattern::LazyRemoteProxy"???
  * </pre>  
251   *   *
252   */   */
253  class DesignPattern_RemoteProxy extends DesignPattern_Proxy {  class DesignPattern_RemoteProxy extends DesignPattern_Proxy {
# Line 268  class DesignPattern_RemoteProxy extends Line 302  class DesignPattern_RemoteProxy extends
302        session_register_safe("proxy");        session_register_safe("proxy");
303      }        }  
304    
305        /**
306         * <!-- Autodia -->
307         * can do: (this is metadata supplied for Autodia, don't delete!)
308         *  $this->backend = new DataSource_Proxy_XMLRPC()
309         *
310         */
311    
312      if ($this->meta[remote]) {      if ($this->meta[remote]) {
313        //$this->backend = mkObject('Data::Driver::RPC::Remote', $this->meta[rpcinfo]);        //$this->backend = mkObject('Data::Driver::RPC::Remote', $this->meta[rpcinfo]);
314        $this->backend = php::mkComponent('DataSource::Proxy::XMLRPC', $this->meta[rpcinfo]);        $this->backend = php::mkComponent('DataSource::Proxy::XMLRPC', $this->meta[rpcinfo]);
# Line 441  class DesignPattern_RemoteProxy extends Line 482  class DesignPattern_RemoteProxy extends
482            logp(get_class($this) . "->_loadRemote: argument 'guid' requires 'classname'", PEAR_LOG_WARNING);            logp(get_class($this) . "->_loadRemote: argument 'guid' requires 'classname'", PEAR_LOG_WARNING);
483            return;            return;
484          }          }
485            logp(get_class($this) . "->_loadRemote: getObjectByGuid", PEAR_LOG_DEBUG);
486          $args = array( guid => $this->objectId, classname => $this->meta[classname] );          $args = array( guid => $this->objectId, classname => $this->meta[classname] );
487          $result = $this->backend->send('getObjectByGuid', $args );          $result = $this->backend->send('getObjectByGuid', $args );
488    
# Line 449  class DesignPattern_RemoteProxy extends Line 491  class DesignPattern_RemoteProxy extends
491            logp(get_class($this) . "->_loadRemote: argument 'oid' requires valid objectId", PEAR_LOG_WARNING);            logp(get_class($this) . "->_loadRemote: argument 'oid' requires valid objectId", PEAR_LOG_WARNING);
492            return;            return;
493          }          }
494            logp(get_class($this) . "->_loadRemote: getObject", PEAR_LOG_DEBUG);
495          $result = $this->backend->send('getObject', $this->objectId);          $result = $this->backend->send('getObject', $this->objectId);
496    
497        } elseif ($this->meta[key]) {        } elseif ($this->meta[key]) {
# Line 462  class DesignPattern_RemoteProxy extends Line 505  class DesignPattern_RemoteProxy extends
505            return;            return;
506          }          }
507          */          */
508            //logp(get_class($this) . "->_loadRemote: $this->meta[command](" . join(' ', $this->meta[query]) . ")", PEAR_LOG_DEBUG);
509            //print Dumper(array($this->meta[command], $this->meta[query]));
510          $result = $this->backend->send($this->meta[command], $this->meta[query]);          $result = $this->backend->send($this->meta[command], $this->meta[query]);
511                    
512        }        }
513    
514        //print "result: " . dumpVar($result) . "<br>";
515    
516        $status = $this->backend->getStatus();
517        //print Dumper($status);
518            
519      if ($result) {      if (constants::get('VERBOSE')) {
520        //print "result: " . dumpVar($result) . "<br>";        $style = html_style("text/css", '.boxlabel_yellow { color: yellow; font-weight:bold; }');
521        if (count($result) == 0) { return; }        $statusbox = html_div();
522          $statusbox->set_style('background: #558856; border: 2px black groove; width:640px; padding:10px; margin:40px;');
523          $statusbox->add( html_span('boxlabel_yellow', "Connected:"), $status[connected], html_br() );
524          foreach ($status[errors] as $error) {
525            $statusbox->add( html_span('boxlabel_yellow', "Error($error[code]):"), $error[message], html_br() );
526          }
527        }
528        
529        if (is_array($result)) {
530          $good = 1;
531        } else {
532          $message = get_class($this) . "->_loadRemote: Error while trying to talk to remote side. Please check wire, socket or api.";
533          logp($message, PEAR_LOG_CRIT);
534          if (constants::get('VERBOSE')) {
535            $statusbox->add( html_span('boxlabel_yellow', "Critical:"), $message, html_br() );
536          }
537        }
538    
539        if ($good && sizeof($result)) {
540                
541        // FIXME: this is dangerous!        // FIXME: this is dangerous!
542        if ($_GET[debug]) {        if ($_GET[debug]) {
# Line 483  class DesignPattern_RemoteProxy extends Line 549  class DesignPattern_RemoteProxy extends
549        $this->_saveProxy();        $this->_saveProxy();
550        //print "oid: $this->objectId<br>";        //print "oid: $this->objectId<br>";
551        $this->flushState();        $this->flushState();
552        
553      } else {      } else {
554        //print "Error in _loadRemote!!!<br>";        if (constants::get('VERBOSE')) {
555        logp(get_class($this) . "->_loadRemote: error while trying to talk to remote side", PEAR_LOG_CRIT);          print $style->render();
556            print $statusbox->render();
557          } else {
558            foreach ($status[errors] as $error) {
559              print Dumper($error);
560            }
561          }
562        
563      }      }
564            
565    }    }

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

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