00001
00002 #include "tao/PI_Server/PortableServer_PolicyFactory.h"
00003
00004 #include "tao/PortableServer/ThreadPolicy.h"
00005 #include "tao/PortableServer/LifespanPolicy.h"
00006 #include "tao/PortableServer/IdAssignmentPolicy.h"
00007 #include "tao/PortableServer/IdUniquenessPolicy.h"
00008 #include "tao/PortableServer/ImplicitActivationPolicy.h"
00009 #include "tao/PortableServer/RequestProcessingPolicy.h"
00010 #include "tao/PortableServer/ServantRetentionPolicy.h"
00011 #include "tao/PortableServer/PortableServer.h"
00012 #include "tao/PI_Server/Policy_Creator_T.h"
00013
00014 ACE_RCSID (PI_Server,
00015 PortableServer_PolicyFactory,
00016 "PortableServer_PolicyFactory.cpp,v 1.4 2006/06/20 06:17:05 jwillemsen Exp")
00017
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019
00020 CORBA::Policy_ptr
00021 TAO_PortableServer_PolicyFactory::create_policy (
00022 CORBA::PolicyType type,
00023 const CORBA::Any &value
00024 ACE_ENV_ARG_DECL)
00025 ACE_THROW_SPEC ((CORBA::SystemException,
00026 CORBA::PolicyError))
00027 {
00028 #if (TAO_HAS_MINIMUM_POA == 0)
00029
00030
00031 if (type == ::PortableServer::THREAD_POLICY_ID)
00032 {
00033 TAO::Portable_Server::ThreadPolicy *thread_policy = 0;
00034 PortableServer::ThreadPolicyValue thr_value;
00035
00036 TAO::Portable_Server::create_policy (thread_policy, thr_value, value ACE_ENV_ARG_PARAMETER);
00037 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00038
00039 return thread_policy;
00040 }
00041
00042 #endif
00043 if (type == PortableServer::LIFESPAN_POLICY_ID)
00044 {
00045 TAO::Portable_Server::LifespanPolicy *lifespan_policy = 0;
00046 PortableServer::LifespanPolicyValue lifespan_value;
00047
00048 TAO::Portable_Server::create_policy (lifespan_policy, lifespan_value, value ACE_ENV_ARG_PARAMETER);
00049 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00050
00051 return lifespan_policy;
00052 }
00053
00054 if (type == PortableServer::ID_UNIQUENESS_POLICY_ID)
00055 {
00056 TAO::Portable_Server::IdUniquenessPolicy *id_uniqueness_policy = 0;
00057 PortableServer::IdUniquenessPolicyValue id_uniqueness_value;
00058
00059 TAO::Portable_Server::create_policy (id_uniqueness_policy, id_uniqueness_value, value ACE_ENV_ARG_PARAMETER);
00060 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00061
00062 return id_uniqueness_policy;
00063 }
00064
00065 if (type == PortableServer::ID_ASSIGNMENT_POLICY_ID)
00066 {
00067 TAO::Portable_Server::IdAssignmentPolicy *id_assignment_policy = 0;
00068 PortableServer::IdAssignmentPolicyValue id_assignment_value;
00069
00070 TAO::Portable_Server::create_policy (id_assignment_policy, id_assignment_value, value ACE_ENV_ARG_PARAMETER);
00071 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00072
00073 return id_assignment_policy;
00074 }
00075
00076 #if (TAO_HAS_MINIMUM_POA == 0)
00077
00078 if (type == PortableServer::IMPLICIT_ACTIVATION_POLICY_ID)
00079 {
00080 TAO::Portable_Server::ImplicitActivationPolicy *implicit_activatation_policy = 0;
00081 PortableServer::ImplicitActivationPolicyValue implicit_activation_value;
00082
00083 TAO::Portable_Server::create_policy (implicit_activatation_policy, implicit_activation_value, value ACE_ENV_ARG_PARAMETER);
00084 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00085
00086 return implicit_activatation_policy;
00087 }
00088
00089 if (type == PortableServer::SERVANT_RETENTION_POLICY_ID)
00090 {
00091 TAO::Portable_Server::ServantRetentionPolicy *servant_retention_policy = 0;
00092 PortableServer::ServantRetentionPolicyValue servant_retention_value;
00093
00094 TAO::Portable_Server::create_policy (servant_retention_policy, servant_retention_value, value ACE_ENV_ARG_PARAMETER);
00095 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00096
00097 return servant_retention_policy;
00098 }
00099
00100 if (type == PortableServer::REQUEST_PROCESSING_POLICY_ID)
00101 {
00102 TAO::Portable_Server::RequestProcessingPolicy *request_processing_policy = 0;
00103 PortableServer::RequestProcessingPolicyValue request_processing_value;
00104
00105 TAO::Portable_Server::create_policy (request_processing_policy, request_processing_value, value ACE_ENV_ARG_PARAMETER);
00106 ACE_CHECK_RETURN (CORBA::Policy::_nil ());
00107
00108 return request_processing_policy;
00109 }
00110
00111 #endif
00112
00113 ACE_THROW_RETURN (CORBA::PolicyError (CORBA::BAD_POLICY_TYPE),
00114 CORBA::Policy::_nil ());
00115 }
00116
00117 TAO_END_VERSIONED_NAMESPACE_DECL