Merge pull request #2046 from jwillemsen/jwinullptrexce
[ACE_TAO.git] / TAO / tao / PortableServer / ThreadStrategyFactoryImpl.cpp
blob908513d3cb467af19a4e834f8a5c0dbbf30e1d0c
1 #include "tao/PortableServer/ThreadStrategyFactoryImpl.h"
2 #include "tao/PortableServer/ThreadStrategy.h"
3 #include "ace/Dynamic_Service.h"
4 #include "ace/Log_Msg.h"
6 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
8 namespace TAO
10 namespace Portable_Server
12 ThreadStrategy*
13 ThreadStrategyFactoryImpl::create (
14 ::PortableServer::ThreadPolicyValue value)
16 ThreadStrategy* strategy = 0;
18 switch (value)
20 case ::PortableServer::SINGLE_THREAD_MODEL :
22 ThreadStrategyFactory *strategy_factory =
23 ACE_Dynamic_Service<ThreadStrategyFactory>::instance ("ThreadStrategySingleFactory");
25 if (strategy_factory)
27 strategy = strategy_factory->create (value);
29 else
30 TAOLIB_ERROR ((LM_ERROR,
31 ACE_TEXT ("(%P|%t) %p\n"),
32 ACE_TEXT ("ERROR, Unable to get ")
33 ACE_TEXT ("ThreadStrategySingleFactory")));
35 break;
37 case ::PortableServer::ORB_CTRL_MODEL :
39 strategy =
40 ACE_Dynamic_Service<ThreadStrategy>::instance ("ThreadStrategyORBControl");
42 if (!strategy)
43 TAOLIB_ERROR ((LM_ERROR,
44 ACE_TEXT ("(%P|%t) %p\n"),
45 ACE_TEXT ("ERROR, Unable to get ")
46 ACE_TEXT ("ThreadStrategyORBControl")));
48 break;
52 return strategy;
55 void
56 ThreadStrategyFactoryImpl::destroy (
57 ThreadStrategy *strategy)
59 switch (strategy->type ())
61 case ::PortableServer::SINGLE_THREAD_MODEL :
63 ThreadStrategyFactory *strategy_factory =
64 ACE_Dynamic_Service<ThreadStrategyFactory>::instance ("ThreadStrategySingleFactory");
66 if (strategy_factory)
68 strategy_factory->destroy (strategy);
70 break;
72 case ::PortableServer::ORB_CTRL_MODEL :
74 // Noop
75 break;
82 ACE_STATIC_SVC_DEFINE (
83 ThreadStrategyFactoryImpl,
84 ACE_TEXT ("ThreadStrategyFactory"),
85 ACE_SVC_OBJ_T,
86 &ACE_SVC_NAME (ThreadStrategyFactoryImpl),
87 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
90 ACE_FACTORY_NAMESPACE_DEFINE (
91 ACE_Local_Service,
92 ThreadStrategyFactoryImpl,
93 TAO::Portable_Server::ThreadStrategyFactoryImpl)
95 TAO_END_VERSIONED_NAMESPACE_DECL