incutio.com/xmlrpc/IXR_Library.inc.php.txt
We are creating a time server from which we can get Greenwich Mean Time (GMT):
include('IXR_Library.inc.php');
function gmtTime() {
return gmdate("F, d Y H:i:s");
}
$server = new IXR_Server(array(
'time.getGMTTime' => 'gmtTime',
));
?>
Well very simple. We just create some methods and then map them to the XML RPC
server. Now let us see how we can code for clients:
include('IXR_Library.inc.php');
$client = new IXR_Client('http://localhost/proxy/server.php');
if (!$client->query('time.getGMTTime'))
{
die('Something went wrong - '.$client->getErrorCode().' :
'.$client->getErrorMessage());
}
echo ($client->getResponse());
?>
Design Patterns
[ 88 ]
If you place the server in your web server (here localhost) document, the root in a
folder named proxy and then access the client, you will get the following output:
March, 28 2007 16:13:20
That's it! This is how Proxy pattern works and gives interface to remote objects for
local applications.
Decorator Pattern
Decorator pattern is an important problem-solving approach introduced by GoF
in their legendary design pattern book. Using this pattern you can add additional
functionalities in an existing object without extending an object.
Pages:
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107