コード例 #1
0
ファイル: Servant_Impl_T.cpp プロジェクト: DOCGroup/CIAO
  Session_Servant_Impl_T<BASE_SKEL, EXEC, CONTEXT>::Session_Servant_Impl_T (
        EXEC * exe,
        Components::CCMHome_ptr home,
        const char * ins_name,
        Home_Servant_Impl_Base *home_servant,
        ::CIAO::Session_Container_ptr c)
    : CONTEXT::svnt_base_type (home, home_servant, c),
      activated_ (false),
      configuration_completed_ (false),
      executor_ (EXEC::_duplicate (exe)),
      context_ (0),
      ins_name_ (ins_name)
  {
    ACE_NEW (this->context_,
             CONTEXT (home, c, this, ins_name));

    ::Components::SessionComponent_var scom =
      ::Components::SessionComponent::_narrow (exe);

    if (! ::CORBA::is_nil (scom.in ()))
      {
        scom->set_session_context (this->context_);
      }
    else
      {
        CIAO_DEBUG (6,
                    (LM_DEBUG, CLINFO
                     "Session_Servant_Impl_T_T::Session_Servant_Impl_T_T - "
                     "Couldn't set session context for %C\n",
                     ins_name));
      }
  }
コード例 #2
0
ファイル: Container_Handler.cpp プロジェクト: DOCGroup/CIAO
  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));
  }
コード例 #3
0
ファイル: Container_Handler.cpp プロジェクト: DOCGroup/CIAO
  void
  Container_Handler_i::install_instance (const ::Deployment::DeploymentPlan &plan,
                                         ::CORBA::ULong instanceRef,
                                         ::CORBA::Any_out instance_reference)
  {
    CIAO_TRACE ("Container_Handler_i::install_instance");

    ACE_NEW_THROW_EX (instance_reference,
                      ::CORBA::Any (),
                      CORBA::NO_MEMORY ());

    const char *name (plan.instance[instanceRef].name.in ());
    CIAO::Session_Container *cont (0);

    CIAO_DEBUG (6, (LM_DEBUG, CLINFO
                    "Container_Handler_i::install_instance - "
                    "Creating session container with id <%C>\n",
                    name));
    ACE_NEW_THROW_EX (cont,
                      CIAO::Session_Container_i (this->orb_,
                                                 this->poa_),
                      CORBA::NO_MEMORY ());

    CIAO::Container_var container_ref (cont);

    CIAO_DEBUG (8, (LM_DEBUG, CLINFO
                    "Container_Handler_i::install_instance - "
                    "Container <%C> successfully created\n",
                    name));

    container_ref->init (name);

    CIAO_DEBUG (8, (LM_DEBUG, CLINFO
                    "Container_Handler_i::install_instance - "
                    "Container <%C> successfully initialized\n",
                    name));

    DEPLOYMENT_STATE::instance ()->add_container (name, container_ref.in ());

    *instance_reference <<= container_ref;
  }
コード例 #4
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 ()));
            }
        }
    }
コード例 #5
0
ファイル: Component_Handler.cpp プロジェクト: Yijtx/ACE
  void
  Component_Handler_i::install_instance (const ::Deployment::DeploymentPlan &plan,
                                         ::CORBA::ULong instanceRef,
                                         ::CORBA::Any_out instance_reference)
  {
    CORBA::Any *retval = 0;
    ACE_NEW_THROW_EX (retval,
                      CORBA::Any (),
                      CORBA::NO_MEMORY ());

    instance_reference = retval;

    CIAO_TRACE ("Component_Handler_i::install_instance");

    const ::Deployment::InstanceDeploymentDescription &idd (plan.instance[instanceRef]);
    const ::Deployment::MonolithicDeploymentDescription &mdd (plan.implementation[idd.implementationRef]);

    DAnCE::Utility::PROPERTY_MAP *pmap = 0;

    ACE_NEW_THROW_EX (pmap,
                      DAnCE::Utility::PROPERTY_MAP (idd.configProperty.length () +
                                                    mdd.execParameter.length ()),
                      CORBA::NO_MEMORY ());

    Deployment_Common::Instance_Info info;
    info.name = idd.name.in ();
    info.pmap.reset (pmap);

    DAnCE::Utility::build_property_map (*pmap,
                                        mdd.execParameter);
    DAnCE::Utility::build_property_map (*pmap,
                                        idd.configProperty);

    CORBA::String_var exec_art, exec_entry, svnt_art, svnt_entry, cont_id;

    CORBA::Any val;
    const char *tmp = 0;
    int open_mode = ACE_DEFAULT_SHLIB_MODE;

    if (pmap->find (CIAO::Deployment::SVNT_ENTRYPT, val) == 0)
        {
          val >>= tmp;
          svnt_entry = tmp;
          CIAO_DEBUG (9, (LM_TRACE, CLINFO
                          "Component_Handler_i::install_instance - "
                          "Found Servant entrypoint <%C>\n", svnt_entry.in ()));
        }
コード例 #6
0
Home_Servant_Impl<BASE_SKEL,
                  EXEC,
                  COMP_SVNT,
                  CONTAINER>::Home_Servant_Impl (
                      typename EXEC::_ptr_type exe,
                      typename CONTAINER::_ptr_type c,
                      const char *ins_name)
                      : Home_Servant_Impl_Base (),
                        ins_name_ (ins_name),
                        executor_ (EXEC::_duplicate (exe)),
                        serial_number_ (0),
                        container_ (CONTAINER::_duplicate(c))
{
    CIAO_DEBUG (9, (LM_TRACE, CLINFO "Home_Servant_Impl<>::Home_Servant_Impl - "
                    "Creating servant for home with ID %C\n",
                    ins_name));
}
コード例 #7
0
ファイル: Container_Handler.cpp プロジェクト: DOCGroup/CIAO
  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 ());
  }
コード例 #8
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"));
}
コード例 #9
0
    void
    build_name (const char *name, CosNaming::Name &nm)
    {
      CIAO_TRACE ("Name_Utilities::build_name");

      char* buf = ACE_OS::strdup (name);

      ACE_Tokenizer_T<char> parser (buf);
      parser.delimiter ('/');

      for (char *next = parser.next (); next; next = parser.next ())
        {
          CORBA::ULong const i = nm.length ();
          nm.length (i + 1);

          CIAO_DEBUG (9, (LM_TRACE, CLINFO
                          "Name_Utilities::build_name - "
                          "Found name component <%C>\n",
                          next));

          nm[i].id = CORBA::string_dup (next);
        }
      ACE_OS::free (buf);
    }
コード例 #10
0
ファイル: Session_Container.cpp プロジェクト: Yijtx/ACE
  //@@ 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 ();
  }
コード例 #11
0
ファイル: Session_Container.cpp プロジェクト: Yijtx/ACE
  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 ();
  }