Snippets of the day – Friday, March 21, 2014

Posted on Posted in Snippets

snip2code-scissors-text

Here are some of the most recently published snippets!

Simple CORBA java server

This code shows an example of simple corba server in java.

A CORBA server needs a local ORB object.
The server instantiates an ORB and registers its servant objects so that the ORB can find the server when it receives an invocation for it.

the server is a process that instantiates one or more servant objects.
Each servant implements the interface generated by idltojava and performs the operations on that interface.

The server needs a HelloServant object, defined below.

Note the server waits for client to invoke the remote method.
For such reason, Object.wait requires HelloServer to remain alive (though quiescent) until an invocation comes from the ORB. Because of its placement in main, after an invocation completes and sayHello returns, the server will wait again.

Open the snippet

Author:    lbottaro

Simple RMI Java client

This is a simple RMI client implementation.
Here the client program obtains a stub for the registry on the server’s host, then looks up the remote object’s stub by name in the registry. Finally invokes the sayHello method on the remote object using the stub.
Here the client invokes the method exposes by Hello remote interface.

Note that if no hostname is specified, then null is used as the hostname indicating that the local host address should be used.

Open the snippet

Author:    lbottaro

Simple RMI Java server

This code shows a basic RMI server example.
A “server” is the class which has a main method that creates an instance of the remote object implementation, exports the remote object and then binds that instance to a name in a RMI registry.
Here the server implements the remote interface Hello.
The class that contains this main method could be the implementation class itself, or another class entirely.

Open the snippet

Author:    lbottaro

Leave a Reply

Your email address will not be published. Required fields are marked *