diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-26 00:49:53 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-06-26 00:49:53 +0000 |
commit | 1ff8f71368c1c59250d751e24e3e6747b2e7ef9f (patch) | |
tree | 8c37ba0db91a07734d6d0ed78b3349d15c677812 | |
parent | 83140cfdd596c33368ce726b29d904e5bf5b6e75 (diff) | |
download | ATCD-1ff8f71368c1c59250d751e24e3e6747b2e7ef9f.tar.gz |
ChangeLog entry: Thu Jun 25 19:35:50 1998 Michael Kircher <mk1@cs.wustl.edu>
37 files changed, 3476 insertions, 0 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index fa0d2d1c00d..0fdac68f61b 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,10 @@ +Thu Jun 25 19:35:50 1998 Michael Kircher <mk1@cs.wustl.edu> + + * tests/NestedUpcall/{Triangle_Test, Reactor}: Added the + Triangle test to examine ORB behavior doing nested upcalls. + Also moved the Reactor test one level down in the hierarchy + which means it is now in ../NestedUpcall/Reactor + Thu Jun 25 17:57:50 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * tests/Cubit/TAO/DII_Cubit/Makefile: Integrated the new DII_Cubit diff --git a/TAO/tests/NestedUpcall/Reactor/Makefile b/TAO/tests/NestedUpcall/Reactor/Makefile new file mode 100644 index 00000000000..aed436a4fdd --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/Makefile @@ -0,0 +1,69 @@ +#---------------------------------------------------------------------------- +# +# $Id$ +# +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +ifndef TAO_ROOT + TAO_ROOT = $(ACE_ROOT)/TAO +endif # ! TAO_ROOT + +LDLIBS = -lorbsvcs -lTAO + +IDL_SRC = ReactorC.cpp ReactorS.cpp +PROG_SRCS = $(IDL_SRC) server.cpp client.cpp #tmplinst.cpp + +LSRC = $(PROG_SRCS) + +NESTEDUPCALLS_SVR_OBJS = ReactorS.o ReactorC.o server.o reactor_i.o +NESTEDUPCALLS_CLT_OBJS = ReactorS.o ReactorC.o client.o eh_i.o +TEST_OBJS = NestedUpCalls_Test.o + +BIN = server client NestedUpCalls_Test +BUILD = $(BIN) +VLDLIBS = $(LDLIBS:%=%$(VAR)) +VBIN = $(BIN:%=%$(VAR)) + +#---------------------------------------------------------------------------- +# Include macros and targets +#---------------------------------------------------------------------------- + +include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU +include $(ACE_ROOT)/include/makeinclude/macros.GNU +include $(TAO_ROOT)/rules.tao.GNU +include $(ACE_ROOT)/include/makeinclude/rules.common.GNU +include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU +include $(ACE_ROOT)/include/makeinclude/rules.local.GNU +include $(TAO_ROOT)/taoconfig.mk + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +LDFLAGS += -L$(TAO_ROOT)/orbsvcs/orbsvcs -L$(TAO_ROOT)/tao -L$(TAO_ROOT)/orbsvcs/Naming_Service +CPPFLAGS += -I$(TAO_ROOT)/orbsvcs + +.PRECIOUS: ReactorC.h ReactorC.i ReactorC.cpp +.PRECIOUS: ReactorS.h ReactorS.i ReactorS.cpp + +server: $(addprefix $(VDIR),$(NESTEDUPCALLS_SVR_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK) + +client: $(addprefix $(VDIR),$(NESTEDUPCALLS_CLT_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK) +NestedUpCalls_Test: $(addprefix $(VDIR),$(TEST_OBJS)) + $(LINK.cc) $(LDFLAGS) -o $@ $^ $(VLDLIBS) $(POSTLINK) + +realclean: clean + -/bin/rm -rf ReactorS.* ReactorC.* + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + + + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/TAO/tests/NestedUpcall/Reactor/NestedUpCalls_Test.cpp b/TAO/tests/NestedUpcall/Reactor/NestedUpCalls_Test.cpp new file mode 100644 index 00000000000..8d06ea90cba --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/NestedUpCalls_Test.cpp @@ -0,0 +1,90 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls +// +// = FILENAME +// NestedUpCalls_Test.cpp +// +// = DESCRIPTION +// This example tests the NestedUpCalls server and client +// components. The test forks and execs a process to run +// the client. The clerk and the server +// communicate for a short duration after which the main process +// kills both the processes. No command line arguments are needed +// to run the test. +// +// = AUTHOR +// Nagarajan Surendran +// +// ============================================================================ + +#include "tests/test_config.h" +#include "ace/Process.h" + +int +main (int, char *[]) +{ + ACE_START_TEST ("NestedUpCalls_Test:"); + + // Make sure that the backing store is not there. We need to make + // sure because this test kills the Time Clerk and on some platforms + // the Clerk is not allowed to do a graceful shutdown. By cleaning + // the backing store here, we are sure that we get a fresh start and + // no garbage data from a possible aborted run + + ACE_OS::unlink (ACE_DEFAULT_BACKING_STORE); + + ACE_Process_Options server_options; + server_options.command_line ("./server -ORBport 0"); + ACE_Process server; + + if (server.spawn (server_options) == -1) + ACE_ERROR_RETURN ((LM_DEBUG, + "%n %p.\n", + "Server fork failed"), + 0); + else + ACE_DEBUG ((LM_DEBUG, + "Server forked with pid = %d.\n", + server.getpid ())); + + ACE_OS::sleep (5); + + ACE_Process_Options clerk_options; + clerk_options.command_line ("./client -ORBport 0"); + ACE_Process clerk; + + if (clerk.spawn (clerk_options) == -1) + ACE_ERROR_RETURN ((LM_DEBUG, + "%p.\n", + "Client spawn failed"), + 0); + else + ACE_DEBUG ((LM_DEBUG, + "Client forked with pid = %d.\n", + clerk.getpid ())); + + ACE_DEBUG ((LM_DEBUG, "Sleeping...\n")); + ACE_OS::sleep (10); + + if (clerk.terminate () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Terminate failed for clerk.\n"), + -1); + + if (server.terminate () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Terminate failed for server.\n"), + -1); + + // Since we kill the clerk process, on Win32 it may not do a + // graceful shutdown and the backing store file is left behind. + if (clerk.wait () != 0) + ACE_OS::unlink (ACE_DEFAULT_BACKING_STORE); + + ACE_END_TEST; + return 0; +} diff --git a/TAO/tests/NestedUpcall/Reactor/NestedUpCalls_i.h b/TAO/tests/NestedUpcall/Reactor/NestedUpCalls_i.h new file mode 100644 index 00000000000..73c3195c4fe --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/NestedUpCalls_i.h @@ -0,0 +1,99 @@ +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/IDL_Cubit +// +// = FILENAME +// NestedUpCalls_i.h +// +// = AUTHOR +// Andy Gokhale, Sumedh Mungee and Sergio Flores-Gaitan +// +// ============================================================================ + +#if !defined (_NESTEDUPCALLS_I_H) +#define _NESTEDUPCALLS_I_H + +//#include "cubitS.h" + +// Forward declarations. +class NestedUpCalls_i; + +// Typedefs. +typedef NestedUpCalls_i *NestedUpCalls_i_ptr; +typedef NestedUpCalls_i_ptr NestedUpCalls_i_ref; + +class NestedUpCalls_i : public POA +{ + // = TITLE + // Illustrates how to integrate a servant with the generated + // skeleton. + // + // = DESCRIPTION + // Implementation of the cubit example at the servant side. + // Cubes an octet, short, long, struct and union. +public: + NestedUpCalls_i (const char *obj_name = 0); + // Constructor + + ~NestedUpCalls_i (void); + // Destructor + +/* virtual CORBA::Octet cube_octet (CORBA::Octet o, + CORBA::Environment &env); + // Cube an octet + + virtual CORBA::Short cube_short (CORBA::Short s, + CORBA::Environment &env); + // Cube a short + + virtual CORBA::Long cube_long (CORBA::Long l, + CORBA::Environment &env); + // Cube a long + + virtual Cubit::Many cube_struct (const Cubit::Many &values, + CORBA::Environment &env); + // Cube a struct. + + virtual Cubit::oneof cube_union (const Cubit::oneof &values, + CORBA::Environment &env); + // Cube a union. + + virtual void cube_sequence (const Cubit::vector &input, + Cubit::vector_out output, + CORBA::Environment &env); + // Cube a sequence. +*/ + virtual void shutdown (CORBA::Environment &env); + // Shutdown routine. +}; + +class NestedUpCalls_Reactor_i; + +typedef NestedUpCalls_Reactor_i *NestedUpCalls_Reactor_i_ptr; + +class NestedUpCalls_Reactor_i: public POA_Cubit_Factory +{ + // = TITLE + // NestedUpCalls_Reactor_i + // + // = DESCRIPTION + // Factory object returning the cubit objrefs +public: + NestedUpCalls_Reactor_i (void); + // Constructor. + + ~NestedUpCalls_Reactor_i (void); + // Destructor. + + virtual Cubit_ptr make_cubit (const char *key, + CORBA::Environment &env); + // Make the cubit object whose key is "key". + +private: + NestedUpCalls_i my_cubit_; +}; + +#endif /* _NestedUpCalls_i_H */ diff --git a/TAO/tests/NestedUpcall/Reactor/NestedUpcall.dsw b/TAO/tests/NestedUpcall/Reactor/NestedUpcall.dsw new file mode 100644 index 00000000000..512c7d017db --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/NestedUpcall.dsw @@ -0,0 +1,41 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "client"=.\client.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "server"=.\server.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/tests/NestedUpcall/Reactor/README b/TAO/tests/NestedUpcall/Reactor/README new file mode 100644 index 00000000000..a1147be10e4 --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/README @@ -0,0 +1,86 @@ +-*- indented-text -*- + +$Id$ + + BACKGROUND + ========== + +This example tests the scenario of nested upcalls in TAO. For +example, a particular process may need to act in both the role of +client and server. This interaction is common in situations where the +process makes a twoway invocation on a remote servant, passing a local +object reference 'o' to that servant. In the process of servicing +that invocation, the servant makes a twoway invocation on 'o'. + +This example illustrates an interaction that should be familiar to +anyone who's used ACE: the process of registering a handler with a +Reactor. The EventHandler is the local object reference, and the +Reactor the remote servant. NOTE: This example in no way should be +construed as testimony that remote Reactors make sense or are in any +way useful. It is merely a motivating example! + +You can either run the server in the background in the same window as +the client or open a separate window for the client and server. + +The client and server by default make use of the Naming Service. The +cubit server now has its own NamingServer implementation and hence you +don't have to start the NamingService before starting the client and +server. + + You just have to use the -s flags on both the server and +client if you don't want to use the naming service. + + EXECUTION + ========= + +server: +------- + +% server [-d] [-s] [-ORBhost <serverhost>] [-ORBport <portnum>] + [-o <ior_output_file>] + +Options: +------- +-s Tells the server not to use the Naming Service. + +-d Debug flag (It is additive more -d flags will give debugging). + +-o Outputs the ior file to the file + +Using -d turns on debugging messages. It is additive, i.e., the more +-d options provided, the more debugging you can get. At the moment, +only 2 levels of debugging are implemented, and more than 2 -d options +are ignored. + + +client: +------- + +% client [-d] [-s] [-x] <-f ior_file> <-k ior> -n <iterations> + +Options: +------- + d Debug flag + s Don't Use the Naming Service + x Tells the server to shutdown. + f Reads the ior from the file + k Reads the ior from commandline + + There are 3 ways of giving the IOR to the client: + + 1. From a file using the -f option. (This file can be produced using + the -o option of the server.) + + 2. Directly on the commandline using the -k option. + + 3. Get it from the Naming Service (which is the default client + behavior). + +NestedUpCalls_Test: +------------------ + + This is a simple test program which tests the server and +client using the default options of the server and client. To test +using this just run + + % NestedUpCalls_Test diff --git a/TAO/tests/NestedUpcall/Reactor/Reactor.idl b/TAO/tests/NestedUpcall/Reactor/Reactor.idl new file mode 100644 index 00000000000..ae70a317d8b --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/Reactor.idl @@ -0,0 +1,52 @@ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpcall +// +// = FILENAME +// Reactor.idl +// +// = DESCRIPTION +// A simple test of nested upcalls using a structure we likely all +// know and love. +// +// Existence of this interface should not be taken as testimony that +// such a structure would work in ACE! There is no such thing as an +// IDL interface to the Reactor (yet)! +// +// = AUTHORS +// Chris Cleeland +// +// ============================================================================ + +interface Reactor; + +interface EventHandler +{ + Long peer (); + // Returns an integer corresponding to the event handler's file + // descriptor. + + UShort decrement (in Reactor r, in UShort num); + // Decrements <num> by invoking the <decrement> operation on <r> + // and returning that value, finally stopping when it gets to zero. +}; + +interface Reactor +{ + Long register_handler (in EventHandler eh); + // Turns around and queries <eh> for the peer. + + oneway void set_value (); + // do-nothing oneway to check for proper operation. + + UShort decrement (in EventHandler eh, in UShort num); + // Decrements <num> by invoking the <decrement> operation on <eh> + // and returning that value, finally stopping when it gets to zero. + + void stop (); + // Stops the reactor. +}; + diff --git a/TAO/tests/NestedUpcall/Reactor/client.cpp b/TAO/tests/NestedUpcall/Reactor/client.cpp new file mode 100644 index 00000000000..9191230d647 --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/client.cpp @@ -0,0 +1,302 @@ +// $Id$ + +#include "ace/Profile_Timer.h" +#include "ace/Env_Value_T.h" +#include "ace/Read_Buffer.h" +#include "client.h" +#include "eh_i.h" +#include "orbsvcs/CosNamingC.h" + +#define quote(x) #x + +// Constructor. +NestedUpCalls_Client::NestedUpCalls_Client (void) + : nested_up_calls_reactor_key_ (0), + shutdown_ (0), + call_count_ (0), + nested_up_calls_reactor_ior_file_ (0), + f_handle_ (ACE_INVALID_HANDLE), + use_naming_service_ (1) +{ +} + +// Simple function that returns the substraction of 117 from the +// parameter. + +int +NestedUpCalls_Client::func (u_int i) +{ + return i - 117; +} + +// Reads the NestedUpCalls reactor ior from a file + +int +NestedUpCalls_Client::read_ior (char *filename) +{ + // Open the file for reading. + this->f_handle_ = ACE_OS::open (filename,0); + + if (this->f_handle_ == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for writing: %p\n", + filename), + -1); + ACE_Read_Buffer ior_buffer (this->f_handle_); + this->nested_up_calls_reactor_key_ = ior_buffer.read (); + + if (this->nested_up_calls_reactor_key_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to allocate memory to read ior: %p\n"), + -1); + return 0; +} + +// Parses the command line arguments and returns an error status. + +int +NestedUpCalls_Client::parse_args (void) +{ + ACE_Get_Opt get_opts (argc_, argv_, "dn:f:k:xs"); + int c; + int result; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag + TAO_debug_level++; + break; + case 'f': // read the IOR from the file. + result = this->read_ior (get_opts.optarg); + if (result < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to read ior from %s : %p\n", + get_opts.optarg), + -1); + break; + case 'k': // read the nestedupcalls IOR from the command-line. + this->nested_up_calls_reactor_key_ = + ACE_OS::strdup (get_opts.optarg); + break; + case 'x': + this->shutdown_ = 1; + break; + case 's': // Don't use the TAO Naming Service. + this->use_naming_service_ = 0; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-f nested_up_calls_reactor-obj-ref-key-file]" + " [-k nestedupcalls-obj-ref-key]" + " [-x]" + " [-s]" + "\n", + this->argv_ [0]), + -1); + } + + // Indicates successful parsing of command line. + return 0; +} + +// Execute client example code. +int +NestedUpCalls_Client::run (void) +{ + + TAO_TRY + { + // Create an EventHandler servant to hand to the other side... + auto_ptr<EventHandler_i> eh_impl (new EventHandler_i); + EventHandler_var eh = eh_impl->_this (TAO_TRY_ENV); + + // Get into the event loop briefly...just to make sure that the + // ORB gets a chance to set things up for us to be a server. + // What this really means is that there's a listening port. + // + // The bad thing is that we have to do something non-standard + // such as call orb->run() with a zero timeout. It would be + // nice if the spec gave us a standard way to do this. + if (orb_->run (ACE_Time_Value::zero) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%s: %p\n", + argv_[0], "unable to get the ORB Core to listen"), + -1); + + // Now, after all that, we can invoke an operation on the remote + // side. + CORBA::Long r = this->reactor_->register_handler (eh.in (), TAO_TRY_ENV); + + // We ought to have a result! + ACE_DEBUG ((LM_DEBUG, + "%s: received %d as return from register_handler ()\n", + argv_[0], r)); + + this->reactor_->set_value (TAO_TRY_ENV); + TAO_CHECK_ENV; + + this->reactor_->decrement (eh.in (), 5, TAO_TRY_ENV); + TAO_CHECK_ENV; + + this->reactor_->stop (TAO_TRY_ENV); + TAO_CHECK_ENV; + + if (this->shutdown_) + { + dexc (this->env_, "server, please ACE_OS::exit"); + } + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("Nestedupcalls::run ()"); + return -1; + } + TAO_ENDTRY; + return 0; +} + +NestedUpCalls_Client::~NestedUpCalls_Client (void) +{ + // Free resources + // Close the ior files + if (this->nested_up_calls_reactor_ior_file_) + ACE_OS::fclose (this->nested_up_calls_reactor_ior_file_); + if (this->f_handle_ != ACE_INVALID_HANDLE) + ACE_OS::close (this->f_handle_); + + if (this->nested_up_calls_reactor_key_ != 0) + ACE_OS::free (this->nested_up_calls_reactor_key_); +} + +int +NestedUpCalls_Client::init_naming_service (void) +{ + TAO_TRY + { + CORBA::Object_var naming_obj = + this->orb_->resolve_initial_references ("NameService"); + if (CORBA::is_nil (naming_obj.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Unable to resolve the Name Service.\n"), + -1); + CosNaming::NamingContext_var naming_context = + CosNaming::NamingContext::_narrow (naming_obj.in (), + TAO_TRY_ENV); + TAO_CHECK_ENV; + + CosNaming::Name nested_up_calls_reactor_name (2); + nested_up_calls_reactor_name.length (2); + nested_up_calls_reactor_name[0].id = CORBA::string_dup ("NestedUpCalls"); + nested_up_calls_reactor_name[1].id = CORBA::string_dup ("nested_up_calls_reactor"); + CORBA::Object_var reactor_obj = + naming_context->resolve (nested_up_calls_reactor_name,TAO_TRY_ENV); + TAO_CHECK_ENV; + + this->reactor_ = + Reactor::_narrow (reactor_obj.in (),TAO_TRY_ENV); + TAO_CHECK_ENV; + + if (CORBA::is_nil (this->reactor_.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " could not resolve nested up calls reactor in Naming service <%s>\n"), + -1); + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("NestedUpCalls::init_naming_service"); + return -1; + } + TAO_ENDTRY; + + return 0; +} + +int +NestedUpCalls_Client::init (int argc, char **argv) +{ + int naming_result; + this->argc_ = argc; + this->argv_ = argv; + + TAO_TRY + { + // Retrieve the ORB. + this->orb_ = CORBA::ORB_init (this->argc_, + this->argv_, + "internet", + TAO_TRY_ENV); + TAO_CHECK_ENV; + + // Parse command line and verify parameters. + if (this->parse_args () == -1) + return -1; + + if (this->use_naming_service_) + { + naming_result = this->init_naming_service (); + if (naming_result < 0) + return naming_result; + } + else + { + if (this->nested_up_calls_reactor_key_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "%s: no nested up calls reactor key specified\n", + this->argv_[0]), + -1); + + + CORBA::Object_var reactor_object = + this->orb_->string_to_object (this->nested_up_calls_reactor_key_, + TAO_TRY_ENV); + TAO_CHECK_ENV; + + this->reactor_ = + Reactor::_narrow (reactor_object.in(), TAO_TRY_ENV); + TAO_CHECK_ENV; + + if (CORBA::is_nil (this->reactor_.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "invalid reactor key <%s>\n", + this->nested_up_calls_reactor_key_), + -1); + } + + ACE_DEBUG ((LM_DEBUG, "Reactor received OK\n")); + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("NestedUpCalls::init"); + return -1; + } + TAO_ENDTRY; + + return 0; +} + +// This function runs the test. +int +main (int argc, char **argv) +{ + NestedUpCalls_Client nestedupcalls_client; + + ACE_DEBUG ((LM_DEBUG, + "\n \t NestedUpCalls: client \n\n")); + + if (nestedupcalls_client.init (argc, argv) == -1) + return 1; + else + return nestedupcalls_client.run (); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class auto_ptr<EventHandler_i>; +template class ACE_Auto_Basic_Ptr<EventHandler_i>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate auto_ptr<EventHandler_i> +#pragma instantiate ACE_Auto_Basic_Ptr<EventHandler_i> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tests/NestedUpcall/Reactor/client.dsp b/TAO/tests/NestedUpcall/Reactor/client.dsp new file mode 100644 index 00000000000..419cb3f55d2 --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/client.dsp @@ -0,0 +1,138 @@ +# Microsoft Developer Studio Project File - Name="client" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=client - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "client.mak" CFG="client - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "client - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "client - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "client - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\.." /I "..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /machine:I386
+# ADD LINK32 ace.lib TAO.lib orbsvcs.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\orbsvcs\orbsvcs"
+
+!ELSEIF "$(CFG)" == "client - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\.." /I "..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib TAO.lib orbsvcs.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\orbsvcs\orbsvcs"
+
+!ENDIF
+
+# Begin Target
+
+# Name "client - Win32 Release"
+# Name "client - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\client.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\eh_i.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Reactor.idl
+
+!IF "$(CFG)" == "client - Win32 Release"
+
+!ELSEIF "$(CFG)" == "client - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\Reactor.idl
+InputName=Reactor
+
+BuildCmds= \
+ tao_idl $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\ReactorC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ReactorS.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/TAO/tests/NestedUpcall/Reactor/client.h b/TAO/tests/NestedUpcall/Reactor/client.h new file mode 100644 index 00000000000..706a4d9105a --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/client.h @@ -0,0 +1,94 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls +// +// = FILENAME +// client.h +// +// = DESCRIPTION +// +// +// = AUTHORS +// Aniruddha Gokhale, Sumedh Mungee, and Sergio Flores-Gaitan +// +// ============================================================================ + +#include "ace/Get_Opt.h" +#include "tao/corba.h" +#include "reactor_i.h" +#include "ace/Auto_Ptr.h" + +class NestedUpCalls_Client +{ + // = TITLE + // Defines a class that encapsulates behaviour of the NestedUpCalls client + // example. Provides a better understanding of the logic in an + // object oriented way. + // + // = DESCRIPTION + // This class declares an interface to run the example client for + // NestedUpCalls CORBA server. All the complexity for initializing the + // server is hidden in the class. Just the run() interface is needed. +public: + // = Constructor and destructor. + NestedUpCalls_Client (void); + ~NestedUpCalls_Client (void); + + int run (void); + // Execute client example code. + + int init (int argc, char **argv); + // Initialize the client communication endpoint with server. + +private: + int init_naming_service (void); + // Function to initialize the naming service. + + int func (u_int i); + // Simple function that returns the substraction of 117 from the + // parameter. + + int read_ior (char *filename); + // Function to read the NestedUpCalls reactor ior from a file. + + int parse_args (void); + // Parses the arguments passed on the command line. + + int argc_; + // # of arguments on the command line. + + char **argv_; + // arguments from command line. + + char *nested_up_calls_reactor_key_; + // Key of reactor obj ref. + + int shutdown_; + // Flag to tell server to shutdown. + + Reactor_var reactor_; + // reactor pointer for NestedUpCalls. + + CORBA::Environment env_; + // Environment variable. + + CORBA::ORB_var orb_; + // Remember our orb. + + u_int call_count_; + // # of calls made to functions. + + FILE *nested_up_calls_reactor_ior_file_; + // File from which to obtain the IOR. + + ACE_HANDLE f_handle_; + // File handle to read the IOR. + + int use_naming_service_; + // Flag to tell client not to use Namingservice to find the NestedUpCalls + // reactor. +}; diff --git a/TAO/tests/NestedUpcall/Reactor/eh_i.cpp b/TAO/tests/NestedUpcall/Reactor/eh_i.cpp new file mode 100644 index 00000000000..a6961ea984e --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/eh_i.cpp @@ -0,0 +1,47 @@ +// $Id$ + +#include "tao/corba.h" +#include "eh_i.h" + +// CTOR +EventHandler_i::EventHandler_i (void) +{ +} + +// DTOR +EventHandler_i::~EventHandler_i (void) +{ +} + +// Return a long +CORBA::Long +EventHandler_i::peer (CORBA::Environment &env) +{ + // Doesn't matter what value we return! + CORBA::Long val = 6; + + ACE_DEBUG ((LM_DEBUG, + "EventHandler_i::peer() returning %d\n", + val)); + + return val; +} + +CORBA::UShort +EventHandler_i::decrement (Reactor_ptr eh, + CORBA::UShort num, + CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, "%{%I(%P|%t) EventHandler::decrement (%d)%$", num)); + + CORBA::UShort ret; + if (--num <= 0) + ret = 0; + else + { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) EventHandler::decrement() invoking Reactor::decrement(%d)%$", num)); + ret = eh->decrement (_this (env), num, env); + } + ACE_DEBUG ((LM_DEBUG, "%}(%P|%t) EventHandler::decrement() returning %d%$", ret)); + return ret; +} diff --git a/TAO/tests/NestedUpcall/Reactor/eh_i.h b/TAO/tests/NestedUpcall/Reactor/eh_i.h new file mode 100644 index 00000000000..c8443da0bcb --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/eh_i.h @@ -0,0 +1,30 @@ +// -*- c++ -*- +// $Id$ + +#if !defined (EVENTHANDLER_I_H) +# define EVENTHANDLER_I_H + +#include "ReactorS.h" + +class EventHandler_i : public POA_EventHandler +{ + // = TITLE + // Servant implementation for the <EventHandler> IDL interface. +public: + EventHandler_i (void); + // Constructor. + + virtual ~EventHandler_i (void); + // Destructor. + + virtual CORBA::Long peer (CORBA::Environment &env); + // Return some value...doesn't matter what. + + virtual CORBA::UShort decrement (Reactor_ptr eh, + CORBA::UShort num, + CORBA::Environment &env); + // deccrement <num> by calling decrement thru <eh> until zero is + // reached, then return. +}; + +#endif /* EVENTHANDLER_I_H */ diff --git a/TAO/tests/NestedUpcall/Reactor/reactor_i.cpp b/TAO/tests/NestedUpcall/Reactor/reactor_i.cpp new file mode 100644 index 00000000000..d5b5119c6f0 --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/reactor_i.cpp @@ -0,0 +1,78 @@ +// $Id$ + +#include "tao/corba.h" +#include "reactor_i.h" + +// CTOR +Reactor_i::Reactor_i (void) +{ +} + +// DTOR +Reactor_i::~Reactor_i (void) +{ +} + +// register...with nothing +CORBA::Long +Reactor_i::register_handler (EventHandler_ptr eh, + CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) BEGIN Reactor_i::register_handler ()\n")); + + CORBA::Long r = 0; + + TAO_TRY + { + r = eh->peer (TAO_TRY_ENV); + TAO_CHECK_ENV; + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("getting peer"); + } + TAO_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) got this value from peer: %d\n", + r)); + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) END Reactor_i::register_handler ()\n")); + return 0; +} + +void +Reactor_i::set_value (CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) doing Reactor_i::set_value()\n")); +} + +CORBA::UShort +Reactor_i::decrement (EventHandler_ptr eh, + CORBA::UShort num, + CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, "%{%I(%P|%t) Reactor::decrement (%d)%$", num)); + + CORBA::UShort ret; + if (--num <= 0) + ret = 0; + else + { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Reactor::decrement() invoking EventHandler::decrement(%d)%$", num)); + Reactor_var me = _this (env); + ret = eh->decrement (me.in (), num, env); + } + ACE_DEBUG ((LM_DEBUG, "%}(%P|%t) Reactor::decrement() returning %d\n", ret)); + return ret; +} + +void +Reactor_i::stop (CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, "(%P|%t) stopping.\n")); + TAO_ORB_Core_instance ()->orb ()->shutdown (); +} diff --git a/TAO/tests/NestedUpcall/Reactor/reactor_i.h b/TAO/tests/NestedUpcall/Reactor/reactor_i.h new file mode 100644 index 00000000000..3d4ede734c9 --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/reactor_i.h @@ -0,0 +1,36 @@ +// -*- c++ -*- +// $Id$ + +#if !defined (REACTOR_I_H) +# define REACTOR_I_H + +#include "ReactorS.h" + +class Reactor_i : public POA_Reactor +{ + // = TITLE + // Implement the <Reactor> IDL interface. +public: + Reactor_i (void); + // Constructor. + + virtual ~Reactor_i (void); + // Destructor. + + virtual CORBA::Long register_handler(EventHandler_ptr eh, + CORBA::Environment &env); + // Register (with nothing...it's an example!) + + virtual void set_value (CORBA::Environment &env); + + virtual CORBA::UShort decrement (EventHandler_ptr eh, + CORBA::UShort num, + CORBA::Environment &env); + // deccrement <num> by calling decrement thru <eh> until zero is + // reached, then return. + + virtual void stop (CORBA::Environment &env); + // Stops the reactor. +}; + +#endif /* REACTOR_I_H */ diff --git a/TAO/tests/NestedUpcall/Reactor/server.cpp b/TAO/tests/NestedUpcall/Reactor/server.cpp new file mode 100644 index 00000000000..ba2e2a181bb --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/server.cpp @@ -0,0 +1,175 @@ +// $Id$ + +#include "server.h" + +NestedUpCalls_Server::NestedUpCalls_Server (void) + : use_naming_service_ (1), + ior_output_file_ (0) +{ +} + +int +NestedUpCalls_Server::parse_args (void) +{ + ACE_Get_Opt get_opts (argc_, argv_, "dn:o:s"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag. + TAO_debug_level++; + break; + case 'o': // output the IOR to a file. + this->ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w"); + if (this->ior_output_file_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for writing: %p\n", + get_opts.optarg), -1); + break; + case 's': // Don't use the TAO Naming Service. + this->use_naming_service_=0; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-o] <ior_output_file>" + " [-s]" + "\n", + argv_ [0]), + 1); + } + + // Indicates successful parsing of command line. + return 0; +} + +int +NestedUpCalls_Server::init (int argc, + char** argv, + CORBA::Environment& env) +{ + // Call the init of TAO_ORB_Manager to create a child POA + // under the root POA. + this->orb_manager_.init_child_poa (argc, + argv, + "child_poa", + env); + + TAO_CHECK_ENV_RETURN (env,-1); + this->argc_ = argc; + this->argv_ = argv; + + this->parse_args (); + // ~~ check for the return value here + + CORBA::String_var str = + this->orb_manager_.activate_under_child_poa ("reactor", + &this->reactor_impl_, + env); + ACE_DEBUG ((LM_DEBUG, + "The IOR is: <%s>\n", + str.in ())); + + if (this->ior_output_file_) + { + ACE_OS::fprintf (this->ior_output_file_, + "%s", + str.in ()); + ACE_OS::fclose (this->ior_output_file_); + } + + if (this->use_naming_service_) + return this->init_naming_service (env); + + return 0; +} + +// Initialisation of Naming Service and register IDL_Cubit Context and +// cubit_factory object. + +int +NestedUpCalls_Server::init_naming_service (CORBA::Environment& env) +{ + int result; + CORBA::ORB_var orb; + PortableServer::POA_var child_poa; + + orb = this->orb_manager_.orb (); + child_poa = this->orb_manager_.child_poa (); + + result = this->my_name_server_.init (orb.in (), + child_poa.in ()); + if (result < 0) + return result; + reactor_ = this->reactor_impl_._this (env); + TAO_CHECK_ENV_RETURN (env,-1); + + //Register the nested_up_calls_reactor name with the NestedUpCalls Naming + //Context... + CosNaming::Name nested_up_calls_context_name (1); + nested_up_calls_context_name.length (1); + nested_up_calls_context_name[0].id = CORBA::string_dup ("NestedUpCalls"); + this->naming_context_ = + this->my_name_server_->bind_new_context (nested_up_calls_context_name, + env); + TAO_CHECK_ENV_RETURN (env,-1); + + CosNaming::Name reactor_name (1); + reactor_name.length (1); + reactor_name[0].id = CORBA::string_dup ("nested_up_calls_reactor"); + this->naming_context_->bind (reactor_name, + reactor_.in (), + env); + TAO_CHECK_ENV_RETURN (env,-1); + return 0; +} + +int +NestedUpCalls_Server::run (CORBA::Environment& env) +{ + if (this->orb_manager_.run (env) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "NestedUpCalls_Server::run"), + -1); + return 0; +} + +NestedUpCalls_Server::~NestedUpCalls_Server (void) +{ +} + +int +main (int argc, char *argv[]) +{ + NestedUpCalls_Server nested_up_calls_server; + + ACE_DEBUG ((LM_DEBUG, + "\n \t NestedUpCalls:SERVER \n \n")); + TAO_TRY + { + if (nested_up_calls_server.init (argc,argv,TAO_TRY_ENV) == -1) + return 1; + else + { + nested_up_calls_server.run (TAO_TRY_ENV); + TAO_CHECK_ENV; + } + } + TAO_CATCH (CORBA::SystemException, sysex) + { + ACE_UNUSED_ARG (sysex); + TAO_TRY_ENV.print_exception ("System Exception"); + return -1; + } + TAO_CATCH (CORBA::UserException, userex) + { + ACE_UNUSED_ARG (userex); + TAO_TRY_ENV.print_exception ("User Exception"); + return -1; + } + TAO_ENDTRY; + return 0; +} diff --git a/TAO/tests/NestedUpcall/Reactor/server.dsp b/TAO/tests/NestedUpcall/Reactor/server.dsp new file mode 100644 index 00000000000..76c5544d10c --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/server.dsp @@ -0,0 +1,138 @@ +# Microsoft Developer Studio Project File - Name="server" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=server - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "server.mak" CFG="server - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "server - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "server - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "server - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\.." /I "..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /machine:I386
+# ADD LINK32 TAO.lib ace.lib orbsvcs.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\orbsvcs\orbsvcs"
+
+!ELSEIF "$(CFG)" == "server - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir ""
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\.." /I "..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 TAO.lib aced.lib orbsvcs.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\orbsvcs\orbsvcs"
+
+!ENDIF
+
+# Begin Target
+
+# Name "server - Win32 Release"
+# Name "server - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\Reactor.idl
+
+!IF "$(CFG)" == "server - Win32 Release"
+
+!ELSEIF "$(CFG)" == "server - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\Reactor.idl
+InputName=Reactor
+
+BuildCmds= \
+ tao_idl $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\reactor_i.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ReactorC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ReactorS.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\server.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/TAO/tests/NestedUpcall/Reactor/server.h b/TAO/tests/NestedUpcall/Reactor/server.h new file mode 100644 index 00000000000..cb02f84b701 --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/server.h @@ -0,0 +1,98 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls +// +// = FILENAME +// server.h +// +// = DESCRIPTION +// This class implements a simple NestedUpCalls CORBA server for the NestedUpCalls +// example using skeletons generated by the TAO ORB compiler. +// +// = AUTHORS +// Nagarajan Surendran (naga@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_NUC_SERVER_H) +#define _NUC_SERVER_H + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "tao/TAO.h" +#include "orbsvcs/CosNamingC.h" +#include "reactor_i.h" +#include "orbsvcs/Naming/Naming_Utils.h" + +class NestedUpCalls_Server +{ + // = TITLE + // Defines a NestedUpCalls Server class that implements the functionality + // of a server process as an object. + // + // = DESCRIPTION + // The interface is quite simple. A server program has to call + // init to initialize the NestedUpCalls_Server's state and then call run + // to run the orb. +public: + + NestedUpCalls_Server (void); + // Default constructor + + ~NestedUpCalls_Server (void); + // Destructor + + int init (int argc, + char **argv, + CORBA::Environment& env); + // Initialize the NestedUpCalls_Server state - parsing arguments and ... + + int run (CORBA::Environment& env); + // Run the orb + +private: + int parse_args (void); + // Parses the commandline arguments. + + int init_naming_service (CORBA::Environment &env); + // Initialises the name server and registers NestedUpCalls reactor with the + // name server. + + int use_naming_service_; + //Flag to tell server not to use the TAO Naming Service to register + //the NestedUpCalls reactor. + + FILE* ior_output_file_; + // File to output the NestedUpCalls reactor IOR. + + TAO_ORB_Manager orb_manager_; + // The ORB manager + + TAO_Naming_Server my_name_server_; + // An instance of the name server used for registering the reactor + // objects. + + Reactor_i reactor_impl_; + // Implementation object of the NestedUpCalls reactor. + + Reactor_var reactor_; + // Reactor_var to register with NamingService. + + CosNaming::NamingContext_var NestedUpCalls_context_; + // Naming context for the NestedUpCalls_reactor. + + CosNaming::NamingContext_var naming_context_; + // Naming context for the Naming Service. + + int argc_; + // Number of commandline arguments. + + char **argv_; + // commandline arguments. +}; + +#endif /* _NUC_SERVER_H */ diff --git a/TAO/tests/NestedUpcall/Reactor/svc.conf b/TAO/tests/NestedUpcall/Reactor/svc.conf new file mode 100644 index 00000000000..43c6a486c92 --- /dev/null +++ b/TAO/tests/NestedUpcall/Reactor/svc.conf @@ -0,0 +1,49 @@ +# $Id$ +# +# This file contains a sample ACE_Service_Config configuration +# file specifying the strategy factories utilized by an application +# using TAO. There are currently only two possible factories: +# Client_Strategy_Factory and Server_Strategy_Factory. These names +# must be used as the second argument to their corresponding line, +# because that's what the ORB uses to find the desired factory. +# +# Note that there are two unordinary characteristics of the way *this* +# file is set up: +# - both client and server strategies are specified in the same +# file, which would only make sense for co-located clients & servers +# - both of the factories are actually sourced out of libTAO.so +# (TAO.DLL on Win32), and they would normally be in a separate +# dll from the TAO ORB Core. +# +# The options which can be passed to the Resource Factory are: +# +# -ORBresources <which> +# where <which> can be 'global' to specify globally-held resources, +# or 'tss' to specify thread-specific resources. +# +# The options which can be passed to the Client are: +# <none currently> +# +# The options which can be passed to the Server are: +# +# -ORBconcurrency <which> +# where <which> can be 'thread-per-connection' to specify +# use of the ACE_Threaded_Strategy concurrency strategy, +# or 'reactive' to specify use of the ACE_Reactive_Strategy +# concurrency strategy. +# +# -ORBthreadflags <flags> +# specifies the default thread flags to use, where <flags> is a +# logical OR'ing of the flags THR_DETACHED, THR_BOUND, THR_NEW_LWP, +# THR_SUSPENDED, or THR_DAEMON. Note that not every flag may be valid +# on every platform. +# +# -ORBdemuxstrategy <which> +# where <which> can be one of 'dynamic', 'linear', 'active', or 'user', +# and specifies the type of object lookup strategy used internally. +# -ORBtablesize <unsigned> +# specifies the size of the object table +# +dynamic Resource_Factory Service_Object * TAO:_make_TAO_Resource_Factory() "-ORBresources global" +dynamic Client_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Client_Strategy_Factory() +dynamic Server_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Server_Strategy_Factory() "-ORBconcurrency reactive -ORBdemuxstrategy dynamic -ORBtablesize 128" diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Initiator_Impl.cpp b/TAO/tests/NestedUpcall/Triangle_Test/Initiator_Impl.cpp new file mode 100644 index 00000000000..833de7d3e9c --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Initiator_Impl.cpp @@ -0,0 +1,62 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// Object_A_Impl.cpp +// +// = DESCRIPTION +// This class implements the Object A of the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#include "tao/corba.h" +#include "Initiator_Impl.h" + +// CTOR +Initiator_Impl::Initiator_Impl (Object_A_ptr object_A_ptr, + Object_B_ptr object_B_ptr) +: object_A_var_ (Object_A::_duplicate (object_A_ptr)), + object_B_var_ (Object_B::_duplicate (object_B_ptr)) +{ +} + +// DTOR +Initiator_Impl::~Initiator_Impl (void) +{ +} + + + +void +Initiator_Impl::foo_object_B (CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) BEGIN Initiator_Impl::foo_object_B ()\n")); + + TAO_TRY + { + this->object_B_var_->foo (this->object_A_var_.in (), + TAO_TRY_ENV); + TAO_CHECK_ENV; + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) BEGIN Initiator_Impl::foo_object_B: Returned from call.\n")); + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("calling the server_"); + } + TAO_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) END Initiator_Impl::foo_object_B ()\n")); +} + diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Initiator_Impl.h b/TAO/tests/NestedUpcall/Triangle_Test/Initiator_Impl.h new file mode 100644 index 00000000000..155c1b7e7c7 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Initiator_Impl.h @@ -0,0 +1,48 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// Initiator_Impl.h +// +// = DESCRIPTION +// This class implements the Initiator of the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#if !defined (INITIATOR_IMPL_H) +# define INITIATOR_IMPL_H + +#include "Triangle_TestS.h" + +class Initiator_Impl : public POA_Initiator +{ + // = TITLE + // Implement the <Initiator> IDL interface. +public: + Initiator_Impl (Object_A_ptr object_A_ptr, + Object_B_ptr object_B_ptr); + // Constructor. + + virtual ~Initiator_Impl (void); + // Destructor. + + virtual void foo_object_B (CORBA::Environment &env); + +private: + Object_A_var object_A_var_; + // reference to object A + + Object_B_var object_B_var_; + // reference to object B +}; + +#endif /* INITIATOR_IMPL_H */ diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Object_A_Impl.cpp b/TAO/tests/NestedUpcall/Triangle_Test/Object_A_Impl.cpp new file mode 100644 index 00000000000..7cf28038e2e --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Object_A_Impl.cpp @@ -0,0 +1,73 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// Object_A_Impl.cpp +// +// = DESCRIPTION +// This class implements the Object A of the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#include "tao/corba.h" +#include "Object_A_Impl.h" + +// CTOR +Object_A_Impl::Object_A_Impl (void) +: finish_two_way_call_ (0) +{ +} + +// DTOR +Object_A_Impl::~Object_A_Impl (void) +{ +} + + + +void +Object_A_Impl::foo (Initiator_ptr initiator_ptr, + CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) BEGIN Object_A_Impl::foo ()\n")); + + TAO_TRY + { + initiator_ptr->foo_object_B (TAO_TRY_ENV); + TAO_CHECK_ENV; + + while (!this->finish_two_way_call_) + TAO_ORB_Core_instance ()->reactor ()->handle_events (); + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("calling the initiator"); + } + TAO_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) END Object_A_Impl::foo ()\n")); +} + +void +Object_A_Impl::finish (CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) BEGIN Object_A_Impl::finish ()\n")); + + this->finish_two_way_call_ = 1; + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) END Object_A_Impl::finish ()\n")); + +}
\ No newline at end of file diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Object_A_Impl.h b/TAO/tests/NestedUpcall/Triangle_Test/Object_A_Impl.h new file mode 100644 index 00000000000..27f54f6b204 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Object_A_Impl.h @@ -0,0 +1,45 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// Object_A_Impl.h +// +// = DESCRIPTION +// This class implements the Object A of the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#if !defined (OBJECT_B_IMPL_H) +# define OBJECT_B_IMPL_H + +#include "Triangle_TestS.h" + +class Object_A_Impl : public POA_Object_A +{ + // = TITLE + // Implement the <Object_A> IDL interface. +public: + Object_A_Impl (void); + // Constructor. + + virtual ~Object_A_Impl (void); + // Destructor. + + virtual void foo (Initiator_ptr initiator_ptr, + CORBA::Environment &env); + + virtual void finish (CORBA::Environment &env); + + unsigned long finish_two_way_call_; +}; + +#endif /* OBJECT_B_IMPL_H */ diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Object_B_Impl.cpp b/TAO/tests/NestedUpcall/Triangle_Test/Object_B_Impl.cpp new file mode 100644 index 00000000000..1adba85321e --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Object_B_Impl.cpp @@ -0,0 +1,69 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// Object_B_Impl.cpp +// +// = DESCRIPTION +// This class implements the Object B of the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#include "tao/corba.h" +#include "Object_B_Impl.h" + +// CTOR +Object_B_Impl::Object_B_Impl (void) +{ +} + +// DTOR +Object_B_Impl::~Object_B_Impl (void) +{ +} + + + +void +Object_B_Impl::foo (Object_A_ptr object_A_ptr, + CORBA::Environment &env) +{ + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) BEGIN Object_B_Impl::foo ()\n")); + + TAO_TRY + { + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) BEGIN Object_B_Impl::foo: Trying to call Object A\n")); + + object_A_ptr->finish (TAO_TRY_ENV); + TAO_CHECK_ENV; + + // Start to wait on this variable, it is set to true + // by the method finish () + long int usecs = 500000; + ACE_Time_Value pause(0, usecs); + + ACE_OS::sleep(pause); + + } + TAO_CATCHANY + { + TAO_TRY_ENV.print_exception ("calling the initiator"); + } + TAO_ENDTRY; + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) END Object_B_Impl::foo ()\n")); +} + diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Object_B_Impl.h b/TAO/tests/NestedUpcall/Triangle_Test/Object_B_Impl.h new file mode 100644 index 00000000000..9e195772cc1 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Object_B_Impl.h @@ -0,0 +1,41 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// Object_B_Impl.h +// +// = DESCRIPTION +// This class implements the Object B of the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#if !defined (OBJECT_B_IMPL_H) +# define OBJECT_B_IMPL_H + +#include "Triangle_TestS.h" + +class Object_B_Impl : public POA_Object_B +{ + // = TITLE + // Implement the <Object_B> IDL interface. +public: + Object_B_Impl (void); + // Constructor. + + virtual ~Object_B_Impl (void); + // Destructor. + + virtual void foo(Object_A_ptr object_A_ptr, + CORBA::Environment &env); +}; + +#endif /* OBJECT_B_IMPL_H */ diff --git a/TAO/tests/NestedUpcall/Triangle_Test/README b/TAO/tests/NestedUpcall/Triangle_Test/README new file mode 100644 index 00000000000..70e8d57e5fe --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/README @@ -0,0 +1,31 @@ +$Id$ +Documentation about the Triangle test + +Purpose: + +Is to show how nested upcalls are handled. + +Three objects exist: +Object A, Object B and the Initiator + +The initiator calls a two-way call foo on object A, +object A calls foo_object_B, a one-way call, on the initiator, +this causes initiator to call foo on object B, +this causes object B to (oneway) call finish on object A, +this causes object A to return from its first two-way call +(before object B returns from its two-way call), +after a second or so object B returns from its two-way call. + +The printed order should show, that the replies are +handled in the stack order, but not in the actual +arriving order. + +To start: + +%server_A -o server1 -ORBport 10045 +% +%server_B -o server2 -ORBport 10046 +% +%initiator -f server1 -g server2 -ORBport 10047 + +
\ No newline at end of file diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Triangle_Test.dsw b/TAO/tests/NestedUpcall/Triangle_Test/Triangle_Test.dsw new file mode 100644 index 00000000000..2c705afdaab --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Triangle_Test.dsw @@ -0,0 +1,53 @@ +Microsoft Developer Studio Workspace File, Format Version 5.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "initiator"=.\initiator.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "server_A"=.\server_A.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "server_B"=.\server_B.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/TAO/tests/NestedUpcall/Triangle_Test/Triangle_Test.idl b/TAO/tests/NestedUpcall/Triangle_Test/Triangle_Test.idl new file mode 100644 index 00000000000..cb9ee8d1728 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/Triangle_Test.idl @@ -0,0 +1,38 @@ +// $Id$ +// +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpcall/Triangle_Test +// +// = FILENAME +// Triangle_Test.idl +// +// = DESCRIPTION +// An example of how nested upcalls work/fail? +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + + +interface Initiator { + + oneway void foo_object_B (); + +}; + +interface Object_A { + + void foo (in Initiator initiator); + + oneway void finish (); + +}; + +interface Object_B { + + void foo (in Object_A object_A); + +}; diff --git a/TAO/tests/NestedUpcall/Triangle_Test/initiator.cpp b/TAO/tests/NestedUpcall/Triangle_Test/initiator.cpp new file mode 100644 index 00000000000..5003ad68ce7 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/initiator.cpp @@ -0,0 +1,312 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// initiator.cpp +// +// = DESCRIPTION +// This class implements a simple server for the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#include "ace/Read_Buffer.h" +#include "initiator.h" + +Initiator_Server::Initiator_Server (void) + : object_A_key_ (0), + object_B_key_ (0), + initiator_Impl_ptr_ (0), + object_A_var_ (0), + object_B_var_ (0) +{ +} + +// Reads the Object A/B IOR from a file +// A_B == 0, means read Object A's IOR +// A_B == 1, means read Object B's IOR + +int +Initiator_Server::read_ior (char *filename, unsigned int A_B) +{ + // Open the file for reading. + ACE_HANDLE f_handle = ACE_OS::open (filename,0); + + if (f_handle == ACE_INVALID_HANDLE) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for reading: %p\n", + filename), + -1); + ACE_Read_Buffer ior_buffer (f_handle); + + if (A_B == 0) + { + this->object_A_key_ = ior_buffer.read (); + if (this->object_A_key_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to allocate memory to read ior: %p\n"), + -1); + } + else + { + this->object_B_key_ = ior_buffer.read (); + if (this->object_B_key_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to allocate memory to read ior: %p\n"), + -1); + } + + return 0; +} + + +int +Initiator_Server::parse_args (void) +{ + ACE_Get_Opt get_opts (argc_, argv_, "df:g:"); + int c, result; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag. + TAO_debug_level++; + break; + case 'f': // read the IOR from the file. + result = this->read_ior (get_opts.optarg,0); + // read IOR for Object A + if (result < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to read ior from %s : %p\n", + get_opts.optarg), + -1); + break; + case 'g': // read the IOR from the file. + result = this->read_ior (get_opts.optarg,1); + // read IOR for Object A + if (result < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to read ior from %s : %p\n", + get_opts.optarg), + -1); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-f] <object_A_ior_file>" + " [-g] <object_B_ior_file>" + "\n", + argv_ [0]), + 1); + } + + // Indicates successful parsing of command line. + return 0; +} + +int +Initiator_Server::init (int argc, + char** argv, + CORBA::Environment& env) +{ + // Call the init of TAO_ORB_Manager to create a child POA + // under the root POA. + this->orb_manager_.init_child_poa (argc, + argv, + "child_poa", + env); + + TAO_CHECK_ENV_RETURN (env,-1); + this->argc_ = argc; + this->argv_ = argv; + + this->parse_args (); + // ~~ check for the return value here + + if (this->object_A_key_ == 0 || this->object_B_key_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "%s: The two objects A and B are missing\n", + this->argv_[0]), + -1); + + + TAO_TRY + { + // Get Object A + + CORBA::Object_var object_A_obj_var = + this->orb_manager_.orb()->string_to_object (this->object_A_key_, + TAO_TRY_ENV); + TAO_CHECK_ENV; + + this->object_A_var_ = + Object_A::_narrow (object_A_obj_var.in(), TAO_TRY_ENV); + TAO_CHECK_ENV; + + if (CORBA::is_nil (this->object_A_var_.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "invalid object A key <%s>\n", + object_A_key_), + -1); + + ACE_DEBUG ((LM_DEBUG, + "Object A IOR: %s\n", + this->object_A_key_)); + ACE_DEBUG ((LM_DEBUG, "Object A received OK\n")); + + + // Get Object B + + CORBA::Object_var object_B_obj_var = + this->orb_manager_.orb()->string_to_object (this->object_B_key_, + TAO_TRY_ENV); + TAO_CHECK_ENV; + + this->object_B_var_ = + Object_B::_narrow (object_B_obj_var.in(), TAO_TRY_ENV); + TAO_CHECK_ENV; + + if (CORBA::is_nil (this->object_B_var_.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "invalid object b key <%s>\n", + object_B_key_), + -1); + + ACE_DEBUG ((LM_DEBUG, + "Object A IOR: %s\n", + this->object_A_key_)); + ACE_DEBUG ((LM_DEBUG, "Object B received OK\n")); + + } + TAO_CATCH (CORBA::SystemException, sysex) + { + ACE_UNUSED_ARG (sysex); + TAO_TRY_ENV.print_exception ("System Exception"); + return -1; + } + TAO_CATCH (CORBA::UserException, userex) + { + ACE_UNUSED_ARG (userex); + TAO_TRY_ENV.print_exception ("User Exception"); + return -1; + } + TAO_ENDTRY; + + + ACE_NEW_RETURN (this->initiator_Impl_ptr_, + Initiator_Impl(this->object_A_var_.in(), + this->object_B_var_.in()), + -1); + + CORBA::String_var str = + this->orb_manager_.activate_under_child_poa ("initiator", + this->initiator_Impl_ptr_, + env); + ACE_DEBUG ((LM_DEBUG, + "The IOR is: <%s>\n", + str.in ())); + + + return 0; +} + + +int +Initiator_Server::run (CORBA::Environment& env) +{ + TAO_TRY + { + + // Get into the event loop briefly...just to make sure that the + // ORB gets a chance to set things up for us to be a server. + // What this really means is that there's a listening port. + // + // The bad thing is that we have to do something non-standard + // such as call orb->run() with a zero timeout. It would be + // nice if the spec gave us a standard way to do this. + ACE_Time_Value tv = ACE_Time_Value::zero; + if (orb_manager_.run (TAO_TRY_ENV, &tv) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%s: %p\n", + argv_[0], "unable to get the ORB Core to listen"), + -1); + TAO_CHECK_ENV; + + ACE_DEBUG ((LM_DEBUG, + "Initiator_Server::run: Trying to invoke foo on Object A\n")); + + this->object_A_var_->foo (this->initiator_Impl_ptr_->_this(TAO_TRY_ENV), + TAO_TRY_ENV); + TAO_CHECK_ENV; + ACE_DEBUG ((LM_DEBUG, + "Initiator_Server::run: Returned from invoke foo on Object A\n")); + } + TAO_CATCH (CORBA::SystemException, sysex) + { + ACE_UNUSED_ARG (sysex); + TAO_TRY_ENV.print_exception ("System Exception"); + return -1; + } + TAO_CATCH (CORBA::UserException, userex) + { + ACE_UNUSED_ARG (userex); + TAO_TRY_ENV.print_exception ("User Exception"); + return -1; + } + TAO_ENDTRY; + + return 0; +} + +Initiator_Server::~Initiator_Server (void) +{ + if (this->object_A_key_ != 0) + ACE_OS::free (this->object_A_key_); + if (this->object_B_key_ != 0) + ACE_OS::free (this->object_B_key_); + if (this->initiator_Impl_ptr_ != 0) + delete initiator_Impl_ptr_; +} + +int +main (int argc, char *argv[]) +{ + Initiator_Server initiator_Server; + + ACE_DEBUG ((LM_DEBUG, + "\n \t NestedUpCalls.Triangle_Test: Initiator Server \n \n")); + TAO_TRY + { + if (initiator_Server.init (argc,argv,TAO_TRY_ENV) == -1) + return 1; + else + { + initiator_Server.run (TAO_TRY_ENV); + TAO_CHECK_ENV; + } + } + TAO_CATCH (CORBA::SystemException, sysex) + { + ACE_UNUSED_ARG (sysex); + TAO_TRY_ENV.print_exception ("System Exception"); + return -1; + } + TAO_CATCH (CORBA::UserException, userex) + { + ACE_UNUSED_ARG (userex); + TAO_TRY_ENV.print_exception ("User Exception"); + return -1; + } + TAO_ENDTRY; + return 0; +} diff --git a/TAO/tests/NestedUpcall/Triangle_Test/initiator.dsp b/TAO/tests/NestedUpcall/Triangle_Test/initiator.dsp new file mode 100644 index 00000000000..d07799039a2 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/initiator.dsp @@ -0,0 +1,167 @@ +# Microsoft Developer Studio Project File - Name="initiator" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=initiator - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "initiator.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "initiator.mak" CFG="initiator - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "initiator - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "initiator - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "initiator - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\..\\" /I "..\..\\" /I "..\..\orbsvcs\orbsvcs" /I "..\..\.." /I "..\..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /machine:I386
+# ADD LINK32 tao.lib aced.lib orbsvcs.lib /nologo /subsystem:console /machine:I386 /out:"initiator.exe"
+
+!ELSEIF "$(CFG)" == "initiator - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\.." /I "..\.." /I "..\..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib TAO.lib orbsvcs.lib tao.lib /nologo /subsystem:console /debug /machine:I386 /out:"initiator.exe" /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\orbsvcs\orbsvcs"
+
+!ENDIF
+
+# Begin Target
+
+# Name "initiator - Win32 Release"
+# Name "initiator - Win32 Debug"
+# Begin Group "source files"
+
+# PROP Default_Filter "*.cpp"
+# Begin Source File
+
+SOURCE=.\initiator.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Initiator_Impl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestS.cpp
+# End Source File
+# End Group
+# Begin Group "header files"
+
+# PROP Default_Filter "*.h"
+# Begin Source File
+
+SOURCE=.\initiator.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Initiator_Impl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestC.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestS.h
+# End Source File
+# End Group
+# Begin Group "IDL files"
+
+# PROP Default_Filter "*.idl"
+# Begin Source File
+
+SOURCE=.\Triangle_Test.idl
+
+!IF "$(CFG)" == "initiator - Win32 Release"
+
+!ELSEIF "$(CFG)" == "initiator - Win32 Debug"
+
+# Begin Custom Build - Invoking TAO IDL compiler
+InputPath=.\Triangle_Test.idl
+InputName=Triangle_Test
+
+BuildCmds= \
+ tao_idl $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/NestedUpcall/Triangle_Test/initiator.h b/TAO/tests/NestedUpcall/Triangle_Test/initiator.h new file mode 100644 index 00000000000..749571b7fcc --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/initiator.h @@ -0,0 +1,85 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// initiator.h +// +// = DESCRIPTION +// This class implements a simple server for the +// Nested Upcalls - Triangle test +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#if !defined (_TRIANGLE_TEST_INITITATOR_SERVER_H) +#define _TRIANGLE_TEST_INITITATOR_SERVER_H + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "tao/TAO.h" +#include "Initiator_Impl.h" + +class Initiator_Server +{ + // = TITLE + // This is the server for the Initiator in the test. + // + // = DESCRIPTION + // See the README file for more information. + +public: + + Initiator_Server (void); + // Default constructor + + ~Initiator_Server (void); + // Destructor + + int read_ior (char *filename, unsigned int A_B); + // read in the IOR's for the two objects A and B + + int init (int argc, + char **argv, + CORBA::Environment& env); + // Initialize the Initiator_Server state - parsing arguments and ... + + int run (CORBA::Environment& env); + // Run the orb + +private: + int parse_args (void); + // Parses the commandline arguments. + + char * object_A_key_; + // The IOR of object A + + char * object_B_key_; + // The IOR of object B + + Object_A_var object_A_var_; + // reference to object A + + Object_B_var object_B_var_; + // reference to object B + + TAO_ORB_Manager orb_manager_; + // The ORB manager + + Initiator_Impl *initiator_Impl_ptr_; + // Implementation object of the Initiator + + int argc_; + // Number of commandline arguments. + + char **argv_; + // commandline arguments. +}; + +#endif /* _TRIANGLE_TEST_INITITATOR_SERVER_H */ diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_A.cpp b/TAO/tests/NestedUpcall/Triangle_Test/server_A.cpp new file mode 100644 index 00000000000..ef4382f69b6 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_A.cpp @@ -0,0 +1,147 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// server_A.cpp +// +// = DESCRIPTION +// This class implements a simple server for the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#include "server_A.h" + +Object_A_Server::Object_A_Server (void) + : ior_output_file_ (0) +{ +} + +int +Object_A_Server::parse_args (void) +{ + ACE_Get_Opt get_opts (argc_, argv_, "do:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag. + TAO_debug_level++; + break; + case 'o': // output the IOR to a file. + this->ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w"); + if (this->ior_output_file_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for writing: %p\n", + get_opts.optarg), -1); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-o] <ior_output_file>" + "\n", + argv_ [0]), + 1); + } + + // Indicates successful parsing of command line. + return 0; +} + +int +Object_A_Server::init (int argc, + char** argv, + CORBA::Environment& env) +{ + // Call the init of TAO_ORB_Manager to create a child POA + // under the root POA. + this->orb_manager_.init_child_poa (argc, + argv, + "child_poa", + env); + + TAO_CHECK_ENV_RETURN (env,-1); + this->argc_ = argc; + this->argv_ = argv; + + this->parse_args (); + // ~~ check for the return value here + + CORBA::String_var str = + this->orb_manager_.activate_under_child_poa ("object_A", + &this->object_A_Impl_, + env); + ACE_DEBUG ((LM_DEBUG, + "The IOR is: <%s>\n", + str.in ())); + + if (this->ior_output_file_) + { + ACE_OS::fprintf (this->ior_output_file_, + "%s", + str.in ()); + ACE_OS::fclose (this->ior_output_file_); + } + + + return 0; +} + + +int +Object_A_Server::run (CORBA::Environment& env) +{ + if (this->orb_manager_.run (env) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "NestedUpCalls_Server::run"), + -1); + return 0; +} + +Object_A_Server::~Object_A_Server (void) +{ +} + +int +main (int argc, char *argv[]) +{ + Object_A_Server object_A_Server; + + ACE_DEBUG ((LM_DEBUG, + "\n \t NestedUpCalls.Triangle_Test: Object A Server \n \n")); + TAO_TRY + { + if (object_A_Server.init (argc,argv,TAO_TRY_ENV) == -1) + return 1; + else + { + object_A_Server.run (TAO_TRY_ENV); + TAO_CHECK_ENV; + } + } + TAO_CATCH (CORBA::SystemException, sysex) + { + ACE_UNUSED_ARG (sysex); + TAO_TRY_ENV.print_exception ("System Exception"); + return -1; + } + TAO_CATCH (CORBA::UserException, userex) + { + ACE_UNUSED_ARG (userex); + TAO_TRY_ENV.print_exception ("User Exception"); + return -1; + } + TAO_ENDTRY; + return 0; +} diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_A.dsp b/TAO/tests/NestedUpcall/Triangle_Test/server_A.dsp new file mode 100644 index 00000000000..74e2903ddf3 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_A.dsp @@ -0,0 +1,167 @@ +# Microsoft Developer Studio Project File - Name="server_A" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=server_A - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "server_A.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "server_A.mak" CFG="server_A - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "server_A - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "server_A - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "server_A - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\.." /I "..\..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /machine:I386
+# 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 tao.lib aced.lib orbsvcs.lib /nologo /subsystem:console /machine:I386 /out:"server_A.exe"
+
+!ELSEIF "$(CFG)" == "server_A - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\.." /I "..\.." /I "..\..\orbsvcs" /I "..\..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib TAO.lib orbsvcs.lib tao.lib /nologo /subsystem:console /debug /machine:I386 /out:"server_A.exe" /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\orbsvcs\orbsvcs"
+
+!ENDIF
+
+# Begin Target
+
+# Name "server_A - Win32 Release"
+# Name "server_A - Win32 Debug"
+# Begin Group "source files"
+
+# PROP Default_Filter "*.cpp"
+# Begin Source File
+
+SOURCE=.\Object_A_Impl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\server_A.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestS.cpp
+# End Source File
+# End Group
+# Begin Group "header files"
+
+# PROP Default_Filter "*.h"
+# Begin Source File
+
+SOURCE=.\Object_A_Impl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\server_A.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestC.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestS.h
+# End Source File
+# End Group
+# Begin Group "IDL files"
+
+# PROP Default_Filter "*.idl"
+# Begin Source File
+
+SOURCE=.\Triangle_Test.idl
+
+!IF "$(CFG)" == "server_A - Win32 Release"
+
+!ELSEIF "$(CFG)" == "server_A - Win32 Debug"
+
+# Begin Custom Build - Invoking TAO IDL compiler
+InputPath=.\Triangle_Test.idl
+InputName=Triangle_Test
+
+BuildCmds= \
+ tao_idl $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_A.h b/TAO/tests/NestedUpcall/Triangle_Test/server_A.h new file mode 100644 index 00000000000..54086b5d706 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_A.h @@ -0,0 +1,73 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// server_A.h +// +// = DESCRIPTION +// This class implements a simple server for the +// Nested Upcalls - Triangle test +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#if !defined (_TRIANGLE_TEST_OBJECT_A_SERVER_H) +#define _TRIANGLE_TEST_OBJECT_A_SERVER_H + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "tao/TAO.h" +#include "Object_A_Impl.h" + +class Object_A_Server +{ + // = TITLE + // This is the server for the object A in the test. + // + // = DESCRIPTION + // See the README file for more information. + +public: + + Object_A_Server (void); + // Default constructor + + ~Object_A_Server (void); + // Destructor + + int init (int argc, + char **argv, + CORBA::Environment& env); + // Initialize the NestedUpCalls_Server state - parsing arguments and ... + + int run (CORBA::Environment& env); + // Run the orb + +private: + int parse_args (void); + // Parses the commandline arguments. + + FILE* ior_output_file_; + // File to output the IOR of the object A. + + TAO_ORB_Manager orb_manager_; + // The ORB manager + + Object_A_Impl object_A_Impl_; + // Implementation object of the NestedUpCalls reactor. + + int argc_; + // Number of commandline arguments. + + char **argv_; + // commandline arguments. +}; + +#endif /* _TRIANGLE_TEST_OBJECT_A_SERVER_H */ diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_B.cpp b/TAO/tests/NestedUpcall/Triangle_Test/server_B.cpp new file mode 100644 index 00000000000..f6c6dd6ac32 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_B.cpp @@ -0,0 +1,147 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// server_B.cpp +// +// = DESCRIPTION +// This class implements a simple server for the +// Nested Upcalls - Triangle test. +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#include "server_B.h" + +Object_B_Server::Object_B_Server (void) + : ior_output_file_ (0) +{ +} + +int +Object_B_Server::parse_args (void) +{ + ACE_Get_Opt get_opts (argc_, argv_, "do:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag. + TAO_debug_level++; + break; + case 'o': // output the IOR to a file. + this->ior_output_file_ = ACE_OS::fopen (get_opts.optarg, "w"); + if (this->ior_output_file_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for writing: %p\n", + get_opts.optarg), -1); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + " [-d]" + " [-o] <ior_output_file>" + "\n", + argv_ [0]), + 1); + } + + // Indicates successful parsing of command line. + return 0; +} + +int +Object_B_Server::init (int argc, + char** argv, + CORBA::Environment& env) +{ + // Call the init of TAO_ORB_Manager to create a child POA + // under the root POA. + this->orb_manager_.init_child_poa (argc, + argv, + "child_poa", + env); + + TAO_CHECK_ENV_RETURN (env,-1); + this->argc_ = argc; + this->argv_ = argv; + + this->parse_args (); + // ~~ check for the return value here + + CORBA::String_var str = + this->orb_manager_.activate_under_child_poa ("object_B", + &this->object_B_Impl_, + env); + ACE_DEBUG ((LM_DEBUG, + "The IOR is: <%s>\n", + str.in ())); + + if (this->ior_output_file_) + { + ACE_OS::fprintf (this->ior_output_file_, + "%s", + str.in ()); + ACE_OS::fclose (this->ior_output_file_); + } + + + return 0; +} + + +int +Object_B_Server::run (CORBA::Environment& env) +{ + if (this->orb_manager_.run (env) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Object_B_Server::run"), + -1); + return 0; +} + +Object_B_Server::~Object_B_Server (void) +{ +} + +int +main (int argc, char *argv[]) +{ + Object_B_Server object_B_Server; + + ACE_DEBUG ((LM_DEBUG, + "\n \t NestedUpCalls.Triangle_Test: Object B Server \n \n")); + TAO_TRY + { + if (object_B_Server.init (argc,argv,TAO_TRY_ENV) == -1) + return 1; + else + { + object_B_Server.run (TAO_TRY_ENV); + TAO_CHECK_ENV; + } + } + TAO_CATCH (CORBA::SystemException, sysex) + { + ACE_UNUSED_ARG (sysex); + TAO_TRY_ENV.print_exception ("System Exception"); + return -1; + } + TAO_CATCH (CORBA::UserException, userex) + { + ACE_UNUSED_ARG (userex); + TAO_TRY_ENV.print_exception ("User Exception"); + return -1; + } + TAO_ENDTRY; + return 0; +} diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_B.dsp b/TAO/tests/NestedUpcall/Triangle_Test/server_B.dsp new file mode 100644 index 00000000000..3a94fb67e69 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_B.dsp @@ -0,0 +1,167 @@ +# Microsoft Developer Studio Project File - Name="server_B" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=server_B - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "server_B.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "server_B.mak" CFG="server_B - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "server_B - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "server_B - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "server_B - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\.." /I "..\..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /machine:I386
+# 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 tao.lib aced.lib orbsvcs.lib /nologo /subsystem:console /machine:I386 /out:"server_B.exe"
+
+!ELSEIF "$(CFG)" == "server_B - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\.." /I "..\.." /I "..\..\orbsvcs" /I "..\..\..\.." /I "..\..\..\orbsvcs" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# 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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 aced.lib TAO.lib orbsvcs.lib tao.lib /nologo /subsystem:console /debug /machine:I386 /out:"server_B.exe" /pdbtype:sept /libpath:"..\..\..\..\ace" /libpath:"..\..\..\tao" /libpath:"..\..\..\orbsvcs\orbsvcs"
+
+!ENDIF
+
+# Begin Target
+
+# Name "server_B - Win32 Release"
+# Name "server_B - Win32 Debug"
+# Begin Group "source files"
+
+# PROP Default_Filter "*.cpp"
+# Begin Source File
+
+SOURCE=.\Object_B_Impl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\server_B.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestS.cpp
+# End Source File
+# End Group
+# Begin Group "header files"
+
+# PROP Default_Filter "*.h"
+# Begin Source File
+
+SOURCE=.\Object_B_Impl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\server_B.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestC.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Triangle_TestS.h
+# End Source File
+# End Group
+# Begin Group "IDL files"
+
+# PROP Default_Filter "*.idl"
+# Begin Source File
+
+SOURCE=.\Triangle_Test.idl
+
+!IF "$(CFG)" == "server_B - Win32 Release"
+
+!ELSEIF "$(CFG)" == "server_B - Win32 Debug"
+
+# Begin Custom Build - Invoking TAO IDL compiler
+InputPath=.\Triangle_Test.idl
+InputName=Triangle_Test
+
+BuildCmds= \
+ tao_idl $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)S.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/TAO/tests/NestedUpcall/Triangle_Test/server_B.h b/TAO/tests/NestedUpcall/Triangle_Test/server_B.h new file mode 100644 index 00000000000..5ee823376c2 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/server_B.h @@ -0,0 +1,73 @@ +// -*- c++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/NestedUpCalls/Triangle_Test +// +// = FILENAME +// server_B.h +// +// = DESCRIPTION +// This class implements a simple server for the +// Nested Upcalls - Triangle test +// +// = AUTHORS +// Michael Kircher +// +// ============================================================================ + +#if !defined (_TRIANGLE_TEST_OBJECT_B_SERVER_H) +#define _TRIANGLE_TEST_OBJECT_B_SERVER_H + +#include "ace/Get_Opt.h" +#include "ace/Log_Msg.h" +#include "tao/TAO.h" +#include "Object_B_Impl.h" + +class Object_B_Server +{ + // = TITLE + // This is the server for the object A in the test. + // + // = DESCRIPTION + // See the README file for more information. + +public: + + Object_B_Server (void); + // Default constructor + + ~Object_B_Server (void); + // Destructor + + int init (int argc, + char **argv, + CORBA::Environment& env); + // Initialize the NestedUpCalls_Server state - parsing arguments and ... + + int run (CORBA::Environment& env); + // Run the orb + +private: + int parse_args (void); + // Parses the commandline arguments. + + FILE* ior_output_file_; + // File to output the IOR of the object A. + + TAO_ORB_Manager orb_manager_; + // The ORB manager + + Object_B_Impl object_B_Impl_; + // Implementation object of the NestedUpCalls reactor. + + int argc_; + // Number of commandline arguments. + + char **argv_; + // commandline arguments. +}; + +#endif /* _TRIANGLE_TEST_OBJECT_B_SERVER_H */ diff --git a/TAO/tests/NestedUpcall/Triangle_Test/svc.conf b/TAO/tests/NestedUpcall/Triangle_Test/svc.conf new file mode 100644 index 00000000000..43c6a486c92 --- /dev/null +++ b/TAO/tests/NestedUpcall/Triangle_Test/svc.conf @@ -0,0 +1,49 @@ +# $Id$ +# +# This file contains a sample ACE_Service_Config configuration +# file specifying the strategy factories utilized by an application +# using TAO. There are currently only two possible factories: +# Client_Strategy_Factory and Server_Strategy_Factory. These names +# must be used as the second argument to their corresponding line, +# because that's what the ORB uses to find the desired factory. +# +# Note that there are two unordinary characteristics of the way *this* +# file is set up: +# - both client and server strategies are specified in the same +# file, which would only make sense for co-located clients & servers +# - both of the factories are actually sourced out of libTAO.so +# (TAO.DLL on Win32), and they would normally be in a separate +# dll from the TAO ORB Core. +# +# The options which can be passed to the Resource Factory are: +# +# -ORBresources <which> +# where <which> can be 'global' to specify globally-held resources, +# or 'tss' to specify thread-specific resources. +# +# The options which can be passed to the Client are: +# <none currently> +# +# The options which can be passed to the Server are: +# +# -ORBconcurrency <which> +# where <which> can be 'thread-per-connection' to specify +# use of the ACE_Threaded_Strategy concurrency strategy, +# or 'reactive' to specify use of the ACE_Reactive_Strategy +# concurrency strategy. +# +# -ORBthreadflags <flags> +# specifies the default thread flags to use, where <flags> is a +# logical OR'ing of the flags THR_DETACHED, THR_BOUND, THR_NEW_LWP, +# THR_SUSPENDED, or THR_DAEMON. Note that not every flag may be valid +# on every platform. +# +# -ORBdemuxstrategy <which> +# where <which> can be one of 'dynamic', 'linear', 'active', or 'user', +# and specifies the type of object lookup strategy used internally. +# -ORBtablesize <unsigned> +# specifies the size of the object table +# +dynamic Resource_Factory Service_Object * TAO:_make_TAO_Resource_Factory() "-ORBresources global" +dynamic Client_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Client_Strategy_Factory() +dynamic Server_Strategy_Factory Service_Object * TAO:_make_TAO_Default_Server_Strategy_Factory() "-ORBconcurrency reactive -ORBdemuxstrategy dynamic -ORBtablesize 128" |