Package org.openstreetmap.osmosis.core.plugin

Examples of org.openstreetmap.osmosis.core.plugin.PluginLoader


   *            the ClassLoader to use
   */
  @SuppressWarnings("unchecked")
  private void loadPluginClass(final String pluginClassName, final ClassLoader classLoader) {
    Class<?> untypedPluginClass;
    PluginLoader pluginLoader;
    Map<String, TaskManagerFactory> pluginTasks;
    // Load the plugin class.
    try {
      untypedPluginClass = classLoader.loadClass(pluginClassName);
    } catch (ClassNotFoundException e) {
      throw new OsmosisRuntimeException("Unable to load plugin class (" + pluginClassName + ").", e);
    }
    // Verify that the plugin implements the plugin loader interface.
    if (!PluginLoader.class.isAssignableFrom(untypedPluginClass)) {
      throw new OsmosisRuntimeException("The class (" + pluginClassName + ") does not implement interface ("
          + PluginLoader.class.getName() + "). Maybe it's not a plugin?");
    }
    Class<PluginLoader> pluginClass = (Class<PluginLoader>) untypedPluginClass;

    // Instantiate the plugin loader.
    try {
      pluginLoader = pluginClass.newInstance();
    } catch (InstantiationException e) {
      throw new IllegalArgumentException("Unable to instantiate plugin class (" + pluginClassName + ").", e);
    } catch (IllegalAccessException e) {
      throw new IllegalArgumentException("Unable to instantiate plugin class (" + pluginClassName + ").", e);
    }

    // Obtain the plugin task factories with their names.
    pluginTasks = pluginLoader.loadTaskFactories();

    // Register the plugin tasks.
    for (Entry<String, TaskManagerFactory> taskEntry : pluginTasks.entrySet()) {
      factoryRegister.register(taskEntry.getKey(), taskEntry.getValue());
    }
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.core.plugin.PluginLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.