LifespanStrategyTransient.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #include "tao/PortableServer/LifespanStrategyTransient.h"
00004 
00005 ACE_RCSID (PortableServer,
00006            Lifespan_Strategy,
00007            "LifespanStrategyTransient.cpp,v 1.7 2006/03/10 07:19:13 jtc Exp")
00008 
00009 #include "ace/OS_NS_sys_time.h"
00010 #include "ace/OS_NS_string.h"
00011 #include "tao/PortableServer/POAManager.h"
00012 #include "tao/PortableServer/Root_POA.h"
00013 #include "tao/ORB_Constants.h"
00014 #include "tao/PortableServer/Creation_Time.h"
00015 
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 namespace TAO
00019 {
00020   namespace Portable_Server
00021   {
00022     LifespanStrategyTransient::LifespanStrategyTransient () :
00023       creation_time_ (ACE_OS::gettimeofday ())
00024     {
00025     }
00026 
00027     void
00028     LifespanStrategyTransient::notify_startup (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00029     {
00030     }
00031 
00032     void
00033     LifespanStrategyTransient::notify_shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
00034     {
00035     }
00036 
00037     CORBA::Boolean
00038     LifespanStrategyTransient::is_persistent (void) const
00039     {
00040       return false;
00041     }
00042 
00043     bool
00044     LifespanStrategyTransient::validate (
00045       CORBA::Boolean is_persistent,
00046       const TAO::Portable_Server::Temporary_Creation_Time &creation_time) const
00047     {
00048       return (!is_persistent && this->creation_time_ == creation_time);
00049     }
00050 
00051     CORBA::ULong
00052     LifespanStrategyTransient::key_length (void) const
00053     {
00054       CORBA::ULong keylength = sizeof (char);
00055 
00056       #if (POA_NO_TIMESTAMP == 0)
00057         // Calculate the space required for the timestamp.
00058           keylength += TAO::Portable_Server::Creation_Time::creation_time_length ();
00059       #endif /* POA_NO_TIMESTAMP */
00060 
00061       return keylength;
00062     }
00063 
00064     void
00065     LifespanStrategyTransient::create_key (
00066       CORBA::Octet *buffer,
00067       CORBA::ULong& starting_at)
00068     {
00069       // Copy the persistence byte.
00070       buffer[starting_at] = (CORBA::Octet) this->key_type ();
00071       starting_at += this->key_type_length ();
00072 
00073       #if (POA_NO_TIMESTAMP == 0)
00074         // Then copy the timestamp for transient POAs.
00075         ACE_OS::memcpy (&buffer[starting_at],
00076                         this->creation_time_.creation_time (),
00077                        TAO::Portable_Server::Creation_Time::creation_time_length ());
00078         starting_at += TAO::Portable_Server::Creation_Time::creation_time_length ();
00079       #endif /* POA_NO_TIMESTAMP */
00080     }
00081 
00082     char
00083     LifespanStrategyTransient::key_type (void) const
00084     {
00085       return 'T';
00086     }
00087 
00088     void
00089     LifespanStrategyTransient::check_state (ACE_ENV_SINGLE_ARG_DECL)
00090     {
00091       if (this->poa_->tao_poa_manager().get_state_i () ==
00092             PortableServer::POAManager::INACTIVE)
00093       {
00094         ACE_THROW (CORBA::OBJECT_NOT_EXIST (CORBA::OMGVMCID | 4,
00095                                             CORBA::COMPLETED_NO));
00096       }
00097       else
00098       {
00099         this->poa_->tao_poa_manager().check_state (ACE_ENV_SINGLE_ARG_PARAMETER);
00100         ACE_CHECK;
00101       }
00102     }
00103 
00104     bool
00105     LifespanStrategyTransient::use_imr () const
00106     {
00107       return false;
00108     }
00109 
00110     ::PortableServer::LifespanPolicyValue
00111     LifespanStrategyTransient::type() const
00112     {
00113       return ::PortableServer::TRANSIENT;
00114     }
00115   } /* namespace Portable_Server */
00116 } /* namespace TAO */
00117 
00118 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 12:40:38 2006 for TAO_PortableServer by doxygen 1.3.6