Exemplo n.º 1
0
Components::CCMObject_ptr
AssemblyImpl::getInstance (std::string name)
throw( Components::CreateFailure )
{
    Components::CCMObject_var obj;
	std::map < std::string, Components::CCMObject_var > ::iterator it;
    it = instanceMap_.find(name);
    if (it != instanceMap_.end())
    {
        obj = (*it).second;
        return obj._retn();
    }

    DEBUG_OUT2(".......... no component reference for ", name);
    throw Components::CreateFailure();
}
Exemplo n.º 2
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 ();
  }