You can add analyzers from existing PDI non-OSGi plug-ins. For examples of custom analyzers and external resource consumers, see GitHub - pentaho/pentaho-metaverse for details.
When adding analyzers, you still need to add a compile-time dependency to the pentaho-metaverse-api JAR file and you must also create your StepAnalyzer class.
The main difference is how you register your analyzer with the rest of the
metaverse analyzers. Since this is not an OSGi bundle, the blueprint configuration is not an
option. Instead, you have to create a KettleLifecyclePlugin
which instantiates your analyzer class and registers it with PentahoSystem. The following examples illustrate registration to extract the
lineage information from documents:
- Analyzer class example for the CSV File Input step: pentaho-metaverse/CsvFileInputStepAnalyzer.java at master · pentaho/pentaho-metaverse
- External resource consumer class example for the CSV File Input step: pentaho-metaverse/CsvFileInputExternalResourceConsumer.java at master · pentaho/pentaho-metaverse
The lifecycle listener is a new plug-in:
import org.pentaho.di.core.annotations.LifecyclePlugin; import org.pentaho.di.core.lifecycle.LifeEventHandler; import org.pentaho.di.core.lifecycle.LifecycleListener; import org.pentaho.platform.engine.core.system.PentahoSystem; @LifecyclePlugin( id = "CsvFileInputPlugin", name = "CsvFileInputPlugin" ) public class CsvFileInputLifecycleListener implements LifecycleListener { CsvFileInputStepAnalyzer analyzer; CsvFileInputExternalResourceConsumer consumer; @Override public void onStart( LifeEventHandler lifeEventHandler ) { // instantiate a new analyzer analyzer = new CsvFileInputStepAnalyzer(); // construct the external resource consumer for the files that it reads from consumer = new CsvFileInputExternalResourceConsumer(); analyzer.setExternalResourceConsumer( consumer ); // register the analyzer with PentahoSystem. this also adds it to the service reference list that contains ALL IStepAnalyzers registered PentahoSystem.registerObject( analyzer ); // register the consumer with PentahoSystem. this also adds it to the service reference list that contains ALL IStepExternalResourceConsumers registered PentahoSystem.registerObject( consumer ); } @Override public void onExit( LifeEventHandler lifeEventHandler ) { } }