summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-04-24 15:14:37 +0000
committermk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-04-24 15:14:37 +0000
commit0a8ca3780bda36fe1894365d65fee23049a24d66 (patch)
treefea73893440b2ff286848bcd609c0c066673400d
parent4cf7705bd882b23ee6f45f88328f4e5bb084e61d (diff)
downloadATCD-0a8ca3780bda36fe1894365d65fee23049a24d66.tar.gz
Fri Apr 24 10:15:37 1998 Michael Kircher <mk1@cs.wustl.edu>
-rw-r--r--TAO/ChangeLog-98c8
-rw-r--r--TAO/tests/Quoter/Factory_Finder.cpp16
-rw-r--r--TAO/tests/Quoter/Factory_Finder_Impl.h4
-rw-r--r--TAO/tests/Quoter/Generic_Factory.cpp230
-rw-r--r--TAO/tests/Quoter/Generic_Factory.dsp86
-rw-r--r--TAO/tests/Quoter/Generic_Factory.h61
-rw-r--r--TAO/tests/Quoter/Generic_Factory_Impl.cpp178
-rw-r--r--TAO/tests/Quoter/Generic_Factory_Impl.h44
-rw-r--r--TAO/tests/Quoter/Quoter.dsw16
-rw-r--r--TAO/tests/Quoter/Quoter.idl18
-rwxr-xr-xTAO/tests/Quoter/client.exebin471 -> 1168 bytes
-rwxr-xr-xTAO/tests/Quoter/server.exebin1909 -> 431 bytes
12 files changed, 643 insertions, 18 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index 8a414b9f303..9bc1d29f1ce 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,11 @@
+Fri Apr 24 10:15:37 1998 Michael Kircher <mk1@cs.wustl.edu>
+
+ * tests/Quoter/Generic_Factory.{h,cpp,dsp}: server for a
+ Generic Factory conforming to the LifeCycle Service
+
+ * tests/Quoter/Generic_Factory_Impl.{h,cpp}: Implementation
+ of a LifeCycle Service conforming Generic Factory
+
Fri Apr 24 10:08:37 1998 David L. Levine <levine@cs.wustl.edu>
* tao/NVList.cpp: added ACE_Node<CORBA::NamedValue_ptr> template
diff --git a/TAO/tests/Quoter/Factory_Finder.cpp b/TAO/tests/Quoter/Factory_Finder.cpp
index 5ce1b0dbcde..a91e0be781d 100644
--- a/TAO/tests/Quoter/Factory_Finder.cpp
+++ b/TAO/tests/Quoter/Factory_Finder.cpp
@@ -30,11 +30,11 @@ Quoter_Factory_Finder_Server::~Quoter_Factory_Finder_Server ()
TAO_TRY
{
// Unbind the Quoter Factory Finder.
- CosNaming::Name factory_name (2);
- factory_name.length (2);
- factory_name[0].id = CORBA::string_dup ("IDL_Quoter");
- factory_name[1].id = CORBA::string_dup ("Quoter_Factory_Finder");
- this->quoterNamingContext_var_->unbind (factory_name,TAO_TRY_ENV);
+ CosNaming::Name factory_Finder_Name (2);
+ factory_Finder_Name.length (2);
+ factory_Finder_Name[0].id = CORBA::string_dup ("IDL_Quoter");
+ factory_Finder_Name[1].id = CORBA::string_dup ("Quoter_Factory_Finder");
+ this->quoterNamingContext_var_->unbind (factory_Finder_Name,TAO_TRY_ENV);
TAO_CHECK_ENV;
}
TAO_CATCH (CORBA::SystemException, sysex)
@@ -194,17 +194,17 @@ Quoter_Factory_Finder_Server::parse_args ()
int
main (int argc, char *argv [])
{
- Quoter_Factory_Finder_Server quoterFactoryFinder_server;
+ Quoter_Factory_Finder_Server quoter_Factory_Finder_server;
ACE_DEBUG ((LM_DEBUG,
"\n\tIDL_Quoter:Quoter_Factory_Finder \n \n"));
TAO_TRY
{
- if (quoterFactoryFinder_server.init (argc,argv,TAO_TRY_ENV) == -1)
+ if (quoter_Factory_Finder_Server.init (argc,argv,TAO_TRY_ENV) == -1)
return 1;
else
{
- quoterFactoryFinder_server.run (TAO_TRY_ENV);
+ quoter_Factory_Finder_Server.run (TAO_TRY_ENV);
TAO_CHECK_ENV;
}
}
diff --git a/TAO/tests/Quoter/Factory_Finder_Impl.h b/TAO/tests/Quoter/Factory_Finder_Impl.h
index 567c597313b..c92289832d1 100644
--- a/TAO/tests/Quoter/Factory_Finder_Impl.h
+++ b/TAO/tests/Quoter/Factory_Finder_Impl.h
@@ -33,10 +33,6 @@ public:
// Returns a squence of Factories if factories matching the
// factory_key were found. If no factory was found, then the
// NoFactory exception, defined in CosLifeCycle, is raised.
-
-private:
- // CosNaming::NamingContext_var quoterNamingContext_var_;
- // Hold a reference to the Quoter example naming context.
};
#endif /* QUOTER_FACTORY_FINDER_IMPL_H */
diff --git a/TAO/tests/Quoter/Generic_Factory.cpp b/TAO/tests/Quoter/Generic_Factory.cpp
new file mode 100644
index 00000000000..3b57047faec
--- /dev/null
+++ b/TAO/tests/Quoter/Generic_Factory.cpp
@@ -0,0 +1,230 @@
+// $Id$
+
+// ============================================================================
+//
+// = FILENAME
+// Generic_Factory.cpp
+//
+// = DESCRIPTION
+// The server for the GenericFactory for the quoter example.
+//
+// = AUTHOR
+// Michael Kircher (mk1@cs.wustl.edu)
+//
+// ============================================================================
+
+#include "tao/corba.h"
+#include "Generic_Factory.h"
+
+
+static const char usage [] =
+"[-? |\n[-O[RBport] ORB port number]]";
+
+Quoter_Generic_Factory_Server::Quoter_Generic_Factory_Server ()
+{
+}
+
+Quoter_Generic_Factory_Server::~Quoter_Generic_Factory_Server ()
+{
+ TAO_TRY
+ {
+ // Unbind the Quoter Factory Finder.
+ CosNaming::Name generic_Factory_Name (2);
+ generic_Factory_Name.length (2);
+ generic_Factory_Name[0].id = CORBA::string_dup ("IDL_Quoter");
+ generic_Factory_Name[1].id = CORBA::string_dup ("Quoter_Generic_Factory");
+ this->quoterNamingContext_var_->unbind (generic_Factory_Name,TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+ TAO_CATCH (CORBA::SystemException, sysex)
+ {
+ ACE_UNUSED_ARG (sysex);
+ TAO_TRY_ENV.print_exception ("System Exception");
+ }
+ TAO_CATCH (CORBA::UserException, userex)
+ {
+ ACE_UNUSED_ARG (userex);
+ TAO_TRY_ENV.print_exception ("User Exception");
+ }
+ TAO_ENDTRY;
+}
+
+Quoter_Generic_Factory_Server::init (int argc, char *argv[], CORBA::Environment& env)
+{
+ if (this->orb_manager_.init (argc,
+ argv,
+ env) == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "init"),
+ -1);
+
+ // Copy them, because parse_args expects them there.
+ this->argc_ = argc;
+ this->argv_ = argv;
+
+ this->parse_args ();
+
+
+ ACE_NEW_RETURN (this->quoter_Generic_Factory_Impl_ptr_,
+ Quoter_Generic_Factory_Impl(),
+ -1);
+
+ // Activate the object.
+ CORBA::String_var str =
+ this->orb_manager_.activate (this->quoter_Generic_Factory_Impl_ptr_,
+ env);
+
+ // Failure while activating the Quoter Factory Finder object
+ if (str == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "init: Failure while activating the Quoter Generic Factory Impl.\n"),
+ -1);
+
+
+ ACE_DEBUG ((LM_DEBUG,
+ "The IOR is: <%s>\n",
+ str.in ()));
+
+ // Register the Quoter GenericFactory with the Naming Service
+ TAO_TRY
+ {
+ ACE_DEBUG ((LM_DEBUG,"Trying to get a reference to the Naming Service.\n"));
+
+ // Get the Naming Service object reference.
+ CORBA::Object_var namingObj_var =
+ orb_manager_.orb()->resolve_initial_references ("NameService");
+ TAO_CHECK_ENV;
+
+ if (CORBA::is_nil (namingObj_var.in ()))
+ ACE_ERROR ((LM_ERROR,
+ " (%P|%t) Unable get the Naming Service.\n"));
+
+ // Narrow the object reference to a Naming Context.
+ CosNaming::NamingContext_var namingContext_var =
+ CosNaming::NamingContext::_narrow (namingObj_var.in (),
+ TAO_TRY_ENV);
+
+ if (CORBA::is_nil (namingContext_var.ptr ()))
+ ACE_ERROR ((LM_ERROR,
+ " (%P|%t) Unable get the Naming Service.\n"));
+
+
+ TAO_CHECK_ENV;
+ ACE_DEBUG ((LM_DEBUG,"Have a proper reference to the Naming Service.\n"));
+
+ // Get the IDL_Quoter naming context.
+ CosNaming::Name quoterContextName (1); // max = 1
+ quoterContextName.length (1);
+ quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter");
+
+ CORBA::Object_var quoterNamingObj_var =
+ namingContext_var->resolve (quoterContextName, TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+
+ quoterNamingContext_var_ =
+ CosNaming::NamingContext::_narrow (quoterNamingObj_var.in (),
+ TAO_TRY_ENV);
+
+ ACE_DEBUG ((LM_DEBUG,"Have a proper reference to the Quoter Naming Context.\n"));
+
+ // Bind the Quoter GenericFactory to the IDL_Quoter naming
+ // context.
+ CosNaming::Name quoter_Generic_Factory_Name_ (1);
+ quoter_Generic_Factory_Name_.length (1);
+ quoter_Generic_Factory_Name_[0].id = CORBA::string_dup ("Quoter_Generic_Factory");
+
+ quoterNamingContext_var_->bind (quoter_Generic_Factory_Name_,
+ this->quoter_Generic_Factory_Impl_ptr_->_this(TAO_TRY_ENV),
+ TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ ACE_DEBUG ((LM_DEBUG,"Bound the Quoter GenericFactory to the Quoter Naming Context.\n"));
+ }
+ TAO_CATCHANY
+ {
+ TAO_TRY_ENV.print_exception ("SYS_EX");
+ }
+ TAO_ENDTRY;
+
+
+ return 0;
+}
+
+int
+Quoter_Generic_Factory_Server::run (CORBA::Environment& env)
+{
+ if (orb_manager_.orb()->run () == -1)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%p\n",
+ "run"),
+ -1);
+ return 0;
+}
+
+
+// Function get_options.
+
+unsigned int
+Quoter_Generic_Factory_Server::parse_args ()
+{
+ // We need the 'O' in get_opt () because we also want to have ORB
+ // parameters, they all start with 'O'.
+ ACE_Get_Opt get_opt (this->argc_, this->argv_, "O?");
+ int opt;
+
+ while ((opt = get_opt ()) != EOF)
+ switch (opt)
+ {
+ case '?':
+ ACE_DEBUG ((LM_DEBUG,
+ "Usage: %s %s\n",
+ this->argv_[0], usage));
+ ACE_OS::exit (0);
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "%s: unknown arg, -%c\n"
+ "Usage: %s %s\n",
+ this->argv_[0], char (opt),
+ this->argv_[0],
+ usage),
+ 1);
+ }
+ return 0;
+}
+
+// function main
+
+int
+main (int argc, char *argv [])
+{
+ Quoter_Generic_Factory_Server quoter_Generic_Factory_Server;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\n\tIDL_Quoter: Quoter_Generic_Factory_Server \n \n"));
+ TAO_TRY
+ {
+ if (quoter_Generic_Factory_Server.init (argc,argv,TAO_TRY_ENV) == -1)
+ return 1;
+ else
+ {
+ quoter_Generic_Factory_Server.run (TAO_TRY_ENV);
+ TAO_CHECK_ENV;
+ }
+ }
+ TAO_CATCH (CORBA::SystemException, sysex)
+ {
+ ACE_UNUSED_ARG (sysex);
+ TAO_TRY_ENV.print_exception ("System Exception");
+ return -1;
+ }
+ TAO_CATCH (CORBA::UserException, userex)
+ {
+ ACE_UNUSED_ARG (userex);
+ TAO_TRY_ENV.print_exception ("User Exception");
+ return -1;
+ }
+ TAO_ENDTRY;
+ return 0;
+}
diff --git a/TAO/tests/Quoter/Generic_Factory.dsp b/TAO/tests/Quoter/Generic_Factory.dsp
new file mode 100644
index 00000000000..1e2619e1173
--- /dev/null
+++ b/TAO/tests/Quoter/Generic_Factory.dsp
@@ -0,0 +1,86 @@
+# Microsoft Developer Studio Project File - Name="QuoterGenericFactory" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 5.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=QuoterGenericFactory - 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 "QuoterGenericFactory.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 "QuoterGenericFactory.mak"\
+ CFG="QuoterGenericFactory - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "QuoterGenericFactory - Win32 Release" (based on\
+ "Win32 (x86) Console Application")
+!MESSAGE "QuoterGenericFactory - 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)" == "QuoterGenericFactory - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "QuoterGenericFactory - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "QuoterGe"
+# PROP BASE Intermediate_Dir "QuoterGe"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "QuoterGe"
+# PROP Intermediate_Dir "QuoterGe"
+# 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 /W3 /Gm /GX /Zi /Od /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 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
+
+!ENDIF
+
+# Begin Target
+
+# Name "QuoterGenericFactory - Win32 Release"
+# Name "QuoterGenericFactory - Win32 Debug"
+# End Target
+# End Project
diff --git a/TAO/tests/Quoter/Generic_Factory.h b/TAO/tests/Quoter/Generic_Factory.h
new file mode 100644
index 00000000000..5288344af70
--- /dev/null
+++ b/TAO/tests/Quoter/Generic_Factory.h
@@ -0,0 +1,61 @@
+// $Id$
+
+// ============================================================================
+//
+// = FILENAME
+// Generic_Factory.h
+//
+// = DESCRIPTION
+// A generic factory, customized for the use with the Quoter example.
+//
+// = AUTHOR
+// Michael Kircher (mk1@cs.wustl.edu)
+//
+// ============================================================================
+
+#include "ace/Get_Opt.h"
+#include "tao/tao.h"
+#include "Generic_Factory_Impl.h"
+
+#if !defined (GENERIC_FACTORY_H)
+#define GENERIC_FACTORY_H
+
+class Quoter_Generic_Factory_Server
+{
+ // = TILE
+ // Server object for the Quoter Generic Factory
+
+public:
+ Quoter_Generic_Factory_Server (void);
+ // Default constructor
+
+ ~Quoter_Generic_Factory_Server (void);
+ // Destructor
+
+ int init (int argc, char *argv[], CORBA::Environment& env);
+ // Initialize the Quoter_Server state - parsing arguments and ...
+
+ int run (CORBA::Environment& env);
+ // Run the orb
+
+ unsigned int parse_args ();
+ // parse the passed parameters
+
+private:
+ TAO_ORB_Manager orb_manager_;
+ // instance of the ORB Manager
+
+ Quoter_Generic_Factory_Impl *quoter_Generic_Factory_Impl_ptr_;
+ // instance of the Quoter Generic Factory
+
+ CosNaming::NamingContext_var quoterNamingContext_var_;
+ // reference to the Quoter naming context
+
+ int argc_;
+ // Number of commandline arguments.
+
+ char **argv_;
+ // commandline arguments.
+};
+
+#endif /* GENERIC_FACTORY_H */
diff --git a/TAO/tests/Quoter/Generic_Factory_Impl.cpp b/TAO/tests/Quoter/Generic_Factory_Impl.cpp
new file mode 100644
index 00000000000..c340164b61e
--- /dev/null
+++ b/TAO/tests/Quoter/Generic_Factory_Impl.cpp
@@ -0,0 +1,178 @@
+// $Id$
+
+// ============================================================================
+//
+// = FILENAME
+// Generic_Factory_Impl.cpp
+//
+// = DESCRIPTION
+// The implementation of a LifeCycle Service GenericFactory for the
+// Quoter example.
+//
+// = AUTHOR
+// Michael Kircher (mk1@cs.wustl.edu)
+//
+// ============================================================================
+
+#include "ace/Get_Opt.h"
+#include "tao/corba.h"
+#include "Generic_Factory_Impl.h"
+#include "QuoterC.h"
+
+static const char usage [] =
+"[-? |\n[-O[RBport] ORB port number]]";
+
+// Constructor
+Quoter_Generic_Factory_Impl::Quoter_Generic_Factory_Impl (void)
+{
+}
+
+// Destructor.
+Quoter_Generic_Factory_Impl::~Quoter_Generic_Factory_Impl (void)
+{
+}
+
+
+CORBA::Boolean
+Quoter_Generic_Factory_Impl::supports (const CosLifeCycle::Key & factory_key,
+ CORBA::Environment &_env_there)
+{
+ ACE_UNUSED_ARG (factory_key);
+ ACE_UNUSED_ARG (_env_there);
+ return true;
+}
+
+CORBA::Object_ptr
+Quoter_Generic_Factory_Impl::create_object (const CosLifeCycle::Key & factory_key,
+ const CosLifeCycle::Criteria & the_criteria,
+ CORBA::Environment &_env_there)
+{
+ ACE_UNUSED_ARG (the_criteria);
+
+ CORBA::Environment env_here;
+
+ // Get a reference to the ORB.
+ CORBA::ORB_ptr orb_ptr = TAO_ORB_Core_instance ()->orb ();
+
+ // Get the Naming Service object reference.
+ CORBA::Object_var namingObj_var =
+ orb_ptr->resolve_initial_references ("NameService");
+
+ if (CORBA::is_nil (namingObj_var.in ()))
+ ACE_ERROR ((LM_ERROR,
+ " (%P|%t) Unable get the Naming Service.\n"));
+
+ // Narrow the object reference to a Naming Context.
+ CosNaming::NamingContext_var namingContext_var =
+ CosNaming::NamingContext::_narrow (namingObj_var.in (),
+ env_here);
+
+ // see if there is an exception, if yes then throw the NoFactory exception
+ if (env_here.exception () != 0) // throw a NoFactory exception
+ {
+ _env_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+
+ // Get the IDL_Quoter naming context.
+ CosNaming::Name quoterContextName (1); // max = 1
+ quoterContextName.length (1);
+ quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter");
+
+ CORBA::Object_var quoterNamingObj_var =
+ namingContext_var->resolve (quoterContextName, env_here);
+
+ // see if there is an exception, if yes then throw the NoFactory exception
+ if (env_here.exception () != 0) // throw a NoFactory exception
+ {
+ _env_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+
+ CosNaming::NamingContext_var quoterNamingContext_var =
+ CosNaming::NamingContext::_narrow (quoterNamingObj_var.in (),
+ env_here);
+
+ // see if there is an exception, if yes then throw the NoFactory exception
+ if (env_here.exception () != 0) // throw a NoFactory exception
+ {
+ _env_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+
+
+ // ** now a proper reference to the quoter naming context is available
+
+
+ // fill in the name of the Quoter Factory
+ CosNaming::Name factory_Name (1); // max = 1
+ factory_Name.length (1);
+ factory_Name[0].id = CORBA::string_dup ("Quoter_Factory");
+ // or
+ // Take the key supplied to search for a Quoter Factory
+ //CosNaming::Name factoryName = (CosNaming::Name) factory_key;
+
+ // Try to get a reference to a Quoter Factory
+ CORBA::Object_var quoterFactoryObject_var =
+ quoterNamingContext_var->resolve (factory_Name, env_here);
+
+ // see if there is an exception, if yes then throw the NoFactory exception
+ if (env_here.exception () != 0) // throw a NoFactory exception
+ {
+ _env_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+
+ // were able to get a reference to Quoter Factory
+
+ // Check if it is a valid Quoter Factory reference
+ if (CORBA::is_nil (quoterFactoryObject_var.in()))
+ { // throw a NoFactory exception
+ _env_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+ else {
+
+
+ // Check if it is a valid Quoter Factory reference.
+ if (CORBA::is_nil (quoterFactoryObject_var.in ())) // throw a NoFactory exception.
+ {
+ _env_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+
+
+ Stock::Quoter_Factory_var factory_var =
+ Stock::Quoter_Factory::_narrow (quoterFactoryObject_var.in (),
+ env_here);
+
+ // see if there is an exception, if yes then throw the NoFactory exception
+ if (env_here.exception () != 0) // throw a NoFactory exception
+ {
+ _env_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+
+
+ if (CORBA::is_nil (factory_var.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,"invalid factory.\n"),
+ 0);
+
+ ACE_DEBUG ((LM_DEBUG, "Factory reference OK.\n"));
+
+ // Now retrieve the Quoter obj ref corresponding to the key.
+ Stock::Quoter_var quoter_var = factory_var->create_quoter ("test",
+ _env_there);
+
+ ACE_DEBUG ((LM_DEBUG, "Quoter Created\n"));
+
+ if (CORBA::is_nil (quoter_var))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "null quoter objref returned by factory\n"),
+ 0);
+
+ ACE_DEBUG ((LM_DEBUG,"Return a object reference to a new object.\n"));
+
+ return CORBA::Object::_duplicate (quoter_var.ptr());
+ }
+}
diff --git a/TAO/tests/Quoter/Generic_Factory_Impl.h b/TAO/tests/Quoter/Generic_Factory_Impl.h
new file mode 100644
index 00000000000..d3e1c5935a4
--- /dev/null
+++ b/TAO/tests/Quoter/Generic_Factory_Impl.h
@@ -0,0 +1,44 @@
+// $Id$
+
+// ============================================================================
+//
+// = FILENAME
+// Generic_Factory_Impl.h
+//
+// = DESCRIPTION
+// A LifeCycle Service Generic Factory for the Quoter example.
+//
+// = AUTHOR
+// Michael Kircher (mk1@cs.wustl.edu)
+//
+// ============================================================================
+
+#include "quoterS.h"
+
+#if !defined (QUOTER_GENERIC_FACTORY_IMPL_H)
+#define QUOTER_GENERIC_FACTORY_IMPL_H
+
+class Quoter_Generic_Factory_Impl : public POA_Stock::Quoter_Generic_Factory
+{
+ // = TILE
+ // A CosLifeCycle conforming Generic Factory for the Quoter
+ // example. It uses the Naming Service to find a fitting factory.
+
+public:
+ Quoter_Generic_Factory_Impl (void);
+ ~Quoter_Generic_Factory_Impl (void);
+
+ CORBA::Boolean supports (const CosLifeCycle::Key & factory_key,
+ CORBA::Environment &_env_there);
+ // returns true if the Generic Factory is able to forward a request for
+ // creating an objct described by k
+
+ CORBA::Object_ptr create_object (const CosLifeCycle::Key &factory_key,
+ const CosLifeCycle::Criteria & the_criteria,
+ CORBA::Environment &_env_there);
+ // Returns an object reference to a newly created object, though the
+ // Generic Factory itself cannot create objects, it will forward the request to
+ // a more concrete Factory.
+};
+
+#endif /* QUOTER_GENERIC_FACTORY_IMPL_H */
diff --git a/TAO/tests/Quoter/Quoter.dsw b/TAO/tests/Quoter/Quoter.dsw
index 5ba50df4466..03e09302383 100644
--- a/TAO/tests/Quoter/Quoter.dsw
+++ b/TAO/tests/Quoter/Quoter.dsw
@@ -3,7 +3,7 @@ Microsoft Developer Studio Workspace File, Format Version 5.00
###############################################################################
-Project: "Quoter Factory Finder"=.\Factory_Finder.dsp - Package Owner=<4>
+Project: "Quoter Client"=.\client.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -15,7 +15,7 @@ Package=<4>
###############################################################################
-Project: "Quoter Client"=.\client.dsp - Package Owner=<4>
+Project: "Quoter Factory Finder"=.\Factory_Finder.dsp - Package Owner=<4>
Package=<5>
{{{
@@ -39,6 +39,18 @@ Package=<4>
###############################################################################
+Project: "QuoterGenericFactory"=.\Generic_Factory.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
Global:
Package=<5>
diff --git a/TAO/tests/Quoter/Quoter.idl b/TAO/tests/Quoter/Quoter.idl
index b68f5bc4b02..7f43ad18e4e 100644
--- a/TAO/tests/Quoter/Quoter.idl
+++ b/TAO/tests/Quoter/Quoter.idl
@@ -32,10 +32,8 @@ module Stock
long get_quote (in string stock_name)
raises (Invalid_Stock, Invalid_Quoter);
- // Returns the current stock value or throws and exception.
- void destroy ();
- // Destroy a Quoter session and release resources.
+ // Returns the current stock value or throws and exception.
// LifeCycleObject copy(in FactoryFinder there,
// in Criteria the_criteria)
@@ -56,7 +54,7 @@ module Stock
interface Quoter_Factory
{
// = TITLE
- // Manage the lifecycle of a Quoter object.
+ // Creation of Quoter objects
Quoter create_quoter (in string name)
raises (Invalid_Quoter);
@@ -73,5 +71,17 @@ module Stock
// inherits:
// Factories find_factories(in Key factory_key) raises(NoFactory);
};
+
+ interface Quoter_Generic_Factory : CosLifeCycle::GenericFactory
+ {
+ // = TITLE
+ // Wrapper for the CosLifeCycle GenericFactory
+ //
+ // inherits:
+ // boolean supports(in Key k);
+ // Object create_object(in Key k, in Criteria the_criteria)
+ // raises (NoFactory, InvalidCriteria, CannotMeetCriteria);
+ };
+
};
diff --git a/TAO/tests/Quoter/client.exe b/TAO/tests/Quoter/client.exe
index 9c3b4ad8bda..b8c25f9882d 100755
--- a/TAO/tests/Quoter/client.exe
+++ b/TAO/tests/Quoter/client.exe
Binary files differ
diff --git a/TAO/tests/Quoter/server.exe b/TAO/tests/Quoter/server.exe
index 918b5dd055a..dcd5d206668 100755
--- a/TAO/tests/Quoter/server.exe
+++ b/TAO/tests/Quoter/server.exe
Binary files differ