/** * Find the plugin ID based on the name of the plugin * * @param pluginType the type of plugin * @param pluginId The name to look for * @return The plugin with the specified name or null if nothing was found. */ public PluginInterface findPluginWithId( Class<? extends PluginTypeInterface> pluginType, String pluginId ) { return getPlugin( pluginType, pluginId ); }
/** * Retrieve the Plugin for a given class * * @param pluginType The type of plugin to search for * @param pluginClass The class of this object is used to look around * @return the plugin or null if nothing could be found */ public PluginInterface getPlugin( Class<? extends PluginTypeInterface> pluginType, Object pluginClass ) { String pluginId = getPluginId( pluginType, pluginClass ); if ( pluginId == null ) { return null; } return getPlugin( pluginType, pluginId ); }
public static PluginInterface getPlugin( JobEntryInterface jobEntryInterface ) { return PluginRegistry.getInstance().getPlugin( JobEntryPluginType.class, jobEntryInterface ); }
private StepMetaInterface getNewMeta() throws KettleException { PluginRegistry pluginRegistry = PluginRegistry.getInstance(); String id = pluginRegistry.getPluginId( StepPluginType.class, this ); PluginInterface plugin = pluginRegistry.getPlugin( StepPluginType.class, id ); return (StepMetaInterface) pluginRegistry.loadClass( plugin ); } }
/** * Load the class of the type specified for the plugin with the ID specified. * * @param pluginType the type of plugin * @param pluginId The plugin id to use * @param classType The type of class to load * @return the instantiated class. * @throws KettlePluginException */ public <T> T loadClass( Class<? extends PluginTypeInterface> pluginType, String pluginId, Class<T> classType ) throws KettlePluginException { PluginInterface plugin = getPlugin( pluginType, pluginId ); if ( plugin == null ) { return null; } return loadClass( plugin, classType ); }
/** * Load the class of the type specified for the plugin that owns the class of the specified object. * * @param pluginType the type of plugin * @param object The object for which we want to search the class to find the plugin * @param classType The type of class to load * @return the instantiated class. * @throws KettlePluginException */ public <T> T loadClass( Class<? extends PluginTypeInterface> pluginType, Object object, Class<T> classType ) throws KettlePluginException { PluginInterface plugin = getPlugin( pluginType, object ); if ( plugin == null ) { return null; } return loadClass( plugin, classType ); }
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(); }
protected PluginInterface getPlugin() { if ( plugin == null ) { plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); } return plugin; }
public static ValueMetaInterface createValueMeta( String name, int type, int length, int precision ) throws KettlePluginException { PluginInterface stringPlugin = pluginRegistry.getPlugin( ValueMetaPluginType.class, String.valueOf( type ) ); if ( stringPlugin == null ) { throw new KettlePluginException( "Unable to locate value meta plugin of type (id) " + type ); } ValueMetaInterface valueMeta = pluginRegistry.loadClass( stringPlugin, ValueMetaInterface.class ); valueMeta.setName( name ); valueMeta.setLength( length, precision ); return valueMeta; }
public static final RepositoryRevisionBrowserDialogInterface getVersionBrowserDialog( Shell shell, Repository repository, final RepositoryElementInterface element ) throws Exception { String className = repository.getRepositoryMeta().getRevisionBrowserDialogClassName(); PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( RepositoryPluginType.class, repository.getRepositoryMeta().getId() ); Class<? extends RepositoryRevisionBrowserDialogInterface> dialogClass = registry.getClass( plugin, className ); Constructor<?> constructor = dialogClass.getConstructor( Shell.class, Integer.TYPE, Repository.class, RepositoryElementInterface.class ); return (RepositoryRevisionBrowserDialogInterface) constructor.newInstance( new Object[] { shell, Integer.valueOf( SWT.NONE ), repository, element, } ); } }
public void registerPlugin( URLClassLoader classLoader, Class<? extends AuthenticationConsumerType> clazz ) throws KettlePluginException { AuthenticationConsumerPlugin pluginAnnotation = clazz.getAnnotation( AuthenticationConsumerPlugin.class ); AuthenticationConsumerPluginType.getInstance().handlePluginAnnotation( clazz, pluginAnnotation, new ArrayList<String>(), false, null ); PluginRegistry.getInstance().addClassLoader( classLoader, PluginRegistry.getInstance().getPlugin( AuthenticationConsumerPluginType.class, pluginAnnotation.id() ) ); }
protected Image getImage() { final PluginInterface plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); final String id = plugin.getIds()[ 0 ]; if ( id != null ) { return GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE ); } return null; }
private Image getImage() { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); String id = plugin.getIds()[ 0 ]; if ( id != null ) { return GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE ); } return null; }
private Image getImage() { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); String id = plugin.getIds()[ 0 ]; if ( id != null ) { return GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE ); } return null; } }
private Image getImage() { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); String id = plugin.getIds()[ 0 ]; if ( id != null ) { return GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.LARGE_ICON_SIZE, ConstUI.LARGE_ICON_SIZE ); } return null; } }
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(); }
/** * Add a Class Mapping + factory for a plugin. This allows extra classes to be added to existing plugins. * * @param pluginType Type of plugin * @param tClass Class to factory * @param id ID of the plugin to extend * @param callable Factory Callable * @param <T> Type of the object factoried * @throws KettlePluginException */ public <T> void addClassFactory( Class<? extends PluginTypeInterface> pluginType, Class<T> tClass, String id, Callable<T> callable ) throws KettlePluginException { String key = createSupplemantalKey( pluginType.getName(), id ); SupplementalPlugin supplementalPlugin = (SupplementalPlugin) getPlugin( pluginType, key ); if ( supplementalPlugin == null ) { supplementalPlugin = new SupplementalPlugin( pluginType, key ); registerPlugin( pluginType, supplementalPlugin ); } supplementalPlugin.addFactory( tClass, callable ); }
private void setShellImage( Shell shell ) { if ( stepMeta != null ) { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( StepPluginType.class, stepMeta.getStepMetaInterface() ); createHelpButton( shell, stepMeta, plugin ); String id = plugin.getIds()[ 0 ]; if ( id != null ) { shell.setImage( GUIResource.getInstance().getImagesSteps().get( id ).getAsBitmapForSize( shell.getDisplay(), ConstUI.ICON_SIZE, ConstUI.ICON_SIZE ) ); } } }
/** * Search for the right type of DatabaseInterface object and return it. * * @param databaseTypeDesc * the type of DatabaseInterface to look for (id or description) * @return The requested DatabaseInterface * * @throws KettleDatabaseException * when the type could not be found or referenced. */ private static final DatabaseInterface findDatabaseInterface( String databaseTypeDesc ) throws KettleDatabaseException { PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( DatabasePluginType.class, databaseTypeDesc ); if ( plugin == null ) { plugin = registry.findPluginWithName( DatabasePluginType.class, databaseTypeDesc ); } if ( plugin == null ) { throw new KettleDatabaseException( "database type with plugin id [" + databaseTypeDesc + "] couldn't be found!" ); } return getDatabaseInterfacesMap().get( plugin.getIds()[0] ); }
private void setShellImage( Shell shell ) { PluginInterface plugin = PluginRegistry.getInstance().getPlugin( PartitionerPluginType.class, partitioner.getId() ); if ( !Utils.isEmpty( plugin.getDocumentationUrl() ) ) { createHelpButton( shell, stepMeta, plugin ); } shell.setImage( GUIResource.getInstance().getImageSpoon() ); } }