1 |
<? |
2 |
// --------------------------------------------------------------------------- |
3 |
// $Id: AbstractBackend.php,v 1.4 2003/03/01 04:58:02 joko Exp $ |
4 |
// --------------------------------------------------------------------------- |
5 |
// $Log: AbstractBackend.php,v $ |
6 |
// Revision 1.4 2003/03/01 04:58:02 joko |
7 |
// shifted four methods one more level to concreteness |
8 |
// |
9 |
// Revision 1.3 2003/02/28 04:16:19 joko |
10 |
// fix: getStatus now return status in bool |
11 |
// |
12 |
// Revision 1.2 2003/02/27 14:37:56 jonen |
13 |
// + added function 'saveObjectByGuid()' |
14 |
// |
15 |
// Revision 1.1 2003/02/22 16:19:38 joko |
16 |
// + initial commit |
17 |
// |
18 |
// --------------------------------------------------------------------------- |
19 |
|
20 |
|
21 |
class Application_AbstractBackend { |
22 |
|
23 |
var $rpcinfo; |
24 |
|
25 |
function Application_AbstractBackend($rpcinfo) { |
26 |
$this->rpcinfo = $rpcinfo; |
27 |
// debug |
28 |
//print Dumper($this->rpcinfo); |
29 |
} |
30 |
|
31 |
function _remote_method() { |
32 |
$arg_list = func_get_args(); |
33 |
|
34 |
$command = array_shift($arg_list); |
35 |
|
36 |
$cache_key = join("-", array(session_id(), $command, join('_', $arg_list) )); |
37 |
//print "cache_key: $cache_key<br>"; |
38 |
|
39 |
// FIXME: what if arg_list still contains more elements after doing this? |
40 |
$query = array_shift($arg_list); |
41 |
|
42 |
// -------------------- clone this & modify ---------- |
43 |
$rpcinfo = $this->rpcinfo; |
44 |
//$rpcinfo[to_latin] = 1; // FIXME! implement this into Data::Driver::RPC::Remote! |
45 |
$resultHandle = mkObject('DesignPattern::RemoteProxy', $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) ); |
46 |
$result = $resultHandle->getAttributes(); |
47 |
return $result; |
48 |
// -------------------- clone this & modify ---------- |
49 |
|
50 |
} |
51 |
|
52 |
function getStatus() { |
53 |
global $app; |
54 |
$proxy = mkObject('DesignPattern::RemoteProxy', null, array( remote => 1, rpcinfo => $app->getConfig("rpcinfo") ) ); |
55 |
return $proxy->backend->isConnected(); |
56 |
} |
57 |
|
58 |
function forceConnect() { |
59 |
global $app; |
60 |
//print Dumper($app); |
61 |
$proxy = mkObject('DesignPattern::RemoteProxy', null, array( remote => 1, rpcinfo => $app->getConfig("rpcinfo"), connect => 1 ) ); |
62 |
//print Dumper($proxy); |
63 |
$proxy->backend->ping(); |
64 |
$status_bool = $proxy->backend->isConnected(); |
65 |
$status_yesno = $status_bool ? 'yes' : 'no'; |
66 |
return $status_yesno; |
67 |
} |
68 |
|
69 |
} |
70 |
|
71 |
?> |