summaryrefslogtreecommitdiff
path: root/TAO/tests/Exposed_Policies/server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/Exposed_Policies/server.cpp')
-rw-r--r--TAO/tests/Exposed_Policies/server.cpp91
1 files changed, 48 insertions, 43 deletions
diff --git a/TAO/tests/Exposed_Policies/server.cpp b/TAO/tests/Exposed_Policies/server.cpp
index 4093a237a82..94931085a88 100644
--- a/TAO/tests/Exposed_Policies/server.cpp
+++ b/TAO/tests/Exposed_Policies/server.cpp
@@ -7,29 +7,35 @@
// - ClientProtocolPolicy
//
// This policies are embedded in the object reference, by writem
-// them into the IOR.
+// them into the IOR.
//
//
#include "Counter_i.h"
+
+// @@ Angelo, we don't use angle brackets in our tests or examples
+// because that disables dependencies, we need to have the code
+// automatically compile if something fails.
#include <tao/RT_ORB.h>
#include <tao/RT_Policy_i.h>
#include <ace/Arg_Shifter.h>
+// @@ Angelo: any reason to have an inconsistent order of declaration?
#include "RT_Properties.h"
ACE_RCSID(tao, server, "$Id$");
-
+// @@ Angelo: please move this routine to some common place (but *NOT*
+// in the TAO library).
CORBA::Boolean check_reference (CORBA::Object_ptr object,
const char *msg = 0)
{
if (CORBA::is_nil (object))
{
if (msg == 0)
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("The Object reference is nil.\n")));
else
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
ACE_TEXT (msg)));
return 0;
}
@@ -50,9 +56,9 @@ main (int argc, char *argv[])
// Here we parse the command line paramether passed
// to the application.
-
+
ACE_Arg_Shifter arg_shifter (argc, argv);
-
+
RT_Properties *rt_object_properties = 0;
RT_Properties *rt_poa_properties = 0;
@@ -70,25 +76,25 @@ main (int argc, char *argv[])
rt_object_properties = RT_Properties::read_from (arg, ACE_TRY_ENV);
ACE_TRY_CHECK;
}
- else
+ else
arg_shifter.consume_arg ();
-
- }
-
+
+ }
+
CORBA::Object_var object;
-
+
// Get a reference to the RT-ORB.
object = orb->resolve_initial_references ("RTORB", ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
CORBA::PolicyList poa_policy_list;
poa_policy_list.length (3);
-
-
+
+
// Create the priority policy using the RT-ORB.
RTCORBA::Priority priority = rt_poa_properties->priority ();
poa_policy_list[0] =
@@ -96,21 +102,21 @@ main (int argc, char *argv[])
priority,
ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
// Create priority Banded Connection Policy.
RTCORBA::PriorityBands poa_priority_bands = rt_poa_properties->priority_bands ();
-
- poa_policy_list[1] =
- rt_orb->create_priority_banded_connection_policy (poa_priority_bands,
+
+ poa_policy_list[1] =
+ rt_orb->create_priority_banded_connection_policy (poa_priority_bands,
ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
// Client Protocol Policy.
RTCORBA::ProtocolList protocol_list;
protocol_list.length (1);
-
+
protocol_list[0].protocol_type = IOP::TAG_INTERNET_IOP;
- protocol_list[0].orb_protocol_properties =
+ protocol_list[0].orb_protocol_properties =
TAO_Protocol_Properties_Factory::create_orb_protocol_property (IOP::TAG_INTERNET_IOP);
protocol_list[0].transport_protocol_properties =
@@ -121,19 +127,19 @@ main (int argc, char *argv[])
object = orb->resolve_initial_references ("RootPOA", ACE_TRY_ENV);
ACE_TRY_CHECK;
-
+
PortableServer::POA_var poa =
PortableServer::POA::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
PortableServer::POAManager_var poa_mgr =
PortableServer::POAManager::_nil ();
-
+
PortableServer::POA_var child_poa =
poa->create_POA ("Child_POA",
poa_mgr ,
poa_policy_list);
-
+
// Create a Corba Object reference, using the policies
// set at the POA level.
object =
@@ -141,17 +147,17 @@ main (int argc, char *argv[])
ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Reference Created!\n")));
- if (!check_reference (object,
+ if (!check_reference (object,
"Unable to create a Counter Object!\n"))
return 1;
Counter_var counter = Counter::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
-
- if (!check_reference (counter.in(),
+
+ if (!check_reference (counter.in(),
"Unable to create a Counter Object!\n"))
return 1;
@@ -163,7 +169,7 @@ main (int argc, char *argv[])
orb->object_to_string (counter.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Activated as <%s>\n"), ior.in ()));
FILE *output_file = ACE_OS::fopen (rt_poa_properties->ior_source (), "w");
@@ -174,45 +180,45 @@ main (int argc, char *argv[])
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
-
+
// Now we create an object that overrides some of the policies
// set at the POA level.
// Create a Corba Object reference, using the policies
// set at the POA level.
-
- // @@ Shortcut - The following code is not definitive, and
+
+ // @@ Shortcut - The following code is not definitive, and
// the cast is only used to access a RTPortableServer::POA
// method that isn't currently accessible otherwise.
-
+
object =
((TAO_POA*)child_poa.ptr ())->create_reference_with_priority ("IDL:Counter:1.0",
rt_object_properties->priority (),
ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Reference Created!\n")));
- if (!check_reference (object,
+ if (!check_reference (object,
"Unable to create a Counter Object!\n"))
return 1;
Counter_var counter_over = Counter::_narrow (object.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
-
- if (!check_reference (counter_over.in(),
+
+ if (!check_reference (counter_over.in(),
"Unable to create a Counter Object!\n"))
return 1;
-
+
CORBA::String_var o_ior = orb->object_to_string (counter_over.in (), ACE_TRY_ENV);
ACE_TRY_CHECK;
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Activated as <%s>\n"), o_ior.in ()));
-
+
output_file = ACE_OS::fopen (rt_object_properties->ior_source (), "w");
if (output_file == 0)
@@ -240,7 +246,7 @@ main (int argc, char *argv[])
ACE_CATCHANY
{
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
ACE_TEXT ("CORBA Exception Raised."));
return 1;
}
@@ -248,4 +254,3 @@ main (int argc, char *argv[])
return 0;
}
-