summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelo Corsaro <angelo@icorsaro.net>2000-08-17 19:25:13 +0000
committerAngelo Corsaro <angelo@icorsaro.net>2000-08-17 19:25:13 +0000
commit77ca0fb9e473b3c53ec7360ca2091059594df5a3 (patch)
tree5fe643f54d15275cac029eb34604c95bc7424bad
parent4c87300777faebb46ca84ff5683a233b31d9fbfc (diff)
downloadATCD-77ca0fb9e473b3c53ec7360ca2091059594df5a3.tar.gz
ChangeLogTag: Thu Aug 17 14:07:24 2000 Angelo Corsaro <corsaro@cs.wustl.edu>
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a15
-rw-r--r--TAO/tests/Exposed_Policies/Client.dsp2
-rw-r--r--TAO/tests/Exposed_Policies/Makefile3
-rw-r--r--TAO/tests/Exposed_Policies/Object.cfg12
-rw-r--r--TAO/tests/Exposed_Policies/POA.cfg17
-rw-r--r--TAO/tests/Exposed_Policies/README81
-rw-r--r--TAO/tests/Exposed_Policies/RT_Properties.cpp104
-rw-r--r--TAO/tests/Exposed_Policies/RT_Properties.h54
-rw-r--r--TAO/tests/Exposed_Policies/Server.dsp14
-rw-r--r--TAO/tests/Exposed_Policies/client.cpp147
-rw-r--r--TAO/tests/Exposed_Policies/server.cpp120
11 files changed, 460 insertions, 109 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index 6be6b540cf7..8c15b887639 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,18 @@
+Thu Aug 17 14:07:24 2000 Angelo Corsaro <corsaro@cs.wustl.edu>
+
+ * test/Exposed_Policies/server.cpp:
+ * test/Exposed_Policies/client.cpp:
+ * test/test/Exposed_Policies/Client.dsp:
+ * test/Exposed_Policies/Server.dsp:
+ * test/Exposed_Policies/RTProperties.h:
+ * test/Exposed_Policies/RTProperties.cpp:
+ * test/Exposed_Policies/README:
+ * test/Exposed_Policies/Makefile:
+ * test/Exposed_Policies/POA.cfg
+ * test/Exposed_Policies/Object.cfg
+ Extended the example to test the client exposed policies
+ to read the policies from a configuration file (.cfg file).
+
Thu Aug 17 11:46:49 2000 Priyanka Gontla <pgontla@ece.uci.edu>
* orbsvcs/Naming_Service/Naming_Service.cpp (parse_args):
diff --git a/TAO/tests/Exposed_Policies/Client.dsp b/TAO/tests/Exposed_Policies/Client.dsp
index c6589ce5f2c..4feb08df095 100644
--- a/TAO/tests/Exposed_Policies/Client.dsp
+++ b/TAO/tests/Exposed_Policies/Client.dsp
@@ -74,7 +74,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib taod.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\tao"
+# ADD LINK32 aced.lib taod.lib /nologo /subsystem:console /debug /machine:I386 /out:"Client.exe" /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\tao"
!ENDIF
diff --git a/TAO/tests/Exposed_Policies/Makefile b/TAO/tests/Exposed_Policies/Makefile
index cfc867577f7..8264de87aaf 100644
--- a/TAO/tests/Exposed_Policies/Makefile
+++ b/TAO/tests/Exposed_Policies/Makefile
@@ -17,7 +17,8 @@ LDFLAGS += -L$(TAO_ROOT)/tao
PROG_SRCS = \
client.cpp \
- server.cpp
+ server.cpp \
+ RTProperties.cpp
LSRC = $(PROG_SRCS)
diff --git a/TAO/tests/Exposed_Policies/Object.cfg b/TAO/tests/Exposed_Policies/Object.cfg
new file mode 100644
index 00000000000..fb8b54def2c
--- /dev/null
+++ b/TAO/tests/Exposed_Policies/Object.cfg
@@ -0,0 +1,12 @@
+IOR_Source overridden.ior
+
+Priority 20
+
+
+
+
+
+
+
+
+
diff --git a/TAO/tests/Exposed_Policies/POA.cfg b/TAO/tests/Exposed_Policies/POA.cfg
new file mode 100644
index 00000000000..99270fa15af
--- /dev/null
+++ b/TAO/tests/Exposed_Policies/POA.cfg
@@ -0,0 +1,17 @@
+IOR_Source default.ior
+
+Priority 10
+
+Priority_Bands 5
+Priority_Range 3 5
+Priority_Range 7 11
+Priority_Range 5 9
+Priority_Range 1 5
+Priority_Range 10 15
+
+
+
+
+
+
+
diff --git a/TAO/tests/Exposed_Policies/README b/TAO/tests/Exposed_Policies/README
index 66c3868737a..c09c90f8857 100644
--- a/TAO/tests/Exposed_Policies/README
+++ b/TAO/tests/Exposed_Policies/README
@@ -1,17 +1,78 @@
-// @@ Angelo, we do not need the info below - it is self-explanatory,
-but we do need: 1) what this test is checking, 2) what is the expected
-output, 3) what are command line args ...
+$Id$
-# $Id$
+This directory contains a test case used to verify that the client
+exposed policies get embedded correctly in the IOR and exposed to the
+client in the object reference.
- - Counter.idl
+The policy tested are:
- IDL interface definition.
+ - PriorityModelPolicy
+ - PriorityBandedConnectionPolicy
+ - ClientProtocolPolicy
- - Counter_i.h,cpp
+The policy can be set at POA level or at object level. The policies
+that have to be associated with a POA or with an object are specified
+using a configuration file. As an example we can consider the file
+POA.cfg that contains the policy used to create a child POA:
- IDL interface implementation.
+File: POA.cfg
+
+ IOR_Source poa.ior
+
+ Priority 10
+
+ Priority_Bands 5
+ Priority_Range 3 5
+ Priority_Range 7 11
+ Priority_Range 5 9
+ Priority_Range 1 5
+ Priority_Range 10 15
+
+
+The tag used to decribe the information have the following meaning:
+
+ - IOR_Source: Defines the name of the file that has to be used to
+ store the IOR of the object created.
+
+ - Priority: Defines a CORBA::Priority value.
+
+ - Priority_Bands: Defines the number of priority bands.
+
+ - Priority_Range: Defines the priority range associated with a
+ priority_band.
+
+
+The policies value that are specified in the config file can be used
+to set the policy at POA level or to override those police on a Object
+level basis (beaware that the only policy that can be overridden on an
+Object basis is the Priority).
+
+In particular the option "-POAConfigFile" let you specify the policy
+that have to be used when the POA is created. While the option
+"-ObjectConfigFile" let you set the options on a object basis
+overriding the policies that were set at a POA level.
+
+
+When the test is run two object are created, of this object one has
+the same priority that where specified when the POA was created, while
+the other ovverride some of them as prescribed in the config file
+specified with the option "-ObjectConfigFile".
+
+
+USAGE:
+
+ server -POAConfigFile <config_file_name>
+ -ObjectConfigFile <config_file_name>
+
+ client -IORSource <ior_source>
+
+
+EXAMPLE:
+
+ $ server -POAConfigFile POA.cfg -ObjectConfigFile Object.cfg
+
+ $ client -IORSource file://default.ior
+
+ $ client -IORSource file://overridden.ior
- - client.cpp
- - server.cpp
diff --git a/TAO/tests/Exposed_Policies/RT_Properties.cpp b/TAO/tests/Exposed_Policies/RT_Properties.cpp
new file mode 100644
index 00000000000..ce727d6c3f4
--- /dev/null
+++ b/TAO/tests/Exposed_Policies/RT_Properties.cpp
@@ -0,0 +1,104 @@
+//$Id$
+
+#include "RT_Properties.h"
+
+ACE_RCSID(tao, RT_Properties.cpp, "$Id$");
+
+RT_Properties::RT_Properties (void)
+ : priority_ (10)
+{
+ ACE_OS_String::strcpy (ior_source_, "poa_default.ior");
+}
+
+RT_Properties::~RT_Properties (void)
+{
+ // No-Op.
+}
+
+RT_Properties *
+RT_Properties::read_from (const char *file_name,
+ CORBA::Environment &ACE_TRY_ENV)
+{
+ FILE *fp = ACE_OS::fopen (file_name, "r");
+
+ RT_Properties *rt_properties;
+
+ ACE_NEW_THROW_EX (rt_properties,
+ RT_Properties,
+ CORBA::NO_MEMORY (TAO_DEFAULT_MINOR_CODE,
+ CORBA::COMPLETED_NO));
+
+ char string_field[256];
+ int int_field;
+ unsigned int i = 0;
+ while (fscanf (fp, "%s", string_field) != EOF )
+ {
+ if (ACE_OS_String::strcmp (string_field, "IOR_Source") == 0)
+ {
+ fscanf (fp, "%s", string_field);
+ rt_properties->ior_source (string_field);
+ }
+
+ else if (ACE_OS_String::strcmp (string_field, "Priority") == 0)
+ {
+ fscanf (fp, "%d", &int_field);
+ rt_properties->priority (int_field);
+ }
+ else if (ACE_OS_String::strcmp (string_field, "Priority_Bands") == 0)
+ {
+ fscanf (fp, "%d", &int_field);
+ rt_properties->priority_bands_.length (int_field);
+
+ }
+ else if (ACE_OS_String::strcmp (string_field, "Priority_Range") == 0)
+ {
+ fscanf (fp, "%d", &int_field);
+ rt_properties->priority_bands_[i].low = int_field;
+
+ fscanf (fp, "%d", &int_field);
+ rt_properties->priority_bands_[i].high = int_field;
+
+ ++i;
+ }
+ }
+
+
+ return rt_properties;
+}
+
+void
+RT_Properties::priority (RTCORBA::Priority priority)
+{
+ this->priority_ = priority;
+}
+
+RTCORBA::Priority
+RT_Properties::priority (void)
+{
+ return this->priority_;
+}
+
+void
+RT_Properties::priority_bands (const RTCORBA::PriorityBands& priority_bands)
+{
+ this->priority_bands_ = priority_bands;
+}
+
+const RTCORBA::PriorityBands&
+RT_Properties::priority_bands (void)
+{
+ return this->priority_bands_;
+}
+
+
+void
+RT_Properties::ior_source (const char *s)
+{
+ ACE_OS_String::strcpy (this->ior_source_, s);
+}
+
+const char *
+RT_Properties::ior_source (void)
+{
+ return this->ior_source_;
+}
diff --git a/TAO/tests/Exposed_Policies/RT_Properties.h b/TAO/tests/Exposed_Policies/RT_Properties.h
new file mode 100644
index 00000000000..87dbeb69444
--- /dev/null
+++ b/TAO/tests/Exposed_Policies/RT_Properties.h
@@ -0,0 +1,54 @@
+//$Id$
+//
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// RT_Properties.h
+//
+// = DESCRIPTION
+// Defines a series of "real time" property that an Object
+// or a POA created on a RT-ORB can have.
+//
+// = AUTHOR
+// Angelo Corsaro <corsaro@cs.wustl.edu>
+//
+// ============================================================================
+
+#ifndef RT_PROPERTIES_H_
+#define RT_PROPERTIES_H_
+
+#include "tao/corba.h"
+#include <tao/RT_ORB.h>
+
+class RT_Properties
+{
+public:
+ // -- Ctor/Dtor --
+ RT_Properties (void);
+ ~RT_Properties (void);
+
+ static RT_Properties * read_from (const char *file_name,
+ CORBA::Environment &ACE_TRY_ENV);
+
+ // -- Accessor Methods --
+ void priority (RTCORBA::Priority priority);
+ RTCORBA::Priority priority (void);
+
+ void priority_bands (const RTCORBA::PriorityBands& priority_bands);
+ const RTCORBA::PriorityBands& priority_bands (void);
+
+ void ior_source (const char *s);
+ const char* ior_source (void);
+
+private:
+
+ RTCORBA::Priority priority_;
+ RTCORBA::PriorityBands priority_bands_;
+ char ior_source_[256];
+};
+
+
+#endif /* RT_PROPERTIES_H_ */
diff --git a/TAO/tests/Exposed_Policies/Server.dsp b/TAO/tests/Exposed_Policies/Server.dsp
index 894084a467c..edd817c05e1 100644
--- a/TAO/tests/Exposed_Policies/Server.dsp
+++ b/TAO/tests/Exposed_Policies/Server.dsp
@@ -74,7 +74,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib aced.lib taod.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\tao"
+# ADD LINK32 aced.lib taod.lib /nologo /subsystem:console /debug /machine:I386 /out:"Server.exe" /pdbtype:sept /libpath:"..\..\..\ace" /libpath:"..\..\tao"
!ENDIF
@@ -99,6 +99,10 @@ SOURCE=.\CounterS.cpp
# End Source File
# Begin Source File
+SOURCE=.\RT_Properties.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\server.cpp
# End Source File
# End Group
@@ -111,8 +115,16 @@ SOURCE=.\Counter_i.h
# End Source File
# Begin Source File
+SOURCE=.\CounterC.h
+# End Source File
+# Begin Source File
+
SOURCE=.\CounterS.h
# End Source File
+# Begin Source File
+
+SOURCE=.\RT_Properties.h
+# End Source File
# End Group
# Begin Group "Resource Files"
diff --git a/TAO/tests/Exposed_Policies/client.cpp b/TAO/tests/Exposed_Policies/client.cpp
index 86013a550bd..5f9d0f3d1c2 100644
--- a/TAO/tests/Exposed_Policies/client.cpp
+++ b/TAO/tests/Exposed_Policies/client.cpp
@@ -1,7 +1,10 @@
// $Id$
+#include "ace/Arg_Shifter.h"
#include "CounterC.h"
+char object_ref[256];
+
ACE_RCSID(tao, client, "$Id$")
@@ -32,11 +35,32 @@ main (int argc, char *argv[])
// ORB Initialization
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "TAO", ACE_TRY_ENV);
ACE_TRY_CHECK;
+
+ ACE_Arg_Shifter arg_shifter (argc, argv);
+
+ int file_set = 0;
+ while (arg_shifter.is_anything_left ())
+ {
+ char *arg;
+ if ((arg = arg_shifter.get_the_parameter ("-IORSource")))
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("IOR File Name: %s\n"),
+ arg));
+ ACE_OS_String::strcpy (object_ref, arg);
+ file_set = 1;
+ }
+ else
+ arg_shifter.consume_arg ();
+ }
+
+ if (file_set == 0)
+ ACE_OS_String::strcpy (object_ref, "file://poa_default.ior");
CORBA::Object_var object;
// Get the IOR from a file.
- object = orb->string_to_object ("file://s.ior", ACE_TRY_ENV);
+ object = orb->string_to_object (object_ref, ACE_TRY_ENV);
ACE_TRY_CHECK;
if (!check_reference (object, "Invalid IOR file!\n"))
@@ -54,78 +78,79 @@ main (int argc, char *argv[])
ACE_TRY_ENV);
ACE_TRY_CHECK;
- if (!check_reference (policy_ptr, "Unable to get Priority Policy.\n"))
- return 1;
-
- RTCORBA::PriorityModelPolicy_var priority_policy =
- RTCORBA::PriorityModelPolicy::_narrow (policy_ptr);
-
- RTCORBA::PriorityModel priority_model =
- priority_policy->priority_model (ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- RTCORBA::Priority priority =
- priority_policy->server_priority (ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- if (priority_model == RTCORBA::SERVER_DECLARED)
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("\n\nPriority Model: RTCORBA::SERVER_DECLARED\n")
- ));
-
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("\nPriority Model: %d\nCORBA Priority: %d\n"),
- priority_model,
- priority
- ));
+ if (check_reference (policy_ptr, "Unable to get Priority Policy.\n"))
+ {
+ RTCORBA::PriorityModelPolicy_var priority_policy =
+ RTCORBA::PriorityModelPolicy::_narrow (policy_ptr);
+
+ RTCORBA::PriorityModel priority_model =
+ priority_policy->priority_model (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ RTCORBA::Priority priority =
+ priority_policy->server_priority (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
+ if (priority_model == RTCORBA::SERVER_DECLARED)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\n\nPriority Model: RTCORBA::SERVER_DECLARED\n")
+ ));
+
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Priority Model: %d\nCORBA Priority: %d\n\n"),
+ priority_model,
+ priority
+ ));
+ }
policy_ptr = object->_get_policy (RTCORBA::PRIORITY_BANDED_CONNECTION_POLICY_TYPE,
ACE_TRY_ENV);
- if (!check_reference (policy_ptr, "Unable to get Priority Banded Policy\n"))
- return 1;
+ if (check_reference (policy_ptr, "Unable to get Priority Banded Policy\n"))
+ {
- RTCORBA::PriorityBandedConnectionPolicy_var priority_banded_policy =
- RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy_ptr,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- if (!check_reference (priority_banded_policy, "Unable to get Priority Banded Policy\n"))
- return 1;
+ RTCORBA::PriorityBandedConnectionPolicy_var priority_banded_policy =
+ RTCORBA::PriorityBandedConnectionPolicy::_narrow (policy_ptr,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+
- // Here we have a priority banded connection policy.
-
- RTCORBA::PriorityBands_var pb = priority_banded_policy->priority_bands ();
- unsigned int band_num = pb->length ();
- for (unsigned int i = 0; i < band_num; ++i)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("Priority Band <%d>: (%d, %d)\n"),
- i,
- pb[i].low,
- pb[i].high
- ));
+ if (check_reference (priority_banded_policy, "Unable to get Priority Banded Policy\n"))
+ {
+
+ // Here we have a priority banded connection policy.
+
+ RTCORBA::PriorityBands_var pb = priority_banded_policy->priority_bands ();
+ unsigned int band_num = pb->length ();
+ for (unsigned int i = 0; i < band_num; ++i)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("Priority Band <%d>: (%d, %d)\n"),
+ i,
+ pb[i].low,
+ pb[i].high
+ ));
+ }
+ }
}
-
policy_ptr = object->_get_policy (RTCORBA::CLIENT_PROTOCOL_POLICY_TYPE,
ACE_TRY_ENV);
- if (!check_reference (policy_ptr, "Unable to get Priority Banded Policy\n"))
- return 1;
-
- RTCORBA::ClientProtocolPolicy_var client_protocol_policy =
- RTCORBA::ClientProtocolPolicy::_narrow (policy_ptr, ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ if (check_reference (policy_ptr, "Unable Client Protocol Policy\n"))
+ {
+ RTCORBA::ClientProtocolPolicy_var client_protocol_policy =
+ RTCORBA::ClientProtocolPolicy::_narrow (policy_ptr, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
- RTCORBA::ProtocolList_var protocol_list =
- client_protocol_policy->protocols (ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ RTCORBA::ProtocolList_var protocol_list =
+ client_protocol_policy->protocols (ACE_TRY_ENV);
+ ACE_TRY_CHECK;
- for (i = 0; i < protocol_list->length (); i++)
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("The Client Protocol Type: %d\n"),
- protocol_list[i].protocol_type));
+ for (unsigned int i = 0; i < protocol_list->length (); i++)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("\nThe Client Protocol Type: %d\n"),
+ protocol_list[ i].protocol_type));
+ }
}
-
ACE_CATCHANY
{
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "CORBA Excaption Raised");
diff --git a/TAO/tests/Exposed_Policies/server.cpp b/TAO/tests/Exposed_Policies/server.cpp
index c65ac40cf89..4093a237a82 100644
--- a/TAO/tests/Exposed_Policies/server.cpp
+++ b/TAO/tests/Exposed_Policies/server.cpp
@@ -1,5 +1,6 @@
//$Id$
-//
+
+////////////////////////////////////////////////////////////////////////
// This files tests the Client exposed policies:
// - PriorityModelPolicy
// - PriorityBandedConnectionPolicy
@@ -9,16 +10,12 @@
// them into the IOR.
//
//
-// TODO: Create another object reference and override its POA's policies
-// using the CORBA::Object::_set_policy_ovverides method.
-//
-//
#include "Counter_i.h"
#include <tao/RT_ORB.h>
#include <tao/RT_Policy_i.h>
#include <ace/Arg_Shifter.h>
-const char *ior_output_file = "s.ior";
+#include "RT_Properties.h"
ACE_RCSID(tao, server, "$Id$");
@@ -39,6 +36,7 @@ CORBA::Boolean check_reference (CORBA::Object_ptr object,
return 1;
}
+
int
main (int argc, char *argv[])
{
@@ -52,14 +50,31 @@ main (int argc, char *argv[])
// Here we parse the command line paramether passed
// to the application.
- /*
+
ACE_Arg_Shifter arg_shifter (argc, argv);
- char *arg;
+ RT_Properties *rt_object_properties = 0;
+ RT_Properties *rt_poa_properties = 0;
+
while (arg_shifter.is_anything_left ())
{
+ char *arg;
+ // IOR File Name Option.
+ if ((arg = arg_shifter.get_the_parameter ("-POAConfigFile")))
+ {
+ rt_poa_properties = RT_Properties::read_from (arg, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ else if ((arg = arg_shifter.get_the_parameter ("-ObjectConfigFile")))
+ {
+ rt_object_properties = RT_Properties::read_from (arg, ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ else
+ arg_shifter.consume_arg ();
+
}
- */
+
CORBA::Object_var object;
// Get a reference to the RT-ORB.
@@ -70,37 +85,23 @@ main (int argc, char *argv[])
ACE_TRY_ENV);
ACE_TRY_CHECK;
- CORBA::PolicyList policy_list;
- policy_list.length (3);
+ CORBA::PolicyList poa_policy_list;
+ poa_policy_list.length (3);
+
// Create the priority policy using the RT-ORB.
- RTCORBA::Priority priority = 10;
- policy_list[0] =
+ RTCORBA::Priority priority = rt_poa_properties->priority ();
+ poa_policy_list[0] =
rt_orb->create_priority_model_policy (RTCORBA::SERVER_DECLARED,
priority,
ACE_TRY_ENV);
ACE_TRY_CHECK;
// Create priority Banded Connection Policy.
- // In order to do this we have to create a sequence
- // of priority bands.
-
- RTCORBA::PriorityBands priority_bands;
- priority_bands.length (2);
-
- RTCORBA::PriorityBand p_band1, p_band2;
-
- p_band1.low = 10;
- p_band1.high = 30;
-
- p_band2.low = 7;
- p_band2.high = 21;
-
- priority_bands[0] = p_band1;
- priority_bands[1] = p_band2;
+ RTCORBA::PriorityBands poa_priority_bands = rt_poa_properties->priority_bands ();
- policy_list[1] =
- rt_orb->create_priority_banded_connection_policy (priority_bands,
+ poa_policy_list[1] =
+ rt_orb->create_priority_banded_connection_policy (poa_priority_bands,
ACE_TRY_ENV);
ACE_TRY_CHECK;
@@ -115,7 +116,7 @@ main (int argc, char *argv[])
protocol_list[0].transport_protocol_properties =
TAO_Protocol_Properties_Factory::create_transport_protocol_property (IOP::TAG_INTERNET_IOP);
- policy_list[2] =
+ poa_policy_list[2] =
rt_orb->create_client_protocol_policy (protocol_list);
object = orb->resolve_initial_references ("RootPOA", ACE_TRY_ENV);
@@ -131,7 +132,7 @@ main (int argc, char *argv[])
PortableServer::POA_var child_poa =
poa->create_POA ("Child_POA",
poa_mgr ,
- policy_list);
+ poa_policy_list);
// Create a Corba Object reference, using the policies
// set at the POA level.
@@ -165,14 +166,63 @@ main (int argc, char *argv[])
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Activated as <%s>\n"), ior.in ()));
- FILE *output_file = ACE_OS::fopen (ior_output_file, "w");
+ FILE *output_file = ACE_OS::fopen (rt_poa_properties->ior_source (), "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Cannot open output file for writing IOR: %s"),
- ior_output_file),
+ rt_poa_properties->ior_source ()),
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
+ // 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_TEXT ("Reference Created!\n")));
+
+ 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(),
+ "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_TEXT ("Activated as <%s>\n"), o_ior.in ()));
+
+ output_file = ACE_OS::fopen (rt_object_properties->ior_source (), "w");
+
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("Cannot open output file for writing IOR: %s"),
+ rt_object_properties->ior_source ()),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", o_ior.in ());
+ ACE_OS::fclose (output_file);
+
PortableServer::POAManager_var poa_manager =
child_poa->the_POAManager (ACE_TRY_ENV);