00001
00002
00003 #include "tao/PortableServer/ServantRetentionStrategyFactoryImpl.h"
00004 #include "tao/PortableServer/ServantRetentionStrategy.h"
00005 #include "tao/debug.h"
00006 #include "ace/Dynamic_Service.h"
00007 #include "ace/Log_Msg.h"
00008
00009 ACE_RCSID (PortableServer,
00010 ServantRetentionStrategyFactoryImpl,
00011 "$Id: ServantRetentionStrategyFactoryImpl.cpp 77409 2007-02-26 23:48:49Z ossama $")
00012
00013 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00014
00015 namespace TAO
00016 {
00017 namespace Portable_Server
00018 {
00019 ServantRetentionStrategy*
00020 ServantRetentionStrategyFactoryImpl::create (
00021 ::PortableServer::ServantRetentionPolicyValue value)
00022 {
00023 ServantRetentionStrategyFactory *strategy_factory = 0;
00024 const char *strategy_factory_name = 0;
00025
00026 switch (value)
00027 {
00028 case ::PortableServer::RETAIN :
00029 {
00030 strategy_factory_name = "ServantRetentionStrategyRetainFactory";
00031 break;
00032 }
00033 case ::PortableServer::NON_RETAIN :
00034 {
00035 strategy_factory_name = "ServantRetentionStrategyNonRetainFactory";
00036 break;
00037 }
00038 }
00039
00040 strategy_factory =
00041 ACE_Dynamic_Service<ServantRetentionStrategyFactory>::instance (strategy_factory_name);
00042
00043 if (strategy_factory == 0)
00044 {
00045 if (TAO_debug_level > 1)
00046 ACE_ERROR ((LM_ERROR,
00047 ACE_TEXT ("(%P|%t) ERROR, Unable to get %s\n"),
00048 strategy_factory_name));
00049
00050 return 0;
00051 }
00052
00053 return strategy_factory->create (value);
00054 }
00055
00056 void
00057 ServantRetentionStrategyFactoryImpl::destroy (
00058 ServantRetentionStrategy *strategy)
00059 {
00060 const char *strategy_factory_name = 0;
00061
00062 switch (strategy->type ())
00063 {
00064 case ::PortableServer::RETAIN :
00065 {
00066 strategy_factory_name = "ServantRetentionStrategyRetainFactory";
00067 break;
00068 }
00069 case ::PortableServer::NON_RETAIN :
00070 {
00071 strategy_factory_name = "ServantRetentionStrategyNonRetainFactory";
00072 break;
00073 }
00074 }
00075
00076 ServantRetentionStrategyFactory *servantretention_strategy_factory =
00077 ACE_Dynamic_Service<ServantRetentionStrategyFactory>::instance (strategy_factory_name);
00078
00079 if (servantretention_strategy_factory != 0)
00080 {
00081 servantretention_strategy_factory->destroy (strategy);
00082 }
00083 }
00084 }
00085 }
00086
00087 TAO_END_VERSIONED_NAMESPACE_DECL
00088
00089 ACE_STATIC_SVC_DEFINE (
00090 ServantRetentionStrategyFactoryImpl,
00091 ACE_TEXT ("ServantRetentionStrategyFactory"),
00092 ACE_SVC_OBJ_T,
00093 &ACE_SVC_NAME (ServantRetentionStrategyFactoryImpl),
00094 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
00095 0)
00096
00097 ACE_FACTORY_NAMESPACE_DEFINE (
00098 ACE_Local_Service,
00099 ServantRetentionStrategyFactoryImpl,
00100 TAO::Portable_Server::ServantRetentionStrategyFactoryImpl)