diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-04-26 10:02:55 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2006-04-26 10:02:55 +0000 |
commit | 1ea8717addc388a4729c83d909ac1dcb81facbda (patch) | |
tree | 65f12d6b1a36e7aed556a32853edb74814ffda31 | |
parent | 6a0c9722c156ce60730558bd0afd80171ecb3570 (diff) | |
download | ATCD-1ea8717addc388a4729c83d909ac1dcb81facbda.tar.gz |
ChangeLogTag: Wed Apr 26 09:53:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>Wed Apr 26 09:56:12 UTC 2006 Johnny Willemsen <jwillemsen@remedy.nl>
-rw-r--r-- | TAO/tests/OBV/Simple/Client_i.cpp | 69 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/Client_i.h | 56 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/OBV.idl | 16 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/OBV_Simple.mpc | 37 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/OBV_impl.cpp | 44 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/OBV_impl.h | 39 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/Server_i.cpp | 80 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/Server_i.h | 60 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/Simple_util.cpp | 317 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/Simple_util.h | 170 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/client.cpp | 23 | ||||
-rwxr-xr-x | TAO/tests/OBV/Simple/run_test.pl | 44 | ||||
-rw-r--r-- | TAO/tests/OBV/Simple/server.cpp | 44 |
13 files changed, 999 insertions, 0 deletions
diff --git a/TAO/tests/OBV/Simple/Client_i.cpp b/TAO/tests/OBV/Simple/Client_i.cpp new file mode 100644 index 00000000000..c3548daf462 --- /dev/null +++ b/TAO/tests/OBV/Simple/Client_i.cpp @@ -0,0 +1,69 @@ +//$Id$ + +#include "Client_i.h" +#include "OBV_impl.h" + +#include "tao/ORB_Core.h" + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_sys_time.h" + +int +Checkpoint_Client_i::run (const char *name, + int argc, + char *argv[]) +{ + // Initialize the client (read ior...). + if (checkpoint.init (name,argc, argv) == -1) + return -1; + + // Set random seed + ACE_Time_Value now (ACE_OS::gettimeofday ()); + ACE_OS::srand ((unsigned int) now.sec () ); + + ACE_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + ACE_DEBUG ((LM_DEBUG, "Send some random events:\n")); + + CORBA::Long value = 64; + Event_var t_e (static_cast<Event*> (new Event_impl (value))); + t_e->do_print (); + checkpoint->put_event (t_e ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + value = 34; + t_e = new Event_impl (value); + t_e->do_print (); + checkpoint->put_event (t_e ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (checkpoint.shutdown () == 1) + checkpoint->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"\n Exception in RMI"); + return -1; + } + ACE_ENDTRY; + ACE_CHECK_RETURN (-1); + + return 0; +} + +// Constructor. +Checkpoint_Client_i::Checkpoint_Client_i (void) +{ + //no-op +} + +//Destructor. +Checkpoint_Client_i::~Checkpoint_Client_i (void) +{ + //no-op +} + diff --git a/TAO/tests/OBV/Simple/Client_i.h b/TAO/tests/OBV/Simple/Client_i.h new file mode 100644 index 00000000000..05ef03b5cbb --- /dev/null +++ b/TAO/tests/OBV/Simple/Client_i.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/examples/OBV/Typed_Events +// +// = FILENAME +// Client_i.h +// +// = DESCRIPTION +// This class is a template for a CORBA client. +// run () sends some valuetypes to a server and +// gets back a list of valuetypes. +// +// = AUTHOR +// +// Torsten Kuepper +// based on the echo example +// from code from Balachandran Natarajan <bala@cs.wustl.edu> +// +// ============================================================================ + +#ifndef ECHO_CLIENT_I_H +#define ECHO_CLIENT_I_H + +#include "OBVC.h" +#include "Simple_Util.h" + +class Checkpoint_Client_i +{ + // = TITLE + // Checkpoint_Client interface subclass. + // + // = DESCRIPTION + // This class implements the interface between the interface + // objects and the client . +public: + // = Initialization and termination methods. + Checkpoint_Client_i (void); + // Constructor + + virtual ~Checkpoint_Client_i (void); + // Destructor + + virtual int run (const char *,int, char** ); + // Execute the methods + +private: + Client<Checkpoint, Checkpoint_var> checkpoint; + // Instantiate the checkpoint object. +}; + + +#endif /* TIME_CLIENT_I_H */ diff --git a/TAO/tests/OBV/Simple/OBV.idl b/TAO/tests/OBV/Simple/OBV.idl new file mode 100644 index 00000000000..f909dc25975 --- /dev/null +++ b/TAO/tests/OBV/Simple/OBV.idl @@ -0,0 +1,16 @@ +// $Id$ + +valuetype Event +{ + void do_print (); + public long value_; +}; + +interface Checkpoint +{ + void put_event (in Event e); + // This operation will shutdown the server. + oneway void shutdown (); +}; + + diff --git a/TAO/tests/OBV/Simple/OBV_Simple.mpc b/TAO/tests/OBV/Simple/OBV_Simple.mpc new file mode 100644 index 00000000000..0e4105cb9e1 --- /dev/null +++ b/TAO/tests/OBV/Simple/OBV_Simple.mpc @@ -0,0 +1,37 @@ +// -*- MPC -*- +// $Id$ + +project(*IDL): taoidldefaults { + IDL_Files { + OBV.idl + } + custom_only = 1 +} + +project(*server): taoserver, utils, valuetype, minimum_corba { + exename = server + after += *IDL + Source_Files { + Server_i.cpp + OBV_impl.cpp + server.cpp + OBVS.cpp + OBVC.cpp + } + IDL_Files { + } +} + +project(*client): taoserver, utils, valuetype, minimum_corba { + exename = client + after += *IDL + Source_Files { + Client_i.cpp + OBV_impl.cpp + client.cpp + OBVS.cpp + OBVC.cpp + } + IDL_Files { + } +} diff --git a/TAO/tests/OBV/Simple/OBV_impl.cpp b/TAO/tests/OBV/Simple/OBV_impl.cpp new file mode 100644 index 00000000000..f55cee0af44 --- /dev/null +++ b/TAO/tests/OBV/Simple/OBV_impl.cpp @@ -0,0 +1,44 @@ +// $Id$ + +#include "OBV_impl.h" +#include "ace/OS_NS_sys_time.h" + +// Implementation of the valuetype member functions. + +Event_impl::Event_impl () +{ +} + +Event_impl::Event_impl (CORBA::Long value) +{ + this->value_ (value); +} + +Event_impl::~Event_impl () +{ +} + +CORBA::ValueBase* +Event_impl::_copy_value (void) +{ + return new Event_impl (this->value_ ()); +} + + +void +Event_impl::do_print (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + ACE_DEBUG((LM_DEBUG, "(value %d) \n", + (CORBA::ULong) this->value_())); +} + +Event_factory::~Event_factory () +{ +} + +TAO_OBV_CREATE_RETURN_TYPE (Event) +Event_factory::create_for_unmarshal (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return new Event_impl; +} + diff --git a/TAO/tests/OBV/Simple/OBV_impl.h b/TAO/tests/OBV/Simple/OBV_impl.h new file mode 100644 index 00000000000..1b619553402 --- /dev/null +++ b/TAO/tests/OBV/Simple/OBV_impl.h @@ -0,0 +1,39 @@ +// -*- C++ -*- +// $Id$ + +#if !defined (OBV_IMPL_H) +#define OBV_IMPL_H + +#include "OBVC.h" + +#include "tao/Valuetype/ValueFactory.h" + +class Event_impl : public virtual OBV_Event, + public virtual CORBA::DefaultValueRefCountBase +{ + public: + Event_impl (); + Event_impl (CORBA::Long value); + virtual ~Event_impl (); + virtual CORBA::ValueBase* _copy_value (void); + + + virtual void do_print (ACE_ENV_SINGLE_ARG_DECL); +}; + +class Event_factory : public CORBA::ValueFactoryBase +{ +public: + + // create (...) would go here + +protected: + + virtual ~Event_factory (); + +private: + + TAO_OBV_CREATE_RETURN_TYPE (Event) create_for_unmarshal (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS); +}; + +#endif /* OBV_IMPL_H */ diff --git a/TAO/tests/OBV/Simple/Server_i.cpp b/TAO/tests/OBV/Simple/Server_i.cpp new file mode 100644 index 00000000000..a429ce1bc3a --- /dev/null +++ b/TAO/tests/OBV/Simple/Server_i.cpp @@ -0,0 +1,80 @@ +// $Id$ + +#include "Server_i.h" +#include "OBV_impl.h" +#include "tao/ORB_Core.h" + +// Set the ORB pointer, register OBV factories and init the +// lists declared above. + +void +Checkpoint_i::orb (CORBA::ORB_ptr o) +{ + this->orb_ = CORBA::ORB::_duplicate (o); + + TAO_OBV_REGISTER_FACTORY (Event_factory, Event); +} + + +// Sidebar on assignment from pointer to _var type. +// +// Event_var e_var (event); +// This is fatal because the reference counter in *event is not increased +// when a pointer is assigned to a _var. (This happens only +// in assignments from another Event_var; +// But Assignment from new is fine, the referencecount is yet one.) +// +// ok is +// CORBA::add_ref (event); +// Event_var e_var (event); +// +// but possibly easier to read it a macro +#define DUP_REF(vt_ptr) (CORBA::add_ref (vt_ptr), vt_ptr) +// then it reads: Event_var e_var (DUP_REF (event)); +// (But it may cause desaster if vt_ptr is a function call.) +// +// Be careful with assignments from T1_var to T2_var, if T1 and T2 are +// related through inheritance. Because there are many implicit casts +// between pointer and _var types possible, the reference counter of +// the duplicated reference is not increased. +// +// Is there any general solution with faulty reference counting ? + + +void +Checkpoint_i::put_event (Event *event + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Let us see what event has arrived + event->do_print (); + + return; +} + +// Shutdown the server application. + +void +Checkpoint_i::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, + "\n%s\n", + "The Checkpoint server is shutting down")); + + // Instruct the ORB to shutdown. + this->orb_->shutdown (); +} + + +// Constructor. + +Checkpoint_i::Checkpoint_i (void) +{ +} + +// Destructor. + +Checkpoint_i::~Checkpoint_i (void) +{ +} diff --git a/TAO/tests/OBV/Simple/Server_i.h b/TAO/tests/OBV/Simple/Server_i.h new file mode 100644 index 00000000000..c1a026c25e2 --- /dev/null +++ b/TAO/tests/OBV/Simple/Server_i.h @@ -0,0 +1,60 @@ +// -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO/tests/OBV/Typed_Events +// +// = FILENAME +// Server_i.h +// +// = DESCRIPTION +// This class implements the Event_Types IDL interface. +// +// = AUTHOR +// Torsten Kuepper +// derived from the Echo example TAO/example/Simple/echo +// of Kirthika Parameswaran <kirthika@cs.wustl.edu> +// +// ============================================================================ + +#ifndef ECHO_I_H +#define ECHO_I_H + +#include "OBVS.h" + + +class Checkpoint_i : public POA_Checkpoint +{ +public: + // = Initialization and termination methods. + Checkpoint_i (void); + // Constructor. + + ~Checkpoint_i (void); + // Destructor. + + virtual void put_event ( + Event * e + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void shutdown ( + ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS + ) + ACE_THROW_SPEC (( + ::CORBA::SystemException + )); + + void orb (CORBA::ORB_ptr o); + // Set the ORB pointer. + +private: + CORBA::ORB_var orb_; + // ORB pointer. +}; + +#endif /* ECHO_I_H */ + diff --git a/TAO/tests/OBV/Simple/Simple_util.cpp b/TAO/tests/OBV/Simple/Simple_util.cpp new file mode 100644 index 00000000000..979bc54cc79 --- /dev/null +++ b/TAO/tests/OBV/Simple/Simple_util.cpp @@ -0,0 +1,317 @@ +// $Id$ + +// This version of Simple_Util doesn't need to link against orbsvcs +// On the other hand it has no naming service. + +#ifndef SIMPLE_UTIL_C +#define SIMPLE_UTIL_C +# include "Simple_util.h" +# include "tao/debug.h" +# include "ace/OS_NS_stdio.h" +# include "ace/OS_NS_fcntl.h" +# include "ace/OS_NS_unistd.h" +# include "ace/OS_NS_string.h" + +// Constructor. + +template <class Servant> +Server<Servant>::Server (void) + : ior_output_file_ (0) +{ + // no-op. +} + +// Destructor. + +template <class Servant> +Server<Servant>::~Server (void) +{ +} + +// Parse the command-line arguments and set options. + +template <class Servant> int +Server<Servant>::parse_args (void) +{ + ACE_Get_Opt get_opts (this->argc_, this->argv_, "do:ni:"); + int c = 0; + + 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.opt_arg (), "w"); + if (this->ior_output_file_ == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to open %s for writing: %p\n", + get_opts.opt_arg ()), -1); + break; + + case '?': // display help for use of the server. + 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; +} + +// Initialize the server. +template <class Servant> int +Server<Servant>::init (const char *servant_name, + int argc, + char *argv[] + ACE_ENV_ARG_DECL) +{ + // Call the init of <TAO_ORB_Manager> to initialize the ORB and + // create a child POA under the root POA. + if (this->orb_manager_.init_child_poa (argc, + argv, + "child_poa" + ACE_ENV_ARG_PARAMETER) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "init_child_poa"), + -1); + + ACE_CHECK_RETURN (-1); + + this->argc_ = argc; + this->argv_ = argv; + + int retval = this->parse_args (); + + if (retval != 0) + return retval; + + CORBA::ORB_var orb = this->orb_manager_.orb (); + + // Stash our ORB pointer for later reference. + this->servant_.orb (orb.in ()); + + // Activate the servant in its own child POA. + + // Make sure that you check for failures here via the ACE_TRY + // macros?! + ACE_TRY + { + CORBA::String_var str = + this->orb_manager_.activate_under_child_poa (servant_name, + &this->servant_ + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + 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_); + } + + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception in activation of POA"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + +template <class Servant>int +Server<Servant>::run (ACE_ENV_SINGLE_ARG_DECL) +{ + // Run the main event loop for the ORB. + if (this->orb_manager_.run (ACE_ENV_SINGLE_ARG_PARAMETER) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "Server_i::run"), + -1); + + return 0; +} + +template <class Servant> int +Server<Servant>::register_name (void) +{ + return -1; +} + +// Constructor. + +template <class InterfaceObj, class Var> +Client<InterfaceObj, Var>::Client (void) + : ior_ (0) +{ + //no-op +} + +// Reads the Server ior from a file + +template <class InterfaceObj, class Var> int +Client<InterfaceObj, Var>::read_ior (char *filename) +{ + // 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 writing: %p\n", + filename), + -1); + + ACE_Read_Buffer ior_buffer (f_handle); + char *data = ior_buffer.read (); + + if (data == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to read ior: %p\n"), + -1); + + this->ior_ = ACE_OS::strdup (data); + ior_buffer.alloc ()->free (data); + + ACE_OS::close (f_handle); + + return 0; +} + +// Parses the command line arguments and returns an error status. + +template <class InterfaceObj, class Var> int +Client<InterfaceObj, Var>::parse_args (void) +{ + ACE_Get_Opt get_opts (argc_, argv_, "df:nk:x"); + int c = 0; + int result = 0; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': // debug flag + TAO_debug_level++; + break; + case 'k': // ior provide on command line + this->ior_ = ACE_OS::strdup (get_opts.opt_arg ()); + break; + case 'f': // read the IOR from the file. + result = this->read_ior (get_opts.opt_arg ()); + if (result < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Unable to read ior from %s : %p\n", + get_opts.opt_arg ()), + -1); + break; + case 'x': // read the flag for shutting down + this->shutdown_ = 1; + break; + } + + // Indicates successful parsing of command line. + return 0; +} + +template <class InterfaceObj, class Var> +Client<InterfaceObj, Var>::~Client (void) +{ + ACE_OS::free (this->ior_); +} + +template <class InterfaceObj, class Var> int +Client<InterfaceObj, Var>::init (const char *name, + int argc, + char **argv) +{ + this->argc_ = argc; + this->argv_ = argv; + + + ACE_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + // Retrieve the ORB. + this->orb_ = CORBA::ORB_init (this->argc_, + this->argv_, + name + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Parse command line and verify parameters. + if (this->parse_args () == -1) + return -1; + + + + if(this->ior_ != 0) + { + CORBA::Object_var server_object = + this->orb_->string_to_object (this->ior_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + + if (CORBA::is_nil (server_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + "invalid ior <%s>\n", + this->ior_), + -1); + this->server_ = InterfaceObj::_narrow (server_object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + else + ACE_ERROR_RETURN ((LM_ERROR, + "no ior or naming options specified\n"), + -1); + + + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Client_i::init"); + return -1; + } + ACE_ENDTRY; + + + return 0; +} + + +template <class InterfaceObj, class Var> int +Client<InterfaceObj, Var>::obtain_initial_references (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + + return 0; +} + +template <class InterfaceObj, class Var> int +Client<InterfaceObj, Var>::shutdown (void ) +{ + // Returns the shutdwon flag + return shutdown_; +} + +template <class InterfaceObj, class Var> void +Client<InterfaceObj, Var>::shutdown (int flag) +{ + // Fills the flag + shutdown_ = flag; +} + +#endif diff --git a/TAO/tests/OBV/Simple/Simple_util.h b/TAO/tests/OBV/Simple/Simple_util.h new file mode 100644 index 00000000000..380dc749dc6 --- /dev/null +++ b/TAO/tests/OBV/Simple/Simple_util.h @@ -0,0 +1,170 @@ +//$Id$ + +// This version of Simple_Util doesn't need to link against orbsvcs +// On the other hand it has no naming service. + +// ============================================================================ +// +// = LIBRARY +// +// taken from TAO/tests/Simple +// +// = FILENAME +// Simple_Util.h +// +// = DESCRIPTION +// The classe define the templates for the client and server. +// +// = AUTHOR +// Balachandran Natarajan <bala@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_UTIL_H +#define TAO_UTIL_H + +#include "tao/Utils/ORB_Manager.h" + +#include "ace/Get_Opt.h" +#include "ace/Read_Buffer.h" + +template <class Servant> +class Server +{ + // = TITLE + // A set of useful class Templates for using the TAO CORBA + // implementation. + // + // = DESCRIPTION + // A template server definition. This template can be used by + // single server/client projects for defintion of their + // server/clients. See the directories time, bank, echo for + // further details of implemenatation. +public: + // = Initialization and termination methods. + + Server (void); + // Constructor. + + ~Server (void); + // Destructor. + + int init (const char *servant_name, + int argc, + char *argv[] + ACE_ENV_ARG_DECL); + // Initialize the Server state - parsing arguments and waiting. + // interface_name is the name used to register the Servant. + + int register_name (void); + // After calling <init>, this method will register the server with + // the TAO Naming Service using the servant_name passed to <init>. + + int run (ACE_ENV_SINGLE_ARG_DECL); + // Run the orb. + +protected: + Servant servant_; + // Servant class + + const char *name; + // name of the servant to be used for TAO Naming Service + + int parse_args (void); + // Parses the commandline arguments. + + TAO_ORB_Manager orb_manager_; + // The ORB manager - a helper class for accessing the POA and + // registering objects. + + // TAO_Naming_Server namingServer; + // helper class for getting access to Naming Service. + + FILE *ior_output_file_; + // File where the IOR of the server object is stored. + + int argc_; + // Number of command line arguments. + + char **argv_; + // The command line arguments. +}; + +template <class InterfaceObj, class Var> +class Client +{ + // = TITLE + // Template Client class + // + // = DESCRIPTION + // A template client implementation for a single server/client + // model. The example usage of these usage can be found in the + // sub-directories below +public: + + // = Initialization and termination methods. + Client (void); + // Constructor. + + ~Client (void); + // Destructor. + + int init (const char *name,int argc, char *argv[]); + // Initialize the client communication endpoint with server. + + InterfaceObj *operator-> () { return server_.in ();}; + // Return the interface object pointer. + + int shutdown (void ); + // Returns the shutdown flag. + + void shutdown (int); + // Fills in the shutdwon flag. + + int obtain_initial_references (ACE_ENV_SINGLE_ARG_DECL); + // Initialize naming service + +protected: + int read_ior (char *filename); + // Function to read the server IOR from a file. + + int parse_args (void); + // Parses the arguments passed on the command line. + +// TAO_Naming_Client namingClient; + // helper class for getting access to Naming Service. + + int argc_; + // # of arguments on the command line. + + char **argv_; + // arguments from command line. + + char *ior_; + // IOR of the obj ref of the server. + + char *name_; + // Name to be usred for the naming service + + CORBA::ORB_var orb_; + // Remember our orb. + + Var server_; + // Server object + + int naming_; + // Flag to use the naming service + + int shutdown_; + // Flag for shutting down the server + +}; + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Simple_util.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Simple_util.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* TAO_UTIL_H */ diff --git a/TAO/tests/OBV/Simple/client.cpp b/TAO/tests/OBV/Simple/client.cpp new file mode 100644 index 00000000000..d4e502a26bd --- /dev/null +++ b/TAO/tests/OBV/Simple/client.cpp @@ -0,0 +1,23 @@ +//$Id$ + +# include "Client_i.h" + +// The client program for the application. + +int +main (int argc, char **argv) +{ + Checkpoint_Client_i client; + + + ACE_DEBUG ((LM_DEBUG, + "\nEvent_Types client\n\n")); + + if (client.run ("Event_Types_Checkpoint", + argc, + argv) == -1) + return -1; + else + return 0; + +} diff --git a/TAO/tests/OBV/Simple/run_test.pl b/TAO/tests/OBV/Simple/run_test.pl new file mode 100755 index 00000000000..3a125c5703c --- /dev/null +++ b/TAO/tests/OBV/Simple/run_test.pl @@ -0,0 +1,44 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "../../../../bin"; +use PerlACE::Run_Test; + +$status = 0; + +$iorfile = PerlACE::LocalFile ("obv.ior"); + +unlink $iorfile; + +$SV = new PerlACE::Process ("server", "-o $iorfile"); +$CL = new PerlACE::Process ("client", "-f $iorfile"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 15) == -1) { + print STDERR "ERROR: timed out waiting for file <$iorfile>\n"; + $SV->Kill (); + exit 1; +} + +$client = $CL->SpawnWaitKill (60); + +if ($client != 0) { + print STDERR "ERROR: the client returned $client\n"; + $status = 1; +} + +$server = $SV->TerminateWaitKill (5); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/tests/OBV/Simple/server.cpp b/TAO/tests/OBV/Simple/server.cpp new file mode 100644 index 00000000000..c5f5140f307 --- /dev/null +++ b/TAO/tests/OBV/Simple/server.cpp @@ -0,0 +1,44 @@ +// $Id$ +#include "Simple_util.h" +#include "Server_i.h" + +// This is the main driver program for the time and date server. + +int +main (int argc, char *argv[]) +{ + Server<Checkpoint_i> server; + + ACE_DEBUG ((LM_DEBUG, + "\n\tCheckpoint Event_Types server\n\n")); + + ACE_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + if (server.init ("Event_Types_Checkpoint", + argc, + argv + ACE_ENV_ARG_PARAMETER) == -1) + return 1; + else + { + server.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCH (CORBA::SystemException, sysex) + { + ACE_PRINT_EXCEPTION (sysex, "System Exception"); + return -1; + } + ACE_CATCH (CORBA::UserException, userex) + { + ACE_PRINT_EXCEPTION (userex, "User Exception"); + return -1; + } + ACE_ENDTRY; + + return 0; +} + |