1 |
<? |
2 |
/** |
3 |
* This file contains the Application::AbstractBackend class. |
4 |
* |
5 |
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
* @package org.netfrag.glib |
7 |
* @name Application::AbstractBackend |
8 |
* |
9 |
*/ |
10 |
|
11 |
|
12 |
// --------------------------------------------------------------------------- |
13 |
// $Id: AbstractBackend.php,v 1.6 2003/03/05 11:59:34 joko Exp $ |
14 |
// --------------------------------------------------------------------------- |
15 |
// $Log: AbstractBackend.php,v $ |
16 |
// Revision 1.6 2003/03/05 11:59:34 joko |
17 |
// renamed method |
18 |
// |
19 |
// Revision 1.5 2003/03/03 21:11:01 joko |
20 |
// mungled the namespaces |
21 |
// |
22 |
// Revision 1.4 2003/03/01 04:58:02 joko |
23 |
// shifted four methods one more level to concreteness |
24 |
// |
25 |
// Revision 1.3 2003/02/28 04:16:19 joko |
26 |
// fix: getStatus now return status in bool |
27 |
// |
28 |
// Revision 1.2 2003/02/27 14:37:56 jonen |
29 |
// + added function 'saveObjectByGuid()' |
30 |
// |
31 |
// Revision 1.1 2003/02/22 16:19:38 joko |
32 |
// + initial commit |
33 |
// |
34 |
// --------------------------------------------------------------------------- |
35 |
|
36 |
|
37 |
/** |
38 |
* --- Application::AbstractBackend |
39 |
* |
40 |
* @author Andreas Motl <andreas.motl@ilo.de> |
41 |
* @package org.netfrag.glib |
42 |
* @subpackage Application |
43 |
* @name Application::AbstractBackend |
44 |
* |
45 |
*/ |
46 |
class Application_AbstractBackend { |
47 |
|
48 |
var $rpcinfo; |
49 |
|
50 |
function Application_AbstractBackend($rpcinfo) { |
51 |
$this->rpcinfo = $rpcinfo; |
52 |
// debug |
53 |
//print Dumper($this->rpcinfo); |
54 |
} |
55 |
|
56 |
function _remote_method() { |
57 |
$arg_list = func_get_args(); |
58 |
|
59 |
$command = array_shift($arg_list); |
60 |
|
61 |
$cache_key = join("-", array(session_id(), $command, join('_', $arg_list) )); |
62 |
//print "cache_key: $cache_key<br>"; |
63 |
|
64 |
// FIXME: what if arg_list still contains more elements after doing this? |
65 |
$query = array_shift($arg_list); |
66 |
|
67 |
// -------------------- clone this & modify ---------- |
68 |
$rpcinfo = $this->rpcinfo; |
69 |
//$rpcinfo[to_latin] = 1; // FIXME! implement this into Data::Driver::RPC::Remote! |
70 |
$resultHandle = mkObject('DesignPattern::RemoteProxy', $cache_key, array( key => 1, command => $command, query => $query, remote => 1, rpcinfo => $rpcinfo, cache => array( db => 0, session => 1 ) ) ); |
71 |
$result = $resultHandle->getResult(); |
72 |
//print Dumper($result); exit; |
73 |
return $result; |
74 |
// -------------------- clone this & modify ---------- |
75 |
|
76 |
} |
77 |
|
78 |
function getStatus() { |
79 |
global $app; |
80 |
$proxy = mkObject('DesignPattern::RemoteProxy', null, array( remote => 1, rpcinfo => $app->getConfig("rpcinfo") ) ); |
81 |
return $proxy->backend->isConnected(); |
82 |
} |
83 |
|
84 |
function forceConnect() { |
85 |
global $app; |
86 |
//print Dumper($app); |
87 |
$proxy = mkObject('DesignPattern::RemoteProxy', null, array( remote => 1, rpcinfo => $app->getConfig("rpcinfo"), connect => 1 ) ); |
88 |
//print Dumper($proxy); |
89 |
$proxy->backend->ping(); |
90 |
$status_bool = $proxy->backend->isConnected(); |
91 |
$status_yesno = $status_bool ? 'yes' : 'no'; |
92 |
return $status_yesno; |
93 |
} |
94 |
|
95 |
} |
96 |
|
97 |
?> |