summaryrefslogtreecommitdiff
path: root/TAO/examples/Quoter/Generic_Factory_i.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/examples/Quoter/Generic_Factory_i.cpp')
-rw-r--r--TAO/examples/Quoter/Generic_Factory_i.cpp230
1 files changed, 128 insertions, 102 deletions
diff --git a/TAO/examples/Quoter/Generic_Factory_i.cpp b/TAO/examples/Quoter/Generic_Factory_i.cpp
index d55c44252ab..4a61e7a23cc 100644
--- a/TAO/examples/Quoter/Generic_Factory_i.cpp
+++ b/TAO/examples/Quoter/Generic_Factory_i.cpp
@@ -6,7 +6,7 @@
// Generic_Factory_i.cpp
//
// = DESCRIPTION
-// The implementation of a LifeCycle Service GenericFactory for the
+// The implementation of a LifeCycle Service GenericFactory for the
// Quoter example.
//
// = AUTHOR
@@ -30,7 +30,7 @@ Quoter_Generic_Factory_i::~Quoter_Generic_Factory_i (void)
{
}
-CORBA::Boolean
+CORBA::Boolean
Quoter_Generic_Factory_i::supports (const CosLifeCycle::Key &,
CORBA::Environment &)
ACE_THROW_SPEC ((CORBA::SystemException))
@@ -42,131 +42,157 @@ Quoter_Generic_Factory_i::supports (const CosLifeCycle::Key &,
CosNaming::NamingContext_ptr
Quoter_Generic_Factory_i::get_naming_context (const CosLifeCycle::Key &factory_key,
- CORBA::Environment &ACE_TRY_ENV)
+ CORBA::Environment &env_here,
+ CORBA::Environment &TAO_IN_ENV_there)
{
- CosNaming::NamingContext_var quoterNamingContext_var;
- ACE_TRY
- {
- // @@ FIXME 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", ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- 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 (),
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- CosNaming::Name quoterContextName (1); // max = 1
- quoterContextName.length (1);
- quoterContextName[0].id = CORBA::string_dup ("IDL_Quoter");
-
- // Get the IDL_Quoter naming context.
- CORBA::Object_var quoterNamingObj_var =
- namingContext_var->resolve (quoterContextName, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- quoterNamingContext_var =
- CosNaming::NamingContext::_narrow (quoterNamingObj_var.in (),
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ // 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
+ {
+ TAO_IN_ENV_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
}
- ACE_CATCHANY
- {
- ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key),
- CosNaming::NamingContext::_nil ());
+
+ // 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
+ {
+ TAO_IN_ENV_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
}
- ACE_ENDTRY;
- return quoterNamingContext_var._retn ();
-}
+ 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
+ {
+ TAO_IN_ENV_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
+
+
+ return CosNaming::NamingContext::_duplicate (quoterNamingContext_var.in ());
+}
+
CORBA::Object_ptr
-Quoter_Generic_Factory_i::create_object (const CosLifeCycle::Key &factory_key,
+Quoter_Generic_Factory_i::create_object (const CosLifeCycle::Key &factory_key,
const CosLifeCycle::Criteria &,
- CORBA::Environment &ACE_TRY_ENV)
+ CORBA::Environment &TAO_IN_ENV_there)
ACE_THROW_SPEC ((CORBA::SystemException,
CosLifeCycle::NoFactory,
CosLifeCycle::InvalidCriteria,
CosLifeCycle::CannotMeetCriteria))
{
- Stock::Quoter_var quoter_var;
- ACE_TRY
- {
- CosNaming::NamingContext_var quoterNamingContext_var =
- this->get_naming_context (factory_key,
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- // ** now a proper reference to the quoter naming context is
- // available
-
- // Fill in the name of the Quoter Factory.
- // Take the key supplied to search for a Quoter Factory
- CosNaming::Name factory_Name = (CosNaming::Name) factory_key;
-
- // Try to get a reference to a Quoter Factory
- CORBA::Object_var quoterFactoryObject_var =
- quoterNamingContext_var->resolve (factory_Name, ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
- // We 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
- ACE_TRY_THROW (CosLifeCycle::NoFactory (factory_key));
- }
+ CORBA::Environment env_here;
+
+ CosNaming::NamingContext_var quoterNamingContext_var =
+ this->get_naming_context (factory_key,
+ env_here,
+ TAO_IN_ENV_there);
+
+ // ** now a proper reference to the quoter naming context is
+ // available
+
+ // Fill in the name of the Quoter Factory.
+ // Take the key supplied to search for a Quoter Factory
+ CosNaming::Name factory_Name = (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
+ {
+ TAO_IN_ENV_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
+ }
- Stock::Quoter_Factory_var factory_var =
- Stock::Quoter_Factory::_narrow (quoterFactoryObject_var.in (),
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
+ // We were able to get a reference to Quoter Factory.
- if (CORBA::is_nil (factory_var.in ()))
- {
- ACE_ERROR ((LM_ERROR,
- "invalid factory.\n"));
- return CORBA::Object::_nil ();
+ // Check if it is a valid Quoter Factory reference
+ if (CORBA::is_nil (quoterFactoryObject_var.in()))
+ { // throw a NoFactory exception
+ TAO_IN_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.
+ {
+ TAO_IN_ENV_there.exception (new CosLifeCycle::NoFactory (factory_key));
+ return 0;
}
- ACE_DEBUG ((LM_DEBUG,
- "Factory reference OK.\n"));
+ 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
+ {
+ TAO_IN_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.
- quoter_var =
+ Stock::Quoter_var quoter_var =
factory_var->create_quoter ("test",
- ACE_TRY_ENV);
- ACE_TRY_CHECK;
-
+ TAO_IN_ENV_there);
ACE_DEBUG ((LM_DEBUG,
"Quoter Created\n"));
-
+
if (CORBA::is_nil (quoter_var.in ()))
- {
- ACE_ERROR ((LM_ERROR,
- "null quoter objref returned by factory\n"));
- return CORBA::Object::_nil ();
- }
+ 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"));
+ CORBA::Object_ptr object_ptr =
+ CORBA::Object::_duplicate ((CORBA::Object_ptr) quoter_var.ptr ());
+
+ return object_ptr;
}
- ACE_CATCHANY
- {
- ACE_THROW_RETURN (CosLifeCycle::NoFactory (factory_key),
- CORBA::Object::_nil ());
- }
- ACE_ENDTRY;
- return quoter_var._retn ();
-}
+}