NameUtil.hpp
header file (located in the server_root
/wai/include
directory on UNIX and the server_root
\wai\include
directory on Windows NT) declares functions for registering an object implementation (associating the object with a URL) and for resolving a URL into an object reference.
This header file declares the following functions:
registerWAS
Registers an object implementation with a URL of the form http://
hostname
:
portnumber
/NameService/WAS/
object_name
.
Syntax
WAIBool DLLEXPORT
registerWAS(const char *host, const char *object_name,
CORBA::Object_ptr obj); Parameters
This method has the following parameters:
Returns
WAI_TRUE
if the object implemented was registered with the URL successfully. WAI_FALSE
if registration did not complete.
Description
When you register your object, a URL of the following format is constructed (based on the arguments you pass to the registerWAS
method) and is associated with your object:
http://hostname:portnumber/NameService/WAS/object_name
where object_name
is a unique name that you want to assign to the object instance.
After you register an object implementation with a URL, you can retrieve the object reference by resolving the URL (call the resolveURI
method).
To register an object that is not under the web application services section of the URL (NameService/WAS), call the registerObject
function instead.
resolveWAS
Resolves an object name (a string value) and returns the corresponding object reference.
Syntax
CORBA::Object_ptr DLLEXPORT
resolveWAS(const char *object_name); Parameters
This method has the following parameters:
object_name | Name of the object (a string value) |
Returns
An object reference to the object associated with the name.
Description
To register an object with a URL, call the registerWAS
method.
resolveURI
Resolves a URL and returns the corresponding object reference.
Syntax
WAIReturnType_t DLLEXPORT resolveURI(const char *host, int port,
const char *uri, CORBA::Object_ptr& obj); Parameters
This method has the following parameters:
host | Name of host machine. |
port | Port number on which the server listens. |
url | The URL that you want to resolve to an object reference. |
obj | Object reference to the object associated with the URI. |
Returns
WAISPISucess
if the object reference was retrieved successfully. WAISPIFailure
if no object reference could be determined.
Description
The URI is typically in the following format:
http://hostname:portnumber/NameService/WAS/object_name
where object_name
is a name under which the object instance is registered.
To register an object with a URL, call the registerWAS
method.
registerObject
Registers an object implementation with a URL of the form http://hostname
:portnumber
/NameService/object_name
.
Syntax
WAIReturnType_t DLLEXPORT registerObject(const char *host,
const char *url, CORBA::Object_ptr obj); Parameters
This method has the following parameters:
Returns
WAI_TRUE
if the object implemented was registered with the URL successfully. WAI_FALSE
if registration did not complete.
Description
When you register your object, a URL of the following format is constructed (based on the arguments you pass to the registerWAS
method) and is associated with your object:
http://hostname:portnumber/NameService/object_name
where object_name
is a unique name that you want to assign to the object instance.
After you register an object implementation with a URL, you can retrieve the object reference by resolving the URL (call the resolveURI
method).
To register an object under the web application services section of the URL (NameService/WAS), call the registerWAS
function instead.
putObject
For internal use only.
Syntax
WAIReturnType_t DLLEXPORT putObject(const char *url,
CORBA::Object_ptr obj,
WAIBool create_intermediate_nodes=WAI_FALSE); putContext
For internal use only.
Syntax
WAIReturnType_t DLLEXPORT
putContext(const char *url,
WAIBool create_intermediate_nodes=WAI_FALSE); Java Classes for Naming Services
Netscape Communicator 4.0 and version 3.0/3.01 of Netscape web servers contain naming services that allow you to associate a URL with an object. Once the URL is associated with the object, clients of the web server can access the object reference through the URL.
Netscape provides two Java classes for associating URLs with objects:
netscape.WAI.Naming
class provides methods for registering an object implementation (associating the object with a URL) and for resolving a URL into an object reference.
The netscape.WAI.Naming
class is part of the iiop10.jar
file in Netscape Communicator and is part of the nisb.zip
file in Netscape web servers.
Naming
class defines the following members:
Methods
register
Registers an object implementation with a URL.
Syntax
public static
void register(String url, org.omg.CORBA.Object obj); Throws
SystemException
.
Parameters
This method has the following parameters:
url | The URL that you want to register your object with |
obj | The object implementation that you want to register |
Description
The URL must have the following format:
http://hostname:portnumber/path/object_name
where object_name
is a unique name that you want to assign to the object instance.
After you register an object with a URL, you can retrieve the object reference by resolving the URL (call the resolve
method).
resolve
Resolves a URL and returns the corresponding object reference.
Syntax
public static org.omg.CORBA.Object resolve(String url);
Throws
SystemException
.
Parameters
This method has the following parameters:
url | The URL that you want to resolve to an object reference. |
Returns
An object reference to the object associated with the URL.
Description
The URL must have the following format:
http://hostname:portnumber/path/object_name
where object_name
is a name under which the object instance is registered.
To register an object with a URL, call the register
method.
netscape.WAI.NameUtil
The netscape.WAI.NameUtil
class provides methods for registering an object implementation (associating the object with a URL) and for resolving a URL into an object reference.
The netscape.WAI.NameUtil
class is part of the WAI.zip
file in Netscape web servers.
Member Summary
The NameUtil
class defines the following members:
Methods
getRootNaming
Gets the object reference of the NamingContext
object for a web server, given the server's hostname and port number.
Syntax
public static
CosNaming.NamingContext getRootNaming(String host, int port); Throws
SystemException
.
Parameters
This method has the following parameters:
host | Hostname of the machine running the web server. |
port | Port number that the web server listens to. |
NameFromString
Gets a list of name components from a given string.
Syntax
public static
CosNaming.NameHolder NameFromString(String s, String sepchar); Throws
SystemException
.
Parameters
This method has the following parameters:
s | String that you want parsed into name component |
sepchar | Character representing the separator between name components (for example, "/") |
registerObject
Registers an object implementation with a URL of the form http://hostname
:portnumber
/NameService/object_name
.
Syntax
public static
boolean registerObject(String host, String object_name, org.omg.CORBA.Object obj); Throws
CosNaming.NamingContextPackage.NotFound
CosNaming.NamingContextPackage.CannotProceed
CosNaming.NamingContextPackage.InvalidName, org.omg.CORBA.SystemException, java.lang.Exception Parameters
This method has the following parameters:
Example
try {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omb.CORBA.ORM.init(); // Initialize the BOA.
org.omg.CORBA.BOA boa = orb.BOA_init(); // Create the account manager object.
AccountManager manager =
new AccountManager("Netscape Bank"); // Export the newly created object.
boa.obj_is_ready(manager); // Register the object with a name service.
netscape.WAI.NameUtil.registerObject (InetAddress.getLocalHost().getHostName(),
"/NameService/NetscapeBank", manager);
System.out.println(manager + " is ready."); // Wait for incoming requests.
boa.impl_is_ready();
}
catch(CosNaming.NamingContextPackage.InvalidName e) {
System.err.println(e);
}
catch(CosNaming.NamingContextPackage.NotFound e) {
System.err.println(e);
}
catch(CosNaming.NamingContextPackage.CannotProceed e) {
System.err.println(e);
}
catch(org.omg.CORBA.SystemException e) {
System.err.println(e);
}
catch(java.lang.Exception e) {
System.err.println(e);
}}
registerWAS
Registers an object implementation with a URL.
Syntax
public static
boolean registerWAS(String host, String object_name,
org.omg.CORBA.Object obj); Throws
CosNaming.NamingContextPackage.NotFound
, CosNaming.NamingContextPackage.CannotProceed
, CosNaming.NamingContextPackage.InvalidName
, org.omg.CORBA.SystemException
.
Parameters
This method has the following parameters:
Returns
true
if the object implemented was registered with the URL successfully. false
if registration did not complete.
Description
When you register your object, a URL of the following format is constructed (based on the arguments you pass to the registerWAS method) and is associated with your object:
http://hostname:portnumber/NameService/WAS/object_name
where object_name
is a unique name that you want to assign to the object instance.
After you register an object implementation with a URL, you can retrieve the object reference by resolving the URL (call the resolveURI
method).
resolveURI
Resolves a URL and returns the corresponding object reference.
Syntax
public static
org.omg.CORBA.Object resolveURI(String protocol, String host,
int port, String uri); Throws
SystemException
.
Parameters
This method has the following parameters:
protocol | Protocol used to find the naming service: |
host | Name of host machine. |
port | Port number on which the server listens. |
url | The URL that you want to resolve to an object reference. |
Returns
An object reference to the object associated with the URL.
Description
The URI is typically in the following format:
http://host:port/NameService/WAS/object_name
where object_name
is a name under which the object instance is registered.
To register an object with a URL, call the registerWAS
method.
Last Updated: 12/04/97 16:13:13
Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use