Exemplo n.º 1
0
// =-=-=-=-=-=-=-
// function to load and return an initialized database plugin
    error load_database_plugin(
        database_ptr&      _plugin,
        const std::string& _plugin_name,
        const std::string& _inst_name,
        const std::string& _context ) {
        // =-=-=-=-=-=-=-
        // resolve plugin directory
        std::string plugin_home;
        error ret = resolve_plugin_path( PLUGIN_TYPE_DATABASE, plugin_home );
        if( !ret.ok() ) {
            return PASS( ret );
        }

        // =-=-=-=-=-=-=-
        // call generic plugin loader
        database* db = 0;
        ret = load_plugin< database >(
                  db,
                  _plugin_name,
                  plugin_home,
                  _inst_name,
                  _context );
        if ( ret.ok() && db ) {
            _plugin.reset( db );
            return SUCCESS();

        }
        else {
            return PASS( ret );

        }

    } // load_database_plugin
Exemplo n.º 2
0
// =-=-=-=-=-=-=-
// given the name of a microservice, try to load the shared object
// and then register that ms with the table
    error load_microservice_plugin( ms_table& _table, const std::string _ms ) {
        // =-=-=-=-=-=-=-
        // resolve plugin directory
        std::string plugin_home;
        error ret = resolve_plugin_path( PLUGIN_TYPE_MICROSERVICE, plugin_home );
        if( !ret.ok() ) {
            return PASS( ret );
        }

        ms_table_entry* entry = 0;
        error load_err = load_plugin< ms_table_entry >( entry, _ms, plugin_home, "msvc", "ctx" );
        if ( load_err.ok() && entry ) {
            _table[ _ms ] = entry;
            return SUCCESS();
        }
        else {
            error ret = PASSMSG( "Failed to create ms plugin entry.", load_err );
            // JMC :: spams the log - log( ret );
            return ret;
        }
    } // load_microservice_plugin
Exemplo n.º 3
0
// =-=-=-=-=-=-=-
// function to load and return an initialized resource plugin
    error load_resource_plugin( resource_ptr&     _plugin,
                                const std::string _plugin_name,
                                const std::string _inst_name,
                                const std::string _context ) {
        // =-=-=-=-=-=-=-
        // resolve plugin directory
        std::string plugin_home;
        error ret = resolve_plugin_path( PLUGIN_TYPE_RESOURCE, plugin_home );
        if ( !ret.ok() ) {
            return PASS( ret );
        }

        resource* resc = 0;
        ret = load_plugin< resource >(
                  resc,
                  _plugin_name,
                  plugin_home,
                  _inst_name,
                  _context );
        if ( ret.ok() && resc ) {
            _plugin.reset( resc );

        }
        else {
            rodsLog(
                LOG_DEBUG,
                "loading impostor resource for [%s] of type [%s] with context [%s]",
                _inst_name.c_str(),
                _plugin_name.c_str(),
                _context.c_str() );
            _plugin.reset(
                new impostor_resource(
                    "impostor_resource", "" ) );

        }

        return SUCCESS();

    } // load_resource_plugin
Exemplo n.º 4
0
// =-=-=-=-=-=-=-
// public - load api plugins
    error init_api_table(
        api_entry_table&  _api_tbl,
        pack_entry_table& _pack_tbl,
        bool              _cli_flg ) {
        // =-=-=-=-=-=-=-
        // resolve plugin directory
        std::string plugin_home;
        error ret = resolve_plugin_path( irods::PLUGIN_TYPE_API, plugin_home );
        if ( !ret.ok() ) {
            return PASS( ret );
        }

        // =-=-=-=-=-=-=-
        // iterate over the API_HOME directory entries
        boost::filesystem::path so_dir( plugin_home );
        if ( boost::filesystem::exists( so_dir ) ) {
            for ( boost::filesystem::directory_iterator it( so_dir );
                    it != boost::filesystem::directory_iterator();
                    ++it ) {


                // =-=-=-=-=-=-=-
                // given a shared object, load the plugin from it
                std::string name  = it->path().stem().string();

                // =-=-=-=-=-=-=-
                // if client side, skip server plugins, etc.
                if ( _cli_flg ) {
                    size_t pos = name.find( "_server" );
                    if ( std::string::npos != pos ) {
                        continue;
                    }

                }
                else {
                    size_t pos = name.find( "_client" );
                    if ( std::string::npos != pos ) {
                        continue;
                    }

                }

                // =-=-=-=-=-=-=-
                // clip off the lib to remain compliant with
                // load_plugin's expected behavior
                size_t pos = name.find( "lib" );
                if ( std::string::npos == pos ) {
                    continue;
                }
                name = name.substr( 3 );

                api_entry*  entry = 0;
                error ret = load_plugin< api_entry >(
                                entry,
                                name,
                                plugin_home,
                                "inst", "ctx" );
                if ( ret.ok() && entry ) {
                    // =-=-=-=-=-=-=-
                    //
                    rodsLog(
                        LOG_DEBUG,
                        "init_api_table :: adding %d - [%s]",
                        entry->apiNumber,
                        entry->fcn_name_.c_str() );

                    // =-=-=-=-=-=-=-
                    // ask the plugin to fill in the api and pack
                    // tables with its appropriate values
                    _api_tbl[ entry->apiNumber ] = api_entry_ptr( entry );

                    // =-=-=-=-=-=-=-
                    // add the in struct
                    if ( !entry->in_pack_key.empty() ) {
                        _pack_tbl[ entry->in_pack_key ].packInstruct = entry->in_pack_value;
                        entry->inPackInstruct = entry->in_pack_key.c_str();
                    }

                    // =-=-=-=-=-=-=-
                    // add the out struct
                    if ( !entry->out_pack_key.empty() ) {
                        _pack_tbl[ entry->out_pack_key ].packInstruct = entry->out_pack_value;
                        entry->outPackInstruct = entry->out_pack_key.c_str();
                    }

                    // =-=-=-=-=-=-=-
                    // some plugins may define additional packinstructions
                    // which are composites of the in or out structs
                    if ( !entry->extra_pack_struct.empty() ) {
                        lookup_table<std::string>::iterator itr;
                        for ( itr  = entry->extra_pack_struct.begin();
                                itr != entry->extra_pack_struct.end();
                                ++itr ) {
                            _pack_tbl[ itr->first ].packInstruct = itr->second;

                        } // for itr

                    } // if empty

                }
                else {
                    irods::log( PASS( ret ) );

                }

            } // for itr

        } // if exists

        return SUCCESS();

    } // init_api_table