TAO_Stub * TAO_DynamicImplementation::_create_stub (void) { // If DynamicImplementation::_this() is invoked outside of the // context of a request invocation on a target object being served // by the DSI servant, it raises the PortableServer::WrongPolicy // exception. See the CORBA C++ mapping, section 1.38.3. TAO::Portable_Server::POA_Current_Impl *poa_current_impl = static_cast <TAO::Portable_Server::POA_Current_Impl *> (TAO_TSS_Resources::instance ()->poa_current_impl_); if (poa_current_impl == 0 || this != poa_current_impl->servant ()) { throw PortableServer::POA::WrongPolicy (); } PortableServer::POA_var poa = poa_current_impl->get_POA (); CORBA::PolicyList_var client_exposed_policies = poa_current_impl->poa ()->client_exposed_policies ( poa_current_impl->priority ()); CORBA::RepositoryId_var pinterface = this->_primary_interface (poa_current_impl->object_id (), poa.in ()); return poa_current_impl->poa ()->key_to_stub (poa_current_impl->object_key (), pinterface.in (), poa_current_impl->priority ()); }
// Shutdown. void AccountManager_i::close (Bank::Account_ptr account) { try { CORBA::String_var name = account->name (); ACE_DEBUG((LM_DEBUG, ACE_TEXT ("[SERVER] Process/Thread Id : (%P/%t) Closing Account for %C\n"), name.in ())); Account_i_var account; if (hash_map_.unbind (name.in (), account) == -1) { if (TAO_debug_level > 0) ACE_DEBUG((LM_DEBUG, ACE_TEXT ("Unable to close account\n"))); } if (!account.is_nil ()) { PortableServer::POA_var poa = account->_default_POA (); PortableServer::ObjectId_var id = poa->servant_to_id (account.in ()); poa->deactivate_object (id.in ()); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Unable to close Account\n"); } }
TAO_BEGIN_VERSIONED_NAMESPACE_DECL PortableServer::POA_var create_persistent_poa(PortableServer::POA_var root_poa, PortableServer::POAManager_var mgr, const char* name, CORBA::PolicyList& policy_list) { PortableServer::POA_var result; PortableServer::LifespanPolicy_var lifespan = root_poa->create_lifespan_policy(PortableServer::PERSISTENT); // create a USER_ID IdAssignmentPolicy object PortableServer::IdAssignmentPolicy_var assign = root_poa->create_id_assignment_policy(PortableServer::USER_ID); // create PolicyList. size_t orig_len = policy_list.length(); policy_list.length(orig_len+2); policy_list[orig_len+0]= PortableServer::LifespanPolicy::_duplicate(lifespan.in()); policy_list[orig_len+1]= PortableServer::IdAssignmentPolicy::_duplicate(assign.in()); // create the child POA result = root_poa->create_POA(name, mgr.in(), policy_list); return result; }
TAO_Trader<TRADER_LOCK_TYPE, MAP_LOCK_TYPE>::~TAO_Trader (void) { // Remove Trading Components from POA for (int i = LOOKUP_IF; i <= LINK_IF; i++) { if (this->ifs_[i] != 0) { try { PortableServer::POA_var poa = this->ifs_[i]->_default_POA (); PortableServer::ObjectId_var id = poa->servant_to_id (this->ifs_[i]); poa->deactivate_object (id.in ()); } catch (const CORBA::Exception&) { // Don't let exceptions propagate out of this call since // it's the destructor! } } } }
int main(int argc, char* argv[]) { CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, ""); CORBA::Object_var poa_obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_obj); PortableServer::POAManager_var poa_manager = poa->the_POAManager(); return_allprimitives_impl return_allprimitives(orb); PortableServer::ObjectId_var oid = poa->activate_object (&return_allprimitives); CORBA::Object_var ref = poa->id_to_reference (oid.in()); CORBA::String_var str = orb->object_to_string (ref.in()); if(argc > 1) { std::ofstream ofs(argv[1]); ofs << str.in() << std::endl; } else std::cout << str.in() << std::endl; std::cout << "Running" << std::endl; poa_manager->activate(); orb->run(); assert(return_allprimitives.foo7_ && return_allprimitives.foo6_ && return_allprimitives.foo5_ && return_allprimitives.foo4_ && return_allprimitives.foo3_ && return_allprimitives.foo2_ && return_allprimitives.foo1_); }
int TAO_IFR_Server::init_with_orb (int argc, ACE_TCHAR *argv [], CORBA::ORB_ptr orb, int use_multicast_server) { try { // Get the POA from the ORB. CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); if (CORBA::is_nil (poa_object.in ())) { ORBSVCS_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) IFR_Service::init_with_orb ") ACE_TEXT ("Unable to initialize the POA.\n")), -1); } PortableServer::POA_var rp = PortableServer::POA::_narrow (poa_object.in ()); return this->init_with_poa (argc, argv, orb, rp.in(), use_multicast_server); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("IFR_Service::init_with_orb"); throw; } return 0; }
int Consumer_Handler::init (int argc, ACE_TCHAR *argv[], ShutdownCallback *_shutdowncallback) { const char *filtering_criteria = ""; // First see if we have any environment variables. filtering_criteria = ACE_OS::getenv ("FILTERING_CRITERIA"); // Then override these variables with command-line arguments if // necessary. filtering_criteria = argc > 1 ? ACE_TEXT_ALWAYS_CHAR(argv[1]) : ""; try { // Retrieve the ORB. this->orb_ = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = this->orb_->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // Save the Shutdown callback. this->shutdowncallback = _shutdowncallback; // Set the ShutdownCallback callback object // in the Consumer object implementation. this->receiver_i_.set (_shutdowncallback); // Start the servant. this->receiver_ = this->receiver_i_._this (); if (this->get_notifier () == -1) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to get the notifier " "the TAO_Naming_Client.\n"), -1); // Subscribe ourselves with the notifier's broker. this->notifier_->subscribe (this->receiver_.in (), filtering_criteria); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Consumer_Handler::init\n"); return -1; } return 0; }
void TAO_ECG_UDP_Sender::new_connect (const RtecEventChannelAdmin::ConsumerQOS& sub) { // Activate with poa. RtecEventComm::PushConsumer_var consumer_ref; PortableServer::POA_var poa = this->_default_POA (); TAO_EC_Object_Deactivator deactivator; activate (consumer_ref, poa.in (), this, deactivator); // Connect as a consumer to the local EC. RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = this->lcl_ec_->for_consumers (); RtecEventChannelAdmin::ProxyPushSupplier_var proxy = consumer_admin->obtain_push_supplier (); ECG_Sender_Auto_Proxy_Disconnect new_proxy_disconnect (proxy.in ()); proxy->connect_push_consumer (consumer_ref.in (), sub); // Update resource managers. this->supplier_proxy_ = proxy._retn (); this->auto_proxy_disconnect_.set_command (new_proxy_disconnect); this->set_deactivator (deactivator); }
void StructuredPushSupplier::disconnect() { DBG(cout << "Disconnecting StructuredPushSupplier." << endl); Guard guard(connectedMutex_); if (connected_) { proxyConsumer_->disconnect_structured_push_consumer(); supplierAdmin_->destroy(); // Get reference to Root POA. PortableServer::POA_var poa = _default_POA(); // Deactivate. PortableServer::ObjectId_var oid = poa->reference_to_id (objref_); CORBA::release(objref_); // deactivate from the poa. poa->deactivate_object (oid.in ()); connected_ = false; } }
PortableServer::POA_ptr ServerApp::create_poa(CORBA::ORB_ptr orb, const char* poa_name) { // Get the Root POA. PortableServer::POA_var root_poa = RefHelper<PortableServer::POA>::resolve_initial_ref(orb, "RootPOA"); // Get the POAManager from the Root POA. PortableServer::POAManager_var poa_manager = root_poa->the_POAManager(); // Create the child POA Policies. CORBA::PolicyList policies(0); policies.length(0); // Create the child POA PortableServer::POA_var poa = AppHelper::create_poa(poa_name, root_poa.in(), poa_manager.in(), policies); // Give away the child POA_ptr from the POA_var variable. return poa._retn(); }
void Test_Supplier::disconnect (void) { if (CORBA::is_nil (this->consumer_proxy_.in ())) return; try { this->consumer_proxy_->disconnect_push_consumer (); } catch (const CORBA::Exception&) { // The consumer may be gone already, so we // will ignore this exception } this->consumer_proxy_ = RtecEventChannelAdmin::ProxyPushConsumer::_nil (); // Deactivate the servant PortableServer::POA_var poa = this->supplier_._default_POA (); PortableServer::ObjectId_var id = poa->servant_to_id (&this->supplier_); poa->deactivate_object (id.in ()); }
void TAO_Hash_Naming_Context::destroy (void) { // Check to make sure this object didn't have <destroy> method // invoked on it. if (this->destroyed_) throw CORBA::OBJECT_NOT_EXIST (); if (this->context_->current_size () != 0) throw CosNaming::NamingContext::NotEmpty(); // Destroy is a no-op on a root context. if (root ()) return; else { this->destroyed_ = 2; // Remove self from POA. Because of reference counting, the POA // will automatically delete the servant when all pending requests // on this servant are complete. PortableServer::POA_var poa = this->_default_POA (); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId (poa_id_.fast_rep ()); poa->deactivate_object (id.in ()); } }
void ImR_DSI_Forwarder::invoke (CORBA::ServerRequest_ptr request, TAO_AMH_DSI_Response_Handler_ptr resp) { bool is_oneway = !(request->_tao_server_request().response_expected() || request->_tao_server_request().sync_with_server()); if (is_oneway) { return; // nothing else to do, the client isn't waiting so no forwarding // will happen. } PortableServer::POA_var poa = this->poa_current_var_->get_POA(); PortableServer::ObjectId_var oid = this->poa_current_var_->get_object_id (); CORBA::String_var server_name = poa->the_name(); CORBA::String_var key_str; // Unlike POA Current, this implementation cannot be cached. TAO::Portable_Server::POA_Current* tao_current = dynamic_cast <TAO::Portable_Server::POA_Current*> (this->poa_current_var_.in ()); ACE_ASSERT(tao_current != 0); TAO::Portable_Server::POA_Current_Impl* impl = tao_current->implementation (); TAO::ObjectKey::encode_sequence_to_string (key_str.out (), impl->object_key ()); ImR_DSI_ResponseHandler * rh = 0; ACE_NEW (rh, ImR_DSI_ResponseHandler(key_str.in(), this->locator_.debug() > 0 ? server_name.in() : "", this->orb_, resp)); this->locator_.activate_server_by_name (server_name.in(), false, rh); }
int main(int argc, char *argv[]) { cout << "Creating and initializing the ORB..." << endl; CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4"); CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); poa->the_POAManager()->activate(); EnvImpl* envImpl = new EnvImpl(); poa->activate_object(envImpl); // Obtain a reference to the object, and register it in the naming service. obj = envImpl->_this(); cout << orb->object_to_string(obj) << endl; cout << "Binding server implementations to registry..." << endl; bindObjectToName(orb, "Env", obj); envImpl->_remove_ref(); cout << "Waiting for invocations from clients..." << endl; orb->run(); return 0; }
void StructuredPushConsumer::disconnect() { Guard guard(connectedMutex_); if (connected_ == 1) { MIRO_DBG(MIRO, LL_NOTICE, "Disconnecting StructuredPushConsumer.\n"); connected_ = -1; try { proxySupplier_->disconnect_structured_push_supplier(); // Get reference to Root POA. PortableServer::POA_var poa = _default_POA(); // Deactivate. PortableServer::ObjectId_var oid = poa->reference_to_id(objref_); CORBA::release(objref_); // deactivate from the poa. poa->deactivate_object(oid.in()); } catch (const CORBA::Exception & e) { MIRO_LOG_OSTR(LL_ERROR, "StructuredPushConsumer::disconnect() CORBA exception on: " << std::endl << e << std::endl); } } }
PortableServer::POA_ptr createPOA (PortableServer::POA_ptr root_poa, bool share_mgr, const char* poa_name) { PortableServer::LifespanPolicy_var life = root_poa->create_lifespan_policy(PortableServer::PERSISTENT); PortableServer::IdAssignmentPolicy_var assign = root_poa->create_id_assignment_policy(PortableServer::USER_ID); CORBA::PolicyList pols; pols.length(2); pols[0] = PortableServer::LifespanPolicy::_duplicate(life.in()); pols[1] = PortableServer::IdAssignmentPolicy::_duplicate(assign.in()); PortableServer::POAManager_var mgr = PortableServer::POAManager::_nil(); if (share_mgr) { mgr = root_poa->the_POAManager(); } PortableServer::POA_var poa = root_poa->create_POA(poa_name, mgr.in(), pols); life->destroy(); assign->destroy(); return poa._retn(); }
void Session_Control::session_finished (CORBA::Boolean success) { ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); if (this->session_count_ == 0) { ACE_ERROR ((LM_ERROR, "ERROR: (%P|%t) Session_Control::session_finished, " "unexpected callback\n")); } if (success == 0) this->success_ = 0; this->session_count_--; ACE_DEBUG ((LM_DEBUG, "(%P|%t) Session_Control::session_finished, " "%d sessions to go\n", this->session_count_)); if (session_count_ == 0) { PortableServer::POA_var poa = this->_default_POA (); PortableServer::ObjectId_var oid = poa->servant_to_id (this); poa->deactivate_object (oid.in ()); } }
void PortSupplier_impl::deactivatePort (PortBase* servant) { LOG_TRACE(PortSupplier_impl, "Deactivating port '" << servant->getName() << "'"); PortableServer::POA_var poa = servant->_default_POA(); PortableServer::ObjectId_var oid = poa->servant_to_id(servant); poa->deactivate_object(oid); }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in()); PortableServer::POAManager_var man = poa->the_POAManager(); man->activate(); simple_i simp; PortableServer::ObjectId_var objId = poa->activate_object(&simp); orb->run(); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception in main():"); return 1; } return 0; }
void AccessCorbaDef_Impl::activateServantWithName( const std::string& objectName ) { bool deactivated = true; try { // Get the POA we want PortableServer::POA_var poa = this->_default_POA(); // Activate the object PortableServer::ObjectId_var oid = poa->activate_object(this); // The servant is activated deactivated = false; } catch ( const PortableServer::POA::ServantAlreadyActive& ) { // The servant has already been implicitly activated deactivated = false; } catch ( ... ) { printf("ffff\n"); } // register the name //registerNamedObject( objectName ); { // Get a reference to the poa PortableServer::POA_var poa = this->_default_POA(); // Store the object in the TDNS, using the poa to get the object ref // Naming::registerName( poa->servant_to_reference( this ), m_objectName ); setServantKey(this, objectName); } }
void TAO_Notify_Tests_Peer_T<Peer_Traits>::connect (void) { // Get the POA PortableServer::POA_var poa; LOOKUP_MANAGER->resolve (poa, this->poa_name_.c_str ()); // set the POA this->set_poa (poa.in ()); // Resolve the admin typename Admin_Traits::VAR admin_var; LOOKUP_MANAGER->resolve (admin_var, this->admin_name_.c_str ()); typename Admin_Ext_Traits::VAR admin_ext_var = Admin_Ext_Traits_INTERFACE::_narrow (admin_var.in ()); typename Proxy_Traits::VAR proxy_var = this->obtain_proxy (admin_ext_var.in (), this->qos_); ACE_ASSERT (!CORBA::is_nil (proxy_var.in ())); // connect supplier to proxy, // also activates the servant as CORBA object in the POA specified. this->connect (proxy_var.in (), this->proxy_id_); }
void AccessCorbaDef_Impl::setServantKey(PortableServer::ServantBase* theServant, const std::string& key) { try { // Resolve the omnibootstrapping POA and activate it CORBA::Object_var obj = getOrb().resolve_initial_references("omniINSPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var mgr = poa->the_POAManager(); mgr->activate(); // Activate the servant with the bootstrapping POA PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId(key.c_str()); poa->activate_object_with_id(oid, theServant); // Add the bootstrapping POA to the list of POAs the // servant is activated with. //theServant->addPOA(poa); } catch(...)//(const CORBA::SystemException& ex) { printf("SystemException\n"); throw 222; } }
AccessCorbaDef_Impl::~AccessCorbaDef_Impl() { //deactivateServant(); try { // Get the default POA PortableServer::POA_var poa = this->_default_POA(); // Get the object ID PortableServer::ObjectId_var id = poa->servant_to_id(this); // Deactivate the object poa->deactivate_object( id.in() ); ///////////////////////////// m_orbVar->shutdown( CORBA::Boolean(true) ); // Clean up the orb entirely m_orbVar->destroy(); m_orbVar = CORBA::ORB::_nil(); /////////////////////////// } catch ( const PortableServer::POA::ObjectNotActive& ) { // The servant has already been implicitly de-activated // Or never activated } catch ( ... ) { printf("xxx\n"); } }
void Heartbeat_Application::connect_as_consumer (void) { // Activate with poa. RtecEventComm::PushConsumer_var consumer_ref; PortableServer::POA_var poa = this->_default_POA (); TAO_EC_Object_Deactivator deactivator; activate (consumer_ref, poa.in (), this, deactivator); // Obtain reference to ConsumerAdmin. RtecEventChannelAdmin::ConsumerAdmin_var consumer_admin = this->ec_->for_consumers (); // Obtain ProxyPushSupplier.. RtecEventChannelAdmin::ProxyPushSupplier_var proxy = consumer_admin->obtain_push_supplier (); Supplier_Proxy_Disconnect new_proxy_disconnect (proxy.in ()); // Connect this consumer. ACE_ConsumerQOS_Factory qos; qos.start_disjunction_group (1); qos.insert_type (ACE_ES_EVENT_ANY, 0); proxy->connect_push_consumer (consumer_ref.in (), qos.get_ConsumerQOS ()); // Update resource managers. this->supplier_proxy_disconnect_.set_command (new_proxy_disconnect); this->set_deactivator (deactivator); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); try { CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); TAO_AV_CORE::instance ()->init (orb.in (), poa.in ()); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("server::init"); return -1; } int result = 0; result = FTP_SERVER::instance ()->init (argc, argv); if (result < 0) ACE_ERROR_RETURN ((LM_ERROR,"FTP_SERVER::init failed\n"),1); result = FTP_SERVER::instance ()->run (); if (result < 0) ACE_ERROR_RETURN ((LM_ERROR,"FTP_SERVER::run failed\n"),1); FTP_SERVER::close (); // Explicitly finalize the Unmanaged_Singleton. return result; }
CORBA::Boolean ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent, const char *name) { ACE_ASSERT (! CORBA::is_nil(parent)); ACE_ASSERT (name != 0); CORBA::PolicyList policies (3); const char *exception_message = "Null Message"; policies.length (3); try { // Servant Retention Policy exception_message = "While PortableServer::POA::create_servant_retention_policy"; policies[0] = parent->create_servant_retention_policy (PortableServer::NON_RETAIN); // Request Processing Policy exception_message = "While PortableServer::POA::create_request_processing_policy"; policies[1] = parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT); policies[2] = parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID); PortableServer::POAManager_var poa_manager = parent->the_POAManager (); exception_message = "While create_POA"; PortableServer::POA_var child = parent->create_POA (name, poa_manager.in (), policies); exception_message = "While policy->destroy"; for (CORBA::ULong i = 0; i < policies.length (); ++i) { CORBA::Policy_ptr policy = policies[i]; policy->destroy (); } exception_message = "While child->the_activator"; child->the_activator (this); exception_message = "While set_servant"; child->set_servant (this->default_servant_); } catch (const CORBA::Exception& ex) { ORBSVCS_ERROR ((LM_ERROR, "IMR_Adapter_Activator::unknown_adapter - %s\n", exception_message)); ex._tao_print_exception ("System Exception"); return 0; } // Finally, now everything is fine return 1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize orb CORBA::ORB_var orb = CORBA::ORB_init( argc, argv ); //Get reference to Root POA CORBA::Object_var obj = orb->resolve_initial_references( "RootPOA" ); PortableServer::POA_var poa = PortableServer::POA::_narrow( obj.in() ); // Activate POA Manager PortableServer::POAManager_var mgr = poa->the_POAManager(); mgr->activate(); // Find the Naming Service obj = orb->resolve_initial_references("NameService"); CosNaming::NamingContext_var root = CosNaming::NamingContext::_narrow(obj.in()); if (CORBA::is_nil(root.in())) { std::cerr << "Nil Naming Context reference" << std::endl; return 1; } // Bind the example Naming Context, if necessary CosNaming::Name name; name.length( 1 ); name[0].id = CORBA::string_dup("example"); try { obj = root->resolve(name); } catch(const CosNaming::NamingContext::NotFound&) { CosNaming::NamingContext_var dummy = root->bind_new_context(name); } // Bind the Messenger object name.length(2); name[1].id = CORBA::string_dup("Messenger"); // Create an object PortableServer::Servant_var<Messenger_i> servant = new Messenger_i; PortableServer::ObjectId_var oid = poa->activate_object(servant.in()); obj = poa->id_to_reference(oid.in()); Messenger_var messenger = Messenger::_narrow(obj.in()); root->rebind(name, messenger.in()); std::cout << "Messenger object bound in Naming Service" << std::endl; // Accept requests orb->run(); orb->destroy(); } catch(const CORBA::Exception& ex) { std::cerr << "server: Caught a CORBA::Exception: " << ex << std::endl; return 1; } return 0; }
OnlineViewerServer::~OnlineViewerServer() { delete impl; PortableServer::POA_var poa = _default_POA(); PortableServer::ObjectId_var id = poa->servant_to_id(this); poa->deactivate_object(id); }
CORBA::Object_ptr TIDorb::core::poa::CurrentImpl::get_reference() throw (PortableServer::Current::NoContext) { PortableServer::POA_var poa = get_POA(); PortableServer::ObjectId_var oid = get_object_id(); return poa->create_reference_with_id(oid, (const ::CORBA::RepositoryId) "IDL:omg.org/CORBA/Object:1.0"); }
OpenHRPOnlineViewerItemImpl::~OpenHRPOnlineViewerItemImpl() { PortableServer::POA_var poa = _default_POA(); PortableServer::ObjectId_var id = poa->servant_to_id(this); poa->deactivate_object(id); worldItemConnections.disconnect(); }