summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-07-06 16:52:14 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-07-06 16:52:14 +0000
commit5b805cc057a2401770c1872076109153f806e701 (patch)
tree952c2f80fb2ca5b12fd8f56e5693bd352e82224d
parent2bce522be6a0fe1c89003276c3a46cae93bc480f (diff)
downloadATCD-5b805cc057a2401770c1872076109153f806e701.tar.gz
*** empty log message ***
-rw-r--r--TAO/CIAO/tools/RTComponentServer/ChangeLog14
-rw-r--r--TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.cpp134
-rw-r--r--TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.h77
-rw-r--r--TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.inl10
-rw-r--r--TAO/CIAO/tools/RTComponentServer/README15
-rw-r--r--TAO/CIAO/tools/RTComponentServer/RTComponentServer.cpp172
-rw-r--r--TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc17
7 files changed, 439 insertions, 0 deletions
diff --git a/TAO/CIAO/tools/RTComponentServer/ChangeLog b/TAO/CIAO/tools/RTComponentServer/ChangeLog
new file mode 100644
index 00000000000..8565f4d8725
--- /dev/null
+++ b/TAO/CIAO/tools/RTComponentServer/ChangeLog
@@ -0,0 +1,14 @@
+Sun Jul 06 11:50:48 2003 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * tools/RTComponentServer/ComponentServer_Task.cpp:
+ * tools/RTComponentServer/ComponentServer_Task.h:
+ * tools/RTComponentServer/ComponentServer_Task.inl:
+ * tools/RTComponentServer/README:
+ * tools/RTComponentServer/RTComponentServer.cpp:
+ * tools/RTComponentServer/RTComponentServer.mpc: Added the
+ skeleton of RTComponentServer.
+
+Sun Jul 06 11:33:55 2003 Nanbor Wang <nanbor@cs.wustl.edu>
+
+ * Added: this temporary ChangeLog file for changes within the
+ RTComponentServer.
diff --git a/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.cpp b/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.cpp
new file mode 100644
index 00000000000..239593737d3
--- /dev/null
+++ b/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.cpp
@@ -0,0 +1,134 @@
+// $Id$
+
+#include "ComponentServer_Task.h"
+#include "tao/RTPortableServer/RTPortableServer.h"
+#include "ComponentServer_Impl.h"
+#include "Server_init.h"
+#include "CIAO_ServersC.h"
+
+#if !defined (__ACE_INLINE__)
+# include "ComponentServer_Task.inl"
+#endif /* __ACE_INLINE__ */
+
+int
+CIAO::ComponentServer_Task::svc ()
+{
+ ACE_TRY_NEW_ENV
+ {
+ CORBA::Object_var object =
+ this->orb_->resolve_initial_references ("RTORB"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ RTCORBA::RTORB_var rt_orb =
+ RTCORBA::RTORB::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ object =
+ this->orb_->resolve_initial_references ("RootPOA"
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // ...
+ CIAO::ComponentServer_Impl *comserv_servant;
+
+ ACE_NEW_RETURN (comserv_servant,
+ CIAO::ComponentServer_Impl (this->orb_.in (),
+ root_poa.in ()),
+ -1);
+
+ PortableServer::ServantBase_var safe_servant (comserv_servant);
+
+ // @@ We need to call ComponentServer servant's init method.
+ // But it's not sure to me where exactly we can get the
+ // ConfigValues needed by the init method at this moment.
+
+ // comserv_servant->init (config ACE_ENV_ARG_PARAMETER);
+
+ // Configuring ComponentServer.
+ PortableServer::ObjectId_var cs_oid
+ = root_poa->activate_object (comserv_servant
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ object = root_poa->id_to_reference (cs_oid.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ Components::Deployment::ComponentServer_var comserv_obj =
+ Components::Deployment::ComponentServer::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ if (CORBA::is_nil (comserv_obj.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Unable to activate RTComponentServer object\n"),
+ -1);
+
+
+ Components::Deployment::ServerActivator_var activator;
+
+ if (this->options_.use_callback_)
+ {
+ object = this->orb_->string_to_object (this->options_.callback_ior_.c_str ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CIAO::Activator_Callback_var act_callback
+ = ::CIAO::Activator_Callback::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ activator
+ = act_callback->register_component_server (comserv_obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ comserv_servant->set_objref (activator.in (),
+ comserv_obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ CORBA::String_var str = this->orb_->object_to_string (comserv_obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+
+ if (this->options_.ior_output_filename_.length () != 0)
+ CIAO::Utility::write_IOR (this->options_.ior_output_filename_.c_str (),
+ str.in ());
+ ACE_DEBUG ((LM_INFO, "RTComponentServer IOR: %s\n", str.in ()));
+
+ // End Deployment part
+
+ ACE_DEBUG ((LM_DEBUG,
+ "Running RTComponentServer...\n"));
+
+
+ this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ this->orb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught");
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.h b/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.h
new file mode 100644
index 00000000000..ebb953c8731
--- /dev/null
+++ b/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.h
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file ComponentServer_Task.h
+ *
+ * $Id$
+ *
+ * An ACE_Task subclass that manages the RT-ORB thread for CIAO's RT
+ * ComponentServer.
+ *
+ * @author Nanbor Wang <nanbor@cs.wustl.edu>
+ */
+//=============================================================================
+
+
+#ifndef CIAO_COMPONENTSERVER_TASK_H
+#define CIAO_COMPONENTSERVER_TASK_H
+#include "ace/pre.h"
+
+#include "tao/ORB_Core.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "ace/Task.h"
+
+namespace CIAO
+{
+ /**
+ * @class ComponentServer_task
+ *
+ * @brief An ACE_Task subclass that manages the RT-ORB therad
+ */
+ class ComponentServer_Task
+ : public virtual ACE_Task_Base
+ {
+ public:
+ // We can add a rt-task configuration facility here.
+ typedef struct _options
+ {
+ // default ctor.
+ _options () : use_callback_ (1) {}
+
+ // The name of the file to write stringified IOR to.
+ ACE_CString ior_output_filename_;
+
+ // Stringified IOR of a CIAO's callback object.
+ ACE_CString callback_ior_;
+
+ // CIAO ComponentServer uses the callback object to pass it's
+ // own object reference back to ServerActivator.
+ int use_callback_;
+ } Options;
+
+ ComponentServer_Task (ACE_Thread_Manager &thread_manager,
+ CORBA::ORB_ptr orb,
+ Options &opts);
+
+ int svc (void);
+
+ protected:
+ CORBA::ORB_var orb_;
+
+ // ComponentServer config options.
+ Options options_;
+ };
+
+}
+
+#if defined (__ACE_INLINE__)
+# include "ComponentServer_Task.inl"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/post.h"
+#endif /* CIAO_COMPONENTSERVER_TASK_H */
diff --git a/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.inl b/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.inl
new file mode 100644
index 00000000000..7bbd0be31d0
--- /dev/null
+++ b/TAO/CIAO/tools/RTComponentServer/ComponentServer_Task.inl
@@ -0,0 +1,10 @@
+// -*- C++ -*- $Id$
+
+CIAO::ComponentServer_Task::ComponentServer_Task (ACE_Thread_Manager &tm,
+ CORBA::ORB_ptr o,
+ CIAO::ComponentServer_Task::Options &opts)
+ : ACE_Task_Base (&tm),
+ orb_ (CORBA::ORB::_duplicate (o)),
+ options_ (opts)
+{
+}
diff --git a/TAO/CIAO/tools/RTComponentServer/README b/TAO/CIAO/tools/RTComponentServer/README
new file mode 100644
index 00000000000..77cb7430ca8
--- /dev/null
+++ b/TAO/CIAO/tools/RTComponentServer/README
@@ -0,0 +1,15 @@
+$Id$
+
+This directory contains the RTComponentServer implementation
+
+
+RTComponentServer supports the following command line flags:
+
+ * -n : Do not try to call back ServerActivator. This is only useful
+ when testing the server and the server is not created by a
+ ServerActivator.
+
+ * -o <filename> : Specify the filename ComponentServer will write
+ IOR to. This is only useful when debugging also.
+
+ * -d <IOR> : Specify the IOR to the ServerActivator. \ No newline at end of file
diff --git a/TAO/CIAO/tools/RTComponentServer/RTComponentServer.cpp b/TAO/CIAO/tools/RTComponentServer/RTComponentServer.cpp
new file mode 100644
index 00000000000..65dace769c2
--- /dev/null
+++ b/TAO/CIAO/tools/RTComponentServer/RTComponentServer.cpp
@@ -0,0 +1,172 @@
+// $Id$
+
+#include "ace/Get_Opt.h"
+#include "ace/Sched_Params.h"
+#include "ComponentServer_Task.h"
+#include "Server_init.h"
+#include "tao/RTCORBA/RTCORBA.h"
+
+/// The following check is taken from $(TAO_ROOT)/tests/RTCORBA/
+
+int
+parse_args (int argc,
+ char *argv[],
+ CIAO::ComponentServer_Task::Options &opts)
+{
+ ACE_Get_Opt get_opts (argc, argv, "nk:o:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'n':
+ opts.use_callback_ = 0;
+ break;
+
+ case 'o': // get the file name to write to
+ opts.ior_output_filename_ = get_opts.opt_arg ();
+ break;
+
+ case 'k': // get the activator callback IOR
+ opts.callback_ior_ = get_opts.opt_arg ();
+ break;
+
+ case '?': // display help for use of the server.
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s\n"
+ "-n Don't not try to callback ServerActivator (testing)\n"
+ "-o <ior_output_file>\n"
+ "-k <activator_callback_ior>\n"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ if (opts.use_callback_ && opts.callback_ior_.length () == 0)
+ ACE_ERROR_RETURN ((LM_ERROR, "Callback IOR to ServerActivator is required.\n"),
+ -1);
+
+ return 0;
+}
+
+const char *
+sched_policy_name (int sched_policy)
+{
+ const char *name = 0;
+
+ switch (sched_policy)
+ {
+ case ACE_SCHED_OTHER:
+ name = "SCHED_OTHER";
+ break;
+ case ACE_SCHED_RR:
+ name = "SCHED_RR";
+ break;
+ case ACE_SCHED_FIFO:
+ name = "SCHED_FIFO";
+ break;
+ }
+
+ return name;
+}
+
+void
+check_supported_priorities (CORBA::ORB_ptr orb)
+{
+ int sched_policy =
+ orb->orb_core ()->orb_params ()->ace_sched_policy ();
+
+ // Check that we have sufficient priority range to run,
+ // i.e., more than 1 priority level.
+ int max_priority =
+ ACE_Sched_Params::priority_max (sched_policy);
+ int min_priority =
+ ACE_Sched_Params::priority_min (sched_policy);
+
+ if (max_priority == min_priority)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "Not enough priority levels with the %s scheduling policy\n"
+ "on this platform to run, terminating program....\n"
+ "Check svc.conf options\n",
+ sched_policy_name (sched_policy)));
+
+ ACE_OS::exit (2);
+ }
+}
+
+
+int
+main (int argc, char **argv)
+{
+ ACE_TRY_NEW_ENV
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc,
+ argv,
+ ""
+ ACE_ENV_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+
+ // Register value factories for the server side.
+ CIAO::Server_init (orb.in ());
+
+ CIAO::ComponentServer_Task::Options options;
+
+ int result =
+ parse_args (argc, argv, options);
+ if (result != 0)
+ return result;
+
+ // Make sure we can support multiple priorities that are required
+ // for this test.
+ check_supported_priorities (orb.in());
+
+ // Thread Manager for managing task.
+ ACE_Thread_Manager thread_manager;
+
+ // Create task.
+ CIAO::ComponentServer_Task cs_task (thread_manager,
+ orb.in (),
+ options);
+
+ // Task activation flags.
+ long flags =
+ THR_NEW_LWP |
+ THR_JOINABLE |
+ orb->orb_core ()->orb_params ()->thread_creation_flags ();
+
+ // Activate task.
+ result =
+ cs_task.activate (flags);
+ if (result == -1)
+ {
+ if (errno == EPERM)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot create thread with scheduling policy %s\n"
+ "because the user does not have the appropriate privileges, terminating program....\n"
+ "Check svc.conf options and/or run as root\n",
+ sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
+ 2);
+ }
+ else
+ // Unexpected error.
+ ACE_ASSERT (0);
+ }
+
+ // Wait for task to exit.
+ result =
+ thread_manager.wait ();
+ ACE_ASSERT (result != -1);
+ }
+ ACE_CATCHANY
+ {
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught");
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ return 0;
+}
diff --git a/TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc b/TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc
new file mode 100644
index 00000000000..3f93756a9d2
--- /dev/null
+++ b/TAO/CIAO/tools/RTComponentServer/RTComponentServer.mpc
@@ -0,0 +1,17 @@
+// $Id$
+
+project(RTComponentServer): ciao_server,rt_server {
+
+ exename = RTComponentServer
+
+ Source_Files {
+ ComponentServer_Task.cpp
+ RTComponentServer.cpp
+ }
+}
+
+// project(ComponentServer_test_client) : ciao_server {
+// Source_Files {
+// ComponentServer_test_client.cpp
+// }
+// }