Articles Forum Examples Download Open Source
Copyright(c) 2006 by Pocomatic Software. All rights reserved.
This example is similar to the hello example, except, the Server implementation uses TIE mechanism instead of skeleton inheritance.
Greeting.idl: This is the IDL definition of the server's remote interface.
This interface only declares one operation, string hello(in string s). A client can invoke this operation to send a greeting message to server, and receive a reply greeting from server, as the return value.
server.C: This is a simple container, used to deploy the server corba application context.
client.C: This is the client application.
The client application assume the server IOR or URL is provided as the first main() argument. The string IOR or URL is converted into an CORBA object reference using ORB's string_to_object(),
and then, this reference is narrowed to the type specific client stub class, namely, the sample::Greeting_ptr.
GreetingImpl.h, GreetingImpl.C: The server's application logic bean implementation. Here, the implementation class is not subclassed from the POA skeleton, namely the POA_sample::Greeting abstract class.
setup.xml: This is the server's deployment descriptor. It describes the following server structure:
An instance of TIE class POA_sample::Greeting<GreetingImpl> is allocated, and used as the servant for activating a server object.
This object is activated on default POA (therefore, it is directly declared under <orb> element).
The object element has an uri attribute specified. This URI value (“my-server”) will be used as the key_string of this object's corbaloc URL.
The ORB node is declared with an user specified id, “my-orb”. This will let ... to generate a lazy-init'ed ORB runnner bean, with the id of “pocomatic.dispatcher:my-orb”. Initiating this runner bean (such as by calling getBean(“pocomatic.dispatcher:my-orb”) on the bean deployed factory), will start the server's request dispatching loop, after printing out all declared object URLs.
To build this example, the environment variable POCOCAPSULE_DIR should point to the PocoCapsule/C++ installed directory. Also, this example assumes an underneath ORB (e.g. VisiBroker/C++, TAO, etc.) is installed and its runtime and development environment (such as POCOCAPSULE_DIR, VBROKER_DIR or TAO_ROOT, etc. env variable) are set according to its product specification. Then, this example can be built by simply invoking gmake/make on linux/unix or nmake on windows.
· Before starting the server, make sure the LD_LIBRARY_PATH (on linux and solaris) or the PATH (on windows) environment variable is set correctly to include the ${POCOCAPSULE_DIR}/lib directory and the ${VBROKREDIR}/lib (if VisiBroker is used) or the ${TAO_ROOT}/lib directory (if TAO is used).
· Start the server:
prompt> server
By default setting, on successful startup, server will print out all declared corbaloc URLs (namely, <object> elements, with specified uri attribute). In this server, as the object element is declared with uri attribute equals to “my-server”, the print out will be, for instance:
Server is ready, with URL: corbaloc::192.168.2.3:2809/my-server
Here, the URI value “my-server” is declared in the server's deployment descriptor setup.xml file.
· Start client: The server's corbaloc URL should be used as the first main command line argument when starting the client. For instance:
prompt> client corbaloc::192.168.2.3:2809/my-server
On success, client sends a greeting message to server, and server replies one back to client. Both sides will print out the greeting message they received.