TAO_DLL_Parser Class Reference

Implment the parser for the DLL-style IORs. More...

#include <DLL_Parser.h>

Inheritance diagram for TAO_DLL_Parser:

Inheritance graph
[legend]
Collaboration diagram for TAO_DLL_Parser:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~TAO_DLL_Parser (void)
 The destructor.
virtual bool match_prefix (const char *ior_string) const
virtual CORBA::Object_ptr parse_string (const char *ior, CORBA::ORB_ptr orb)

Detailed Description

Implment the parser for the DLL-style IORs.

The DLL-style IORs allows applications to transparently load object implementations. The ORB can parse an IOR in the format:

DLL:Service_Name

the string_to_object() function will use ACE's Service Configurator framework to dynamically load the service named 'Service_Name' using all the normal platform-independent naming conventions and environment variable lookup rules that are normally used by ACE_DLL::open(). The ORB assumes that this service implements the TAO_Object_Loader interface, and uses that interface to create a new object implementation locally. The object reference for this local object is returned to the application.

This can be used in applications that sometimes require local object while other times they may use a remote implementation. For example, the application could be configured to use a remote Event Service or to dynamically load an Event Service implementation and use the local copy instead. The local Event Service would federate to its remote peers to work as-if a single Event Service was in place.

Such an application could be written as follows:

int main (int argc, char* argv) { CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);

CORBA::Object_var object = orb->resolve_initial_references("EventService"); // Use <object> here... }

if the application is invoked using:

$ program -ORBInitRef EventService=IOR:....

then a remote event service is used, but the application could also be invoked using:

$ program -ORBInitRef EventService=DLL:Event_Service_Loader

In this case the Event_Service implementation will be dynamically loaded without any modifications to the application code.

Definition at line 80 of file DLL_Parser.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_DLL_Parser::~TAO_DLL_Parser ( void   )  [virtual]

The destructor.

Definition at line 25 of file DLL_Parser.cpp.

00026 {
00027 }


Member Function Documentation

bool TAO_DLL_Parser::match_prefix ( const char *  ior_string  )  const [virtual]

Return true if ior_string starts with a prefix known to this IOR parser

Implements TAO_IOR_Parser.

Definition at line 31 of file DLL_Parser.cpp.

References dll_prefix, and ACE_OS::strncmp().

00032 {
00033   return (ACE_OS::strncmp (ior_string,
00034                            ::dll_prefix,
00035                            sizeof (::dll_prefix) - 1) == 0);
00036 }

CORBA::Object_ptr TAO_DLL_Parser::parse_string ( const char *  ior,
CORBA::ORB_ptr  orb 
) [virtual]

Parse the ior argument and return an object reference. The call may raise the standard system exceptions (NO_MEMORY, INV_OBJREF, etc.)

Implements TAO_IOR_Parser.

Definition at line 39 of file DLL_Parser.cpp.

References CORBA::SystemException::_tao_minor_code(), CORBA::COMPLETED_NO, TAO_ORB_Core::configuration(), TAO_Object_Loader::create_object(), dll_prefix, ACE_Dynamic_Service< TYPE >::instance(), and CORBA::ORB::orb_core().

00041 {
00042   // Skip the prefix, we know it is there because this method in only
00043   // called if <match_prefix> returns 1.
00044   const char *name =
00045     ior + sizeof (::dll_prefix) - 1;
00046 
00047   TAO_ORB_Core *oc = orb->orb_core ();
00048 
00049   TAO_Object_Loader *loader =
00050     ACE_Dynamic_Service<TAO_Object_Loader>::instance
00051       (oc->configuration(), name);
00052 
00053   if (loader == 0)
00054     {
00055       throw
00056          CORBA::INV_OBJREF
00057          (CORBA::SystemException::_tao_minor_code (
00058             0,
00059             EINVAL),
00060           CORBA::COMPLETED_NO);
00061     }
00062 
00063   return loader->create_object (orb, 0, 0);
00064 }


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:28 2010 for TAO by  doxygen 1.4.7