Java Code Examples for org.pentaho.di.core.exception.KettlePluginException#printStackTrace()

The following examples show how to use org.pentaho.di.core.exception.KettlePluginException#printStackTrace() . 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: SpoonUiExtenderPluginType.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public List<SpoonUiExtenderPluginInterface> getRelevantExtenders( Class<?> clazz, String uiEvent ) {

    PluginRegistry instance = PluginRegistry.getInstance();
    List<PluginInterface> pluginInterfaces = instance.getPlugins( SpoonUiExtenderPluginType.class );

    List<SpoonUiExtenderPluginInterface> relevantPluginInterfaces = new ArrayList<SpoonUiExtenderPluginInterface>(  );
    if ( pluginInterfaces != null ) {
      for ( PluginInterface pluginInterface : pluginInterfaces ) {
        try {
          Object loadClass = instance.loadClass( pluginInterface );

          SpoonUiExtenderPluginInterface spoonUiExtenderPluginInterface = (SpoonUiExtenderPluginInterface) loadClass;

          Set<String> events = spoonUiExtenderPluginInterface.respondsTo().get( clazz );
          if ( events != null && events.contains( uiEvent ) ) {
            relevantPluginInterfaces.add( spoonUiExtenderPluginInterface );
          }
        } catch ( KettlePluginException e ) {
          e.printStackTrace();
        }
      }
    }

    return relevantPluginInterfaces;
  }
 
Example 2
Source File: SpoonPluginManager.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override public void pluginAdded( final Object serviceObject ) {
  try {
    SpoonPluginInterface spoonPluginInterface =
        (SpoonPluginInterface) getPluginRegistry().loadClass( (PluginInterface) serviceObject );

    if ( plugins.get( serviceObject ) != null ) {
      return;
    }
    SpoonPluginCategories categories = spoonPluginInterface.getClass().getAnnotation( SpoonPluginCategories.class );
    if ( categories != null ) {
      for ( String cat : categories.value() ) {
        List<SpoonPluginInterface> categoryList = pluginCategoryMap.get( cat );
        if ( categoryList == null ) {
          categoryList = new ArrayList<>();
          pluginCategoryMap.put( cat, categoryList );
        }
        categoryList.add( spoonPluginInterface );
      }
    }

    if ( spoonPluginInterface.getPerspective() != null ) {
      getSpoonPerspectiveManager().addPerspective( spoonPluginInterface.getPerspective() );
    }

    plugins.put( serviceObject, spoonPluginInterface );

  } catch ( KettlePluginException e ) {
    e.printStackTrace();
  }
}
 
Example 3
Source File: PurRepositoryProxyTest.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  mockRegistry = mock( PluginRegistry.class );
  mockPluginInterface = mock( PluginInterface.class );
  mockClassLoader = mock( ClassLoader.class );
  mockRepository = mock( PurRepository.class );
  try {
    when( mockRegistry.findPluginWithId( any(), anyString() ) ).thenReturn( mockPluginInterface );
    when( mockRegistry.getClassLoader( any() ) ).thenReturn( mockClassLoader );
    proxy = spy( new PurRepositoryProxy( mockRegistry ) );
  } catch ( KettlePluginException e ) {
    e.printStackTrace();
  }
}
 
Example 4
Source File: PluginRegistry.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
/**
 * This method registers plugin types and loads their respective plugins
 *
 * @throws KettlePluginException
 */
public static void init( boolean keepCache ) throws KettlePluginException {
  final PluginRegistry registry = getInstance();

  log.snap( Metrics.METRIC_PLUGIN_REGISTRY_REGISTER_EXTENSIONS_START );

  // Find pluginRegistry extensions
  try {
    registry.registerType( PluginRegistryPluginType.getInstance() );
    List<PluginInterface> plugins = registry.getPlugins( PluginRegistryPluginType.class );
    for ( PluginInterface extensionPlugin : plugins ) {
      log.snap( Metrics.METRIC_PLUGIN_REGISTRY_REGISTER_EXTENSION_START, extensionPlugin.getName() );
      PluginRegistryExtension extension = (PluginRegistryExtension) registry.loadClass( extensionPlugin );
      extension.init( registry );
      extensions.add( extension );
      log.snap( Metrics.METRIC_PLUGIN_REGISTRY_REGISTER_EXTENSIONS_STOP, extensionPlugin.getName() );
    }
  } catch ( KettlePluginException e ) {
    e.printStackTrace();
  }
  log.snap( Metrics.METRIC_PLUGIN_REGISTRY_REGISTER_EXTENSIONS_STOP );

  log.snap( Metrics.METRIC_PLUGIN_REGISTRY_PLUGIN_REGISTRATION_START );
  for ( final PluginTypeInterface pluginType : pluginTypes ) {
    log.snap( Metrics.METRIC_PLUGIN_REGISTRY_PLUGIN_TYPE_REGISTRATION_START, pluginType.getName() );
    registry.registerType( pluginType );
    log.snap( Metrics.METRIC_PLUGIN_REGISTRY_PLUGIN_TYPE_REGISTRATION_STOP, pluginType.getName() );
  }
  log.snap( Metrics.METRIC_PLUGIN_REGISTRY_PLUGIN_REGISTRATION_STOP );

  /*
   * System.out.println(MetricsUtil.getDuration(log.getLogChannelId(),
   * Metrics.METRIC_PLUGIN_REGISTRY_REGISTER_EXTENSIONS_START.getDescription()).get(0));
   * System.out.println(MetricsUtil.getDuration(log.getLogChannelId(),
   * Metrics.METRIC_PLUGIN_REGISTRY_PLUGIN_REGISTRATION_START.getDescription()).get(0)); long total=0; for
   * (MetricsDuration duration : MetricsUtil.getDuration(log.getLogChannelId(),
   * Metrics.METRIC_PLUGIN_REGISTRY_PLUGIN_TYPE_REGISTRATION_START.getDescription())) { total+=duration.getDuration();
   * System.out.println("   - "+duration.toString()+"          Total="+total); }
   */

  // Clear the jar file cache so that we don't waste memory...
  //
  if ( !keepCache ) {
    JarFileCache.getInstance().clear();
  }
}