code

The code that is invoked in the kettle extension point.

This method looks for extension point plug-ins in the plug-in registry based on the given ID. If one or more interfaces are found, their corresponding interfaces are entered immediately and the extension point method is invoked.

   ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.DatabaseConnected.id, this );
Copy the code

Underlying calling code

public void callExtensionPoint( LogChannelInterface log, String id, Object object ) throws KettleException { lock.readLock().lock(); try { if ( extensionPointPluginMap.containsRow( id ) && ! extensionPointPluginMap.rowMap().get( id ).values().isEmpty() ) { for ( Supplier<ExtensionPointInterface> extensionPoint  : extensionPointPluginMap.row( id ).values() ) { extensionPoint.get().callExtensionPoint( log, object ); } } } finally { lock.readLock().unlock(); }}Copy the code

Table<String, String, Supplier>::extensionPointPluginMap

Table

represents R row,C column,V value, respectively. Store a value under the row,column location. The actual structure of Map

> is a Map nested Map
,>
,c,v>

When extensionPointPluginMap stores the value

for ( String id : extensionPointPlugin.getIds() ) {
        extensionPointPluginMap.put( extensionPointPlugin.getName(), id, createLazyLoader( extensionPointPlugin ) );
      }
Copy the code

Deposit ExtensionPointInterface use Table manner and extensionPointPlugin: : ids.

Explain the following

  • Multiple ids are often used when you migrate two different plug-ins to one with the same functionality
  • It can also happen if you discard an old plugin and you want to have a new one to provide compatibility

closure

CreateLazyLoader literally creates lazy class loaders

Supplier<ExtensionPointInterface> createLazyLoader( PluginInterface extensionPointPlugin ) {
    return Suppliers.memoize( new ExtensionPointLoader( extensionPointPlugin ) );
  }
Copy the code

Memoize closures, Use closures to delay the execution of the code new ExtensionPointLoader(extensionPointPlugin) in the previous method callExtensionPoint extensionPoint.get().callExtensionPoint( log, object ); Get calls ExtensionPointLoader(extensionPointPlugin) and finally callExtensionPoint method of ExtensionPointInterface

PluginRegistry

ExtensionPointPluginMap stores values from PluginRegistry, and when pluginChanges are stored in PluginRegistry, extensionPointPluginMap updates the Plugin through the Listener