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