@Override public void pluginRemoved( Object serviceObject ) { PluginInterface plugin = (PluginInterface) serviceObject; String pluginName = plugin.getName(); databaseTypeRemoved( pluginName ); }
/** * Find the plugin ID based on the name of the plugin * * @param pluginType the type of plugin * @param pluginName The name to look for * @return The plugin with the specified name or null if nothing was found. */ public PluginInterface findPluginWithName( Class<? extends PluginTypeInterface> pluginType, String pluginName ) { return getPlugins( pluginType ).stream() .filter( plugin -> plugin.getName().equals( pluginName ) ) .findFirst() .orElse( null ); }
public static String[] getValueMetaNames() { List<String> strings = new ArrayList<String>(); List<PluginInterface> plugins = pluginRegistry.getPlugins( ValueMetaPluginType.class ); for ( PluginInterface plugin : plugins ) { int id = Integer.valueOf( plugin.getIds()[0] ); if ( id > 0 && id != ValueMetaInterface.TYPE_SERIALIZABLE ) { strings.add( plugin.getName() ); } } return strings.toArray( new String[strings.size()] ); }
public static String[] getAllValueMetaNames() { List<String> strings = new ArrayList<String>(); List<PluginInterface> plugins = pluginRegistry.getPlugins( ValueMetaPluginType.class ); for ( PluginInterface plugin : plugins ) { String id = plugin.getIds()[0]; if ( !( "0".equals( id ) ) ) { strings.add( plugin.getName() ); } } return strings.toArray( new String[strings.size()] ); }
public static String getValueMetaName( int type ) { for ( PluginInterface plugin : pluginRegistry.getPlugins( ValueMetaPluginType.class ) ) { if ( Integer.toString( type ).equals( plugin.getIds()[0] ) ) { return plugin.getName(); } } return "-"; }
public static int getIdForValueMeta( String valueMetaName ) { for ( PluginInterface plugin : pluginRegistry.getPlugins( ValueMetaPluginType.class ) ) { if ( valueMetaName != null && valueMetaName.equalsIgnoreCase( plugin.getName() ) ) { return Integer.valueOf( plugin.getIds()[0] ); } } return ValueMetaInterface.TYPE_NONE; }
/** * Add the extension point plugin to the map * * @param extensionPointPlugin */ public void addExtensionPoint( PluginInterface extensionPointPlugin ) { lock.writeLock().lock(); try { for ( String id : extensionPointPlugin.getIds() ) { extensionPointPluginMap.put( extensionPointPlugin.getName(), id, createLazyLoader( extensionPointPlugin ) ); } } finally { lock.writeLock().unlock(); } }
/** * Remove the extension point plugin from the map * * @param extensionPointPlugin */ public void removeExtensionPoint( PluginInterface extensionPointPlugin ) { lock.writeLock().lock(); try { for ( String id : extensionPointPlugin.getIds() ) { extensionPointPluginMap.remove( extensionPointPlugin.getName(), id ); } } finally { lock.writeLock().unlock(); } }
public static String getHelpDialogTitle( PluginInterface plugin ) { if ( plugin == null ) { return ""; } String msgKey = ""; // TODO currently support only Step and JobEntry - extend if required. if ( plugin.getPluginType().equals( StepPluginType.class ) ) { msgKey = "System.ShowHelpDialog.StepPluginType.Title"; } else { msgKey = "System.ShowHelpDialog.JobEntryPluginType.Title"; } return BaseMessages.getString( PKG, msgKey, plugin.getName() ); }
public String getXML() { StringBuilder xml = new StringBuilder(); xml.append( XMLHandler.openTag( XML_TAG ) ).append( Const.CR ).append( Const.CR ); for ( ImportRuleInterface rule : getRules() ) { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( ImportRulePluginType.class, rule.getId() ); xml.append( "<!-- " ).append( plugin.getName() ).append( " : " ).append( plugin.getDescription() ).append( Const.CR ).append( " -->" ).append( Const.CR ); xml.append( rule.getXML() ); xml.append( Const.CR ).append( Const.CR ); } xml.append( XMLHandler.closeTag( XML_TAG ) ); return xml.toString(); }
/** * Instantiate the main plugin class types for the plugin type provided from the set of registered plugins via * {@link PluginRegistry}. * * @param pluginType * Type of plugin whose main class types should be instanticated * @return Set of plugin main class instances (a.k.a. plugins) */ static <T> Set<T> loadPlugins( Class<? extends PluginTypeInterface> pluginType, Class<T> mainPluginClass ) { Set<T> pluginInstances = new HashSet<T>(); List<PluginInterface> plugins = registry.getPlugins( pluginType ); for ( PluginInterface plugin : plugins ) { try { pluginInstances.add( registry.loadClass( plugin, mainPluginClass ) ); } catch ( Throwable e ) { LogChannel.GENERAL.logError( "Unexpected error loading class for plugin " + plugin.getName(), e ); } } return pluginInstances; }
@Override public CompressionProvider createCompressionProviderInstance( String name ) { CompressionProvider provider = null; List<PluginInterface> providers = getPlugins(); if ( providers != null ) { for ( PluginInterface plugin : providers ) { if ( name != null && name.equalsIgnoreCase( plugin.getName() ) ) { try { return PluginRegistry.getInstance().loadClass( plugin, CompressionProvider.class ); } catch ( Exception e ) { provider = null; } } } } return provider; }
@Override public ExtensionPointInterface get() { try { return registry.loadClass( extensionPointPlugin, ExtensionPointInterface.class ); } catch ( Exception e ) { getLog().logError( "Unable to load extension point for name = [" + ( extensionPointPlugin != null ? extensionPointPlugin.getName() : "null" ) + "]", e ); return null; } } }
@SuppressWarnings( "unchecked" ) public String getPlugins() { List<PluginInterface> plugins = pluginRegistry.getPlugins( RepositoryPluginType.class ); JSONArray list = new JSONArray(); for ( PluginInterface pluginInterface : plugins ) { if ( !pluginInterface.getIds()[0].equals( "PentahoEnterpriseRepository" ) ) { JSONObject repoJSON = new JSONObject(); repoJSON.put( "id", pluginInterface.getIds()[ 0 ] ); repoJSON.put( "name", pluginInterface.getName() ); repoJSON.put( "description", pluginInterface.getDescription() ); list.add( repoJSON ); } } return list.toString(); }
@Override public String toString() { // The rule name with an indication of whether or not this rule is enabled should do for now. // String pluginId = PluginRegistry.getInstance().getPluginId( this ); PluginInterface plugin = PluginRegistry.getInstance().findPluginWithId( ImportRulePluginType.class, pluginId ); return plugin.getName() + " (" + ( enabled ? "enabled" : "disabled" ) + ")."; }
private Map<String, SwingUniversalImage> loadStepImages() { Map<String, SwingUniversalImage> map = new HashMap<>(); for ( PluginInterface plugin : PluginRegistry.getInstance().getPlugins( StepPluginType.class ) ) { try { SwingUniversalImage image = getUniversalImageIcon( plugin ); for ( String id : plugin.getIds() ) { map.put( id, image ); } } catch ( Exception e ) { log.logError( "Unable to load step icon image for plugin: " + plugin.getName() + " (id=" + plugin.getIds()[0] + ")", e ); } } return map; }
@Override public void pluginAdded( Object serviceObject ) { PluginInterface plugin = (PluginInterface) serviceObject; String pluginName = plugin.getName(); try { DatabaseInterface databaseInterface = (DatabaseInterface) registry.loadClass( plugin ); databaseInterface.setPluginId( plugin.getIds()[0] ); databaseInterface.setName( pluginName ); databaseTypeAdded( pluginName, databaseInterface ); } catch ( KettleException e ) { Throwable t = e; if ( e.getCause() != null ) { t = e.getCause(); } System.out.println( "Could not create connection entry for " + pluginName + ". " + t.getClass().getName() ); LogChannel.GENERAL.logError( "Could not create connection entry for " + pluginName + ". " + t.getClass().getName() ); } }
private void addStepItem( final TreeItem categoryItem, final PluginInterface step ) { final Image stepImage = GUIResource.getInstance().getImagesStepsSmall().get( step.getIds()[ 0 ] ); String pluginName = step.getName(); String pluginDescription = step.getDescription(); if ( filterMatch( pluginName ) || filterMatch( pluginDescription ) ) { createTreeItem( categoryItem, pluginName, stepImage, step.getIds()[ 0 ] ); coreStepToolTipMap.put( pluginName, pluginDescription ); } }
private Map<String, SwingUniversalImage> loadEntryImages() { Map<String, SwingUniversalImage> map = new HashMap<>(); for ( PluginInterface plugin : PluginRegistry.getInstance().getPlugins( JobEntryPluginType.class ) ) { try { if ( JobMeta.STRING_SPECIAL.equals( plugin.getIds()[0] ) ) { continue; } SwingUniversalImage image = getUniversalImageIcon( plugin ); if ( image == null ) { throw new KettleException( "Unable to find image file: " + plugin.getImageFile() + " for plugin: " + plugin ); } map.put( plugin.getIds()[0], image ); } catch ( Exception e ) { log.logError( "Unable to load job entry icon image for plugin: " + plugin.getName() + " (id=" + plugin.getIds()[0] + ")", e ); } } return map; }
@BeforeClass public static void setUpBeforeClass() throws Exception { KettleClientEnvironment.init(); dbMap.put( DatabaseInterface.class, DBMockIface.class.getName() ); dbMap.put( InfobrightDatabaseMeta.class, InfobrightDatabaseMeta.class.getName() ); PluginRegistry preg = PluginRegistry.getInstance(); mockDbPlugin = mock( PluginInterface.class ); when( mockDbPlugin.matches( anyString() ) ).thenReturn( true ); when( mockDbPlugin.isNativePlugin() ).thenReturn( true ); when( mockDbPlugin.getMainType() ).thenAnswer( (Answer<Class<?>>) invocation -> DatabaseInterface.class ); when( mockDbPlugin.getPluginType() ).thenAnswer( (Answer<Class<? extends PluginTypeInterface>>) invocation -> DatabasePluginType.class ); when( mockDbPlugin.getIds() ).thenReturn( new String[] { "Oracle", "mock-db-id" } ); when( mockDbPlugin.getName() ).thenReturn( "mock-db-name" ); when( mockDbPlugin.getClassMap() ).thenReturn( dbMap ); preg.registerPlugin( DatabasePluginType.class, mockDbPlugin ); }