summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
Diffstat (limited to 'TAO')
-rw-r--r--TAO/ChangeLog-98c25
-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
-rw-r--r--TAO/tests/POA/Forwarding/Foo.idl14
-rw-r--r--TAO/tests/POA/Forwarding/Forwarding.dsw41
-rw-r--r--TAO/tests/POA/Forwarding/MyFooServant.cpp80
-rw-r--r--TAO/tests/POA/Forwarding/MyFooServant.h48
-rw-r--r--TAO/tests/POA/Forwarding/client.cpp177
-rw-r--r--TAO/tests/POA/Forwarding/client.dsp163
-rw-r--r--TAO/tests/POA/Forwarding/server.cpp206
-rw-r--r--TAO/tests/POA/Forwarding/server.dsp167
21 files changed, 1171 insertions, 77 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index b474d207989..4cb5ff597c7 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,28 @@
+Tue May 12 17:13:23 1998 Irfan Pyarali <irfan@cs.wustl.edu>
+
+ * tests/POA/Forwarding/: Added new test that shows the forwarding
+ features in TAO.
+
+ * tao/default_server.cpp (concurrency_strategy): Made sure that
+ the reactive strategy is returned if no concurrency_strategy has
+ been explicitly set by the user. This should allow servers to
+ work without a svc.conf file.
+
+ * tao/Server_Request.cpp (set_result and set_exception): These
+ should not raise exceptions if this->exception_ is set.
+
+ * tao/Servant_Base.cpp: Removed implementation for
+ TAO_ServantBase::_dispatch() and made it pure virtual. Also,
+ passed the system environment to the DSI implementation class.
+
+ * tao/POAC.cpp (ForwardRequest): Fixed old IDL code for this
+ exception.
+
+ * tao/Forwarding_Servant: New DSI servant used by the POA for
+ forwarding.
+
+ * tao/POA.cpp (forward_object): Adding forward support to the POA.
+
Tue May 12 17:34:06 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
* tests/OctetSeq/OctetSeq.cpp:
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 *
diff --git a/TAO/tests/POA/Forwarding/Foo.idl b/TAO/tests/POA/Forwarding/Foo.idl
new file mode 100644
index 00000000000..f97f988917f
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/Foo.idl
@@ -0,0 +1,14 @@
+// $Id$
+
+#include "POA.idl"
+
+interface Foo
+{
+ long doit ()
+ raises (PortableServer::ForwardRequest);
+
+ exception Cannot_Forward {};
+
+ void forward ()
+ raises (Cannot_Forward);
+};
diff --git a/TAO/tests/POA/Forwarding/Forwarding.dsw b/TAO/tests/POA/Forwarding/Forwarding.dsw
new file mode 100644
index 00000000000..f6006d20cb7
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/Forwarding.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/Forwarding/MyFooServant.cpp b/TAO/tests/POA/Forwarding/MyFooServant.cpp
new file mode 100644
index 00000000000..4b2184435f2
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/MyFooServant.cpp
@@ -0,0 +1,80 @@
+// $Id$
+
+//===============================================================================
+//
+//
+// = FILENAME
+// MyFooServant.cpp
+//
+// = DESCRIPTION
+// This is a simple foo servant implementation
+//
+// = AUTHOR
+// Irfan Pyarali
+//
+//==================================================================================
+
+#include "MyFooServant.h"
+
+// Constructor
+MyFooServant::MyFooServant (PortableServer::POA_ptr poa,
+ CORBA::Long value,
+ CORBA::Object_ptr forward_to)
+ : poa_ (PortableServer::POA::_duplicate (poa)),
+ value_ (value),
+ forward_to_ (CORBA::Object::_duplicate (forward_to))
+{
+}
+
+// Destructor
+MyFooServant::~MyFooServant (void)
+{
+}
+
+// Return the Default POA of this Servant
+PortableServer::POA_ptr
+MyFooServant::_default_POA (CORBA::Environment &/*env*/)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
+// Return this->value
+CORBA::Long
+MyFooServant::doit (CORBA::Environment &/*env*/)
+{
+ return this->value_++;
+}
+
+void
+MyFooServant::forward (CORBA::Environment &env)
+{
+ if (!CORBA::is_nil (this->forward_to_.in ()))
+ {
+ PortableServer::ObjectId_var oid = this->poa_->servant_to_id (this, env);
+
+ if (env.exception () != 0)
+ return;
+
+ PortableServer::Servant servant = this->poa_->_servant ();
+ if (servant == 0)
+ {
+ CORBA::Exception *exception = new Foo::Cannot_Forward;
+ env.exception (exception);
+ return;
+ }
+
+ void *ptr = servant->_downcast ("IDL:PortableServer/POA:1.0");
+ POA_PortableServer::POA *poa = (POA_PortableServer::POA *) ptr;
+ TAO_POA *tao_poa = ACE_dynamic_cast (TAO_POA *, poa);
+
+ tao_poa->forward_object (oid.in (),
+ this->forward_to_.in (),
+ env);
+ }
+ else
+ {
+ CORBA::Exception *exception = new Foo::Cannot_Forward;
+ env.exception (exception);
+ return;
+ }
+}
diff --git a/TAO/tests/POA/Forwarding/MyFooServant.h b/TAO/tests/POA/Forwarding/MyFooServant.h
new file mode 100644
index 00000000000..e84f12921f4
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/MyFooServant.h
@@ -0,0 +1,48 @@
+// $Id$
+//=============================================================================
+//
+//
+// = FILENAME
+// MyFooServant.h
+//
+// = DESCRIPTION
+// Defines MyFooServant class for the Foo interface
+//
+// = AUTHOR
+// Irfan Pyarali
+//
+//=============================================================================
+
+#if !defined (MYFOOSERVANT_H)
+#define MYFOOSERVANT_H
+
+#include "FooS.h"
+
+class MyFooServant : public POA_Foo
+{
+public:
+ // constructor - takes a POA and a value parameter
+ MyFooServant (PortableServer::POA_ptr poa,
+ CORBA::Long value,
+ CORBA::Object_ptr forward_to);
+
+ // Destructor
+ virtual ~MyFooServant (void);
+
+ //Returns the Default POA of this Servant object
+ virtual PortableServer::POA_ptr _default_POA (CORBA::Environment &env);
+
+ // Simple doit method
+ virtual CORBA::Long doit (CORBA::Environment &env);
+
+ // Setup forwarding
+ virtual void forward (CORBA::Environment &env);
+
+protected:
+ // Default poa associated with this servant
+ PortableServer::POA_var poa_;
+ CORBA::Long value_;
+ CORBA::Object_var forward_to_;
+};
+
+#endif /* MYFOOSERVANT_H */
diff --git a/TAO/tests/POA/Forwarding/client.cpp b/TAO/tests/POA/Forwarding/client.cpp
new file mode 100644
index 00000000000..6e2654928d7
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/client.cpp
@@ -0,0 +1,177 @@
+// $Id$
+
+//===============================================================================
+//
+//
+// = FILENAME
+// client.cpp
+//
+// = DESCRIPTION
+//
+// This is a simple foo client implementation. Also looks out for
+// forwarding exceptions
+//
+// = AUTHOR
+// Irfan Pyarali
+//
+//==================================================================================
+
+#include "ace/streams.h"
+#include "ace/Get_Opt.h"
+#include "FooC.h"
+
+static char *IOR = 0;
+static int iterations = 6;
+
+static int
+parse_args (int argc, char **argv)
+{
+ ACE_Get_Opt get_opts (argc, argv, "k:i:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ IOR = get_opts.optarg;
+ break;
+ case 'i':
+ iterations = ::atoi (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\n"), -1);
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ CORBA::Environment env;
+
+ // Initialize the ORB
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("CORBA::ORB_init");
+ return -1;
+ }
+
+ // Initialize options based on command-line arguments.
+ int parse_args_result = parse_args (argc, argv);
+ if (parse_args_result != 0)
+ return parse_args_result;
+
+ // Get an object reference from the argument string.
+ CORBA::Object_var object = orb->string_to_object (IOR, env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("CORBA::ORB::string_to_object");
+ return -1;
+ }
+
+ // Try to narrow the object reference to a Foo reference.
+ Foo_var foo = Foo::_narrow (object.in (), env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("Foo::_narrow");
+ return -1;
+ }
+
+ CORBA::String_var original_location = orb->object_to_string (foo.in (), env);
+ if (env.exception () == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "original location = %s \n", original_location.in ()));
+ }
+ else
+ {
+ env.print_exception ("ORB::object_to_string");
+ return -1;
+ }
+
+ CORBA::Long result = 0;
+
+ for (int i = 1; i <= iterations; i++)
+ {
+
+ // About half way through
+ if (i == iterations / 2)
+ {
+ foo->forward (env);
+
+ // If exception
+ if (env.exception () != 0)
+ {
+ env.print_exception ("Foo::forward");
+ return -1;
+ }
+ }
+ else
+ {
+ // Invoke the doit() method of the foo reference.
+ result = foo->doit (env);
+
+ // If exception
+ if (env.exception () != 0)
+ {
+ // Narrow to ForwardRequest
+ PortableServer::ForwardRequest_ptr forward_request =
+ PortableServer::ForwardRequest::_narrow (env.exception ());
+
+ // If narrowing of exception succeeded
+ if (forward_request != 0)
+ {
+ // Set foo to new location
+ foo = Foo::_narrow (forward_request->forward_reference.in (), env);
+
+ // If narrowing of Foo succeeded
+ if (env.exception () == 0)
+ {
+ CORBA::String_var new_location = orb->object_to_string (foo.in (), env);
+ if (env.exception () == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG, "new location = %s \n", new_location.in ()));
+ continue;
+ }
+ else
+ {
+ env.print_exception ("ORB::object_to_string");
+ return -1;
+ }
+ }
+ // If narrowing of Foo failed
+ else
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Foo::_narrow on forwarded location failed\n"),
+ -1);
+ }
+
+ // If narrowing of exception failed
+ else
+ {
+ env.print_exception ("PortableServer::ForwardRequest::_narrow");
+ return -1;
+ }
+ }
+ else
+ // Print the result of doit () method of the foo reference.
+ ACE_DEBUG ((LM_DEBUG, "doit() returned %d \n", result));
+ }
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/POA/Forwarding/client.dsp b/TAO/tests/POA/Forwarding/client.dsp
new file mode 100644
index 00000000000..3459c316fdf
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/client.dsp
@@ -0,0 +1,163 @@
+# 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 "..\..\..\.." /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 /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=.\Foo.idl
+
+!IF "$(CFG)" == "client - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\Foo.idl
+InputName=Foo
+
+BuildCmds= \
+ ..\..\..\tao_idl\tao_idl -Wb,export_macro=GENERIC_SERVANT_Export\
+ -Wb,export_include=generic_servant_export.h $(InputName).idl
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.h" : $(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
+
+!ELSEIF "$(CFG)" == "client - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\Foo.idl
+InputName=Foo
+
+BuildCmds= \
+ ..\..\..\tao_idl\tao_idl -I..\..\..\tao $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(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=.\FooC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FooS.cpp
+# End Source File
+# End Target
+# End Project
diff --git a/TAO/tests/POA/Forwarding/server.cpp b/TAO/tests/POA/Forwarding/server.cpp
new file mode 100644
index 00000000000..34dfac1988c
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/server.cpp
@@ -0,0 +1,206 @@
+// $Id$
+
+// ===========================================================================================
+// = LIBRARY
+// TAO/tests/POA/Forwarding
+//
+// = FILENAME
+// server.cpp
+//
+// = DESCRIPTION
+//
+// = AUTHOR
+// Irfan Pyarali
+// ===========================================================================================
+
+#include "MyFooServant.h"
+
+static char *forward_to_IOR = 0;
+
+static int
+parse_args (int argc, char **argv)
+{
+ ACE_Get_Opt get_opts (argc, argv, "f:O:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'f':
+ forward_to_IOR = get_opts.optarg;
+ break;
+ }
+
+ // Indicates successful parsing of command line.
+ return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+ int result = parse_args (argc, argv);
+ if (result == -1)
+ return -1;
+
+ CORBA::Environment env;
+
+ // Initialize the ORB first.
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, 0, env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("CORBA::ORB_init");
+ return -1;
+ }
+
+ // Obtain the RootPOA.
+ CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
+
+ // Get the POA_var object from Object_var.
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (obj.in (), env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::_narrow");
+ return -1;
+ }
+
+ // Get the POAManager of the RootPOA.
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager (env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::the_POAManager");
+ return -1;
+ }
+
+ // Policies for the childPOA to be created.
+ CORBA::PolicyList policies (2);
+ policies.length (2);
+
+ // Id Assignment Policy
+ policies[0] =
+ root_poa->create_id_assignment_policy (PortableServer::USER_ID, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_id_assignment_policy");
+ return -1;
+ }
+
+ // Lifespan policy
+ policies[1] =
+ root_poa->create_lifespan_policy (PortableServer::PERSISTENT, env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_lifespan_policy");
+ return -1;
+ }
+
+ // Create the childPOA under the RootPOA.
+ ACE_CString name = "childPOA";
+ PortableServer::POA_var child_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;
+ }
+
+ // Creation of childPOA is over. Destroy the Policy objects.
+ for (CORBA::ULong i = 0;
+ i < policies.length () && env.exception () == 0;
+ ++i)
+ {
+ CORBA::Policy_ptr policy = policies[i];
+ policy->destroy (env);
+ }
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::create_POA");
+ return -1;
+ }
+
+
+ CORBA::Object_var forward_to;
+
+ if (forward_to_IOR != 0)
+ {
+ forward_to = orb->string_to_object (forward_to_IOR, env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("ORB::string_to_object");
+ return -1;
+ }
+ }
+
+ // Create MyFooServant
+ MyFooServant foo_impl (child_poa.in (),
+ 27,
+ forward_to.in ());
+
+ // Create ObjectId and use that ObjectId to activate the foo_impl
+ // object.
+ //
+ // Operation Used :
+ // void activate_object_with_id( in ObjectId oid, in Servant p_servant)
+ // raises (ObjectAlreadyActive, ServantAlreadyActive, WrongPolicy);
+ PortableServer::ObjectId_var oid =
+ PortableServer::string_to_ObjectId ("Foo");
+
+ child_poa->activate_object_with_id (oid.in (),
+ &foo_impl,
+ env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("PortableServer::POA::activate_object_with_id");
+ return -1;
+ }
+
+ // Get Object reference for foo_impl object.
+ Foo_var foo = foo_impl._this (env);
+ if (env.exception () != 0)
+ {
+ env.print_exception ("POA_Foo::_this");
+ return -1;
+ }
+
+ // Stringyfy the object reference and print it out.
+ CORBA::String_var ior =
+ orb->object_to_string (foo.in (), env);
+
+ if (env.exception () != 0)
+ {
+ env.print_exception ("CORBA::ORB::object_to_string");
+ return -1;
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "%s\n", ior.in ()));
+
+ 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);
+
+ // Destroy RootPOA. (Also destroys childPOA)
+ 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/Forwarding/server.dsp b/TAO/tests/POA/Forwarding/server.dsp
new file mode 100644
index 00000000000..94c29048e51
--- /dev/null
+++ b/TAO/tests/POA/Forwarding/server.dsp
@@ -0,0 +1,167 @@
+# 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 "..\Generic_Servant\\" /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 ..\Generic_Servant\server.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 /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 ..\Generic_Servant\server.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=.\Foo.idl
+
+!IF "$(CFG)" == "server - Win32 Release"
+
+# Begin Custom Build
+InputPath=.\Foo.idl
+InputName=Foo
+
+BuildCmds= \
+ ..\..\..\tao_idl\tao_idl -Wb,export_macro=GENERIC_SERVANT_Export\
+ -Wb,export_include=generic_servant_export.h $(InputName).idl
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.h" : $(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
+
+!ELSEIF "$(CFG)" == "server - Win32 Debug"
+
+# Begin Custom Build
+InputPath=.\Foo.idl
+InputName=Foo
+
+BuildCmds= \
+ ..\..\..\tao_idl\tao_idl -I..\..\..\tao $(InputName).idl
+
+"$(InputName)C.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(InputName)C.i" : $(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=.\FooC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FooS.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\MyFooServant.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\server.cpp
+# End Source File
+# End Target
+# End Project