Exemplo n.º 1
0
    bool
    unbind_object (const char *name,
                   CosNaming::NamingContext_ptr ctx)
    {
      CIAO_TRACE ("Name_Utilities::unbind_object");

      if (CORBA::is_nil (ctx))
        {
          CIAO_ERROR (1, (LM_WARNING, CLINFO
                          "Name_Utilities::unbind_object - "
                          "Provided naming context is nil, instance <%C> will not be unbound\n",
                          name));
          return false;
        }

      CosNaming::Name nm;
      Name_Utilities::build_name (name, nm);

      try
        {
          ctx->unbind (nm);
        }
      catch (CORBA::Exception &e)
        {
          CIAO_ERROR (1, (LM_ERROR, CLINFO
                          "Name_Utilities::unbind_object - "
                          "Caught CORBA exception whilst unbinding name <%C>: <%C>\n",
                          name, e._info ().c_str ()));
          return false;
        }
      return true;
    }
Exemplo n.º 2
0
  ::CORBA::Object_ptr
  Session_Context_Impl_T<BASE_CTX, COMP>::get_CCM_object (void)
  {
    ::CORBA::Object_var obj;

    try
      {
        ::CIAO::Session_Container_var cnt_safe =
          ::CIAO::Session_Container::_duplicate (this->container_.in ());
        if (::CORBA::is_nil (cnt_safe.in ()))
          {
            CIAO_ERROR (1,
                        (LM_ERROR,
                        CLINFO
                        "Session_Context_Impl_T::get_CCM_object - "
                        "Error: Container is nil\n"));
            throw ::CORBA::INV_OBJREF ();
          }
        obj = cnt_safe->get_objref (this->servant_);
      }
    catch (const CORBA::Exception& ex)
      {
        ex._tao_print_exception ("Caught Exception\n");
      }

    typename COMP::_var_type component = COMP::_narrow (obj.in ());

    if (::CORBA::is_nil (component.in ()))
      {
        throw ::CORBA::INTERNAL ();
      }

    return component._retn ();
  }
Exemplo n.º 3
0
typename COMP_SVNT::_stub_ptr_type
Home_Servant_Impl<BASE_SKEL,
                  EXEC,
                  COMP_SVNT,
                  CONTAINER>::create (void)
{
    CIAO_TRACE ("Home_Servant_Impl<>::create");

    if (::CORBA::is_nil (this->executor_.in ()))
    {
        CIAO_ERROR (1, (LM_ERROR, CLINFO
                        "Home_Servant_Impl<>:create - "
                        "nil executor reference\n"));
        throw CORBA::INTERNAL ();
    }

    typename EXEC::_var_type exec_safe =
        EXEC::_duplicate (this->executor_.in());

    ::Components::EnterpriseComponent_var _ciao_ec = exec_safe->create ();

    typedef typename COMP_SVNT::_exec_type exec_type;
    typename COMP_SVNT::_exec_type::_var_type _ciao_comp =
        exec_type::_narrow (_ciao_ec.in ());

    return this->_ciao_activate_component (_ciao_comp.in ());
}
Exemplo n.º 4
0
void
Servant_Impl_Base::add_consumer (const char *port_name,
                                 ::Components::EventConsumerBase_ptr port_ref)
{
    CIAO_TRACE("Servant_Impl_Base::add_consumer");

    if (0 == port_name || ::CORBA::is_nil (port_ref))
    {
        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Servant_Impl_Base::add_consumer - Bad port name [%C] or bad objref\n",
                     port_name));

        throw ::CORBA::BAD_PARAM ();
    }

    {
        ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                            mon,
                            this->lock_,
                            CORBA::NO_RESOURCES ());

        this->consumer_table_[port_name] = ::Components::EventConsumerBase::_duplicate (port_ref);
    }
}
Exemplo n.º 5
0
  void
  Container_Handler_i::configure (const ::Deployment::Properties &props)
  {
    CIAO_DEBUG (6, (LM_DEBUG, CLINFO
                    "Container_Handler_i::configure - "
                    "Received %u properties for configuration\n",
                    props.length ()));

    this->orb_ = DAnCE::PLUGIN_MANAGER::instance ()->get_orb ();

    if (CORBA::is_nil (this->orb_))
      {
        CIAO_ERROR (1, (LM_ERROR, CLINFO
                        "Container_Handler_i::configure - "
                        "Unable to locate ORB.\n"));
        throw ::Deployment::StartError ("CIAO Container Handler ",
                                        "Unable to locate ORB");
      }

    CORBA::Object_var object =
      this->orb_->resolve_initial_references ("RootPOA");

    this->poa_ =
      PortableServer::POA::_narrow (object.in ());

    if (CORBA::is_nil (this->poa_))
      {
        CIAO_ERROR (1, (LM_ERROR, CLINFO
                        "Container_Handler_i::configure - "
                        "Unable to locate POA.\n"));
        throw ::Deployment::StartError ("CIAO Container Handler ",
                                        "Unable to locate POA");
      }

    CIAO::Server_init (this->orb_);

    // For the time being, we are going to go ahead and construct a container.
    ::Deployment::DeploymentPlan plan;
    plan.instance.length (1);
    plan.instance[0].name = "";

    ::CORBA::Any_var any;
    this->install_instance (plan, 0, any.out ());
  }
Exemplo n.º 6
0
  const char *
  Deployment_Common::get_implementation (const char *name,
                                         const ::Deployment::DeploymentPlan &plan)
  {
    if (name == 0)
      {
        throw ::Deployment::PlanError (name,
                                      "No such artifact");
      }

    for (CORBA::ULong i = 0;
         i < plan.artifact.length ();
         ++i)
      {
        if (ACE_OS::strcmp (plan.artifact[i].name.in (),
                            name) == 0)
          {
            if (plan.artifact[i].location.length () >= 1 &&
                plan.artifact[i].location[0] != 0)
              {
                return plan.artifact[i].location[0].in ();
              }
            else
              {
                CIAO_ERROR (1, (LM_ERROR, CLINFO
                                "Deployment_Common::get_implementation - "
                                "No valid location for artifact <%C>\n",
                                name));
                throw ::Deployment::PlanError (name,
                                               "No valid location field\n");
              }
          }
      }

    CIAO_ERROR (1, (LM_ERROR, CLINFO
                    "Deployment_Common::get_implementation - "
                    "Unable to locate artifact <%C>\n",
                    name));

    throw ::Deployment::PlanError (name,
                                   "Nonexistent artifact");
  }
Exemplo n.º 7
0
  void
  Container_Handler_i::disconnect_instance (const ::Deployment::DeploymentPlan &,
                                            ::CORBA::ULong)
  {
    CIAO_TRACE ("Container_Handler_i::disconnect_instance");

    CIAO_ERROR (1, (LM_ERROR, CLINFO
                    "Container_Handler_i::disconnect_instance - ",
                    "No connections allowed for containers.\n"));
    throw CORBA::NO_IMPLEMENT ();
  }
Exemplo n.º 8
0
 void
 Container_Handler_i::provide_endpoint_reference (const ::Deployment::DeploymentPlan &,
                                                  ::CORBA::ULong,
                                                  ::CORBA::Any_out)
 {
   CIAO_TRACE ("Container_Handler_i::provide_endpoint_reference");
   CIAO_ERROR (1, (LM_ERROR, CLINFO
                   "Container_Handler_i::provide_endpoint_reference - "
                   "Unable to provide any endpoints.\n"));
   throw CORBA::NO_IMPLEMENT ();
 }
Exemplo n.º 9
0
  Session_Servant_Impl_T<BASE_SKEL, EXEC, CONTEXT>::~Session_Servant_Impl_T (void)
  {
    if (this->executor_->_refcount_value () > 1)
      {
        CIAO_ERROR (1,
                    (LM_ERROR, CLINFO
                     "Session_Servant_Impl_T_T::~Session_Servant_Impl_T_T - "
                     "Executor object reference count is %u\n",
                     this->executor_->_refcount_value ()));
      }

    this->context_->_remove_ref ();
  }
Exemplo n.º 10
0
  // Operations for CCMObject interface.
  void
  Connector_Servant_Impl_Base::remove (void)
  {
    CIAO_TRACE("Connector_Servant_Impl_Base::remove (void)");

    try
    {
      Container_var cnt_safe = Container::_duplicate(this->container_.in ());
      PortableServer::POA_var port_poa = cnt_safe->the_port_POA ();

      {
        ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX,
                            mon,
                            this->lock_,
                            CORBA::NO_RESOURCES ());
        // Removing Facets
        for (FacetTable::const_iterator iter =
              this->facet_table_.begin ();
            iter != this->facet_table_.end ();
            ++iter)
          {
            PortableServer::ObjectId_var facet_id =
              port_poa->reference_to_id (iter->second);

            port_poa->deactivate_object (facet_id);
          }
      }

      this->ccm_remove ();

      PortableServer::ObjectId_var oid;
      cnt_safe->uninstall_servant (this,
                                  Container_Types::COMPONENT_t,
                                  oid.out ());

      if (this->home_servant_)
        {
          this->home_servant_->update_component_map (oid);
          this->home_servant_->_remove_ref ();
          this->home_servant_ = 0;
        }
    }
    catch (const CORBA::Exception& ex)
    {
      // log error and propagate so error gets reported to deployment framework
      CIAO_ERROR (1, (LM_ERROR, CLINFO "Connector_Servant_Impl_Base::remove - CORBA exception : %C\n", ex._info ().c_str ()));
      ex._raise (); // propagate
    }
  }
Exemplo n.º 11
0
void
Home_Servant_Impl<BASE_SKEL,
                  EXEC,
                  COMP_SVNT,
                  CONTAINER>::update_component_map (
                      PortableServer::ObjectId &oid)
{
    CIAO_TRACE ("Home_Servant_Impl<>::update_component_map");

    Components::CCMObject_var ccm_obj_ptr;
    if (objref_map_.unbind (oid, ccm_obj_ptr) != 0)
    {
        CIAO_ERROR (1, (LM_ERROR, CLINFO
                        "Home_Servant_Impl<>::update_component_map - "
                        "Invalid component object reference\n"));
    }
}
Exemplo n.º 12
0
  void
  Container_Handler_i::remove_instance (
    const ::Deployment::DeploymentPlan & plan,
    ::CORBA::ULong instanceRef,
    const ::CORBA::Any &)
  {
    CIAO_TRACE ("Container_Handler_i::remove_instance");

    const char *name = plan.instance[instanceRef].name.in ();

    ::CIAO::Container_var cont =
        DEPLOYMENT_STATE::instance ()->fetch_container (name);

    if (::CORBA::is_nil (cont.in ()))
      {
        CIAO_ERROR (1, (LM_ERROR, CLINFO
                        "Container_Handler_i::remove_instance - "
                        "Error, no container with id <%C>\n",
                        name));
        throw ::Deployment::StopError (name,
                                       "No container with ID");
      }

    CIAO_DEBUG (8, (LM_TRACE, CLINFO
                    "Container_Handler_i::remove_instance - "
                    "Finalizing container with Id <%C>\n",
                    name));

    // Instructing container to cleanup its state
    cont->fini ();

    CIAO_DEBUG (8, (LM_TRACE, CLINFO
                    "Container_Handler_i::remove_instance - "
                    "Removing container with Id <%C>\n",
                    name));

    DEPLOYMENT_STATE::instance ()->remove_container (name);

    CIAO_DEBUG (5, (LM_TRACE, CLINFO
                    "Container_Handler_i::remove_instance - "
                    "Container with Id <%C> removed.\n",
                    name));
  }
Exemplo n.º 13
0
void
Home_Servant_Impl<BASE_SKEL,
                  EXEC,
                  COMP_SVNT,
                  CONTAINER>::remove_components (void)
{
    while (this->objref_map_.current_size () > 0)
    {
        OBJ_ITERATOR const first = this->objref_map_.begin ();
        this->remove_component (((*first).int_id_).in ());
        if (this->objref_map_.unbind (first) != 0)
        {
            CIAO_ERROR (1, (LM_WARNING, CLINFO
                            "Home_Servant_Impl<>::remove_components - "
                            "Failed to unbind component\n"));
            throw Components::RemoveFailure ();
        }
    }
}
Exemplo n.º 14
0
  ::CORBA::Object_ptr
  Connector_Servant_Impl_Base::provide_facet (const char *name)
  {
    CIAO_TRACE("Connector_Servant_Impl_Base::provide_facet (const char *name)");

    if (0 == name)
      {
        CIAO_ERROR (1, (LM_ERROR, CLINFO "Connector_Servant_Impl_Base::provide_facet - Got nil name"));

        throw ::Components::InvalidName ();
      }

    CORBA::Object_var retval = this->lookup_facet (name);

    if ( ::CORBA::is_nil (retval. in()))
      {
        throw ::Components::InvalidName ();
      }

    return retval._retn ();
  }
Exemplo n.º 15
0
void
Home_Servant_Impl<BASE_SKEL,
                  EXEC,
                  COMP_SVNT,
                  CONTAINER>::remove_component (
                      ::Components::CCMObject_ptr comp)
{
    CIAO_TRACE ("Home_Servant_Impl<>::remove_component");

    typename CONTAINER::_var_type cnt_safe =
        CONTAINER::_duplicate (this->container_.in());
    PortableServer::POA_var poa = cnt_safe->the_POA ();
    PortableServer::ObjectId_var oid = poa->reference_to_id (comp);

    Components::CCMObject_var ccm_obj_var;
    if (objref_map_.find (oid.in (), ccm_obj_var) != 0)
    {
        CIAO_ERROR (1, (LM_WARNING, CLINFO
                        "Home_Servant_Impl<>::remove_component - "
                        "Invalid component object reference\n"));
        throw Components::RemoveFailure ();
    }

    typedef typename COMP_SVNT::_stub_type stub_type;
    typename COMP_SVNT::_stub_var_type _ciao_comp =
        stub_type::_narrow (ccm_obj_var.in ());

    if (::CORBA::is_nil (_ciao_comp.in ()))
    {
        throw Components::RemoveFailure ();
    }
    else
    {
        _ciao_comp->remove ();
    }

    CIAO_DEBUG (6, (LM_INFO, CLINFO
                    "Home_Servant_Impl<>::remove_component - "
                    "Removed the component\n"));
}
Exemplo n.º 16
0
    void
    bind_context (CosNaming::Name &nm,
                  CosNaming::NamingContext_ptr ctx)
    {
      CIAO_TRACE ("Name_Utilities::bind_context");

      if (CORBA::is_nil (ctx))
        {
          CIAO_ERROR (1, (LM_WARNING, CLINFO
                          "Name_Utilities::bind_context - "
                          "Provided naming context is nil, the naming context will not be bound."));
          return;
        }

      CosNaming::Name newname (nm.length ());

      for (CORBA::ULong i = 0;
           i < (nm.length () - 1); ++i)
        {
          newname.length (i + 1);
          newname[i] = nm[i];

          try
            {
              ctx->bind_new_context (newname);
              CIAO_DEBUG (9, (LM_TRACE, CLINFO
                              "Name_Utilities::bind_context - "
                              "Bound new context <%C>\n",
                              newname[i].id.in ()));
            }
          catch (CosNaming::NamingContext::AlreadyBound &)
            {
              CIAO_DEBUG (9, (LM_TRACE, CLINFO
                              "Name_Utilities::bind_context - "
                              "Context <%C> already bound.\n",
                              newname[i].id.in ()));
            }
        }
    }
Exemplo n.º 17
0
void
Servant_Impl_Base::remove (void)
{
    CIAO_TRACE("Servant_Impl_Base::remove (void)");
#if !defined (CCM_NOEVENT)

    try
    {
        Container_var cnt_safe =
            Container::_duplicate(this->container_.in ());
        PortableServer::POA_var port_poa =
            this->container_->the_port_POA ();

        for (ConsumerTable::const_iterator iter =
                    this->consumer_table_.begin ();
                iter != this->consumer_table_.end ();
                ++iter)
        {
            PortableServer::ObjectId_var cons_id =
                port_poa->reference_to_id (iter->second);

            port_poa->deactivate_object (cons_id);
        }
    }
    catch (const CORBA::Exception& ex)
    {
        // log error and propagate so error gets reported to deployment framework
        CIAO_ERROR (1, (LM_ERROR, CLINFO "Servant_Impl_Base::remove - CORBA exception : %C\n", ex._info ().c_str ()));
        ex._raise (); // propagate
    }
#endif

    /// This call deactivates facets, removes executor and home
    /// servant (if any), and uninstalls us from the container.
    /// It has its own try/catch blocks.
    this->Connector_Servant_Impl_Base::remove ();
}
Exemplo n.º 18
0
    bool
    bind_object (const char *name,
                 CORBA::Object_ptr obj,
                 CosNaming::NamingContext_ptr ctx)
    {
      CIAO_TRACE ("Name_Utilities::bind_object");

      if (CORBA::is_nil (ctx))
        {
          CIAO_ERROR (1, (LM_WARNING, CLINFO "Name_Utilities::bind_object - "
                          "Provided naming context is nil, component <%C> will not be registered.",
                          name));
          return false;
        }

      try
        {
          CosNaming::Name nm;

          Name_Utilities::build_name (name, nm);

          if (nm.length () == 0)
            {
              CIAO_ERROR (1, (LM_WARNING, CLINFO
                              "Name_Utilities::bind_object - "
                              "build_name resulted in an invalid name for string <%C>\n",
                              name));
              return false;
            }

          Name_Utilities::bind_context (nm, ctx);

          try
            {
              ctx->bind (nm, obj);
            }
          catch (const CosNaming::NamingContext::AlreadyBound &)
            {
              CIAO_ERROR (1, (LM_WARNING, CLINFO "Name_Utilities::bind_object - "
                              "Name <%C> already bound, rebinding....\n",
                              name));
              ctx->rebind (nm, obj);
            }
        }
      catch (const CORBA::Exception &ex)
        {
          CIAO_ERROR (1, (LM_ERROR, CLINFO "Name_Utilities::bind_object - "
                          "Caught CORBA exception while attempting to bind name <%C>: <%C>\n",
                          name, ex._info ().c_str ()));
          return false;
        }
      catch (...)
        {
          CIAO_ERROR (1, (LM_ERROR, CLINFO "Name_Utilities::bind_object - "
                          "Caught unknown C++ exception while attemptint to bind name <%C>\n",
                          name));
          return false;
        }

      return true;
    }
Exemplo n.º 19
0
  //@@ Apparently we need to be cautious when handling the exception
  //   thrown here. We should make sure that new DnC interfaces
  //   NodeApplication/NodeApplicationManager etc will cache the new
  //   exceptions--> rethrow of new exceptions is needed.
  //                                            --Tao
  Components::CCMHome_ptr
  Session_Container_i::install_home (const char *primary_artifact,
                                     const char *entry_point,
                                     const char *servant_artifact,
                                     const char *servant_entrypoint,
                                     const char *name,
                                     CORBA::Long open_mode)
  {
    CIAO_TRACE ("Session_Container_i::install_home");

    ACE_DLL executor_dll;
    ACE_DLL servant_dll;

    Container_i < ::CIAO::Session_Container>::prepare_installation ("Session Home",
                                                                    primary_artifact,
                                                                    entry_point,
                                                                    servant_artifact,
                                                                    servant_entrypoint,
                                                                    name,
                                                                    open_mode,
                                                                    executor_dll,
                                                                    servant_dll);

    void *void_ptr_executor = executor_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (entry_point));
    void *void_ptr_servant = servant_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (servant_entrypoint));

    ptrdiff_t tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr_executor);
    HomeFactory hcreator = reinterpret_cast<HomeFactory> (tmp_ptr);

    tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr_servant);
    HomeServantFactory screator = reinterpret_cast<HomeServantFactory> (tmp_ptr);

    if (hcreator == 0)
      {
        std::ostringstream err;
        err << "Home executor factory function [" << entry_point << "] invalid in DLL ["
            << primary_artifact;

        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_home "
                     "- Error: %C\n",
                     err.str ().c_str ()));

        throw CIAO::Installation_Failure (name,
                                          err.str ().c_str ());
      }

    if (screator == 0)
      {
        std::ostringstream err;
        err << "Home servant factory function [" << servant_entrypoint << "] invalid in DLL ["
            << servant_artifact;

        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_home "
                     "- Error: %C\n",
                     err.str ().c_str ()));

        throw CIAO::Installation_Failure (name,
                                          err.str ().c_str ());
      }

    CIAO_DEBUG (9,
                (LM_TRACE,
                 CLINFO
                 "Session_Container_i::install_home"
                 " - Loading home executor\n"));

    Components::HomeExecutorBase_var home_executor = hcreator ();

    if (CORBA::is_nil (home_executor.in ()))
      {
        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_home - "
                     "Home executor factory failed.\n"));

        throw CIAO::Installation_Failure (name,
                                          "Home executor factory function failed\n");
      }

    CIAO_DEBUG (9,
                (LM_TRACE,
                 CLINFO
                 "Session_Container_i::install_home"
                 " - Loading home servant\n"));

    PortableServer::Servant home_servant =
      screator (home_executor.in (), this, name);

    if (home_servant == 0)
      {
        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_home - "
                     "Home servant factory failed.\n"));

        throw CIAO::Installation_Failure (name,
                                          "Home servant factory function failed\n");
      }

    PortableServer::ServantBase_var safe (home_servant);

    CIAO_DEBUG (9,
                (LM_TRACE,
                 CLINFO
                 "Session_Container_i::install_home "
                 "- Installing home servant\n"));

    PortableServer::ObjectId_var oid;

    CORBA::Object_var objref =
      this->install_servant (home_servant,
                             Container_Types::HOME_t,
                             oid.out ());

    Components::CCMHome_var homeref =
      Components::CCMHome::_narrow (objref.in ());

    CIAO_DEBUG (9,
                (LM_TRACE,
                 CLINFO
                 "Session_Container_i::install_home - "
                 "Home successfully created with name\n"));

    return homeref._retn ();
  }
Exemplo n.º 20
0
int
CIAO::Logger_Service::init (int argc, ACE_TCHAR * argv[])
{
    // Get prospective values from the environment first, those given on
    // command line can override
    ACE_Env_Value<int> log (ACE_TEXT("CIAO_LOG_LEVEL"), CIAO_debug_level);
    CIAO_debug_level = log;

    ACE_Env_Value<int> trace (ACE_TEXT("CIAO_TRACE_ENABLE"), 0);
    this->trace_ = (trace != 0);

    ACE_Env_Value<const ACE_TCHAR *> filename (ACE_TEXT("CIAO_LOG_FILE"), this->filename_.c_str ());
    this->filename_ = filename;

    ACE_Env_Value<const ACE_TCHAR *> backend (ACE_TEXT("CIAO_LOG_BACKEND"), this->backend_.c_str ());
    this->backend_ = backend;

    this->parse_args (argc, argv);

    if (this->trace_)
    {
        CIAO_ENABLE_TRACE ();
    }
    else
    {
        CIAO_DISABLE_TRACE ();
    }

    if (this->filename_.length () > 0)
    {
#if defined (ACE_LACKS_IOSTREAM_TOTALLY)

        FILE* output_stream = ACE_OS::fopen (this->filename_.c_str (), ACE_TEXT ("a"));

        ACE_LOG_MSG->msg_ostream (output_stream, 1);
#else /* ! ACE_LACKS_IOSTREAM_TOTALLY */
        ofstream* output_stream = 0;

        ACE_NEW_THROW_EX (output_stream,
                          ofstream (),
                          CORBA::NO_MEMORY (
                              CORBA::SystemException::_tao_minor_code (
                                  0,
                                  ENOMEM),
                              CORBA::COMPLETED_NO));

        output_stream->open (ACE_TEXT_ALWAYS_CHAR (this->filename_.c_str ()),
                             ios::out | ios::app);

        if (!output_stream->bad ())
        {
            ACE_LOG_MSG->msg_ostream (output_stream, 1);
        }
#endif /* ACE_LACKS_IOSTREAM_TOTALLY */

        ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER);
        ACE_LOG_MSG->set_flags (ACE_Log_Msg::OSTREAM);
    }

    if (this->backend_.length () > 0)
    {

        ACE_Log_Msg_Backend* logger_be =
            ACE_Dynamic_Service<ACE_Log_Msg_Backend>::instance(this->backend_.c_str ());

        //        backend->open ("");

        if (logger_be == 0)
        {
            CIAO_ERROR (1,
                        (LM_EMERGENCY, CLINFO
                         "Logger_Service::init - "
                         "Unable to load backend %s\n",
                         this->backend_.c_str ()));
            return -1;
        }

        ACE_Log_Msg::msg_backend (logger_be);

        ACE_LOG_MSG->clr_flags (ACE_Log_Msg::STDERR | ACE_Log_Msg::LOGGER);
        ACE_LOG_MSG->set_flags (ACE_Log_Msg::CUSTOM);
    }

    return 0;
}
Exemplo n.º 21
0
  Components::CCMObject_ptr
  Session_Container_i::install_component (const char *primary_artifact,
                                          const char *entry_point,
                                          const char *servant_artifact,
                                          const char *servant_entrypoint,
                                          const char *name,
                                          CORBA::Long open_mode)
  {
    CIAO_TRACE ("Session_Container_i::install_component");

    ACE_DLL executor_dll;
    ACE_DLL servant_dll;

    Container_i < ::CIAO::Session_Container>::prepare_installation ("Session Component",
                                                                    primary_artifact,
                                                                    entry_point,
                                                                    servant_artifact,
                                                                    servant_entrypoint,
                                                                    name,
                                                                    open_mode,
                                                                    executor_dll,
                                                                    servant_dll);

    void *void_ptr_executor = executor_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (entry_point));
    void *void_ptr_servant = servant_dll.symbol (ACE_TEXT_CHAR_TO_TCHAR (servant_entrypoint));

    ptrdiff_t tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr_executor);
    ComponentFactory ccreator = reinterpret_cast<ComponentFactory> (tmp_ptr);

    tmp_ptr = reinterpret_cast<ptrdiff_t> (void_ptr_servant);
    ComponentServantFactory screator = reinterpret_cast<ComponentServantFactory> (tmp_ptr);

    if (ccreator == 0)
      {
        std::ostringstream err;
        err << "Entry point [" << entry_point << "] invalid in DLL ["
            << primary_artifact;

        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_component "
                     "- Error: %C\n",
                     err.str ().c_str ()));

        throw CIAO::Installation_Failure (name,
                                          err.str ().c_str ());
      }

    if (screator == 0)
      {
        std::ostringstream err;
        err << "Entry point [" << servant_entrypoint << "] invalid in DLL ["
            << servant_artifact;

        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_component "
                     "- Error: %C\n",
                     err.str ().c_str ()));

        throw CIAO::Installation_Failure (name,
                                          err.str ().c_str ());
      }

    CIAO_DEBUG (9,
                (LM_TRACE,
                 CLINFO
                 "Session_Container_i::install_component - "
                 "Loading component executor\n"));

    Components::EnterpriseComponent_var component_executor;
    try
      {
        component_executor = ccreator ();
      }
    catch (...)
      {
        CIAO_ERROR (1,
                    (LM_ERROR, CLINFO
                    "Session_Container_i::install_component - "
                     "Caught unexpected exception from component factory."));
        throw CIAO::Installation_Failure (name,
                                          "Component executor factory threw exception");
      }

    if (CORBA::is_nil (component_executor.in ()))
      {
        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_component - "
                     "Component executor factory failed.\n"));

        throw CIAO::Installation_Failure (name,
                                          "Component executor factory failed");
      }

    CIAO_DEBUG (9,
                (LM_TRACE,
                 CLINFO
                 "Session_Container_i::install_component - "
                 "Loading component servant\n"));

    PortableServer::Servant component_servant;

    try
      {
        component_servant = screator (component_executor.in (),
                                      this,
                                      name);
      }
    catch (...)
      {
        CIAO_ERROR (1,
                    (LM_ERROR, CLINFO
                    "Session_Container_i::install_component - "
                     "Caught unexpected exception from component servant factory."));
        throw CIAO::Installation_Failure (name,
                                          "Component servant factory threw exception");
      }


    if (component_servant == 0)
      {
        CIAO_ERROR (1,
                    (LM_ERROR,
                     CLINFO
                     "Session_Container_i::install_component - "
                     "Component servant factory failed.\n"));

        throw CIAO::Installation_Failure (name,
                                          "Component servant factory failed");
      }

    PortableServer::ServantBase_var safe (component_servant);

    CIAO_DEBUG (9,
                (LM_TRACE,
                 CLINFO
                 "Session_Container_i::install_component - "
                 "Installing component servant\n"));

    PortableServer::ObjectId_var oid;

    CORBA::Object_var objref =
      this->install_servant (component_servant,
                             Container_Types::COMPONENT_t,
                             oid.out ());

    Components::CCMObject_var componentref =
      Components::CCMObject::_narrow (objref.in ());

    CIAO_DEBUG (9, (LM_TRACE, CLINFO
                    "Session_Container_i::install_component - "
                    "Component successfully created\n"));

    return componentref._retn ();
  }