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)
virtual void etherealize (const PortableServer::ObjectId &oid, PortableServer::POA_ptr adapter, PortableServer::Servant servant, CORBA::Boolean cleanup_in_progress, CORBA::Boolean remaining_activations)

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 37 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 22 of file Storable_Naming_Context_Activator.cpp.

00027   : orb_(orb),
00028     factory_(factory),
00029     persistence_directory_(persistence_directory),
00030     context_size_(context_size)
00031 {
00032 }

TAO_Storable_Naming_Context_Activator::~TAO_Storable_Naming_Context_Activator  )  [virtual]
 

Definition at line 34 of file Storable_Naming_Context_Activator.cpp.

00035 {
00036   delete factory_;
00037 }


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
[virtual]
 

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

Definition at line 100 of file Storable_Naming_Context_Activator.cpp.

00106 {
00107   if (!remaining_activations)
00108     {
00109       delete servant;
00110     }
00111 }

PortableServer::Servant TAO_Storable_Naming_Context_Activator::incarnate const PortableServer::ObjectId &  oid,
PortableServer::POA_ptr  poa
[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 40 of file Storable_Naming_Context_Activator.cpp.

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

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


Member Data Documentation

size_t TAO_Storable_Naming_Context_Activator::context_size_ [private]
 

Definition at line 75 of file Storable_Naming_Context_Activator.h.

TAO_Naming_Service_Persistence_Factory* TAO_Storable_Naming_Context_Activator::factory_ [private]
 

Definition at line 73 of file Storable_Naming_Context_Activator.h.

CORBA::ORB_ptr TAO_Storable_Naming_Context_Activator::orb_ [private]
 

Definition at line 72 of file Storable_Naming_Context_Activator.h.

const ACE_TCHAR* TAO_Storable_Naming_Context_Activator::persistence_directory_ [private]
 

Definition at line 74 of file Storable_Naming_Context_Activator.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 16:16:25 2008 for TAO_CosNaming by doxygen 1.3.6