org.objectweb.david.libs.services.CosNaming
Class NSRetriever

java.lang.Object
  |
  +--org.objectweb.david.libs.services.CosNaming.NSRetriever
All Implemented Interfaces:
Factory

public class NSRetriever
extends Object
implements Factory

NSRetriever may be used to retrieve local instances of the COS naming service. It is independent of its actual implementation. Its newObject method returns an instance of the naming service, obtained thanks to defaults set in the provided context.


Constructor Summary
NSRetriever()
          Buids a new Naming Service factory.
 
Method Summary
static NamingContext getNSDirectly(String host, short port, ORB orb)
          Returns a local interface to the name server.
static NamingContext getNSFromFile(String file, ORB orb)
          Returns a local interface to the name server.
static NamingContext getNSFromURL(String url, ORB orb)
          Returns a local interface to the name server.
 Object newObject(Context _c)
          Returns an object created using information contained in the provided context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSRetriever

public NSRetriever()
Buids a new Naming Service factory.
Method Detail

getNSFromFile

public static NamingContext getNSFromFile(String file,
                                          ORB orb)
                                   throws JonathanException,
                                          IOException
Returns a local interface to the name server.

This method tries to read the IOR of a name server from the specified file, and to build a local surrogate for the name server.

Parameters:
file - the file name;
orb - an ORB instance.
Returns:
a local interface to the name server.
Throws:
JonathanException - if the binding with the distant name server failed.
IOException - if an IO error occurred;

getNSFromURL

public static NamingContext getNSFromURL(String url,
                                         ORB orb)
                                  throws JonathanException,
                                         IOException
Returns a local interface to the name server.

This method tries to read the IOR of a name server from the specified url, and to build a local surrogate for the name server.

Parameters:
url - the name of the url corresponding to a file containing an IOR;
orb - an ORB instance.
Returns:
a local interface to the name server.
Throws:
JonathanException - if the binding with the distant name server failed.
IOException - if an IO error occurred;

getNSDirectly

public static NamingContext getNSDirectly(String host,
                                          short port,
                                          ORB orb)
                                   throws JonathanException
Returns a local interface to the name server.

This method tries to forge the IOR of a name server thanks to the specified host and port, and to build a local surrogate for the name server.

Parameters:
host - a hostname;
port - a port number;
orb - an ORB instance.
Returns:
a local interface to the name server.
Throws:
JonathanException - if the binding with the distant name server failed.

newObject

public Object newObject(Context _c)
                 throws JonathanException
Returns an object created using information contained in the provided context.

The provided context must contain either a component of name "/ORB", or a component of name "ORB", of type ORB.

It must also contain information about the method used to retrieve a reference to a name server (to be completed).

Specified by:
newObject in interface Factory
Parameters:
_c - a Context object;
Returns:
an object created using information contained in context.
Throws:
JonathanException - if something goes wrong.