Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Naming Service. 2 Naming service The CORBA COS (Common Object Services) Naming Service provides a tree- like directory for object references –It is.

Similar presentations


Presentation on theme: "1 Naming Service. 2 Naming service The CORBA COS (Common Object Services) Naming Service provides a tree- like directory for object references –It is."— Presentation transcript:

1 1 Naming Service

2 2 Naming service The CORBA COS (Common Object Services) Naming Service provides a tree- like directory for object references –It is like a filesystem provides a directory structure for files. The Naming Service provided with Java IDL is an implementation of the COS Naming Service specification.COS Naming Service specification

3 3 Naming service (cont.) A name-to-object association is called a name binding. A name binding is always defined relative to a naming context. A naming context is an object that contains a set of name bindings in which each name is unique. Different names can be bound to an object in the same or different contexts at the same time.

4 4 Naming service (cont.) To resolve a name is to determine the object associated with the name in a given context.resolve a name To bind a name is to create a name binding in a given context.bind a name A name is always resolved relative to a context - there are no absolute names.

5 5 Naming service (cont.) Because a context is like any other object, it can also be bound to a name in a naming context. Binding contexts in other contexts creates a naming graph – –a directed graph with nodes and labeled edges where the nodes are contexts.

6 6 Naming service (cont.) A naming graph allows more complex names to reference an object. Given a context in a naming graph, a sequence of names can reference an object. This sequence of names (called a compound name) –defines a path in the naming graph to navigate the resolution process.

7 7 Naming service (cont.) For an application to use the COS Naming Service, its ORB must know –the port of a host running a naming service or –have access to a stringified initial naming context for that naming service. The naming service can either be the Java IDL naming service or another COS-compliant naming service.

8 8 Naming service (cont.) Prior to running a client or a server, you will start ORBD. ORBD includes –a persistent Naming Service and –a transient Naming Service, both of which are an implementation of the COS Naming Service.

9 9 Persistent Naming Service The Persistent Naming Service provides persistence for naming contexts. –information is persistent across service shutdowns and startups, and –is recoverable in the event of a service failure. –If ORBD is restarted, the Persistent Naming Service will restore the naming context graph, so that the binding of all clients' and servers' names remains intact (persistent).

10 10 Transient Naming Service For backward compatibility, tnameserv, a Transient Naming Service shipped with older versions of the JDK, is also included in J2SE v.1.4. –A transient naming service retains naming contexts as long as it is running. –If there is a service interruption, the naming context graph is lost.

11 11 How to get the naming service? Both client and server should agree on which root naming context to use. The orb.resolve_initial_references(String name_of_service) method is used to obtain the root naming context. If you get a handle on a Naming Service by providing "NameService" as the name_of_service, you will get a persistent naming service, meaning that the naming context graph will be restored after a service failure. If you get the handle using "TNameService", you will get a transient naming service, meaning that you will need to re- obtain the root naming context using orb.resolve_initial_references(String name_of_service) if there is a service interruption.

12 12 Code to get the naming service? For example, // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

13 13 Getting naming service The string "NameService" is defined for all CORBA ORBs. When you pass in this string, the ORB returns a naming context object that is an object reference for: –The persistent name service if you are using the Naming Service that is part of ORBD. –The transient name service if you are using tnameserv.

14 14 Getting TNameService naming service in ORBD (cont.) To specify that you want to use the transient naming service with ORBD, pass in the string "TNameService". The string "TNameService" is a proprietary name. When you pass in this string, the ORB returns a naming context object that is an object reference for ORBD's transient name service.

15 15 NamingContextExt As with all CORBA object references, objRef is a generic CORBA object. To use it as a NamingContextExt object, you must narrow it to its proper type.narrow NamingContextExtHelper is an idlj -generated helper class, similar in function to HelloHelper. The ncRef object is now an org.omg.CosNaming.NamingContextExt and you can use it to access the naming service and register the server. NamingContextExt and NamingContextExtHelper are new to this release of J2SE.

16 16 NamingContextExt (cont) NamingContextExt is the extension of NamingContext.NamingContextExt It contains a set of name bindings in which each name is unique and It is part of the Interoperable Naming Service. Interoperable Naming Service Different names can be bound to an object in the same or different contexts at the same time. Using NamingContextExt, you can use URL- based names to bind and resolve. NamingContextExtHelper provides additional helper methods like narrow() that are type- specific but don't deal with business logic.

17 17 Interoperable Naming Service (INS) INS is a URL-based naming system on top of the CORBA Naming Service, as well as –a common bootstrap mechanism that lets applications share a common initial naming context. The INS provides the following features: –Capability to resolve using stringified names (e.g., a/b.c/d)stringified names –URLs for CORBA object references (corbaloc: and corbaname: formats)corbaloc: corbaname: –Standard APIs in NamingContextExt for converting between CosNames, URLs, and Strings –ORB arguments for bootstrapping (ORBInitRef and ORBDefaultInitRef)bootstrapping

18 18 Interoperable Naming Service

19 19 Interoperable Naming Service (INS) An object reference contains at least three pieces of information: –an address, – the name of the POA that created an object reference, and –an Object ID. Using INS, you can provide a URL to access the CORBA object, –which is more readable than a stringified IOR.

20 20 stringified object reference The following stringified object reference formats are allowed: 1.Interoperable Object References (IOR) –An IOR is an object reference that is understood by ORBs that can interoperate using the OMG-defined protocols GIOP and IIOP. –A client can obtain an object reference using orb.object_to_string(objRef), as shown in the Browsing the Namespace example, or as a result of an invocation on another object reference. Browsing the Namespace Note: If an IOR contains multiple profiles, the J2SE v.1.4 ORB always uses the first one.

21 21 stringified object reference (cont) 2.Human-Readable URL Formats for CORBA Object References corbaloc: The corbaloc: format is useful for CORBA client programs, and is typically used to resolve the reference using the GIOP LocateRequest or Request message.

22 22 stringified object reference (cont) corbaloc:(cont.) For example, a corbaloc: object reference might look like this: corbaloc:iiop:1.2@MyBank.com:2050/Tra derService This example show how to get an object reference for TraderService from host myBank.com on port 2050.

23 23 stringified object reference (cont) corbaname: The corbaname: format provides a mechanism for a client to bootstrap directly, and is typically used to resolve the stringified name from the root naming context. For example, a corbaname: object reference might look like this: corbaname::myBank.com:2050#Personal/schedule where myBank.com is the host, 2050 is the port.

24 24 stringified object reference (cont) corbaname: (cont.) The portion of the reference up to the hash mark (corbaname::myBank.com:2050 ) is the URL that returns the root naming context. This example provides the URL to use to: a) locate the Naming Service, and, b) resolve the name Personal/schedule from the Naming Service.

25 25 Bootstrap Options for the ORB INS provides ORB options for bootstrapping. To bootstrap a CORBA system, you must give it an object reference. The ORB can be configured to return the handle of a customized CORBA service from resolve_initial_references() using either ORBInitRef and/or ORBDefaultInitRef. For example, -ORBInitRef TraderService = corbaloc::myBank.com:2050/TraderService -ORBDefaultInitRef corbaloc:iiop:1.2:myBank.com:2050

26 26 Bootstrap Options for the ORB The order of resolution when these options are used is as follows: 1.Objects registered with register_initial_references 2.-ORBInitRef 3.-ORBDefaultInitRef 4.Proprietary Bootstrap (Sun ORBs only)

27 27 Using the Naming Service To use the Naming Service, you must first write the server and client code that finds and/or creates the namespace and/or the objects in the namespace. Before running the client and server, you must start the Naming Service and tell the client and server where to find it.start the Naming Service

28 28 Using the Naming Service The following steps loosely suggest what happens when the client and server attempt to access the Naming Service: 1.The server invokes the bind or rebind method to associate a logical name with an object reference. 2.The Naming Service adds this object reference/name binding to its namespace database. 3.A client application invokes the resolve method to obtain an object reference with this name. 4.The client uses an object reference to invoke methods on the target object.

29 29 Starting the Naming Service we use the Object Request Broker Daemon, orbd, which includes both a Persistent and a Transient Naming Service, and is available with every download of J2SE 1.4 and higher. For a caller (client, peer, or client application) to be able to invoke a method on a remote object, that caller must first obtain a reference to the remote object. Once a remote object is registered on the server, callers can look up the object by name, obtain a remote object reference, and then remotely invoke methods on the object.

30 30 Stopping the Naming Service To stop the naming service, use the relevant operating system command, such as kill on Solaris, or Ctrl+C in the DOS window in which orbd is running. Note that names registered with the naming service may disappear when the service is terminated if the naming service is transient. The Java IDL naming service will run until it is explicitly stopped.

31 31 How do I connect to a 3rd-party Naming Service from Sun's ORB? The recommended way is to use the Inter- Operable Naming Service (INS), if this option is supported by the 3rd-party Naming Service.Inter- Operable Naming Service (INS) To use the Sun ORB with another vendor's Naming Service, 1.Start the 3rd-party name server on Host and Port. 2.Pass the following argument to ORB.init(): - ORBInitRef NameService=corbaloc:iiop:1.2@:/NameServic e

32 32 How do I connect to a 3rd-party Naming Service from Sun's ORB? When you do orb.resolve_initial_references( "NameService" ), you should be able to connect to 3rd- party Name Service. If you are still not able to connect, try these troubleshooting hints: –Verify that the 3rd-party Name Service supports INS. –Verify that the host and port information is accurate. –Verify that the 3rd-party Name Service has been started successfully. –Verify that the 3rd-party Name Service supports GIOP 1.2. If not, refer to the Name Server's documentation for the correct the GIOP version, and modify the corbaloc: URL accordingly. –Determine if the 3rd-party Name Service has a different object key it uses to contact NameService. If so, refer to the Name Server's documentation.

33 33 References Naming service: URL:http://java.sun.com/j2se/1.4.2/docs/guide/idl/jidlNamin g.html Java IDL: Interoperable Naming Service (INS): URL:http://java.sun.com/j2se/1.4.2/docs/guide/idl/INStut orial.html


Download ppt "1 Naming Service. 2 Naming service The CORBA COS (Common Object Services) Naming Service provides a tree- like directory for object references –It is."

Similar presentations


Ads by Google