TAO_Storable_Naming_Context_Activator Class Reference

#include <Storable_Naming_Context_Activator.h>

Collaboration diagram for TAO_Storable_Naming_Context_Activator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Storable_Naming_Context_Activator (CORBA::ORB_ptr orb, TAO_Naming_Service_Persistence_Factory *factory, const ACE_TCHAR *persistence_directory, size_t context_size)
virtual ~TAO_Storable_Naming_Context_Activator ()
virtual PortableServer::Servant incarnate (const PortableServer::ObjectId &oid, PortableServer::POA_ptr poa) throw (CORBA::SystemException, PortableServer::ForwardRequest)
virtual void etherealize (const PortableServer::ObjectId &oid, PortableServer::POA_ptr adapter, PortableServer::Servant servant, CORBA::Boolean cleanup_in_progress, CORBA::Boolean remaining_activations) throw (CORBA::SystemException)

Private Attributes

CORBA::ORB_ptr orb_
TAO_Naming_Service_Persistence_Factoryfactory_
const ACE_TCHARpersistence_directory_
size_t context_size_

Detailed Description

A servant activator to be use with a TAO_Storable_Naming_Context. Permits contexts saved to disk in one naming service process to be "lazily" created on demand in other processes by reading the context file off disk only when a request to the context is made.

Definition at line 40 of file Storable_Naming_Context_Activator.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Storable_Naming_Context_Activator::TAO_Storable_Naming_Context_Activator CORBA::ORB_ptr  orb,
TAO_Naming_Service_Persistence_Factory factory,
const ACE_TCHAR persistence_directory,
size_t  context_size
 

The constructor takes arguments needed to create a TAO_Storable_Naming_Context and TAO_Naming_Context on demand.

Definition at line 25 of file Storable_Naming_Context_Activator.cpp.

00030   : orb_(orb),
00031     factory_(factory),
00032     persistence_directory_(persistence_directory),
00033     context_size_(context_size)
00034 {
00035 }

TAO_Storable_Naming_Context_Activator::~TAO_Storable_Naming_Context_Activator  )  [virtual]
 

Definition at line 37 of file Storable_Naming_Context_Activator.cpp.

00038 {
00039   delete factory_;
00040 }


Member Function Documentation

void TAO_Storable_Naming_Context_Activator::etherealize const PortableServer::ObjectId &  oid,
PortableServer::POA_ptr  adapter,
PortableServer::Servant  servant,
CORBA::Boolean  cleanup_in_progress,
CORBA::Boolean  remaining_activations
throw (CORBA::SystemException) [virtual]
 

Used by the POA to delete the servant created from a call to incarnate.

Definition at line 109 of file Storable_Naming_Context_Activator.cpp.

00117 {
00118   if (!remaining_activations) {
00119     delete servant;
00120   }
00121 }

PortableServer::Servant TAO_Storable_Naming_Context_Activator::incarnate const PortableServer::ObjectId &  oid,
PortableServer::POA_ptr  poa
throw (CORBA::SystemException, PortableServer::ForwardRequest) [virtual]
 

Create a TAO_Storable_Naming_Context and TAO_Naming_Context on demand if a request to a naming context CORBA reference is made and the servant implementing this reference does not yet exist.

Definition at line 43 of file Storable_Naming_Context_Activator.cpp.

References ACE_ASSERT, ACE_CHECK_RETURN, ACE_NEW_THROW_EX, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, ACE_TEXT_CHAR_TO_TCHAR, ACE_THROW_RETURN, ACE_TString, TAO_Storable_Base::exists(), and ACE_Auto_Basic_Ptr< X >::release().

00049 {
00050 
00051   // Make sure complete initialization has been done
00052   ACE_ASSERT (factory_ != 0);
00053 
00054   CORBA::String_var poa_id = PortableServer::ObjectId_to_string (oid);
00055 
00056   // The approached used is to simply verify that there is a
00057   // persistence element that exists that corresponds to the
00058   // poa_id. If so, an empty context is created. Later, when the
00059   // context is accessed it will be determined that the contents of
00060   // the persistence elment needs to be read in.
00061 
00062   // Does this already exist on disk?
00063   ACE_TString file_name(persistence_directory_);
00064   file_name += ACE_TEXT("/");
00065   file_name += ACE_TEXT_CHAR_TO_TCHAR(poa_id.in());
00066   TAO_Storable_Base * fl = factory_->create_stream(ACE_TEXT_ALWAYS_CHAR(file_name.c_str()), ACE_TEXT("rw"));
00067   if (!fl->exists()) {
00068     ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (),
00069                       0);
00070   }
00071 
00072   // Store the stub we will return here.
00073   CosNaming::NamingContext_var result (CosNaming::NamingContext::_nil());
00074 
00075   // Put together a servant for the new Naming Context.
00076 
00077   TAO_Storable_Naming_Context *context_impl = 0;
00078   ACE_NEW_THROW_EX (context_impl,
00079                     TAO_Storable_Naming_Context (orb_,
00080                                                  poa,
00081                                                  poa_id.in (),
00082                                                  factory_,
00083                                                  persistence_directory_,
00084                                                  context_size_),
00085                                                  CORBA::NO_MEMORY ());
00086   ACE_CHECK_RETURN (0);
00087 
00088   // Put <context_impl> into the auto pointer temporarily, in case next
00089   // allocation fails.
00090   ACE_Auto_Basic_Ptr<TAO_Storable_Naming_Context> temp (context_impl);
00091 
00092   TAO_Naming_Context *context = 0;
00093   ACE_NEW_THROW_EX (context,
00094                     TAO_Naming_Context (context_impl),
00095                     CORBA::NO_MEMORY ());
00096   ACE_CHECK_RETURN (0);
00097 
00098   // Let <implementation> know about it's <interface>.
00099   context_impl->interface (context);
00100 
00101   // Release auto pointer, and start using reference counting to
00102   // control our servant.
00103   temp.release ();
00104 
00105   return context;
00106 }


Member Data Documentation

size_t TAO_Storable_Naming_Context_Activator::context_size_ [private]
 

Definition at line 83 of file Storable_Naming_Context_Activator.h.

TAO_Naming_Service_Persistence_Factory* TAO_Storable_Naming_Context_Activator::factory_ [private]
 

Definition at line 81 of file Storable_Naming_Context_Activator.h.

CORBA::ORB_ptr TAO_Storable_Naming_Context_Activator::orb_ [private]
 

Definition at line 80 of file Storable_Naming_Context_Activator.h.

const ACE_TCHAR* TAO_Storable_Naming_Context_Activator::persistence_directory_ [private]
 

Definition at line 82 of file Storable_Naming_Context_Activator.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:57:51 2006 for TAO_CosNaming by doxygen 1.3.6