@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(); }
if ( plugin.isNativePlugin() ) { return this.getClass().getClassLoader(); } else { if ( plugin.isSeparateClassLoaderNeeded() ) { classLoaderMap.computeIfAbsent( plugin.getPluginType(), k -> new HashMap<>() ); ucl = classLoaders.get( plugin ); if ( !Utils.isEmpty( plugin.getClassLoaderGroup() ) ) { ucl = classLoaderGroupsMap.get( plugin.getClassLoaderGroup() ); if ( ucl == null ) { ucl = createClassLoader( plugin ); classLoaderGroupsMap.put( plugin.getClassLoaderGroup(), ucl ); } else { ucl.loadClass( plugin.getClassMap().values().iterator().next() ); } catch ( ClassNotFoundException ignored ) { if ( plugin.getPluginDirectory() != null ) { ucl = folderBasedClassLoaderMap.get( plugin.getPluginDirectory().toString() ); if ( ucl == null ) { ucl = createClassLoader( plugin ); folderBasedClassLoaderMap.put( plugin.getPluginDirectory().toString(), ucl ); } else { ucl.loadClass( plugin.getClassMap().values().iterator().next() );
public void fillOptionsAndCodesByPlugins( List<PluginInterface> plugins ) { int pluginIndex = 0; for ( PluginInterface plugin : plugins ) { options[ StepPartitioningMeta.methodDescriptions.length + pluginIndex ] = plugin.getDescription(); codes[ StepPartitioningMeta.methodCodes.length + pluginIndex ] = plugin.getIds()[ 0 ]; pluginIndex++; } }
/** * @param fragment A plugin interface to merge with */ default void merge( PluginInterface fragment ) { if ( fragment != null ) { Optional.ofNullable( fragment.getClassMap() ).ifPresent( this.getClassMap()::putAll ); Optional.ofNullable( fragment.getImageFile() ).ifPresent( this::setImageFile ); Optional.ofNullable( fragment.getLibraries() ).ifPresent( this.getLibraries()::addAll ); Optional.ofNullable( fragment.getErrorHelpFile() ).ifPresent( this::setErrorHelpFile ); Optional.ofNullable( fragment.getDocumentationUrl() ).ifPresent( this::setDocumentationUrl ); Optional.ofNullable( fragment.getCasesUrl() ).ifPresent( this::setCasesUrl ); Optional.ofNullable( fragment.getForumUrl() ).ifPresent( this::setForumUrl ); Optional.ofNullable( fragment.getClassLoaderGroup() ).ifPresent( this::setClassLoaderGroup ); } } }
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() ); }
private ObjectId[] loadPluginsIds( List<PluginInterface> plugins, boolean create ) throws KettleException { ObjectId[] ids = new ObjectId[ plugins.size() ]; if ( create ) { return ids; } Map<String, LongObjectId> stepTypeCodeToIdMap = repository.stepDelegate.getStepTypeCodeToIdMap(); int index = 0; for ( PluginInterface sp : plugins ) { ids[index++] = stepTypeCodeToIdMap.get( sp.getIds()[0] ); } return ids; }
/** * @param pluginType the type of plugin to get information for * @return a row buffer containing plugin information for the given plugin type * @throws KettlePluginException */ public RowBuffer getPluginInformation( Class<? extends PluginTypeInterface> pluginType ) throws KettlePluginException { RowBuffer rowBuffer = new RowBuffer( getPluginInformationRowMeta() ); for ( PluginInterface plugin : getPlugins( pluginType ) ) { Object[] row = new Object[getPluginInformationRowMeta().size()]; int rowIndex = 0; row[rowIndex++] = getPluginType( plugin.getPluginType() ).getName(); row[rowIndex++] = plugin.getIds()[0]; row[rowIndex++] = plugin.getName(); row[rowIndex++] = Const.NVL( plugin.getDescription(), "" ); row[rowIndex++] = Utils.isEmpty( plugin.getLibraries() ) ? "" : plugin.getLibraries().toString(); row[rowIndex++] = Const.NVL( plugin.getImageFile(), "" ); row[rowIndex++] = plugin.getClassMap().values().toString(); row[rowIndex] = Const.NVL( plugin.getCategory(), "" ); rowBuffer.getBuffer().add( row ); } return rowBuffer; }
@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 ); }
@Override Object doCall() throws Exception { List<PluginInterface> registered = new ArrayList<PluginInterface>( cycles ); try { for ( int i = 0; i < cycles; i++ ) { String id = nameSeed + '_' + i; PluginInterface mock = mock( PluginInterface.class ); when( mock.getName() ).thenReturn( id ); when( mock.getIds() ).thenReturn( new String[] { id } ); when( mock.getPluginType() ).thenAnswer( new Answer<Object>() { @Override public Object answer( InvocationOnMock invocation ) throws Throwable { return type; } } ); registered.add( mock ); PluginRegistry.getInstance().registerPlugin( type, mock ); } } finally { // push up registered instances for future clean-up addUsedPlugins( type, registered ); } return null; } }
if ( aClass == null ) { throw new KettlePluginClassMapException( BaseMessages .getString( PKG, "PluginRegistry.RuntimeError.NoValidClassRequested.PLUGINREGISTRY002", plugin.getName(), pluginClass.getName() ) ); } else { String className = plugin.getClassMap().get( pluginClass ); if ( className == null ) { for ( String id : plugin.getIds() ) { try { T aClass = loadClass( plugin.getPluginType(), createSupplemantalKey( plugin.getPluginType().getName(), id ), pluginClass ); if ( aClass != null ) { return aClass; "PluginRegistry.RuntimeError.NoValidClassRequested.PLUGINREGISTRY002", plugin.getName(), pluginClass.getName() ) ); if ( plugin.isNativePlugin() ) { cl = (Class<? extends T>) Class.forName( className ); } else {
.filter( baseStep -> baseStep.getCategory().equalsIgnoreCase( baseCategory ) ) .sorted( Comparator.comparing( PluginInterface::getName ) ) .collect( Collectors.toList() ); addLineToBuilder( stepTree, "--- ", p.getName() ); addStepItem( item, p ); for ( PluginInterface uncategorizedStep : baseSteps ) { addStepItem( item, uncategorizedStep ); addLineToBuilder( stepTree, "--- ", uncategorizedStep.getName() ); if ( stepPlugin != null ) { final Image stepImage = GUIResource.getInstance().getImagesSteps().get( stepPlugin.getIds()[0] ).getAsBitmapForSize( display, ConstUI.MEDIUM_ICON_SIZE, ConstUI.MEDIUM_ICON_SIZE ); String pluginName = Const.NVL( stepPlugin.getName(), "" ); String pluginDescription = Const.NVL( stepPlugin.getDescription(), "" ); coreStepToolTipMap.put( stepPlugin.getDescription(), pluginDescription + " (" + usage.getNrUses() + ")" ); if ( !baseJobEntries.get( j ).getIds()[ 0 ].equals( JobMeta.STRING_SPECIAL ) ) { if ( baseJobEntries.get( j ).getCategory().equalsIgnoreCase( baseCategory ) ) { final Image jobEntryImage = GUIResource.getInstance().getImagesJobentriesSmall().get( baseJobEntries.get( j ).getIds()[0] ); String pluginName = Const.NVL( baseJobEntries.get( j ).getName(), "" ); String pluginDescription = Const.NVL( baseJobEntries.get( j ).getDescription(), "" );
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; }
@Override public void pluginRemoved( Object serviceObject ) { PluginInterface plugin = (PluginInterface) serviceObject; String pluginName = plugin.getName(); databaseTypeRemoved( pluginName ); }
List<GUIOption<Object>> leditables = new ArrayList<GUIOption<Object>>(); for ( PluginInterface plugin : plugins ) { if ( !plugin.getClassMap().keySet().contains( GUIOption.class ) ) { continue; LogChannel.GENERAL.logDebug( "Plugin " + plugin.getIds()[0] + " does not implement GUIOption, it will not be editable" ); } catch ( Exception e ) { LogChannel.GENERAL.logError( "Unexpected error loading class for plugin " + plugin.getName(), e );
PluginInterface plugin = plugins.get( i ); if ( "SPECIAL".equals( plugin.getIds()[ 0 ] ) ) { continue; Image small_image = null; String filename = plugin.getImageFile(); try { ClassLoader classLoader = registry.getClassLoader( plugin ); image = SwtSvgImageUtil.getUniversalImage( display, classLoader, filename ); } catch ( Throwable 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 ); imagesJobentries.put( plugin.getIds()[ 0 ], image ); imagesJobentriesSmall.put( plugin.getIds()[ 0 ], small_image );
private void setDeprecationAndSuggestedStep() { PluginRegistry registry = PluginRegistry.getInstance(); final List<PluginInterface> deprecatedSteps = registry.getPluginsByCategory( StepPluginType.class, BaseMessages.getString( PKG, "BaseStep.Category.Deprecated" ) ); for ( PluginInterface p : deprecatedSteps ) { String[] ids = p.getIds(); if ( !ArrayUtils.isEmpty( ids ) && ids[0].equals( this.stepid ) ) { this.isDeprecated = true; this.suggestion = registry.findPluginWithId( StepPluginType.class, this.stepid ) != null ? registry.findPluginWithId( StepPluginType.class, this.stepid ).getSuggestion() : ""; break; } } }
/** * Find the plugin ID based on the class * * @param pluginType the type of plugin * @param pluginClass The class to look for * @return The ID of the plugin to which this class belongs (checks the plugin class maps) or null if nothing was * found. */ public String getPluginId( Class<? extends PluginTypeInterface> pluginType, Object pluginClass ) { String className = pluginClass.getClass().getName(); PluginInterface plugin = getPlugins( pluginType ).stream() .filter( p -> p.getClassMap().values().contains( className ) ) .findFirst() .orElse( null ); if ( plugin != null ) { return plugin.getIds()[0]; } return extensions.stream() .map( ext -> ext.getPluginId( pluginType, pluginClass ) ) .filter( Objects::nonNull ) .findFirst() .orElse( null ); }
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(); }
lock.writeLock().lock(); try { if ( plugin.getIds()[0] == null ) { throw new KettlePluginException( "Not a valid id specified in plugin :" + plugin ); if ( !Utils.isEmpty( plugin.getCategory() ) ) { .add( plugin.getCategory() );