/[cvs]/nfo/php/libs/org.netfrag.flib/Application/RPC/ProxyObject.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.flib/Application/RPC/ProxyObject.php

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

revision 1.1 by joko, Sun Dec 1 17:23:58 2002 UTC revision 1.4 by joko, Thu Dec 12 02:46:31 2002 UTC
# Line 3  Line 3 
3  ##    $Id$  ##    $Id$
4  ##    -------------------------------------------------------------------------------------  ##    -------------------------------------------------------------------------------------
5  ##    $Log$  ##    $Log$
6    ##    Revision 1.4  2002/12/12 02:46:31  joko
7    ##    + state (session) gets flushed when data was successfully loaded from remote side
8    ##    + fixed _loadBackend
9    ##    + fixed flushState
10    ##
11    ##    Revision 1.3  2002/12/06 04:12:54  joko
12    ##    + replaced 'xyzCache' through 'xyzProxy'
13    ##    + function store(...)
14    ##
15    ##    Revision 1.2  2002/12/05 21:44:09  joko
16    ##    + debugging
17    ##
18  ##    Revision 1.1  2002/12/01 17:23:58  joko  ##    Revision 1.1  2002/12/01 17:23:58  joko
19  ##    + initial check-in  ##    + initial check-in
20  ##  ##
# Line 69  class ProxyObject { Line 81  class ProxyObject {
81      if ($objectId) {      if ($objectId) {
82        $this->objectId = $objectId;        $this->objectId = $objectId;
83        $this->load();        $this->load();
84        //$this->_saveCache();        //$this->_saveProxy();
85      }      }
86    }    }
87    
88    function load() {    function load() {
89      if (!$this->_loadState()) {      if (!$this->_loadState()) {
90        if (!$this->_loadCache()) {        if (!$this->_loadProxy()) {
91          $this->_loadBackend();          $this->_loadBackend();
92        }        }
93      }      }
# Line 94  class ProxyObject { Line 106  class ProxyObject {
106    
107    function flush() {    function flush() {
108      $this->flushState();      $this->flushState();
109      $this->flushCache();      $this->flushProxy();
110    }          }      
111    
112    function _commit() {    function _commit() {
113      $this->_saveBackend($this->attributes);      $this->_saveBackend($this->attributes);
114      $this->flushState();      $this->flushState();
115      $this->flushCache();      $this->flushProxy();
116    }      }  
117    
118    
# Line 109  class ProxyObject { Line 121  class ProxyObject {
121    function _create() {    function _create() {
122      $this->_createBackend($this->attributes);      $this->_createBackend($this->attributes);
123      $this->flushState();      $this->flushState();
124      $this->flushCache();      $this->flushProxy();
125    }      }  
126    */    */
127    
# Line 125  class ProxyObject { Line 137  class ProxyObject {
137      $this->attributes = $data;      $this->attributes = $data;
138    }    }
139    
140    function flushCache() {    function flushProxy() {
141          connectdb();          connectdb();
142      $sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'";      $sql = "DELETE FROM f_proxy WHERE oid='$this->objectId'";
143      send_sql($sql);      send_sql($sql);
# Line 134  class ProxyObject { Line 146  class ProxyObject {
146    function flushState() {    function flushState() {
147      global $proxy;      global $proxy;
148      unset($proxy[$this->objectId]);      unset($proxy[$this->objectId]);
149        $this->meta[decoded] = 0;
150    }    }
151    
152    function _loadState() {    function _loadState() {
# Line 155  class ProxyObject { Line 168  class ProxyObject {
168      // TODO: throw exception-message back to user if operation fails      // TODO: throw exception-message back to user if operation fails
169    }    }
170    
171    function _loadCache() {    function _loadProxy() {
172      logp(get_class($this) . "->_loadCache()", LOG_DEBUG);      logp(get_class($this) . "->_loadProxy()", LOG_DEBUG);
173      connectdb();      connectdb();
174      $sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'";      $sql = "SELECT payload FROM f_proxy WHERE oid='$this->objectId'";
175      if ($res = send_sql($sql)) {      if ($res = send_sql($sql)) {
# Line 169  class ProxyObject { Line 182  class ProxyObject {
182      }      }
183    }    }
184        
185    function _saveCache() {    // TODO: use PEAR here
186      logp(get_class($this) . "->_saveCache()", LOG_DEBUG);    function _saveProxy() {
187        logp(get_class($this) . "->_saveProxy()", LOG_DEBUG);
188          connectdb();          connectdb();
189          if ($this->payload) {          if ($this->payload) {
190        //$sql = "INSERT INTO f_proxy SET payload='$this->payload' WHERE oid='$this->objectId'";        //$sql = "INSERT INTO f_proxy SET payload='$this->payload' WHERE oid='$this->objectId'";
# Line 186  class ProxyObject { Line 200  class ProxyObject {
200      logp(get_class($this) . "->_loadBackend()", LOG_DEBUG);      logp(get_class($this) . "->_loadBackend()", LOG_DEBUG);
201      // TODO: test backend for reachability first (eventually cache this information and "reset" it by another party)      // TODO: test backend for reachability first (eventually cache this information and "reset" it by another party)
202      if ($result = $this->backend->call('getObject', $this->objectId)) {      if ($result = $this->backend->call('getObject', $this->objectId)) {
203        //print dumpVar($result);        //print "result: " . dumpVar($result) . "<br>";
204        if (count($result) == 0) { return; }        if (count($result) == 0) { return; }
205        $encoder = new TextEncode($result);        $encoder = new TextEncode($result);
206        $encoder->toISO();        $encoder->toISO();
# Line 194  class ProxyObject { Line 208  class ProxyObject {
208          print dumpVar($result);          print dumpVar($result);
209        }        }
210        $this->payload = serialize($result);        $this->payload = serialize($result);
211        $this->_saveCache();        $this->_saveProxy();
212          //print "oid: $this->objectId<br>";
213          $this->flushState();
214      }      }
215    }    }
216        
# Line 213  class ProxyObject { Line 229  class ProxyObject {
229        $this->meta[decoded] = 1;        $this->meta[decoded] = 1;
230      }      }
231    }    }
232      
233      function store($struct) {
234        $this->payload = serialize($struct);
235        $this->_saveProxy();
236      }
237    
238  }  }
239    

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

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