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