Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / docs / tutorials / Quoter / Simple / Impl-Repo / index.html
blob8c61dee7cc15d407d0b1671bf015966cae108698
1 <!Doctype HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <title>Implementation Repository</title>
5 <!-- -->
6 </head>
8 <body text = "#000000"
9 link="#000fff"
10 vlink="#ffofof"
11 bgcolor="#ffffff">
13 <h3>Implementation Repository</h3>
14 <P> In the previous example, the client must contact the server
15 at least once. If the server has been moved to a different host or
16 port, or if the server is down, binding between the client and
17 the server fails. Indirect binding through an external location
18 broker like the Implementation Repository solves this problem.
19 </P>
20 <P>An implementation repository maintains a data structure known
21 as a server table to keep track of the servers. It maintains a
22 registry of known servers, records which server is currently
23 running on which host and at which port number, and starts
24 servers on demand if they are registered to do so.
25 </P>
26 <P> When a server
27 creates a persistent reference, it sets the address and port
28 number in the profile body of the IOR to point at the
29 implementation repository that is responsible for the server.
30 When a client uses this IOR, it gets connected to the
31 implementation repository, provided the implementation
32 repository is not down. The repository decodes this IOR and uses
33 the POA name from the object key to index into its server
34 table. The repository replies with the current addressing
35 information of the actual server. The client now sends the
36 request to the actual server.
37 </P>
38 <P>In this example, let's proceed to modify our previous stock
39 factory example to support indirect binding through an
40 implementation repository.
41 </P>
42 <P>The only thing we have to do for this is to register our
43 childPOA with the implementation repository.
44 </P>
45 <PRE>
46 orb->_tao_add_to_IOR_table ("childPOA", stock_factory.in ());
47 </PRE>
48 <P> Then, we stringify all the object references as usual and
49 print them out.
50 </P>
51 <PRE>
52 CORBA::String_var ior = orb->object_to_string (stock_factory.in ());
53 </PRE>
54 <H3>Exercise</H3>
55 Modify the <a href=../Server/server.cpp>server.cpp</a> in the simple
56 server to create the persistent child POA.
57 You can use the same
58 <a href=../Quoter.idl>Quoter.idl</a>
59 <a href=../Server/Stock_i.h>Stock_i.h</a>
60 <a href=../Server/Stock_i.cpp>Stock_i.cpp</a>
61 <a href=../Server/Stock_Factory_i.h>Stock_Factory_i.h</a>
62 <a href=../Server/Stock_Factory_i.cpp>Stock_Factory_i.cpp</a>
63 <a href=../Client/client.cpp>Client.cpp</a>
64 You can use this <a href=Quoter_Simple_Impl_Repo_Server.mpc>MPC file</a>.
65 <H3>Solution</H3>
66 Compare your server.cpp with <a href = server.cpp>server.cpp</a> file.
68 <H3>Testing</H3>
69 <P>To test your changes, you need to run four programs. The first
70 step is to start up the Implementation Repository provided
71 with TAO. The Implementation Repository is split into one locator at least
72 one activator. The locator provides the interface visible
73 to the application intending to use the repository (in our case,
74 the client), while the activators do the real work of activating
75 and maintaining servers.
76 </P>
78 <P>First, we start the locator. We need to dump the IOR of the ImplRepo_Service to a file,
79 so that both the activator and the client can find the locator.
80 </P>
81 <PRE>
82 $ $TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr_locator -o implrepo.ior -d 0 -ORBobjrefstyle URL &
83 </PRE>
85 <P>Second, we start the activator, pointing it to the locator's IOR file.
86 </P>
87 <PRE>
88 $ $TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr_activator -ORBInitRef ImplRepoService=file://implrepo.ior
90 ImR Activator: Starting doc.ece.uci.edu
91 ImR Activator: Registered with ImR.
92 </PRE>
94 <P> Next, we need to register our server with the implementation
95 repository. We can use the
96 <CODE>$TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr_locator</CODE>
97 application provided with TAO to add our server to the server
98 database in the implementation repository.
99 </P>
100 <PRE>
101 $ $TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr_locator -ORBInitRef
102 ImplRepoService=file://implrepo.ior add childPOA -c
103 "./server -ORBUseIMR 1 -ORBobjrefstyle URL -ORBInitRef
104 ImplRepoService=file://implrepo.ior"
106 Successfully registered server <childPOA>
107 </PRE>
108 <p> On Windows platforms, use this command instead to register the server
109 in the implementation repository
110 </p>
111 <PRE>
112 $ACE_ROOT/bin/tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior
113 add childPOA -c "./server -ORBUseIMR 1 -ORBobjrefstyle URL
114 -ORBInitRef ImplRepoService=file://implrepo.ior"
115 </PRE>
116 <P> We specify the <CODE>-ORBInitRef</CODE> option to use the IOR in
117 the <CODE>implrepo.ior</CODE> file and the <CODE>-ORBUseIMR</CODE>
118 option to tell the server to use the IMR for notification of its
119 startup and shutdown.
120 </P>
121 <P>The next step is to generate a simple IOR for our server
122 to be used with the IMR, using the
123 <CODE>ior</CODE> option, and write it to <CODE>stock_factory.ior</CODE>.
125 </P>
126 <PRE>
127 $tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior ior
128 childPOA -f stock_factory.ior
130 corbaloc:iiop:1.1@doc.ece.uci.edu:2690/childPOA
131 </PRE>
132 <P> From now, the implementation repository is all set to keep
133 track of our server and do the needful on a method invocation
134 on our server.
135 </P>
136 <P> Now, execute the client as usual.
137 </P>
138 <PRE>
139 ./client file://stock_factory.ior MSFT RHAT
141 The price of a stock in "Microsoft, Inc." is $91
142 The price of a stock in "RedHat, Inc." is $210
143 </PRE>
144 <P> For testing the persistency of the POA, let's shut down the
145 server and then run the client.
146 </P>
147 <PRE>
148 $tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior
149 shutdown childPOA
151 Successfully shutdown server <childPOA>
153 ./client file://stock_factory.ior MSFT RHAT
155 The price of a stock in "RedHat, Inc." is $210
156 The price of a stock in "Microsoft, Inc." is $91
157 </PRE>
158 <H3>More Reading</H3>
159 <P>More information on Implementation Repository is
160 <A HREF="../../../../../docs/implrepo/index.html">here</A>.
161 </P>
162 <P>The <A HREF="http://www.triodia.com/staff/michi-henning.html">Henning</A> and <A HREF="http://www.iona.com/hyplan/vinoski/">Vinoski</A>
163 <A HREF="http://www.iona.com/hyplan/vinoski/#book">CORBA book</A> discusses POA policies in detail. Likewise,
164 the Schmidt and Vinoski
165 <A HREF="http://www.cs.wustl.edu/~schmidt/report-doc.html">columns</A> in C++ Report also include several articles about the POA. Finally,
166 the <A HREF="http://www.dre.vanderbilt.edu/~schmidt/TAO.html">TAO</A>
167 distribution includes <A HREF="../../../../../examples/POA">examples</A> that illustrate how
168 to use the POA policies.
169 </P>
170 <hr>
171 <address><a href="mailto:pgontla@ece.uci.edu">Priyanka Gontla</a></address>
172 <!-- Created: Wed Mar 29 17:35:30 PST 2000 -->
173 <!-- hhmts start -->
174 Last modified: Sat May 19 17:19:07 CDT 2001
175 <!-- hhmts end -->
176 </body>
177 </html>