This file is indexed.

/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">&lt;&lt; Prev</A></TD><TD><A href="node11.html">- Up -</A></TD><TD><A href="node14.html#chapter.client.server.ozc">Next &gt;&gt;</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&nbsp;-x&nbsp;db-server.oz&nbsp;-o&nbsp;db-server.exe</CODE></BLOCKQUOTE><P> and can be started with the command line: </P><BLOCKQUOTE class="code"><CODE>db-server.exe&nbsp;--ticketfile&nbsp;</CODE><I>file</I></BLOCKQUOTE><P> Initially, it has an empty registry. </P><BLOCKQUOTE><PRE><SPAN class="keyword">functor</SPAN>&nbsp;<BR><SPAN class="keyword">import</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Server&nbsp;<SPAN class="keyword">at</SPAN>&nbsp;<SPAN class="string">'server.ozf'</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Application<BR><SPAN class="keyword">define</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">class</SPAN>&nbsp;<SPAN class="type">Registry</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">feat</SPAN>&nbsp;db<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">meth</SPAN>&nbsp;<SPAN class="functionname">init</SPAN>&nbsp;{Dictionary<SPAN class="keyword">.</SPAN>new&nbsp;<SPAN class="keyword">self.</SPAN>db}&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">meth</SPAN>&nbsp;<SPAN class="functionname">put</SPAN>(Key&nbsp;Val)&nbsp;{Dictionary<SPAN class="keyword">.</SPAN>put&nbsp;<SPAN class="keyword">self.</SPAN>db&nbsp;Key&nbsp;Val}&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">meth</SPAN>&nbsp;<SPAN class="functionname">get</SPAN>(Key&nbsp;Val)&nbsp;{Dictionary<SPAN class="keyword">.</SPAN>get&nbsp;<SPAN class="keyword">self.</SPAN>db&nbsp;Key&nbsp;Val}&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">meth</SPAN>&nbsp;<SPAN class="functionname">condGet</SPAN>(Key&nbsp;Default&nbsp;Val)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Dictionary<SPAN class="keyword">.</SPAN>condGet&nbsp;<SPAN class="keyword">self.</SPAN>db&nbsp;Key&nbsp;Default&nbsp;Val}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;DB&nbsp;=&nbsp;{New&nbsp;Registry&nbsp;init}<BR>&nbsp;&nbsp;&nbsp;Args&nbsp;=&nbsp;{Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;record(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ticketfile(single&nbsp;char:<SPAN class="string">&amp;t</SPAN>&nbsp;type:string&nbsp;optional:<SPAN class="keyword">false</SPAN>))}<BR>&nbsp;&nbsp;&nbsp;{Server<SPAN class="keyword">.</SPAN>start&nbsp;DB&nbsp;Args<SPAN class="keyword">.</SPAN>ticketfile}<BR><SPAN class="keyword">end</SPAN>&nbsp;<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&nbsp;-x&nbsp;db-client.oz&nbsp;-o&nbsp;db-client.exe</CODE></BLOCKQUOTE><P> and can be invoked in one of two ways: </P><BLOCKQUOTE class="code"><CODE>db-client.exe&nbsp;--url=</CODE><I>URL</I><CODE>&nbsp;--get=</CODE><I>KEY</I><CODE>&nbsp;<BR>db-client.exe&nbsp;--url=</CODE><I>URL</I><CODE>&nbsp;--put=</CODE><I>KEY</I><CODE>&nbsp;</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>&nbsp;<BR><SPAN class="keyword">import</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Application&nbsp;Connection&nbsp;System&nbsp;Pickle<BR><SPAN class="keyword">define</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;Args&nbsp;=&nbsp;{Application<SPAN class="keyword">.</SPAN>getCmdArgs<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;record(<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;url(single&nbsp;type:string&nbsp;optional:<SPAN class="keyword">false</SPAN>)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get(single&nbsp;type:atom)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;put(single&nbsp;type:atom))}<BR>&nbsp;&nbsp;&nbsp;DB&nbsp;&nbsp;&nbsp;=&nbsp;{Connection<SPAN class="keyword">.</SPAN>take&nbsp;{Pickle<SPAN class="keyword">.</SPAN>load&nbsp;Args<SPAN class="keyword">.</SPAN>url}}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">if</SPAN>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{HasFeature&nbsp;Args&nbsp;get}&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{System<SPAN class="keyword">.</SPAN>showInfo&nbsp;{DB&nbsp;get(Args<SPAN class="keyword">.</SPAN>get&nbsp;$)}}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">elseif</SPAN>&nbsp;{HasFeature&nbsp;Args&nbsp;put}&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">case</SPAN>&nbsp;Args<SPAN class="keyword">.</SPAN>1&nbsp;<SPAN class="keyword">of</SPAN>&nbsp;[Value]&nbsp;<SPAN class="keyword">then</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{DB&nbsp;put(Args<SPAN class="keyword">.</SPAN>put&nbsp;Value)}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">else</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{System<SPAN class="keyword">.</SPAN>showError&nbsp;<SPAN class="string">'Missing&nbsp;value&nbsp;argument'</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Application<SPAN class="keyword">.</SPAN>exit&nbsp;1}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">else</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{System<SPAN class="keyword">.</SPAN>showError&nbsp;<SPAN class="string">'One&nbsp;of&nbsp;--get&nbsp;or&nbsp;--put&nbsp;is&nbsp;required'</SPAN>}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Application<SPAN class="keyword">.</SPAN>exit&nbsp;1}<BR>&nbsp;&nbsp;&nbsp;<SPAN class="keyword">end</SPAN>&nbsp;<BR>&nbsp;&nbsp;&nbsp;{Application<SPAN class="keyword">.</SPAN>exit&nbsp;0}<BR><SPAN class="keyword">end</SPAN>&nbsp;<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">&lt;&lt; Prev</A></TD><TD><A href="node11.html">- Up -</A></TD><TD><A href="node14.html#chapter.client.server.ozc">Next &gt;&gt;</A></TD></TR></TABLE><HR><ADDRESS><A href="http://www.ps.uni-sb.de/~duchier/">Denys&nbsp;Duchier</A>, <A href="http://www.ps.uni-sb.de/~kornstae/">Leif&nbsp;Kornstaedt</A> and&nbsp;<A href="http://www.ps.uni-sb.de/~schulte/">Christian&nbsp;Schulte</A><BR><SPAN class="version">Version 1.4.0 (20110908185330)</SPAN></ADDRESS></BODY></HTML>