summaryrefslogtreecommitdiff
path: root/TAO/tao
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-12 23:16:47 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-12 23:16:47 +0000
commit7f20a322107dea0198f10cd8175a33631cf0718a (patch)
tree804ab712f0d8de0fb8ca1aca2b8d40aec66bbfff /TAO/tao
parentf5b3139bc447e740c6095d7ddaaf5df6b22e7b33 (diff)
downloadATCD-7f20a322107dea0198f10cd8175a33631cf0718a.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO/tao')
-rw-r--r--TAO/tao/Forwarding_Servant.cpp35
-rw-r--r--TAO/tao/Forwarding_Servant.h56
-rw-r--r--TAO/tao/POA.cpp45
-rw-r--r--TAO/tao/POA.h7
-rw-r--r--TAO/tao/POAC.cpp96
-rw-r--r--TAO/tao/POAC.h21
-rw-r--r--TAO/tao/POAC.i17
-rw-r--r--TAO/tao/Servant_Base.cpp27
-rw-r--r--TAO/tao/Servant_Base.h5
-rw-r--r--TAO/tao/Server_Request.cpp4
-rw-r--r--TAO/tao/TAO.dsp8
-rw-r--r--TAO/tao/default_server.cpp6
12 files changed, 250 insertions, 77 deletions
diff --git a/TAO/tao/Forwarding_Servant.cpp b/TAO/tao/Forwarding_Servant.cpp
new file mode 100644
index 00000000000..ae827e90739
--- /dev/null
+++ b/TAO/tao/Forwarding_Servant.cpp
@@ -0,0 +1,35 @@
+// $Id$
+
+#include "tao/Forwarding_Servant.h"
+
+TAO_Forwarding_Servant::TAO_Forwarding_Servant (CORBA::Object_ptr forward_to,
+ const char *interface_repository_id)
+ : forward_to_ (CORBA::Object::_duplicate (forward_to)),
+ interface_repository_id_ (CORBA::string_dup (interface_repository_id))
+{
+}
+
+void
+TAO_Forwarding_Servant::invoke (CORBA::ServerRequest_ptr request,
+ CORBA::Environment &env)
+{
+ ACE_UNUSED_ARG (request);
+
+ // Throw forward exception
+ CORBA::Exception *exception
+ = new PortableServer::ForwardRequest (this->forward_to_.in ());
+
+ CORBA::Any any (exception->_type (), exception);
+
+ request->set_exception (any, env);
+
+ return;
+}
+
+PortableServer::RepositoryId
+TAO_Forwarding_Servant::_primary_interface (const PortableServer::ObjectId &oid,
+ PortableServer::POA_ptr poa,
+ CORBA::Environment &env)
+{
+ return CORBA::string_dup (this->interface_repository_id_.in ());
+}
diff --git a/TAO/tao/Forwarding_Servant.h b/TAO/tao/Forwarding_Servant.h
new file mode 100644
index 00000000000..a13cae0824b
--- /dev/null
+++ b/TAO/tao/Forwarding_Servant.h
@@ -0,0 +1,56 @@
+// $Id$
+//
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// Forwarding_Servant.h
+//
+// = DESCRIPTION
+//
+// A DSI implementation of a forwarding servant.
+//
+// = AUTHOR
+//
+// Irfan Pyarali
+//
+// ============================================================================
+
+#if !defined (TAO_FORWARDING_SERVANT_H)
+#define TAO_FORWARDING_SERVANT_H
+
+#include "tao/corba.h"
+
+class TAO_Forwarding_Servant : public PortableServer::DynamicImplementation
+{
+public:
+
+ TAO_Forwarding_Servant (CORBA::Object_ptr forward_to,
+ const char *interface_repository_id_);
+ // Constructor
+
+ virtual void invoke (CORBA::ServerRequest_ptr request,
+ CORBA::Environment &env);
+ // The invoke() method receives requests issued to any CORBA object
+ // incarnated by the DSI servant and performs the processing
+ // necessary to execute the request.
+
+ virtual PortableServer::RepositoryId _primary_interface (const PortableServer::ObjectId &oid,
+ PortableServer::POA_ptr poa,
+ CORBA::Environment &env);
+ // The _primary_interface() method receives an ObjectId value and a
+ // POA_ptr as input parameters and returns a valid RepositoryId
+ // representing the most-derived interface for that oid.
+
+protected:
+
+ CORBA::Object_var forward_to_;
+ // Forward all requests to this object
+
+ CORBA::String_var interface_repository_id_;
+ // Here is the interface we support
+};
+
+#endif /* TAO_FORWARDING_SERVANT_H */
diff --git a/TAO/tao/POA.cpp b/TAO/tao/POA.cpp
index 2b48478e0b3..14325094ddf 100644
--- a/TAO/tao/POA.cpp
+++ b/TAO/tao/POA.cpp
@@ -9,6 +9,9 @@
// auto_ptr class
#include "ace/Auto_Ptr.h"
+// Forwarding Servant class
+#include "tao/Forwarding_Servant.h"
+
// This is the maximum space require to convert the ulong into a
// string.
const int TAO_POA::max_space_required_for_ulong = 24;
@@ -2149,6 +2152,42 @@ TAO_POA::id_to_reference_i (const PortableServer::ObjectId &oid,
}
}
+void
+TAO_POA::forward_object (const PortableServer::ObjectId &oid,
+ CORBA::Object_ptr forward_to,
+ CORBA::Environment &env)
+{
+ // Lock access to the POA for the duration of this transaction
+ TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env);
+
+ this->forward_object_i (oid,
+ forward_to,
+ env);
+}
+
+void
+TAO_POA::forward_object_i (const PortableServer::ObjectId &oid,
+ CORBA::Object_ptr forward_to,
+ CORBA::Environment &env)
+{
+ // First, deactivate the object
+ this->deactivate_object_i (oid, env);
+
+ // If failure
+ if (env.exception () != 0)
+ return;
+
+ // If success, create a forwarding servant
+ TAO_Forwarding_Servant *forwarding_servant
+ = new TAO_Forwarding_Servant (forward_to,
+ forward_to->_interface_repository_id ());
+
+ // Register the forwarding servant with the same object Id
+ this->activate_object_with_id_i (oid,
+ forwarding_servant,
+ env);
+}
+
PortableServer::POA_ptr
TAO_POA::the_parent (CORBA::Environment &env)
{
@@ -2550,12 +2589,6 @@ TAO_POA::dispatch_servant_i (const TAO_ObjectKey &key,
context,
env);
- if (env.exception () != 0)
- {
- ACE_DEBUG ((LM_DEBUG, "Servant raised exception: \n"));
- env.print_exception ("detected in POA::dispatch");
- }
-
// Cleanup from upcall
poa->post_invoke (servant,
operation,
diff --git a/TAO/tao/POA.h b/TAO/tao/POA.h
index 73ace7a8471..077696e6c11 100644
--- a/TAO/tao/POA.h
+++ b/TAO/tao/POA.h
@@ -420,6 +420,9 @@ public:
virtual CORBA::Object_ptr id_to_reference (const PortableServer::ObjectId &oid,
CORBA::Environment &env);
+ virtual void forward_object (const PortableServer::ObjectId &oid,
+ CORBA::Object_ptr forward_to,
+ CORBA::Environment &env);
// Utility functions for the other
static void encode_sequence_to_string (CORBA::String &str,
@@ -545,6 +548,10 @@ protected:
virtual CORBA::Object_ptr id_to_reference_i (const PortableServer::ObjectId &oid,
CORBA::Environment &env);
+ virtual void forward_object_i (const PortableServer::ObjectId &oid,
+ CORBA::Object_ptr forward_to,
+ CORBA::Environment &env);
+
virtual ACE_Lock &lock (void);
virtual TAO_POA_Policies &policies (void);
diff --git a/TAO/tao/POAC.cpp b/TAO/tao/POAC.cpp
index 688ce6cebe3..d61d25029b4 100644
--- a/TAO/tao/POAC.cpp
+++ b/TAO/tao/POAC.cpp
@@ -134,48 +134,106 @@ static const CORBA::Long _oc_PortableServer_ObjectId[] =
static CORBA::TypeCode _tc__tc_PortableServer_ObjectId (CORBA::tk_alias, sizeof (_oc_PortableServer_ObjectId), (char *) &_oc_PortableServer_ObjectId, CORBA::B_FALSE);
CORBA::TypeCode_ptr PortableServer::_tc_ObjectId = &_tc__tc_PortableServer_ObjectId;
-// copy constructor
-PortableServer::ForwardRequest::ForwardRequest(const PortableServer::ForwardRequest &_tao_excp)
- :CORBA_UserException (CORBA::TypeCode::_duplicate (_tao_excp._type ()))
+// default constructor
+PortableServer::ForwardRequest::ForwardRequest (void)
+ : CORBA_UserException (CORBA::TypeCode::_duplicate (PortableServer::_tc_ForwardRequest))
+{
+}
+
+// destructor - all members are of self managing types
+PortableServer::ForwardRequest::~ForwardRequest (void)
{
- this->forward_reference = _tao_excp.forward_reference;
}
+// copy constructor
+PortableServer::ForwardRequest::ForwardRequest (const PortableServer::ForwardRequest &_tao_excp)
+ :CORBA_UserException (CORBA::TypeCode::_duplicate (_tao_excp._type ()))
+{
+ }
+
// assignment operator
PortableServer::ForwardRequest&
PortableServer::ForwardRequest::operator= (const PortableServer::ForwardRequest &_tao_excp)
{
this->type_ = CORBA::TypeCode::_duplicate (_tao_excp._type ());
- this->forward_reference = _tao_excp.forward_reference;
- return *this;
+ return *this;
}
-// special constructor
-PortableServer::ForwardRequest::ForwardRequest(const CORBA::Object_ptr &_tao_forward_reference)
- : CORBA_UserException (CORBA::TypeCode::_duplicate (PortableServer::_tc_ForwardRequest))
+PortableServer::ForwardRequest::ForwardRequest(
+ const CORBA::Object_ptr _tao_forward_reference)
+
+ : CORBA_UserException (CORBA::TypeCode::_duplicate (PortableServer::_tc_ForwardRequest))
{
this->forward_reference = _tao_forward_reference;
}
// narrow
-PortableServer::ForwardRequest_ptr
-PortableServer::ForwardRequest::_narrow(CORBA::Exception *exc)
+PortableServer::ForwardRequest_ptr
+PortableServer::ForwardRequest::_narrow (CORBA::Exception *exc)
{
if (!ACE_OS::strcmp ("IDL:PortableServer/ForwardRequest:1.0", exc->_id ())) // same type
- return ACE_dynamic_cast (PortableServer::ForwardRequest_ptr, exc);
+ return ACE_dynamic_cast (PortableServer::ForwardRequest_ptr, exc);
else
- return 0;
+ return 0;
+}
+
+// TAO extension - the _alloc method
+CORBA::Exception *PortableServer::ForwardRequest::_alloc (void)
+{
+ return new PortableServer::ForwardRequest;
+}
+
+void operator<<= (CORBA::Any &_tao_any, const PortableServer::ForwardRequest &_tao_elem) // copying
+{
+ CORBA::Environment _tao_env;
+ _tao_any.replace (PortableServer::_tc_ForwardRequest, &_tao_elem, 1, _tao_env);
+}
+void operator<<= (CORBA::Any &_tao_any, PortableServer::ForwardRequest *_tao_elem) // non copying
+{
+ CORBA::Environment _tao_env;
+ _tao_any.replace (PortableServer::_tc_ForwardRequest, _tao_elem, 0, _tao_env);
+}
+CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, PortableServer::ForwardRequest *&_tao_elem)
+{
+ CORBA::Environment _tao_env;
+ if (!_tao_any.type ()->equal (PortableServer::_tc_ForwardRequest, _tao_env)) return 0; // not equal
+ if (_tao_any.any_owns_data ())
+ {
+ ACE_NEW_RETURN (_tao_elem, PortableServer::ForwardRequest, 0);
+ TAO_InputCDR stream ((ACE_Message_Block *)_tao_any.value ());
+ if (stream.decode (PortableServer::_tc_ForwardRequest, _tao_elem, 0, _tao_env)
+ == CORBA::TypeCode::TRAVERSE_CONTINUE)
+ {
+ ((CORBA::Any *)&_tao_any)->replace (_tao_any.type (), _tao_elem, 1, _tao_env);
+ return 1;
+ }
+ else
+ {
+ delete _tao_elem;
+ return 0;
+ }
+ }
+ else
+ {
+ _tao_elem = (PortableServer::ForwardRequest *)_tao_any.value ();
+ return 1;
+ }
}
static const CORBA::Long _oc_PortableServer_ForwardRequest[] =
{
- 0, // byte order
- 38, 0x49444c3a, 0x506f7274, 0x61626c65, 0x53657276, 0x65722f46, 0x6f727761, 0x72645265, 0x71756573, 0x743a312e, 0x30000000, // repository ID = IDL:PortableServer/ForwardRequest:1.0
- 15, 0x466f7277, 0x61726452, 0x65717565, 0x73740000, // name = ForwardRequest
+ TAO_ENCAP_BYTE_ORDER, // byte order
+ 38, 0x3a4c4449, 0x74726f50, 0x656c6261, 0x76726553, 0x462f7265, 0x6177726f, 0x65526472, 0x73657571, 0x2e313a74, 0xfdfd0030, // repository ID = IDL:PortableServer/ForwardRequest:1.0
+ 15, 0x77726f46, 0x52647261, 0x65757165, 0xfd007473, // name = ForwardRequest
1, // member count
- 18, 0x666f7277, 0x6172645f, 0x72656665, 0x72656e63, 0x65000000, // name = forward_reference
- };
-static CORBA::TypeCode _tc__tc_PortableServer_ForwardRequest (CORBA::tk_struct, sizeof (_oc_PortableServer_ForwardRequest), (char *) &_oc_PortableServer_ForwardRequest, CORBA::B_FALSE);
+ 18, 0x77726f66, 0x5f647261, 0x65666572, 0x636e6572, 0xfdfd0065, // name = forward_reference
+ CORBA::tk_objref,
+44, // encapsulation length
+ TAO_ENCAP_BYTE_ORDER, // byte order
+ 21, 0x3a4c4449, 0x42524f43, 0x624f2f41, 0x7463656a, 0x302e313a, 0xfdfdfd00, // repository ID = IDL:CORBA/Object:1.0
+ 7, 0x656a624f, 0xfd007463, // name = Object,
+};
+static CORBA::TypeCode _tc__tc_PortableServer_ForwardRequest (CORBA::tk_except, sizeof (_oc_PortableServer_ForwardRequest), (char *) &_oc_PortableServer_ForwardRequest, CORBA::B_FALSE);
CORBA::TypeCode_ptr PortableServer::_tc_ForwardRequest = &_tc__tc_PortableServer_ForwardRequest;
diff --git a/TAO/tao/POAC.h b/TAO/tao/POAC.h
index f5377abd7b8..10a08f32d8e 100644
--- a/TAO/tao/POAC.h
+++ b/TAO/tao/POAC.h
@@ -297,8 +297,8 @@ typedef POA *POA_ptr;
class ForwardRequest;
typedef ForwardRequest *ForwardRequest_ptr;
-
-#endif // end #if !defined
+
+#endif /* end #if !defined */
#if !defined (_PORTABLESERVER_FORWARDREQUEST_CH_)
@@ -309,16 +309,23 @@ typedef POA *POA_ptr;
public:
ForwardRequest (void); // default ctor
ForwardRequest (const ForwardRequest &); // copy ctor
- ~ForwardRequest(void); // dtor
- ForwardRequest(const CORBA::Object_ptr&);
+ ~ForwardRequest (void); // dtor
+ ForwardRequest(
+ const CORBA::Object_ptr _tao_forward_reference);
+
ForwardRequest &operator= (const ForwardRequest &);
static ForwardRequest *_narrow (CORBA::Exception *);
CORBA::Object_var forward_reference;
- };
- static CORBA::TypeCode_ptr _tc_ForwardRequest;
+ // the alloc method. This is TAO extension
+ static CORBA::Exception *_alloc (void);
+ }; // exception PortableServer::ForwardRequest
+ friend void operator<<= (CORBA::Any &, const ForwardRequest &); // copying version
+ friend void operator<<= (CORBA::Any &, ForwardRequest*); // noncopying version
+ friend CORBA::Boolean operator>>= (const CORBA::Any &, ForwardRequest *&);
+static CORBA::TypeCode_ptr _tc_ForwardRequest;
-#endif // end #if !defined
+#endif /* end #if !defined */
enum ThreadPolicyValue
{
diff --git a/TAO/tao/POAC.i b/TAO/tao/POAC.i
index a7d79e1689a..d5a16026a8b 100644
--- a/TAO/tao/POAC.i
+++ b/TAO/tao/POAC.i
@@ -574,23 +574,6 @@ PortableServer::_tao_seq_Octet_out::operator[] (CORBA::ULong index)
#endif // end #if !defined
-// *************************************************************
-// Inline operations for exception PortableServer::ForwardRequest
-// *************************************************************
-
-// default constructor
-ACE_INLINE
-PortableServer::ForwardRequest::ForwardRequest (void)
- : CORBA_UserException (CORBA::TypeCode::_duplicate (PortableServer::_tc_ForwardRequest))
-{
-}
-
-// destructor - all members are of self managing types
-ACE_INLINE
-PortableServer::ForwardRequest::~ForwardRequest (void)
-{
-}
-
ACE_INLINE
PortableServer::ThreadPolicy::ThreadPolicy(
STUB_Object *objref,
diff --git a/TAO/tao/Servant_Base.cpp b/TAO/tao/Servant_Base.cpp
index 733aba50f97..289aad908b9 100644
--- a/TAO/tao/Servant_Base.cpp
+++ b/TAO/tao/Servant_Base.cpp
@@ -57,25 +57,6 @@ TAO_ServantBase::_bind (const char *opname,
return optable_->bind (opname, skel_ptr);
}
-void
-TAO_ServantBase::_dispatch (CORBA::ServerRequest &req,
- void *context,
- CORBA::Environment &env)
-{
- // @@ (ASG) - we should check here if the call was for _non_existant, else
- // issue an error. For the time being we issue an error
- const char *opname = req.operation ();
- ACE_UNUSED_ARG (context);
-
- // Something really bad happened: the operation was not
- // found in the object, fortunately there is a standard
- // exception for that purpose.
- env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO));
- ACE_ERROR ((LM_ERROR,
- "Cannot find operation <%s> in object\n",
- opname));
-}
-
STUB_Object *
TAO_ServantBase::_create_stub (CORBA_Environment &env)
{
@@ -196,11 +177,11 @@ TAO_DynamicImplementation::_dispatch (CORBA::ServerRequest &request,
ACE_UNUSED_ARG (context);
// Delegate to user
- this->invoke (&request);
+ this->invoke (&request, env);
+
if (request.response_expected ())
{
- CORBA::Environment env2;
- request.init_reply (env2);
- request.dsi_marshal (env2);
+ request.init_reply (env);
+ request.dsi_marshal (env);
}
}
diff --git a/TAO/tao/Servant_Base.h b/TAO/tao/Servant_Base.h
index 362f1828c88..627f9626f86 100644
--- a/TAO/tao/Servant_Base.h
+++ b/TAO/tao/Servant_Base.h
@@ -56,7 +56,7 @@ protected:
virtual void _dispatch (CORBA::ServerRequest &request,
void *context,
- CORBA::Environment &env);
+ CORBA::Environment &env) = 0;
// Dispatches a request to the object: find the operation, cast the
// type to the most derived type, demarshall all the parameters from
// the request and finally invokes the operation, storing the
@@ -103,7 +103,8 @@ class TAO_Export TAO_DynamicImplementation : public virtual TAO_ServantBase
// circumstances may lead to unpredictable results.
{
public:
- virtual void invoke (CORBA::ServerRequest_ptr request) = 0;
+ virtual void invoke (CORBA::ServerRequest_ptr request,
+ CORBA::Environment &env) = 0;
// The invoke() method receives requests issued to any CORBA object
// incarnated by the DSI servant and performs the processing
// necessary to execute the request.
diff --git a/TAO/tao/Server_Request.cpp b/TAO/tao/Server_Request.cpp
index a7d4ff59890..951bec9944e 100644
--- a/TAO/tao/Server_Request.cpp
+++ b/TAO/tao/Server_Request.cpp
@@ -203,7 +203,7 @@ IIOP_ServerRequest::set_result (const CORBA::Any &value,
// setting a result when another result already exists or if an exception
// exists is an error
- if (!this->params_ || this->retval_ || this->exception_)
+ if (this->retval_ || this->exception_)
env.exception (new CORBA::BAD_INV_ORDER (CORBA::COMPLETED_NO));
else
{
@@ -218,7 +218,7 @@ void
IIOP_ServerRequest::set_exception (const CORBA::Any &value,
CORBA::Environment &env)
{
- if (!this->params_ || this->retval_ || this->exception_)
+ if (this->retval_ || this->exception_)
env.exception (new CORBA::BAD_INV_ORDER (CORBA::COMPLETED_NO));
else
{
diff --git a/TAO/tao/TAO.dsp b/TAO/tao/TAO.dsp
index d74a1b57731..548b8078678 100644
--- a/TAO/tao/TAO.dsp
+++ b/TAO/tao/TAO.dsp
@@ -144,6 +144,10 @@ SOURCE=.\Exception.cpp
# End Source File
# Begin Source File
+SOURCE=.\Forwarding_Servant.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\GIOP.cpp
# End Source File
# Begin Source File
@@ -316,6 +320,10 @@ SOURCE=.\Exception.h
# End Source File
# Begin Source File
+SOURCE=.\Forwarding_Servant.h
+# End Source File
+# Begin Source File
+
SOURCE=.\giop.h
# End Source File
# Begin Source File
diff --git a/TAO/tao/default_server.cpp b/TAO/tao/default_server.cpp
index 303650850d1..393c014502e 100644
--- a/TAO/tao/default_server.cpp
+++ b/TAO/tao/default_server.cpp
@@ -25,7 +25,11 @@ TAO_Default_Server_Strategy_Factory::~TAO_Default_Server_Strategy_Factory (void)
TAO_Default_Server_Strategy_Factory::CONCURRENCY_STRATEGY *
TAO_Default_Server_Strategy_Factory::concurrency_strategy (void)
{
- return this->concurrency_strategy_;
+ if (this->concurrency_strategy_ == 0)
+ // If no strategy is specified, use the reactive one.
+ return &this->reactive_strategy_;
+ else
+ return this->concurrency_strategy_;
}
ACE_Lock *