summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/CIAO/ChangeLog17
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI.mpc21
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp127
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h15
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.cpp29
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.h28
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.cpp30
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.h20
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.cpp64
-rw-r--r--modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.h24
-rw-r--r--modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp7
-rw-r--r--modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h3
12 files changed, 361 insertions, 24 deletions
diff --git a/modules/CIAO/ChangeLog b/modules/CIAO/ChangeLog
index ceb49149b0a..d026177d062 100644
--- a/modules/CIAO/ChangeLog
+++ b/modules/CIAO/ChangeLog
@@ -1,3 +1,20 @@
+Mon Aug 24 07:10:16 UTC 2009 Marcel Smit <msmit@remedy.nl>
+
+ * connectors/AMI_CCM/AMI/AMI.mpc:
+ * connectors/AMI_CCM/AMI/AMI_exec.h:
+ * connectors/AMI_CCM/AMI/AMI_exec.cpp:
+ * connectors/AMI_CCM/AMI/AMI_internal_i.h:
+ * connectors/AMI_CCM/AMI/AMI_internal_i.cpp:
+ * connectors/AMI_CCM/AMI/AMI_perform_work.h:
+ * connectors/AMI_CCM/AMI/AMI_perform_work.cpp:
+ * connectors/AMI_CCM/AMI/AMI_server.h:
+ * connectors/AMI_CCM/AMI/AMI_server.cpp:
+ First step to use CORBA AMI in the AMI component.
+
+ * connectors/AMI_CCM/Sender/Hello_Sender_exec.h:
+ * connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp:
+ Minor changes.
+
Thu Aug 20 09:56:11 UTC 2009 Marcel Smit <msmit@remedy.nl>
* connectors:
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI.mpc b/modules/CIAO/connectors/AMI_CCM/AMI/AMI.mpc
index bba183cb3f0..79afb4cb3a7 100644
--- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI.mpc
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI.mpc
@@ -1,6 +1,13 @@
// $Id$
// This file is generated with "generate_component_mpc.pl -p Hello_Base AMI"
+project(*idl): taoidldefaults, ami {
+ IDL_Files {
+ AMI_internal.idl
+ }
+ custom_only = 1
+}
+
project(Hello_Base_AMI_idl_gen) : componentidldefaults {
custom_only = 1
idlflags += -Wb,stub_export_macro=AMI_STUB_Export \
@@ -90,14 +97,28 @@ project(Hello_Base_AMI_exec) : ciao_executor {
Source_Files {
AMI_exec.cpp
+ AMI_server.cpp
+ AMI_perform_work.cpp
+ AMI_CORBA_handler.cpp
+ AMI_internal_i.cpp
+ AMI_internalC.cpp
+ AMI_internalS.cpp
}
Header_Files {
AMI_exec.h
+ AMI_server.h
+ AMI_perform_work.h
+ AMI_CORBA_handler.h
+ AMI_internal_i.h
AMI_exec_export.h
+ AMI_internalS.h
+ AMI_internalC.h
}
Inline_Files {
+ AMI_internalS.inl
+ AMI_internalC.inl
}
}
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp
index fe0a0bfae0a..644a79de579 100644
--- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.cpp
@@ -17,7 +17,7 @@
// http://doc.ece.uci.edu/
// and
// Institute for Software Integrated Systems
-// Vanderbilt University
+// Vanderbilt Universityaaa
// Nashville, TN
// USA
// http://www.isis.vanderbilt.edu/
@@ -29,10 +29,16 @@
// be/be_codegen.cpp:1278
#include "AMI_exec.h"
+#include "AMI_perform_work.h"
+#include "AMI_CORBA_handler.h"
#include "ciao/CIAO_common.h"
namespace CIAO_Hello_AMI_AMI_Impl
{
+ //============================================================
+ // Implementation of the basic form of AMI: a thread to handle
+ // asynchronous invocations.
+ //============================================================
ami_handler::ami_handler (
::CCM_AMI::Cookie ck,
const char * in_str,
@@ -45,11 +51,6 @@ namespace CIAO_Hello_AMI_AMI_Impl
{
}
- ami_handler::~ami_handler ()
- {
- printf ("AMI :\tami_handler::~ami_handler\n");
- }
-
int ami_handler::svc ()
{
char* out_str;
@@ -64,9 +65,55 @@ namespace CIAO_Hello_AMI_AMI_Impl
}
//============================================================
+ // Implementation of the AMI CORBA reply handler
+ //============================================================
+ class AMI_CORBA_handler : public POA_INTERNAL_CCM_AMI::AMI_AMI_fooHandler
+ {
+ public:
+ AMI_CORBA_handler (void)
+ : foo_callback_ (0)
+ {
+ };
+
+ void set_callback (::CCM_AMI::AMI_foo_callback_ptr foo_callback)
+ {
+ foo_callback_ = ::CCM_AMI::AMI_foo_callback::_duplicate (foo_callback);
+ };
+
+ void asynch_foo (CORBA::Long result,
+ const char * out_str)
+ {
+ printf ("AMI CORBA :\tHandler::asynch_foo\n");
+ foo_callback_->foo_callback_handler (1, result, CORBA::string_dup (out_str));
+ };
+
+ void asynch_foo_excep (::Messaging::ExceptionHolder * excep_holder)
+ {
+ printf ("AMI CORBA :\tHandler::foo_excep\n");
+
+ try
+ {
+ excep_holder->raise_exception ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Caught exception:");
+ }
+ };
+
+ ~AMI_CORBA_handler (void)
+ {
+ };
+ private:
+ ::CCM_AMI::AMI_foo_callback_var foo_callback_;
+ };
+
+ // ReplyHandler.
+ AMI_CORBA_handler handler;
+
+ //============================================================
// Facet Executor Implementation Class: AMI_ami_foo_exec_i
//============================================================
-
AMI_ami_foo_exec_i::AMI_ami_foo_exec_i (
::CCM_AMI::AMI_foo_ptr foo_receiver,
::CCM_AMI::AMI_foo_callback_ptr foo_callback) :
@@ -74,23 +121,65 @@ namespace CIAO_Hello_AMI_AMI_Impl
foo_callback_ (::CCM_AMI::AMI_foo_callback::_duplicate (foo_callback)),
cookie_ (0)
{
+ //initilize AMI client
+ ACE_TCHAR* argv[2];
+ argv[0] = ACE_TEXT ("");
+ argv[1] = ACE_TEXT ("");
+ int argc = 2;
+ orb_ = CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var object =
+ orb_->string_to_object ("file://server.ior");
+ ami_foo_var_ = INTERNAL_CCM_AMI::AMI_foo::_narrow (object.in ());
+
+ if (CORBA::is_nil (ami_foo_var_.in ()))
+ {
+ printf ("Server is NIL\n");
+ }
+
+ // Activate POA to handle the call back.
+ CORBA::Object_var poa_object =
+ orb_->resolve_initial_references("RootPOA");
+
+ if (CORBA::is_nil (poa_object.in ()))
+ printf ("POA is NIL!\n");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ poa_manager->activate ();
+
+ printf ("Start the AMI CORBA handler\n");
+ handler.set_callback (foo_callback);
+ the_handler_var_ = handler._this (/* */);
}
-
+
AMI_ami_foo_exec_i::~AMI_ami_foo_exec_i (void)
{
- printf ("AMI :\tAMI_ami_foo_exec_i::~AMI_ami_foo_exec_i\n");
}
-
+
// Operations from ::CCM_AMI::AMI_ami_foo
-
+
::CCM_AMI::Cookie
AMI_ami_foo_exec_i::sendc_asynch_foo (
const char * in_str)
{
+ printf ("AMI :\tsendc_asynch_foo <%s>\n", in_str);
::CCM_AMI::Cookie ck = ++cookie_;
+ //AMI CORBA implementation.
+ printf ("AMI :\tSending string <%s> for cookie <%ld> to AMI CORBA server\n", in_str, ck);
+ ami_foo_var_->sendc_asynch_foo (the_handler_var_.in (), in_str);
+
+
+/*
+ //single thread to perform asynchronous actions
printf ("AMI :\tReceived string <%s> for <%d>\n", in_str, ck);
ami_handler* ah = new ami_handler (ck, in_str, foo_receiver_, foo_callback_);
ah->activate ();
+*/
return ck;
}
@@ -148,7 +237,21 @@ namespace CIAO_Hello_AMI_AMI_Impl
void
AMI_exec_i::ccm_activate (void)
{
- /* Your code here. */
+ ::CCM_AMI::AMI_foo_var receiver_foo =
+ this->context_->get_connection_receiver_foo ();
+
+ printf ("AMI :\tCCM_ACTIVATE\n");
+ ACE_TCHAR* argv[2];
+ argv[0] = ACE_TEXT ("");
+ argv[1] = ACE_TEXT ("");
+ int argc = 2;
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+ AMI_server *srv = new AMI_server (orb.in (), receiver_foo);
+ AMI_perform_work *pw = new AMI_perform_work (orb.in ());
+ printf ("AMI :\tStarting server and CORBA thread.\n");
+ srv->activate ();
+ pw->activate ();
}
void
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h
index 26d98108d0b..d8b44ccc3cd 100644
--- a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_exec.h
@@ -41,10 +41,14 @@
#include "tao/LocalObject.h"
#include "ace/Task.h"
+#include "AMI_server.h"
namespace CIAO_Hello_AMI_AMI_Impl
{
+ /////////////////////////////
+ //AMI thread implemenatation
+ /////////////////////////////
class ami_handler : public virtual ACE_Task_Base
{
public:
@@ -53,10 +57,7 @@ namespace CIAO_Hello_AMI_AMI_Impl
const char * in_str,
::CCM_AMI::AMI_foo_ptr foo_receiver,
::CCM_AMI::AMI_foo_callback_ptr foo_callback);
- ~ami_handler ();
-
virtual int svc (void);
-
private:
long ck_;
const char * in_str_;
@@ -64,6 +65,8 @@ namespace CIAO_Hello_AMI_AMI_Impl
::CCM_AMI::AMI_foo_callback_ptr foo_callback_;
};
+
+
class AMI_ami_foo_exec_i
: public virtual ::CCM_AMI::CCM_AMI_ami_foo,
public virtual ::CORBA::LocalObject,
@@ -87,6 +90,12 @@ namespace CIAO_Hello_AMI_AMI_Impl
::CCM_AMI::AMI_foo_var foo_receiver_;
::CCM_AMI::AMI_foo_callback_var foo_callback_;
long cookie_;
+
+ CORBA::ORB_var orb_;
+
+ /// Variable to handle CORBA AMI
+ INTERNAL_CCM_AMI::AMI_AMI_fooHandler_var the_handler_var_;
+ INTERNAL_CCM_AMI::AMI_foo_var ami_foo_var_;
};
class AMI_exec_i
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.cpp b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.cpp
new file mode 100644
index 00000000000..8e719e31c1c
--- /dev/null
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.cpp
@@ -0,0 +1,29 @@
+
+#include "AMI_internal_i.h"
+
+AMI_internal_i::AMI_internal_i (CORBA::ORB_ptr orb, ::CCM_AMI::AMI_foo_ptr foo_receiver)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ foo_receiver_ (::CCM_AMI::AMI_foo::_duplicate (foo_receiver))
+{
+}
+
+CORBA::Long
+AMI_internal_i::asynch_foo (const char * in_str,
+ CORBA::String_out out_str)
+{
+ //printf ("CORBA internal :\tReceived string <%s>\n", in_str);
+ //ACE_OS::sleep (ACE_OS::rand () % 5);
+ //out_str = CORBA::string_dup ("This is my answer : Hi");
+ //return ACE_OS::rand () % 100;
+
+ printf ("AMI CORBA :\tReceived string <%s>. Try passing it to the Receiver component\n", in_str);
+ CORBA::Long result = foo_receiver_->asynch_foo (CORBA::string_dup (in_str), out_str);
+ return result;
+}
+
+void
+AMI_internal_i::shutdown (void)
+{
+ printf ("AMI CORBA :\tShutting down\n");
+ this->orb_->shutdown (0);
+}
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.h b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.h
new file mode 100644
index 00000000000..7e3732e4678
--- /dev/null
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_internal_i.h
@@ -0,0 +1,28 @@
+
+#ifndef AMI_INTERNAL_I_H
+#define AMI_INTERNAL_I_H
+
+#include "AMI_internalS.h"
+#include "AMI_exec.h"
+
+class AMI_internal_i : public POA_INTERNAL_CCM_AMI::AMI_foo
+{
+public:
+ /// ctor
+ AMI_internal_i (
+ CORBA::ORB_ptr orb,
+ ::CCM_AMI::AMI_foo_ptr foo_receiver);
+
+ // The AMI methods.
+ CORBA::Long asynch_foo (const char * in_str,
+ CORBA::String_out out_str);
+
+ void shutdown (void);
+
+private:
+ CORBA::ORB_var orb_;
+ ::CCM_AMI::AMI_foo_var foo_receiver_;
+};
+
+#endif /* AMI_INTERNAL_I_H */
+
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.cpp b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.cpp
new file mode 100644
index 00000000000..d199d0ca312
--- /dev/null
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.cpp
@@ -0,0 +1,30 @@
+#include "AMI_perform_work.h"
+
+AMI_perform_work::AMI_perform_work (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+int AMI_perform_work::svc ()
+{
+ try
+ {
+ while (1)
+ {
+ CORBA::Boolean pending = orb_->work_pending();
+
+ if (pending)
+ {
+ orb_->perform_work();
+ }
+ ACE_OS::sleep (1);
+ }
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Caught exception:");
+ return 1;
+ }
+ printf ("AMI :\t Exiting perform work");
+ return 0;
+}
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.h b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.h
new file mode 100644
index 00000000000..04aeb07e8c7
--- /dev/null
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_perform_work.h
@@ -0,0 +1,20 @@
+
+#ifndef AMI_PERFORM_WORK_H
+#define AMI_PERFORM_WORK_H
+
+#include "ace/Task.h"
+#include "AMI_internalC.h"
+
+class AMI_perform_work : public ACE_Task_Base
+{
+public:
+ /// ctor
+ AMI_perform_work (CORBA::ORB_ptr orb);
+ virtual int svc (void);
+
+private:
+ CORBA::ORB_var orb_;
+};
+
+#endif /* AMI_PERFORM_WORK_H */
+
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.cpp b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.cpp
new file mode 100644
index 00000000000..b40edcb49b9
--- /dev/null
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.cpp
@@ -0,0 +1,64 @@
+#include "AMI_server.h"
+
+AMI_server::AMI_server (CORBA::ORB_ptr orb, ::CCM_AMI::AMI_foo_ptr foo_receiver)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ foo_receiver_ (::CCM_AMI::AMI_foo::_duplicate (foo_receiver))
+{
+}
+
+int AMI_server::svc ()
+{
+ try
+ {
+ CORBA::Object_var poa_object =
+ orb_->resolve_initial_references("RootPOA");
+
+ if (CORBA::is_nil (poa_object.in ()))
+ {
+ printf ("Server :\tERROR creating POA \n");
+ return 1;
+ }
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ AMI_internal_i ami_internal_i (orb_.in (), foo_receiver_);
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (&ami_internal_i);
+
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+
+ INTERNAL_CCM_AMI::AMI_foo_var ami_foo_var =
+ INTERNAL_CCM_AMI::AMI_foo::_narrow (object.in ());
+
+ CORBA::String_var ior =
+ orb_->object_to_string (ami_foo_var.in ());
+
+ printf ("Server :\tActivated as <%s>\n", ior.in ());
+
+ // If the ior_output_file exists, output the ior to it
+ FILE *output_file= ACE_OS::fopen ("server.ior", "w");
+ if (output_file == 0)
+ {
+ printf ("Cannot open output file for writing IOR: server.ior\n");
+ return 1;
+ }
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ poa_manager->activate ();
+
+ orb_->run ();
+
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Caught exception:");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.h b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.h
new file mode 100644
index 00000000000..5f50e47beca
--- /dev/null
+++ b/modules/CIAO/connectors/AMI_CCM/AMI/AMI_server.h
@@ -0,0 +1,24 @@
+
+#ifndef AMI_SERVER_H
+#define AMI_SERVER_H
+
+#include "ace/Task.h"
+#include "AMI_internal_i.h"
+#include "AMIEC.h"
+
+class AMI_server : public ACE_Task_Base
+{
+public:
+ /// ctor
+ AMI_server (
+ CORBA::ORB_ptr orb,
+ ::CCM_AMI::AMI_foo_ptr foo_receiver);
+ virtual int svc (void);
+
+private:
+ CORBA::ORB_var orb_;
+ ::CCM_AMI::AMI_foo_var foo_receiver_;
+};
+
+#endif /* AMI_SERVER_H */
+
diff --git a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp
index abf6875a2bb..fac23808ef4 100644
--- a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp
+++ b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.cpp
@@ -36,17 +36,12 @@ namespace CIAO_Hello_AMI_Sender_Impl
pulse_generator::pulse_generator (::CCM_AMI::AMI_ami_foo_ptr foo_ami)
: foo_ami_ (::CCM_AMI::AMI_ami_foo::_duplicate (foo_ami))
{
- printf ("Sender :\tpulse_generator::pulse_generator\n");
-}
-
-pulse_generator::~pulse_generator ()
-{
}
int pulse_generator::svc ()
{
printf ("Sender :\tpulse_generator::svc\n");
- ACE_OS::sleep (10);
+ ACE_OS::sleep (7);
for (int i = 0; i < 5; ++i)
{
if (CORBA::is_nil (foo_ami_))
diff --git a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h
index c7b4d7325e2..c8acc5c4d8b 100644
--- a/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h
+++ b/modules/CIAO/connectors/AMI_CCM/Sender/Hello_Sender_exec.h
@@ -50,12 +50,9 @@ namespace CIAO_Hello_AMI_Sender_Impl
public:
pulse_generator (::CCM_AMI::AMI_ami_foo_ptr foo_ami);
- ~pulse_generator ();
-
virtual int svc (void);
private:
- /// Maintains a handle that actually process the event
::CCM_AMI::AMI_ami_foo_var foo_ami_;
};