1 <!Doctype HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <title>Implementation Repository
</title>
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.
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.
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.
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.
42 <P>The only thing we have to do for this is to register our
43 childPOA with the implementation repository.
46 orb-
>_tao_add_to_IOR_table (
"childPOA", stock_factory.in ());
48 <P> Then, we stringify all the object references as usual and
52 CORBA::String_var ior = orb-
>object_to_string (stock_factory.in ());
55 Modify the
<a href=../Server/server.cpp
>server.cpp
</a> in the simple
56 server to create the persistent child POA.
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>.
66 Compare your server.cpp with
<a href = server.cpp
>server.cpp
</a> file.
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.
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.
82 $ $TAO_ROOT/orbsvcs/ImplRepo_Service/tao_imr_locator -o implrepo.ior -d
0 -ORBobjrefstyle URL &
85 <P>Second, we start the activator, pointing it to the locator's IOR file.
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.
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.
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>
108 <p> On Windows platforms, use this command instead to register the server
109 in the implementation repository
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"
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.
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>.
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
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
136 <P> Now, execute the client as usual.
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
144 <P> For testing the persistency of the POA, let's shut down the
145 server and then run the client.
148 $tao_imr -ORBInitRef ImplRepoService=file://implrepo.ior
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
158 <H3>More Reading
</H3>
159 <P>More information on Implementation Repository is
160 <A HREF=
"../../../../../docs/implrepo/index.html">here
</A>.
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.
171 <address><a href=
"mailto:pgontla@ece.uci.edu">Priyanka Gontla
</a></address>
172 <!-- Created: Wed Mar 29 17:35:30 PST 2000 -->
174 Last modified: Sat May
19 17:
19:
07 CDT
2001