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