LifespanStrategyFactoryImpl.cpp

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

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