Niclas Eklund nick@REDACTED
Thu Apr 20 10:12:12 CEST 2000

On 20 Apr 2000, Luke Gorrie wrote:
> Michael Skowronski <mskow@REDACTED> writes:
> > Hello,
> > 
> > does anyone have a simple example of how to connect a java visibroker
> > client to an orber service?
> I have, though I used JacORB rather than
> Visibroker.
> Cheers,
> Luke


Another way to setup a connection is to use InitialReferences.idl and
follow the example in Orber user's guide 9, but don't compile
cos_naming.idl (included since the example is based on OrbixWeb2.*, which
didn't support 'pragma prefix' until 3.*). The code below illustrates a
OrbixWeb3.2 client:

import org.omg.CosNaming.*;
import org.omg.CORBA.*;
import Orber.InitialReference.*;
import Orber.InitialReferences.*;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.ORB.*;

public class Client 
  public static void main(String args[])
      NamingContext nsContext;
      org.omg.CORBA.Object nsRef, objRef, initRef;
      Orber.InitialReference ir    = new Orber.InitialReference();
      Orber.InitialReferences init = null;

      String  srvHost   = new String(args[0]);
      Integer srvPort   = new Integer(args[1]);

	  ORB orb   = ORB.init(args, null);

          //The next line equals "reading IOR from file" (see Luke's link)
	  String s  = ir.stringified_ior(srvHost, srvPort.intValue());

	  initRef   = orb.string_to_object(s);
	  init      = Orber.InitialReferencesHelper.narrow(initRef);
	  // Fetch name service reference.
	  nsRef     = init.get("NameService");	  
	  nsContext = NamingContextHelper.narrow(nsRef);

          // Now you can use 'resolve' etc and access objects

... cut ...

The OMG published two preliminary Interoperable-NamingServices; Orber
supports one (IBM's). Unfortunately ;-), the next CORBA specification
contains the one we're currently not supporting. The example above, is
based on the IBM-interoperable naming service (also supported by
JavaIDL, and ...?!).

IMHO, if you intend to start a number of servers, it's easier to just
store just one reference, i.e., the NameService. 

You should also consult:

* Orber User's Guide, 10, "Orber Stubs/Skeletons"

* Orber Refernce Manual, "Module_Interface"

These chapters includes example code on how to implement your
'Module_Interface_impl.erl' file, e.g., functions which must be
implemented. Depending on what type of server you intend to implement, it
may be a good idea to use oe_create_link/2 or oe_create/2. The second
argument, 'Options', is usefull (and more features to come :-).


More information about the erlang-questions mailing list