Java Code Examples for org.pentaho.di.core.plugins.PluginRegistry#getPlugin()
The following examples show how to use
org.pentaho.di.core.plugins.PluginRegistry#getPlugin() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RepositoryExplorerDialog.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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, } ); }
Example 2
Source File: SpoonStepsDelegate.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public StepDialogInterface getStepDialog( StepMetaInterface stepMeta, TransMeta transMeta, String stepName ) throws KettleException { Class<?>[] paramClasses = new Class<?>[] { Shell.class, Object.class, TransMeta.class, String.class }; Object[] paramArgs = new Object[] { spoon.getShell(), stepMeta, transMeta, stepName }; PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( StepPluginType.class, stepMeta ); String dialogClassName = plugin.getClassMap().get( StepDialogInterface.class ); if ( dialogClassName == null ) { // try the deprecated way log.logDebug( "Use of StepMetaInterface#getDialogClassName is deprecated, use PluginDialog annotation instead." ); dialogClassName = stepMeta.getDialogClassName(); } try { Class<StepDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<StepDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); return dialogConstructor.newInstance( paramArgs ); } catch ( Exception e ) { // try the old way for compatibility try { Class<?>[] sig = new Class<?>[] { Shell.class, StepMetaInterface.class, TransMeta.class, String.class }; Method method = stepMeta.getClass().getDeclaredMethod( "getDialog", sig ); if ( method != null ) { log.logDebug( "Use of StepMetaInterface#getDialog is deprecated, use PluginDialog annotation instead." ); return (StepDialogInterface) method.invoke( stepMeta, paramArgs ); } } catch ( Throwable ignored ) { } String errorTitle = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingStepDialog.Title" ); String errorMsg = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingStepDialog.Message", dialogClassName ); new ErrorDialog( spoon.getShell(), errorTitle, errorMsg, e ); throw new KettleException( e ); } }
Example 3
Source File: SpoonJobDelegate.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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; } }
Example 4
Source File: DatabaseMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
/** * 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] ); }
Example 5
Source File: DatabaseMeta.java From pentaho-kettle with Apache License 2.0 | 5 votes |
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(); }
Example 6
Source File: MainBeam.java From kettle-beam with Apache License 2.0 | 4 votes |
public static final int mainMethod( final String[] args, final String environment ) { try { System.out.println( "Starting clustered transformation execution on environment: '"+environment+"'" ); System.out.println( "Transformation ktr / args[0] : " + args[ 0 ] ); System.out.println( "MetaStore JSON / args[1] : " + args[ 1 ] ); System.out.println( "Beam Job Config / args[2] : " + args[ 2 ] ); // Read the transformation XML and MetaStore from Hadoop FS // Configuration hadoopConfiguration = new Configuration(); String transMetaXml = readFileIntoString( args[ 0 ], hadoopConfiguration, "UTF-8" ); String metaStoreJson = readFileIntoString( args[ 1 ], hadoopConfiguration, "UTF-8" ); // Third argument: the beam job config // String jobConfigName = args[ 2 ]; // Inflate the metaStore... // IMetaStore metaStore = new SerializableMetaStore( metaStoreJson ); System.out.println( ">>>>>> Loading Kettle Beam Job Config '" + jobConfigName + "'" ); MetaStoreFactory<BeamJobConfig> configFactory = new MetaStoreFactory<>( BeamJobConfig.class, metaStore, PentahoDefaults.NAMESPACE ); BeamJobConfig jobConfig = configFactory.loadElement( jobConfigName ); List<String> stepPluginsList = new ArrayList<>( Arrays.asList( Const.NVL(jobConfig.getStepPluginClasses(), "").split( "," ) ) ); List<String> xpPluginsList = new ArrayList<>( Arrays.asList( Const.NVL(jobConfig.getXpPluginClasses(), "").split( "," ) ) ); System.out.println( ">>>>>> Initializing Kettle runtime (" + stepPluginsList.size() + " step classes, " + xpPluginsList.size() + " XP classes)" ); BeamKettle.init( stepPluginsList, xpPluginsList ); System.out.println( ">>>>>> Loading transformation metadata" ); TransMeta transMeta = new TransMeta( XMLHandler.loadXMLString( transMetaXml, TransMeta.XML_TAG ), null ); transMeta.setMetaStore( metaStore ); String hadoopConfDir = System.getenv( "HADOOP_CONF_DIR" ); System.out.println( ">>>>>> HADOOP_CONF_DIR='" + hadoopConfDir + "'" ); System.out.println( ">>>>>> Building Apache Beam Kettle Pipeline..." ); PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface beamInputPlugin = registry.getPlugin( StepPluginType.class, BeamConst.STRING_BEAM_INPUT_PLUGIN_ID ); if ( beamInputPlugin != null ) { System.out.println( ">>>>>> Found Beam Input step plugin class loader" ); } else { throw new KettleException( "Unable to find Beam Input step plugin, bailing out!" ); } ClassLoader pluginClassLoader = PluginRegistry.getInstance().getClassLoader( beamInputPlugin ); if ( pluginClassLoader != null ) { System.out.println( ">>>>>> Found Beam Input step plugin class loader" ); } else { System.out.println( ">>>>>> NOT found Beam Input step plugin class loader, using system classloader" ); pluginClassLoader = ClassLoader.getSystemClassLoader(); } KettleBeamPipelineExecutor executor = new KettleBeamPipelineExecutor( LogChannel.GENERAL, transMeta, jobConfig, metaStore, pluginClassLoader, stepPluginsList, xpPluginsList ); System.out.println( ">>>>>> Pipeline executing starting..." ); executor.setLoggingMetrics( true ); executor.execute( true ); System.out.println( ">>>>>> Execution finished..." ); return 0; } catch ( Exception e ) { System.err.println( "Error running Beam pipeline on '"+environment+"': " + e.getMessage() ); e.printStackTrace(); return 1; } }
Example 7
Source File: BaseSerializingMeta.java From pentaho-kettle with Apache License 2.0 | 4 votes |
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 ); }