diff options
-rw-r--r-- | TAO/ChangeLog-98c | 11 | ||||
-rw-r--r-- | TAO/tao/poa.cpp | 45 | ||||
-rw-r--r-- | TAO/tao/poa.h | 3 | ||||
-rw-r--r-- | TAO/tao/poaS.cpp | 127 | ||||
-rw-r--r-- | TAO/tao/poaS.h | 42 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/Default_Servant.dsw | 41 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/File.idl | 30 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/File_i.cpp | 163 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/File_i.h | 52 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/client.cpp | 118 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/client.dsp | 99 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/server.cpp | 113 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/server.dsp | 103 | ||||
-rw-r--r-- | TAO/tests/POA/Default_Servant/svc.conf | 49 | ||||
-rw-r--r-- | TAO/tests/POA/Generic_Servant/client.cpp | 8 |
15 files changed, 990 insertions, 14 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index efa62ffc309..357f85356e7 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,14 @@ +Sat Jan 24 03:04:51 1998 Irfan Pyarali <irfan@cs.wustl.edu> + + * tao/poa.cpp (id_to_reference): Reimplemented this method so that + it does not use id_to_servant and servant_to_reference combo. + This is necessary since id_to_reference may be used in a + MULTI_ID mode. + + * tao/poaS: Added explicit copy and destroy to all collocated + policies. This will help avoid the inheritance via dominance + warnings. + Fri Jan 23 17:13:14 1998 Carlos O'Ryan <coryan@cs.wustl.edu> * Merged changes from main_to_poa_merge_11 up to diff --git a/TAO/tao/poa.cpp b/TAO/tao/poa.cpp index 1b7bc638f9f..6c31ba52759 100644 --- a/TAO/tao/poa.cpp +++ b/TAO/tao/poa.cpp @@ -1826,14 +1826,41 @@ CORBA::Object_ptr TAO_POA::id_to_reference (const PortableServer::ObjectId &oid, CORBA::Environment &env) { - PortableServer::Servant servant = this->id_to_servant (oid, - env); + // Lock access to the POA for the duration of this transaction + TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); - if (env.exception () != 0) - return CORBA::Object::_nil (); + return this->id_to_reference_i (oid, env); +} + +CORBA::Object_ptr +TAO_POA::id_to_reference_i (const PortableServer::ObjectId &oid, + CORBA::Environment &env) +{ + // This operation requires the RETAIN policy; if not present, the + // WrongPolicy exception is raised. + if (this->policies ().servant_retention () != PortableServer::RETAIN) + { + CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; + env.exception (exception); + return 0; + } + + // If an object with the specified Object Id value is currently + // active, a reference encapsulating the information used to + // activate the object is returned. + PortableServer::Servant servant = 0; + if (this->active_object_map ().find (oid, servant) != -1) + return this->create_reference_with_id (oid, + servant->_interface_repository_id (), + env); else - return this->servant_to_reference (servant, - env); + // If the Object Id value is not active in the POA, an + // ObjectNotActive exception is raised. + { + CORBA::Exception *exception = new PortableServer::POA::ObjectNotActive; + env.exception (exception); + return 0; + } } PortableServer::POA_ptr @@ -2377,7 +2404,7 @@ TAO_POA::create_object_id (void) // Convert counter into string ACE_OS::sprintf (counter, - "%d", + "%ld", this->counter_); // Calculate the required buffer size. @@ -2404,12 +2431,12 @@ TAO_POA::create_object_key (const PortableServer::ObjectId &id) // Convert seconds into string ACE_OS::sprintf (seconds, - "%d", + "%ld", this->creation_time_.sec ()); // Convert micro seconds into string ACE_OS::sprintf (micro_seconds, - "%d", + "%ld", this->creation_time_.usec ()); // Calculate the required buffer size. diff --git a/TAO/tao/poa.h b/TAO/tao/poa.h index bdf83788ddd..360e716c4aa 100644 --- a/TAO/tao/poa.h +++ b/TAO/tao/poa.h @@ -428,6 +428,9 @@ protected: virtual PortableServer::Servant id_to_servant_i (const PortableServer::ObjectId &oid, CORBA::Environment &env); + virtual CORBA::Object_ptr id_to_reference_i (const PortableServer::ObjectId &oid, + CORBA::Environment &env); + virtual ACE_Lock &lock (void); virtual TAO_POA_Policies &policies (void); diff --git a/TAO/tao/poaS.cpp b/TAO/tao/poaS.cpp index 07c5abec71a..408fe1a407e 100644 --- a/TAO/tao/poaS.cpp +++ b/TAO/tao/poaS.cpp @@ -421,6 +421,25 @@ CORBA::Boolean POA_PortableServer::_tao_collocated_ThreadPolicy::_is_a ( ); } + +PortableServer::Policy_ptr POA_PortableServer::_tao_collocated_ThreadPolicy::copy ( + CORBA::Environment &_tao_environment + ) +{ + return this->servant_->copy ( + _tao_environment + ); +} + +void POA_PortableServer::_tao_collocated_ThreadPolicy::destroy ( + CORBA::Environment &_tao_environment + ) +{ + this->servant_->destroy ( + _tao_environment + ); +} + PortableServer::ThreadPolicyValue POA_PortableServer::_tao_collocated_ThreadPolicy::value ( CORBA::Environment &_tao_environment @@ -562,6 +581,24 @@ CORBA::Boolean POA_PortableServer::_tao_collocated_LifespanPolicy::_is_a ( ); } +PortableServer::Policy_ptr POA_PortableServer::_tao_collocated_LifespanPolicy::copy ( + CORBA::Environment &_tao_environment + ) +{ + return this->servant_->copy ( + _tao_environment + ); +} + +void POA_PortableServer::_tao_collocated_LifespanPolicy::destroy ( + CORBA::Environment &_tao_environment + ) +{ + this->servant_->destroy ( + _tao_environment + ); +} + PortableServer::LifespanPolicyValue POA_PortableServer::_tao_collocated_LifespanPolicy::value ( CORBA::Environment &_tao_environment @@ -703,6 +740,24 @@ CORBA::Boolean POA_PortableServer::_tao_collocated_IdUniquenessPolicy::_is_a ( ); } +PortableServer::Policy_ptr POA_PortableServer::_tao_collocated_IdUniquenessPolicy::copy ( + CORBA::Environment &_tao_environment + ) +{ + return this->servant_->copy ( + _tao_environment + ); +} + +void POA_PortableServer::_tao_collocated_IdUniquenessPolicy::destroy ( + CORBA::Environment &_tao_environment + ) +{ + this->servant_->destroy ( + _tao_environment + ); +} + PortableServer::IdUniquenessPolicyValue POA_PortableServer::_tao_collocated_IdUniquenessPolicy::value ( CORBA::Environment &_tao_environment @@ -844,6 +899,24 @@ CORBA::Boolean POA_PortableServer::_tao_collocated_IdAssignmentPolicy::_is_a ( ); } +PortableServer::Policy_ptr POA_PortableServer::_tao_collocated_IdAssignmentPolicy::copy ( + CORBA::Environment &_tao_environment + ) +{ + return this->servant_->copy ( + _tao_environment + ); +} + +void POA_PortableServer::_tao_collocated_IdAssignmentPolicy::destroy ( + CORBA::Environment &_tao_environment + ) +{ + this->servant_->destroy ( + _tao_environment + ); +} + PortableServer::IdAssignmentPolicyValue POA_PortableServer::_tao_collocated_IdAssignmentPolicy::value ( CORBA::Environment &_tao_environment @@ -985,6 +1058,24 @@ CORBA::Boolean POA_PortableServer::_tao_collocated_ImplicitActivationPolicy::_is ); } +PortableServer::Policy_ptr POA_PortableServer::_tao_collocated_ImplicitActivationPolicy::copy ( + CORBA::Environment &_tao_environment + ) +{ + return this->servant_->copy ( + _tao_environment + ); +} + +void POA_PortableServer::_tao_collocated_ImplicitActivationPolicy::destroy ( + CORBA::Environment &_tao_environment + ) +{ + this->servant_->destroy ( + _tao_environment + ); +} + PortableServer::ImplicitActivationPolicyValue POA_PortableServer::_tao_collocated_ImplicitActivationPolicy::value ( CORBA::Environment &_tao_environment @@ -1126,6 +1217,24 @@ CORBA::Boolean POA_PortableServer::_tao_collocated_ServantRetentionPolicy::_is_a ); } +PortableServer::Policy_ptr POA_PortableServer::_tao_collocated_ServantRetentionPolicy::copy ( + CORBA::Environment &_tao_environment + ) +{ + return this->servant_->copy ( + _tao_environment + ); +} + +void POA_PortableServer::_tao_collocated_ServantRetentionPolicy::destroy ( + CORBA::Environment &_tao_environment + ) +{ + this->servant_->destroy ( + _tao_environment + ); +} + PortableServer::ServantRetentionPolicyValue POA_PortableServer::_tao_collocated_ServantRetentionPolicy::value ( CORBA::Environment &_tao_environment @@ -1267,6 +1376,24 @@ CORBA::Boolean POA_PortableServer::_tao_collocated_RequestProcessingPolicy::_is_ ); } +PortableServer::Policy_ptr POA_PortableServer::_tao_collocated_RequestProcessingPolicy::copy ( + CORBA::Environment &_tao_environment + ) +{ + return this->servant_->copy ( + _tao_environment + ); +} + +void POA_PortableServer::_tao_collocated_RequestProcessingPolicy::destroy ( + CORBA::Environment &_tao_environment + ) +{ + this->servant_->destroy ( + _tao_environment + ); +} + PortableServer::RequestProcessingPolicyValue POA_PortableServer::_tao_collocated_RequestProcessingPolicy::value ( CORBA::Environment &_tao_environment diff --git a/TAO/tao/poaS.h b/TAO/tao/poaS.h index df00ea827e5..4079e9db311 100644 --- a/TAO/tao/poaS.h +++ b/TAO/tao/poaS.h @@ -168,6 +168,12 @@ public: virtual PortableServer::ThreadPolicyValue value ( CORBA::Environment &env ); + virtual PortableServer::Policy_ptr copy ( + CORBA::Environment &_tao_environment + ); + virtual void destroy ( + CORBA::Environment &_tao_environment + ); private: ThreadPolicy_ptr servant_; @@ -226,6 +232,12 @@ public: virtual PortableServer::LifespanPolicyValue value ( CORBA::Environment &env ); + virtual PortableServer::Policy_ptr copy ( + CORBA::Environment &_tao_environment + ); + virtual void destroy ( + CORBA::Environment &_tao_environment + ); private: LifespanPolicy_ptr servant_; @@ -284,6 +296,12 @@ public: virtual PortableServer::IdUniquenessPolicyValue value ( CORBA::Environment &env ); + virtual PortableServer::Policy_ptr copy ( + CORBA::Environment &_tao_environment + ); + virtual void destroy ( + CORBA::Environment &_tao_environment + ); private: IdUniquenessPolicy_ptr servant_; @@ -342,6 +360,12 @@ public: virtual PortableServer::IdAssignmentPolicyValue value ( CORBA::Environment &env ); + virtual PortableServer::Policy_ptr copy ( + CORBA::Environment &_tao_environment + ); + virtual void destroy ( + CORBA::Environment &_tao_environment + ); private: IdAssignmentPolicy_ptr servant_; @@ -400,6 +424,12 @@ public: virtual PortableServer::ImplicitActivationPolicyValue value ( CORBA::Environment &env ); + virtual PortableServer::Policy_ptr copy ( + CORBA::Environment &_tao_environment + ); + virtual void destroy ( + CORBA::Environment &_tao_environment + ); private: ImplicitActivationPolicy_ptr servant_; @@ -458,6 +488,12 @@ public: virtual PortableServer::ServantRetentionPolicyValue value ( CORBA::Environment &env ); + virtual PortableServer::Policy_ptr copy ( + CORBA::Environment &_tao_environment + ); + virtual void destroy ( + CORBA::Environment &_tao_environment + ); private: ServantRetentionPolicy_ptr servant_; @@ -516,6 +552,12 @@ public: virtual PortableServer::RequestProcessingPolicyValue value ( CORBA::Environment &env ); + virtual PortableServer::Policy_ptr copy ( + CORBA::Environment &_tao_environment + ); + virtual void destroy ( + CORBA::Environment &_tao_environment + ); private: RequestProcessingPolicy_ptr servant_; diff --git a/TAO/tests/POA/Default_Servant/Default_Servant.dsw b/TAO/tests/POA/Default_Servant/Default_Servant.dsw new file mode 100644 index 00000000000..f6006d20cb7 --- /dev/null +++ b/TAO/tests/POA/Default_Servant/Default_Servant.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/POA/Default_Servant/File.idl b/TAO/tests/POA/Default_Servant/File.idl new file mode 100644 index 00000000000..0cc11ae4ef4 --- /dev/null +++ b/TAO/tests/POA/Default_Servant/File.idl @@ -0,0 +1,30 @@ +module File +{ + exception IOError + { + long error; + }; + + interface Descriptor + { + typedef sequence<octet> DataBuffer; + + long write (in DataBuffer buffer) + raises (IOError); + + DataBuffer read (in long num_bytes) + raises (IOError); + + unsigned long lseek (in unsigned long offset, + in long whence) + raises (IOError); + + void destroy (); + }; + + interface System + { + Descriptor open (in string file_name, in long flags) + raises (IOError); + }; +}; diff --git a/TAO/tests/POA/Default_Servant/File_i.cpp b/TAO/tests/POA/Default_Servant/File_i.cpp new file mode 100644 index 00000000000..b291006c63b --- /dev/null +++ b/TAO/tests/POA/Default_Servant/File_i.cpp @@ -0,0 +1,163 @@ +#include "File_i.h" + +FileImpl::System::System (PortableServer::POA_ptr poa) + : poa_ (PortableServer::POA::_duplicate (poa)), + fd_servant_ (poa) +{ + CORBA::Environment env; + poa->set_servant (&this->fd_servant_, env); + ACE_ASSERT (env.exception () == 0); +} + +FileImpl::System::~System (void) +{ +} + +PortableServer::POA_ptr +FileImpl::System::_default_POA (CORBA::Environment &env) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} + +File::Descriptor_ptr +FileImpl::System::open (const char *file_name, + CORBA::Long flags, + CORBA::Environment &env) +{ + ACE_HANDLE file_descriptor = ACE_OS::open (file_name, flags); + if (file_descriptor == ACE_INVALID_HANDLE) + { + CORBA::Exception *exception = new File::IOError (errno); + env.exception (exception); + return 0; + } + + char file_descriptor_buffer[BUFSIZ]; + ACE_OS::sprintf (file_descriptor_buffer, "%ld", (CORBA::Long) file_descriptor); + + PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId (file_descriptor_buffer); + CORBA::Object_var obj = this->poa_->create_reference_with_id (oid.in (), + this->_interface_repository_id (), + env); + if (env.exception () != 0) + return File::Descriptor::_nil (); + + File::Descriptor_var fd = File::Descriptor::_narrow (obj.in (), env); + if (env.exception () != 0) + return File::Descriptor::_nil (); + + return fd._retn (); +} + +FileImpl::Descriptor::Descriptor (PortableServer::POA_ptr poa) + : poa_ (PortableServer::POA::_duplicate (poa)) +{ +} + +FileImpl::Descriptor::~Descriptor (void) +{ +} + +PortableServer::POA_ptr +FileImpl::Descriptor::_default_POA (CORBA::Environment &env) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} + +ACE_HANDLE +FileImpl::Descriptor::fd (CORBA::Environment &env) +{ + File::Descriptor_var me = this->_this (env); + if (env.exception () != 0) + return ACE_INVALID_HANDLE; + + PortableServer::ObjectId_var oid = this->poa_->reference_to_id (me.in (), env); + if (env.exception () != 0) + return ACE_INVALID_HANDLE; + + CORBA::String_var s = PortableServer::ObjectId_to_string (oid.in ()); + return (ACE_HANDLE) ::atol (s.in ()); +} + +CORBA::Long +FileImpl::Descriptor::write (const File::Descriptor::DataBuffer &buffer, + CORBA::Environment &env) +{ + ACE_HANDLE file_descriptor = this->fd (env); + if (env.exception () != 0) + return 0; + + const CORBA::Octet *data = &buffer[0]; + int len = ACE_OS::write (file_descriptor, data, buffer.length ()); + + if (len > 0) + { + return len; + } + else + { + CORBA::Exception *exception = new File::IOError (errno); + env.exception (exception); + return 0; + } +} + +File::Descriptor::DataBuffer * +FileImpl::Descriptor::read (CORBA::Long num_bytes, + CORBA::Environment &env) +{ + ACE_HANDLE file_descriptor = this->fd (env); + if (env.exception () != 0) + return 0; + + CORBA::Octet *buffer = File::Descriptor::DataBuffer::allocbuf (num_bytes); + int length = ACE_OS::read (file_descriptor, buffer, num_bytes); + + if (length > 0) + { + return new File::Descriptor::DataBuffer (length, length, buffer, CORBA::B_TRUE); + } + else + { + File::Descriptor::DataBuffer::freebuf (buffer); + CORBA::Exception *exception = new File::IOError (errno); + env.exception (exception); + return 0; + } +} + +CORBA::ULong +FileImpl::Descriptor::lseek (CORBA::ULong offset, + CORBA::Long whence, + CORBA::Environment &env) +{ + ACE_HANDLE file_descriptor = this->fd (env); + if (env.exception () != 0) + return 0; + + CORBA::ULong result = ACE_OS::lseek (file_descriptor, offset, whence); + if (result == -1) + { + CORBA::Exception *exception = new File::IOError (errno); + env.exception (exception); + return 0; + } + else + return result; +} + +void +FileImpl::Descriptor::destroy (CORBA::Environment &env) +{ + ACE_HANDLE file_descriptor = this->fd (env); + if (env.exception () != 0) + return; + + int result = ACE_OS::close (file_descriptor); + if (result != 0) + { + CORBA::Exception *exception = new File::IOError (errno); + env.exception (exception); + return; + } +} diff --git a/TAO/tests/POA/Default_Servant/File_i.h b/TAO/tests/POA/Default_Servant/File_i.h new file mode 100644 index 00000000000..d43ea771b0c --- /dev/null +++ b/TAO/tests/POA/Default_Servant/File_i.h @@ -0,0 +1,52 @@ +#include "FileS.h" + +class FileImpl +{ +public: + class Descriptor : public POA_File::Descriptor + { + public: + Descriptor (PortableServer::POA_ptr poa); + + ~Descriptor (void); + + PortableServer::POA_ptr _default_POA (CORBA::Environment &env); + + virtual CORBA::Long write (const File::Descriptor::DataBuffer &buffer, + CORBA::Environment &env); + + virtual File::Descriptor::DataBuffer *read (CORBA::Long num_bytes, + CORBA::Environment &env); + + virtual CORBA::ULong lseek (CORBA::ULong offset, + CORBA::Long whence, + CORBA::Environment &env); + + virtual void destroy (CORBA::Environment &env); + + private: + ACE_HANDLE fd (CORBA::Environment &env); + + PortableServer::POA_var poa_; + }; + + class System : public POA_File::System + { + public: + System (PortableServer::POA_ptr poa); + + ~System (void); + + PortableServer::POA_ptr _default_POA (CORBA::Environment &env); + + File::Descriptor_ptr open (const char *file_name, + CORBA::Long flags, + CORBA::Environment &env); + + private: + PortableServer::POA_var poa_; + + Descriptor fd_servant_; + }; +}; + diff --git a/TAO/tests/POA/Default_Servant/client.cpp b/TAO/tests/POA/Default_Servant/client.cpp new file mode 100644 index 00000000000..f7ada601d19 --- /dev/null +++ b/TAO/tests/POA/Default_Servant/client.cpp @@ -0,0 +1,118 @@ +#include "ace/streams.h" +#include "ace/Get_Opt.h" +#include "FileC.h" + +static char *ior = 0; +static char *filename = "test"; +static char *message = "POA rules!!"; + +static int +parse_args (int argc, char **argv) +{ + ACE_Get_Opt get_opts (argc, argv, "k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.optarg; + break; + case 'f': + filename = get_opts.optarg; + break; + case 'm': + message = get_opts.optarg; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s" + "-k IOR" + "\n", + argv [0]), + -1); + } + + if (ior == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Please specify the IOR for the servant"), -1); + + // Indicates successful parsing of command line. + return 0; +} + +int +main (int argc, char **argv) +{ + CORBA::Environment env; + + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, env); + if (env.exception () != 0) + { + env.print_exception ("CORBA::ORB_init"); + return -1; + } + + parse_args (argc, argv); + + CORBA::Object_var object = orb->string_to_object (ior, env); + if (env.exception () != 0) + { + env.print_exception ("CORBA::ORB::string_to_object"); + return -1; + } + + File::System_var file_system = File::System::_narrow (object.in (), env); + if (env.exception () != 0) + { + env.print_exception ("File::System::_narrow"); + return -1; + } + + File::Descriptor_var fd = file_system->open (filename, _O_CREAT | O_RDWR, env); + if (env.exception () != 0) + { + env.print_exception ("File::System::open"); + return -1; + } + + int message_length = ACE_OS::strlen (message) + 1; + CORBA::Octet *buffer = File::Descriptor::DataBuffer::allocbuf (message_length); + ACE_OS::strcpy ((char *) buffer, message); + File::Descriptor::DataBuffer data_sent (message_length, message_length, buffer, CORBA::B_TRUE); + + fd->write (data_sent, env); + if (env.exception () != 0) + { + env.print_exception ("File::Descriptor::write"); + return -1; + } + + fd->lseek (0, SEEK_SET, env); + if (env.exception () != 0) + { + env.print_exception ("File::Descriptor::lseek"); + return -1; + } + + File::Descriptor::DataBuffer_var data_received = fd->read (message_length, env); + if (env.exception () != 0) + { + env.print_exception ("File::Descriptor::read"); + return -1; + } + + char *result = (char *) &data_received[0]; + cout << result << endl; + + fd->destroy (env); + if (env.exception () != 0) + { + env.print_exception ("File::Descriptor::destroy"); + return -1; + } + + return 0; +} + diff --git a/TAO/tests/POA/Default_Servant/client.dsp b/TAO/tests/POA/Default_Servant/client.dsp new file mode 100644 index 00000000000..53cb7731091 --- /dev/null +++ b/TAO/tests/POA/Default_Servant/client.dsp @@ -0,0 +1,99 @@ +# 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 /GR /GX /O2 /I "..\..\.." /I "..\..\..\.." /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 /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "client - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "client__"
+# PROP BASE Intermediate_Dir "client__"
+# 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 /GR /GX /Zi /Od /I "..\..\.." /I "..\..\..\.." /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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "client - Win32 Release"
+# Name "client - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\client.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileS.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/TAO/tests/POA/Default_Servant/server.cpp b/TAO/tests/POA/Default_Servant/server.cpp new file mode 100644 index 00000000000..0928f243ff3 --- /dev/null +++ b/TAO/tests/POA/Default_Servant/server.cpp @@ -0,0 +1,113 @@ +#include "ace/streams.h" +#include "File_i.h" + +int +main (int argc, char **argv) +{ + CORBA::Environment env; + + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, env); + if (env.exception () != 0) + { + env.print_exception ("CORBA::ORB_init"); + return -1; + } + + CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in (), env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::_narrow"); + return -1; + } + + PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::the_POAManager"); + return -1; + } + + // CORBA::PolicyList policies (5); + PortableServer::PolicyList policies (5); + policies.length (5); + policies[0] = root_poa->create_id_assignment_policy (PortableServer::USER_ID, env); + policies[1] = root_poa->create_lifespan_policy (PortableServer::PERSISTENT, env); + policies[2] = root_poa->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT, env); + policies[3] = root_poa->create_servant_retention_policy (PortableServer::RETAIN, env); + policies[4] = root_poa->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID, env); + + ACE_CString name = "firstPOA"; + PortableServer::POA_var first_poa = root_poa->create_POA (name.c_str (), + poa_manager.in (), + policies, + env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::create_POA"); + return -1; + } + + for (CORBA::ULong i = 0; + i < policies.length () && env.exception () == 0; + ++i) + { + PortableServer::Policy_ptr policy = policies[i]; + policy->destroy (env); + } + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::create_POA"); + return -1; + } + + FileImpl::System file_system_impl (first_poa.in ()); + + PortableServer::ObjectId_var file_system_oid = PortableServer::string_to_ObjectId ("FileSystem"); + first_poa->activate_object_with_id (file_system_oid.in (), + &file_system_impl, + env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::activate_object_with_id"); + return -1; + } + + CORBA::Object_var file_system = first_poa->id_to_reference (file_system_oid, env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::id_to_reference"); + return -1; + } + + CORBA::String_var file_system_ior = orb->object_to_string (file_system.in (), env); + if (env.exception () != 0) + { + env.print_exception ("CORBA::ORB::object_to_string"); + return -1; + } + + cout << file_system_ior.in () << endl; + + poa_manager->activate (env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POAManager::activate"); + return -1; + } + + if (orb->run () == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "CORBA::ORB::run"), -1); + + root_poa->destroy (CORBA::B_TRUE, + CORBA::B_TRUE, + env); + if (env.exception () != 0) + { + env.print_exception ("PortableServer::POA::destroy"); + return -1; + } + + return 0; +} diff --git a/TAO/tests/POA/Default_Servant/server.dsp b/TAO/tests/POA/Default_Servant/server.dsp new file mode 100644 index 00000000000..eb8830a1c7e --- /dev/null +++ b/TAO/tests/POA/Default_Servant/server.dsp @@ -0,0 +1,103 @@ +# 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 /GR /GX /O2 /I "..\..\.." /I "..\..\..\.." /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 /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# SUBTRACT LINK32 /pdb:none
+
+!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 /GR /GX /Zi /Od /I "..\..\.." /I "..\..\..\.." /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 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\..\..\tao" /libpath:"..\..\..\..\ace"
+# SUBTRACT LINK32 /pdb:none
+
+!ENDIF
+
+# Begin Target
+
+# Name "server - Win32 Release"
+# Name "server - Win32 Debug"
+# Begin Source File
+
+SOURCE=.\File_i.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileS.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\server.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/TAO/tests/POA/Default_Servant/svc.conf b/TAO/tests/POA/Default_Servant/svc.conf new file mode 100644 index 00000000000..43c6a486c92 --- /dev/null +++ b/TAO/tests/POA/Default_Servant/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/POA/Generic_Servant/client.cpp b/TAO/tests/POA/Generic_Servant/client.cpp index e307cae1552..2d8f5ae42d4 100644 --- a/TAO/tests/POA/Generic_Servant/client.cpp +++ b/TAO/tests/POA/Generic_Servant/client.cpp @@ -2,7 +2,7 @@ #include "ace/Get_Opt.h" #include "FooC.h" -char *ior = 0; +static char *ior = 0; static int parse_args (int argc, char **argv) @@ -39,7 +39,7 @@ main (int argc, char **argv) { CORBA::Environment env; - CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv, 0, env); + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, env); if (env.exception () != 0) { env.print_exception ("CORBA::ORB_init"); @@ -58,7 +58,7 @@ main (int argc, char **argv) Foo_var foo = Foo::_narrow (object.in (), env); if (env.exception () != 0) { - env.print_exception ("Foo::_bind"); + env.print_exception ("Foo::_narrow"); return -1; } @@ -71,8 +71,6 @@ main (int argc, char **argv) cout << result << endl; - CORBA::release (orb); - return 0; } |