/usr/share/mozart/doc/apptut/node13.html is in mozart-doc 1.4.0-8ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>10 Registry Application</TITLE><LINK href="ozdoc.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node12.html#chapter.client.server.intro"><< Prev</A></TD><TD><A href="node11.html">- Up -</A></TD><TD><A href="node14.html#chapter.client.server.ozc">Next >></A></TD></TR></TABLE><DIV id="chapter.client.server.db"><H1><A name="chapter.client.server.db">10 Registry Application</A></H1><P>An example application is where the service is a shared registry. A client can connect to the registry server and add or lookup an entry. The registry is simply a dictionary.</P><H2><A name="label36">10.1 Server <CODE>db-server.oz</CODE></A></H2><P>The registry server is compiled as follows: </P><BLOCKQUOTE class="code"><CODE>ozc -x db-server.oz -o db-server.exe</CODE></BLOCKQUOTE><P> and can be started with the command line: </P><BLOCKQUOTE class="code"><CODE>db-server.exe --ticketfile </CODE><I>file</I></BLOCKQUOTE><P> Initially, it has an empty registry. </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR><SPAN class="keyword">import</SPAN> <BR> Server <SPAN class="keyword">at</SPAN> <SPAN class="string">'server.ozf'</SPAN> <BR> Application<BR><SPAN class="keyword">define</SPAN> <BR> <SPAN class="keyword">class</SPAN> <SPAN class="type">Registry</SPAN> <BR> <SPAN class="keyword">feat</SPAN> db<BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">init</SPAN> {Dictionary<SPAN class="keyword">.</SPAN>new <SPAN class="keyword">self.</SPAN>db} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">put</SPAN>(Key Val) {Dictionary<SPAN class="keyword">.</SPAN>put <SPAN class="keyword">self.</SPAN>db Key Val} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">get</SPAN>(Key Val) {Dictionary<SPAN class="keyword">.</SPAN>get <SPAN class="keyword">self.</SPAN>db Key Val} <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">meth</SPAN> <SPAN class="functionname">condGet</SPAN>(Key Default Val)<BR> {Dictionary<SPAN class="keyword">.</SPAN>condGet <SPAN class="keyword">self.</SPAN>db Key Default Val}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">end</SPAN> <BR> DB = {New Registry init}<BR> Args = {Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR> record(<BR> ticketfile(single char:<SPAN class="string">&t</SPAN> type:string optional:<SPAN class="keyword">false</SPAN>))}<BR> {Server<SPAN class="keyword">.</SPAN>start DB Args<SPAN class="keyword">.</SPAN>ticketfile}<BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P></P><H2><A name="label37">10.2 Client <CODE>db-client.oz</CODE></A></H2><P>The client loads the pickled ticket from the given URL and uses it to obtain from the server the forwarding procedure. The client can be compiled as follows: </P><BLOCKQUOTE class="code"><CODE>ozc -x db-client.oz -o db-client.exe</CODE></BLOCKQUOTE><P> and can be invoked in one of two ways: </P><BLOCKQUOTE class="code"><CODE>db-client.exe --url=</CODE><I>URL</I><CODE> --get=</CODE><I>KEY</I><CODE> <BR>db-client.exe --url=</CODE><I>URL</I><CODE> --put=</CODE><I>KEY</I><CODE> </CODE><I>VAL</I></BLOCKQUOTE><P> The first form retrieves a entry from the registry and displays it on standard output. The second form stores an entry in the registry. </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN> <BR><SPAN class="keyword">import</SPAN> <BR> Application Connection System Pickle<BR><SPAN class="keyword">define</SPAN> <BR> Args = {Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR> record(<BR> url(single type:string optional:<SPAN class="keyword">false</SPAN>)<BR> get(single type:atom)<BR> put(single type:atom))}<BR> DB = {Connection<SPAN class="keyword">.</SPAN>take {Pickle<SPAN class="keyword">.</SPAN>load Args<SPAN class="keyword">.</SPAN>url}}<BR> <SPAN class="keyword">if</SPAN> {HasFeature Args get} <SPAN class="keyword">then</SPAN> <BR> {System<SPAN class="keyword">.</SPAN>showInfo {DB get(Args<SPAN class="keyword">.</SPAN>get $)}}<BR> <SPAN class="keyword">elseif</SPAN> {HasFeature Args put} <SPAN class="keyword">then</SPAN> <BR> <SPAN class="keyword">case</SPAN> Args<SPAN class="keyword">.</SPAN>1 <SPAN class="keyword">of</SPAN> [Value] <SPAN class="keyword">then</SPAN> <BR> {DB put(Args<SPAN class="keyword">.</SPAN>put Value)}<BR> <SPAN class="keyword">else</SPAN> <BR> {System<SPAN class="keyword">.</SPAN>showError <SPAN class="string">'Missing value argument'</SPAN>}<BR> {Application<SPAN class="keyword">.</SPAN>exit 1}<BR> <SPAN class="keyword">end</SPAN> <BR> <SPAN class="keyword">else</SPAN> <BR> {System<SPAN class="keyword">.</SPAN>showError <SPAN class="string">'One of --get or --put is required'</SPAN>}<BR> {Application<SPAN class="keyword">.</SPAN>exit 1}<BR> <SPAN class="keyword">end</SPAN> <BR> {Application<SPAN class="keyword">.</SPAN>exit 0}<BR><SPAN class="keyword">end</SPAN> <BR></PRE></BLOCKQUOTE><P></P></DIV><TABLE align="center" border="0" cellpadding="6" cellspacing="6" class="nav"><TR bgcolor="#DDDDDD"><TD><A href="node12.html#chapter.client.server.intro"><< Prev</A></TD><TD><A href="node11.html">- Up -</A></TD><TD><A href="node14.html#chapter.client.server.ozc">Next >></A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif Kornstaedt</A> and <A href="http://www.ps.uni-sb.de/~schulte/">Christian Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>
|