ServantRetentionStrategyNonRetain.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    ServantRetentionStrategyNonRetain.cpp
00006  *
00007  *  $Id: ServantRetentionStrategyNonRetain.cpp 81663 2008-05-09 12:43:47Z johnnyw $
00008  *
00009  */
00010 //=============================================================================
00011 
00012 #include "tao/PortableServer/ServantRetentionStrategyNonRetain.h"
00013 #include "tao/PortableServer/Non_Servant_Upcall.h"
00014 #include "tao/PortableServer/Servant_Upcall.h"
00015 #include "tao/PortableServer/POA_Current_Impl.h"
00016 #include "tao/PortableServer/Root_POA.h"
00017 #include "tao/PortableServer/Servant_Base.h"
00018 #include "tao/debug.h"
00019 
00020 ACE_RCSID (PortableServer,
00021            ServantRetentionStrategyNonRetain,
00022            "$Id: ServantRetentionStrategyNonRetain.cpp 81663 2008-05-09 12:43:47Z johnnyw $")
00023 
00024 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 namespace TAO
00027 {
00028   namespace Portable_Server
00029   {
00030     ServantRetentionStrategyNonRetain::ServantRetentionStrategyNonRetain (void) :
00031       poa_ (0)
00032     {
00033     }
00034 
00035     void
00036     ServantRetentionStrategyNonRetain::strategy_init (TAO_Root_POA *poa)
00037     {
00038       poa_ = poa;
00039     }
00040 
00041     void
00042     ServantRetentionStrategyNonRetain::strategy_cleanup (void)
00043     {
00044       poa_ = 0;
00045     }
00046 
00047     void
00048     ServantRetentionStrategyNonRetain::deactivate_object (
00049       const PortableServer::ObjectId &/*id*/)
00050     {
00051       // When using Non_Retain we don't have an active object map and we just
00052       // can't deactivate any object
00053       throw PortableServer::POA::WrongPolicy ();
00054     }
00055 
00056     PortableServer::Servant
00057     ServantRetentionStrategyNonRetain::find_servant (
00058       const PortableServer::ObjectId &/*system_id*/)
00059     {
00060       throw PortableServer::POA::WrongPolicy ();
00061     }
00062 
00063     PortableServer::ObjectId *
00064     ServantRetentionStrategyNonRetain::system_id_to_object_id (
00065       const PortableServer::ObjectId &system_id)
00066     {
00067       // The system id is the id (and no conversion/transformation is
00068       // needed).
00069       PortableServer::ObjectId *id = 0;
00070       ACE_NEW_THROW_EX (id,
00071                         PortableServer::ObjectId (system_id),
00072                         CORBA::NO_MEMORY ());
00073 
00074       return id;
00075     }
00076 
00077     PortableServer::Servant
00078     ServantRetentionStrategyNonRetain::user_id_to_servant (
00079       const PortableServer::ObjectId &/*id*/)
00080     {
00081       throw PortableServer::POA::WrongPolicy ();
00082     }
00083 
00084     CORBA::Object_ptr
00085     ServantRetentionStrategyNonRetain::id_to_reference (
00086       const PortableServer::ObjectId &/*id*/,
00087       bool /*indirect*/)
00088     {
00089       throw PortableServer::POA::WrongPolicy ();
00090     }
00091 
00092     TAO_SERVANT_LOCATION
00093     ServantRetentionStrategyNonRetain::servant_present (
00094       const PortableServer::ObjectId &/*system_id*/,
00095       PortableServer::Servant &/*servant*/)
00096     {
00097       return TAO_SERVANT_NOT_FOUND;
00098     }
00099 
00100     PortableServer::Servant
00101     ServantRetentionStrategyNonRetain::find_servant (
00102       const PortableServer::ObjectId &system_id,
00103       TAO::Portable_Server::Servant_Upcall &servant_upcall,
00104       TAO::Portable_Server::POA_Current_Impl &poa_current_impl)
00105     {
00106       // We have the NON_RETAIN policy, user id is the system id.
00107 
00108       // Smartly copy all the data; <poa_current_impl.object_id_> does
00109       // not own the data.
00110       poa_current_impl.replace_object_id (system_id);
00111 
00112       servant_upcall.user_id (&system_id);
00113 
00114       return 0;
00115     }
00116 
00117     int
00118     ServantRetentionStrategyNonRetain::find_servant_priority (
00119         const PortableServer::ObjectId &/*system_id*/,
00120         CORBA::Short &/*priority*/)
00121     {
00122       return -1;
00123     }
00124 
00125     int
00126     ServantRetentionStrategyNonRetain::is_servant_in_map (
00127       PortableServer::Servant /*servant*/,
00128       bool &/*wait_occurred_restart_call*/)
00129     {
00130       return 0;
00131     }
00132 
00133     CORBA::ULong
00134     ServantRetentionStrategyNonRetain::waiting_servant_deactivation (void) const
00135     {
00136       return 0;
00137     }
00138 
00139     void
00140     ServantRetentionStrategyNonRetain::deactivate_all_objects (void)
00141     {
00142     }
00143 
00144     PortableServer::ObjectId *
00145     ServantRetentionStrategyNonRetain::servant_to_user_id (
00146       PortableServer::Servant /*servant*/)
00147     {
00148       throw PortableServer::POA::WrongPolicy ();
00149     }
00150 
00151     CORBA::Object_ptr
00152     ServantRetentionStrategyNonRetain::servant_to_reference (
00153       PortableServer::Servant /*servant*/)
00154     {
00155       throw PortableServer::POA::WrongPolicy ();
00156     }
00157 
00158     PortableServer::ObjectId *
00159     ServantRetentionStrategyNonRetain::activate_object (
00160       PortableServer::Servant /*servant*/,
00161       CORBA::Short /*priority*/,
00162       bool &/*wait_occurred_restart_call*/)
00163     {
00164       throw PortableServer::POA::WrongPolicy ();
00165     }
00166 
00167 #if !defined (CORBA_E_MICRO)
00168     void
00169     ServantRetentionStrategyNonRetain::activate_object_with_id (
00170       const PortableServer::ObjectId &/*id*/,
00171       PortableServer::Servant /*servant*/,
00172       CORBA::Short /*priority*/,
00173       bool &/*wait_occurred_restart_call*/)
00174     {
00175       throw PortableServer::POA::WrongPolicy ();
00176     }
00177 #endif
00178 
00179     CORBA::Object_ptr
00180     ServantRetentionStrategyNonRetain::create_reference (
00181       const char *intf,
00182       CORBA::Short priority)
00183     {
00184       // This operation creates an object reference that encapsulates a
00185       // POA-generated Object Id value and the specified interface
00186       // repository id. This operation does not cause an activation to
00187       // take place. The resulting reference may be passed to clients, so
00188       // that subsequent requests on those references will cause the
00189       // appropriate servant manager to be invoked, if one is
00190       // available. The generated Object Id value may be obtained by
00191       // invoking POA::reference_to_id with the created reference.
00192 
00193       PortableServer::ObjectId_var system_id;
00194       PortableServer::ObjectId user_id;
00195 
00196       // Otherwise, it is the NON_RETAIN policy.  Therefore, any ol'
00197       // object id will do (even an empty one).
00198       PortableServer::ObjectId *sys_id = 0;
00199       ACE_NEW_THROW_EX (sys_id,
00200                         PortableServer::ObjectId,
00201                         CORBA::NO_MEMORY ());
00202 
00203       system_id = sys_id;
00204 
00205       // User id is the same as system id.
00206       user_id = system_id.in ();
00207 
00208       // Remember params for potentially invoking <key_to_object> later.
00209       this->poa_->key_to_object_params_.set (system_id,
00210                                              intf,
00211                                              0,
00212                                              1,
00213                                              priority,
00214                                              true);
00215 
00216       return this->poa_->invoke_key_to_object_helper_i (intf, user_id);
00217     }
00218 
00219 #if !defined (CORBA_E_MICRO)
00220     CORBA::Object_ptr
00221     ServantRetentionStrategyNonRetain::create_reference_with_id (
00222       const PortableServer::ObjectId &oid,
00223       const char *intf,
00224       CORBA::Short priority)
00225     {
00226       // This operation creates an object reference that encapsulates the
00227       // specified Object Id and interface repository Id values. This
00228       // operation does not cause an activation to take place.  The
00229       // resulting reference may be passed to clients, so that subsequent
00230       // requests on those references will cause the object to be
00231       // activated if necessary, or the default servant used, depending on
00232       // the applicable policies.
00233 
00234       PortableServer::Servant servant = 0;
00235       PortableServer::ObjectId_var system_id;
00236 
00237       // Otherwise, it is the NON_RETAIN policy.  Therefore, user id
00238       // is the same as system id.
00239       PortableServer::ObjectId *sys_id = 0;
00240       ACE_NEW_THROW_EX (sys_id,
00241                         PortableServer::ObjectId (oid),
00242                         CORBA::NO_MEMORY ());
00243 
00244       system_id = sys_id;
00245 
00246       // Remember params for potentially invoking <key_to_object> later.
00247       this->poa_->key_to_object_params_.set (system_id,
00248                                              intf,
00249                                              servant,
00250                                              1,
00251                                              priority,
00252                                              true);
00253 
00254       return this->poa_->invoke_key_to_object_helper_i (intf, oid);
00255     }
00256 #endif
00257 
00258     int
00259     ServantRetentionStrategyNonRetain::rebind_using_user_id_and_system_id (
00260       PortableServer::Servant /*servant*/,
00261       const PortableServer::ObjectId &/*user_id*/,
00262       const PortableServer::ObjectId &/*system_id*/,
00263       TAO::Portable_Server::Servant_Upcall &/*servant_upcall*/)
00264     {
00265       return -1;
00266     }
00267 
00268     CORBA::Boolean
00269     ServantRetentionStrategyNonRetain::servant_has_remaining_activations (
00270       PortableServer::Servant /*servant*/)
00271     {
00272       return false;
00273     }
00274 
00275     int
00276     ServantRetentionStrategyNonRetain::unbind_using_user_id (
00277       const PortableServer::ObjectId &/*user_id*/)
00278     {
00279       return 0;
00280     }
00281 
00282     ::PortableServer::ServantRetentionPolicyValue
00283     ServantRetentionStrategyNonRetain::type() const
00284     {
00285       return ::PortableServer::NON_RETAIN;
00286     }
00287 
00288   }
00289 }
00290 
00291 TAO_END_VERSIONED_NAMESPACE_DECL
00292 

Generated on Tue Feb 2 17:40:54 2010 for TAO_PortableServer by  doxygen 1.4.7