public static List<ValueMetaInterface> getValueMetaPluginClasses() throws KettlePluginException { List<ValueMetaInterface> list = new ArrayList<ValueMetaInterface>(); List<PluginInterface> plugins = pluginRegistry.getPlugins( ValueMetaPluginType.class ); for ( PluginInterface plugin : plugins ) { ValueMetaInterface valueMetaInterface = (ValueMetaInterface) pluginRegistry.loadClass( plugin ); list.add( valueMetaInterface ); } return list; }
protected List<PluginInterface> getPlugins() { return PluginRegistry.getInstance().getPlugins( CompressionPluginType.class ); } }
/** * Find the plugin ID based on the description of the plugin * * @param pluginType the type of plugin * @param pluginDescription The description to look for * @return The plugin with the specified description or null if nothing was found. */ public PluginInterface findPluginWithDescription( Class<? extends PluginTypeInterface> pluginType, String pluginDescription ) { return getPlugins( pluginType ).stream() .filter( plugin -> plugin.getDescription().equals( pluginDescription ) ) .findFirst() .orElse( null ); }
/** * 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 ); }
/** * @return a unique list of all the step plugin package names */ public List<String> getPluginPackages( Class<? extends PluginTypeInterface> pluginType ) { Set<String> list = new TreeSet<>(); for ( PluginInterface plugin : getPlugins( pluginType ) ) { for ( String className : plugin.getClassMap().values() ) { int lastIndex = className.lastIndexOf( "." ); if ( lastIndex > -1 ) { list.add( className.substring( 0, lastIndex ) ); } } } return new ArrayList<>( list ); }
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()] ); }
/** * Retrieve a list of plugins per category. * * @param pluginType The type of plugins to search * @param pluginCategory The category to look in * @return An unmodifiable list of plugins that belong to the specified type and category. */ public <T extends PluginTypeInterface> List<PluginInterface> getPluginsByCategory( Class<T> pluginType, String pluginCategory ) { List<PluginInterface> plugins = getPlugins( pluginType ).stream() .filter( plugin -> plugin.getCategory() != null && plugin.getCategory().equals( pluginCategory ) ) .collect( Collectors.toList() ); return Collections.unmodifiableList( plugins ); }
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; }
private String[] getRowDistributionLabels() { ArrayList<String> labels = new ArrayList<>(); labels.add( BaseMessages.getString( PKG, "Spoon.Dialog.CopyOrDistribute.Distribute" ) ); labels.add( BaseMessages.getString( PKG, "Spoon.Dialog.CopyOrDistribute.Copy" ) ); if ( PluginRegistry.getInstance().getPlugins( RowDistributionPluginType.class ).size() > 0 ) { labels.add( BaseMessages.getString( PKG, "Spoon.Dialog.CopyOrDistribute.CustomRowDistribution" ) ); } return labels.toArray( new String[labels.size()] ); }
/** * Get a plugin from the registry * * @param pluginType The type of plugin to look for * @param id The ID to scan for * @return the plugin or null if nothing was found. */ public PluginInterface getPlugin( Class<? extends PluginTypeInterface> pluginType, String id ) { if ( Utils.isEmpty( id ) ) { return null; } // getPlugins() never returns null, see his method above return getPlugins( pluginType ).stream() .filter( plugin -> plugin.matches( id ) ) .findFirst() .orElse( null ); }
/** * Reinitialize the extension point plugins map */ public void reInitialize() { lock.writeLock().lock(); try { extensionPointPluginMap = HashBasedTable.create(); final PluginRegistry registry = PluginRegistry.getInstance(); List<PluginInterface> extensionPointPlugins = registry.getPlugins( ExtensionPointPluginType.class ); for ( PluginInterface extensionPointPlugin : extensionPointPlugins ) { addExtensionPoint( extensionPointPlugin ); } } finally { lock.writeLock().unlock(); } }
/** * 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; }
@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 Object doCall() throws Exception { while ( condition.get() ) { PluginRegistry.getInstance().getPlugins( type ); } return null; } }
private SpoonPluginManager() { PluginRegistry pluginRegistry = getPluginRegistry(); pluginRegistry.addPluginListener( SpoonPluginType.class, this ); List<PluginInterface> plugins = pluginRegistry.getPlugins( SpoonPluginType.class ); for ( PluginInterface plug : plugins ) { pluginAdded( plug ); } } }
@Before public void setUpPluginRegistry() throws Exception { // Intercept access to registry registry = LifecycleSupport.registry = KettleLifecycleSupport.registry = mock( PluginRegistry.class ); registeredPlugins = new ArrayList<PluginInterface>(); when( registry.getPlugins( KettleLifecyclePluginType.class ) ).thenReturn( registeredPlugins ); typeListenerRegistration = ArgumentCaptor.forClass( PluginTypeListener.class ); doNothing().when( registry ).addPluginListener( eq( KettleLifecyclePluginType.class ), typeListenerRegistration.capture() ); }
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; }
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; }