Java Code Examples for org.pentaho.di.core.plugins.PluginRegistry#getClassLoader()

The following examples show how to use org.pentaho.di.core.plugins.PluginRegistry#getClassLoader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIResource.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Load all step images from files.
 */
private void loadJobEntryImages() {
  imagesJobentries = new Hashtable<>();
  imagesJobentriesSmall = new Hashtable<>();

  // //
  // // JOB ENTRY IMAGES TO LOAD
  // //
  PluginRegistry registry = PluginRegistry.getInstance();

  List<PluginInterface> plugins = registry.getPlugins( JobEntryPluginType.class );
  for ( PluginInterface plugin : plugins ) {
    if ( "SPECIAL".equals( plugin.getIds()[ 0 ] ) ) {
      continue;
    }

    SwtUniversalImage image = null;
    Image smallImage;

    String filename = plugin.getImageFile();
    try {
      ClassLoader classLoader = registry.getClassLoader( plugin );
      image = SwtSvgImageUtil.getUniversalImage( display, classLoader, filename );
    } catch ( Exception t ) {
      log.logError( "Error occurred loading image [" + filename + "] for plugin " + plugin.getIds()[ 0 ], t );
    } finally {
      if ( image == null ) {
        log.logError( "Unable to load image [" + filename + "] for plugin " + plugin.getIds()[ 0 ] );
        image = SwtSvgImageUtil.getMissingImage( display );
      }
    }
    // Calculate the smaller version of the image @ 16x16...
    // Perhaps we should make this configurable?
    smallImage = image.getAsBitmapForSize( display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE );

    imagesJobentries.put( plugin.getIds()[ 0 ], image );
    imagesJobentriesSmall.put( plugin.getIds()[ 0 ], smallImage );
  }
}
 
Example 2
Source File: DatabaseMeta.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public DatabaseFactoryInterface getDatabaseFactory() throws Exception {
  PluginRegistry registry = PluginRegistry.getInstance();
  PluginInterface plugin = registry.getPlugin( DatabasePluginType.class, databaseInterface.getPluginId() );
  if ( plugin == null ) {
    throw new KettleDatabaseException( "database type with plugin id ["
      + databaseInterface.getPluginId() + "] couldn't be found!" );
  }

  ClassLoader loader = registry.getClassLoader( plugin );

  Class<?> clazz = Class.forName( databaseInterface.getDatabaseFactoryName(), true, loader );
  return (DatabaseFactoryInterface) clazz.newInstance();
}
 
Example 3
Source File: GUIResource.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * Load all step images from files.
 */
private void loadStepImages() {
  // imagesSteps.clear();
  // imagesStepsSmall.clear();

  //
  // STEP IMAGES TO LOAD
  //
  PluginRegistry registry = PluginRegistry.getInstance();

  List<PluginInterface> steps = registry.getPlugins( StepPluginType.class );
  for ( PluginInterface step : steps ) {
    if ( imagesSteps.get( step.getIds()[ 0 ] ) != null ) {
      continue;
    }

    SwtUniversalImage image = null;
    Image smallImage;

    String filename = step.getImageFile();
    try {
      ClassLoader classLoader = registry.getClassLoader( step );
      image = SwtSvgImageUtil.getUniversalImage( display, classLoader, filename );
    } catch ( Exception t ) {
      log.logError(
        String.format( "Error occurred loading image [%s] for plugin %s", filename, step ), t );
    } finally {
      if ( image == null ) {
        log.logError(
          String.format( "Unable to load image file [%s] for plugin %s", filename, step ) );
        image = SwtSvgImageUtil.getMissingImage( display );
      }
    }

    // Calculate the smaller version of the image @ 16x16...
    // Perhaps we should make this configurable?
    //
    smallImage = image.getAsBitmapForSize( display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE );

    imagesSteps.put( step.getIds()[ 0 ], image );
    imagesStepsSmall.put( step.getIds()[ 0 ], smallImage );
  }
}
 
Example 4
Source File: PurRepositoryProxy.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public PurRepositoryProxy( PluginRegistry registry ) throws KettlePluginException {
  PluginInterface purPlugin = registry.findPluginWithId( RepositoryPluginType.class, PUR_PLUGIN_ID );
  purPluginClassLoader = registry.getClassLoader( purPlugin );
}