summaryrefslogtreecommitdiff
path: root/TAO/tests/RTCORBA/Persistent_IOR/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/RTCORBA/Persistent_IOR/server.cpp')
-rw-r--r--TAO/tests/RTCORBA/Persistent_IOR/server.cpp132
1 files changed, 75 insertions, 57 deletions
diff --git a/TAO/tests/RTCORBA/Persistent_IOR/server.cpp b/TAO/tests/RTCORBA/Persistent_IOR/server.cpp
index 2a81402f7ec..a56182609fd 100644
--- a/TAO/tests/RTCORBA/Persistent_IOR/server.cpp
+++ b/TAO/tests/RTCORBA/Persistent_IOR/server.cpp
@@ -63,6 +63,7 @@ test_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
static const char *persistent_ior = "persistent_ior";
static const char *transient_ior = "transient_ior";
+static const char *tp_persistent_ior = "tp_persistent_ior";
static int debug = 0;
static CORBA::ULong stacksize = 0;
@@ -76,12 +77,16 @@ static CORBA::ULong max_request_buffer_size = 0;
int
parse_args (int argc, char *argv[])
{
- ACE_Get_Opt get_opts (argc, argv, "p:t:d:");
+ ACE_Get_Opt get_opts (argc, argv, "a:p:t:d:");
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
+ case 'a':
+ tp_persistent_ior = get_opts.opt_arg ();
+ break;
+
case 'p':
persistent_ior = get_opts.opt_arg ();
break;
@@ -98,6 +103,7 @@ parse_args (int argc, char *argv[])
default:
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s "
+ "-a <tp persistent ior file> "
"-p <persistent ior file> "
"-t <transient ior file> "
"-d <debug> "
@@ -127,7 +133,8 @@ write_iors_to_file (CORBA::Object_ptr object,
if (debug)
ACE_DEBUG ((LM_DEBUG,
- "%s\n",
+ "%s: %s\n",
+ filename,
ior.in ()));
u_int result = 0;
@@ -261,67 +268,76 @@ create_poa_and_servant_with_tp_policy (CORBA::ORB_ptr orb,
}
void
-create_poa_with_tp_and_persistent_policy (RTCORBA::RTORB_ptr rt_orb,
- PortableServer::POA_ptr root_poa
+create_poa_with_tp_and_persistent_policy (CORBA::ORB_ptr orb,
+ RTCORBA::RTORB_ptr rt_orb,
+ PortableServer::POA_ptr root_poa,
+ PortableServer::POAManager_ptr poa_manager
ACE_ENV_ARG_DECL)
{
- ACE_TRY
- {
- CORBA::PolicyList policies;
-
- RTCORBA::ThreadpoolId threadpool_id =
- rt_orb->create_threadpool (stacksize,
- static_threads,
- dynamic_threads,
- default_thread_priority,
- allow_request_buffering,
- max_buffered_requests,
- max_request_buffer_size
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ RTCORBA::ThreadpoolId threadpool_id =
+ rt_orb->create_threadpool (stacksize,
+ static_threads,
+ dynamic_threads,
+ default_thread_priority,
+ allow_request_buffering,
+ max_buffered_requests,
+ max_request_buffer_size
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
- CORBA::Policy_var threadpool_policy =
- rt_orb->create_threadpool_policy (threadpool_id
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ CORBA::Policy_var threadpool_policy =
+ rt_orb->create_threadpool_policy (threadpool_id
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
- CORBA::Policy_var lifespan_policy =
- root_poa->create_lifespan_policy (PortableServer::PERSISTENT
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
+ CORBA::Policy_var implicit_activation_policy =
+ root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
- policies.length (policies.length () + 1);
- policies[policies.length () - 1] =
- lifespan_policy;
+ CORBA::Policy_var lifespan_policy =
+ root_poa->create_lifespan_policy (PortableServer::PERSISTENT
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
- policies.length (policies.length () + 1);
- policies[policies.length () - 1] =
- threadpool_policy;
+ CORBA::PolicyList policies;
- PortableServer::POA_var invalid_poa =
- root_poa->create_POA ("invalid",
- PortableServer::POAManager::_nil (),
- policies
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
+ policies.length (policies.length () + 1);
+ policies[policies.length () - 1] =
+ implicit_activation_policy;
- // This next line of code should not run because an exception
- // should have been raised.
- ACE_DEBUG ((LM_DEBUG, "ERROR: no exception caught\n"));
- }
- ACE_CATCH (PortableServer::POA::InvalidPolicy, ex)
- {
- // Expected exception.
- ACE_DEBUG ((LM_DEBUG,
- "InvalidPolicy exception is caught as expected.\n"));
- }
- ACE_CATCHANY
- {
- // Unexpected exception.
- ACE_DEBUG ((LM_DEBUG, "ERROR: unexpected exception caught\n"));
- ACE_RE_THROW;
- }
- ACE_ENDTRY;
+ policies.length (policies.length () + 1);
+ policies[policies.length () - 1] =
+ threadpool_policy;
+
+ policies.length (policies.length () + 1);
+ policies[policies.length () - 1] =
+ lifespan_policy;
+
+ PortableServer::POA_var poa =
+ root_poa->create_POA ("tp_persistent_child",
+ poa_manager,
+ policies
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ test_i *servant = 0;
+ ACE_NEW_THROW_EX (servant,
+ test_i (orb,
+ poa.in ()),
+ CORBA::NO_MEMORY ());
+ ACE_CHECK;
+
+ PortableServer::ServantBase_var safe_servant (servant);
+
+ test_var test =
+ servant->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_CHECK;
+
+ write_iors_to_file (test.in (),
+ orb,
+ tp_persistent_ior
+ ACE_ENV_ARG_PARAMETER);
ACE_CHECK;
}
@@ -393,8 +409,10 @@ main (int argc, char **argv)
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
- create_poa_with_tp_and_persistent_policy (rt_orb.in (),
- root_poa.in ()
+ create_poa_with_tp_and_persistent_policy (orb.in (),
+ rt_orb.in (),
+ root_poa.in (),
+ poa_manager.in ()
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;