/** * Load the class with a certain name using the class loader of certain plugin. * * @param plugin The plugin for which we want to use the class loader * @param classType The type of class to load * @return the name of the class * @throws KettlePluginException In case there is something wrong */ @SuppressWarnings( "unchecked" ) public <T> T getClass( PluginInterface plugin, T classType ) throws KettlePluginException { String className = plugin.getClassMap().get( classType ); return (T) getClass( plugin, className ); }
protected RepositoryDialogInterface getRepositoryDialog( PluginInterface plugin, RepositoryMeta repositoryMeta, RepositoriesMeta input2, Shell shell ) throws Exception { String className = repositoryMeta.getDialogClassName(); Class<? extends RepositoryDialogInterface> dialogClass = PluginRegistry.getInstance().getClass( plugin, className ); Constructor<?> constructor = dialogClass.getConstructor( Shell.class, Integer.TYPE, RepositoryMeta.class, RepositoriesMeta.class ); return (RepositoryDialogInterface) constructor.newInstance( new Object[] { shell, Integer.valueOf( SWT.NONE ), repositoryMeta, input, } ); }
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, } ); } }
Class<StepDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<StepDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); return dialogConstructor.newInstance( paramArgs );
public JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ) { Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class }; Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta }; PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( JobEntryPluginType.class, jobEntryInterface ); String dialogClassName = plugin.getClassMap().get( JobEntryDialogInterface.class ); if ( dialogClassName == null ) { // try the deprecated way log.logDebug( "Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead." ); dialogClassName = jobEntryInterface.getDialogClassName(); } try { Class<JobEntryDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance( paramArgs ); entryDialogInterface.setMetaStore( spoon.getMetaStore() ); return entryDialogInterface; } catch ( Throwable t ) { t.printStackTrace(); String errorTitle = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title" ); String errorMsg = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName ); spoon.getLog().logError( spoon.toString(), errorMsg ); new ErrorDialog( spoon.getShell(), errorTitle, errorMsg, t ); return null; } }