public void addClassLoader( URLClassLoader ucl, PluginInterface plugin ) { lock.writeLock().lock(); try { Map<PluginInterface, URLClassLoader> classLoaders = classLoaderMap.computeIfAbsent( plugin.getPluginType(), k -> new HashMap<>() ); classLoaders.put( plugin, ucl ); } finally { lock.writeLock().unlock(); } }
public static String getHelpDialogTitle( PluginInterface plugin ) { if ( plugin == null ) { return ""; } String msgKey = ""; // TODO currently support only Step and JobEntry - extend if required. if ( plugin.getPluginType().equals( StepPluginType.class ) ) { msgKey = "System.ShowHelpDialog.StepPluginType.Title"; } else { msgKey = "System.ShowHelpDialog.JobEntryPluginType.Title"; } return BaseMessages.getString( PKG, msgKey, plugin.getName() ); }
Map<PluginInterface, URLClassLoader> classLoaders = classLoaderMap.get( plugin.getPluginType() ); if ( classLoaders != null ) { classLoaders.remove( plugin );
try { Map<PluginInterface, URLClassLoader> classLoaders = classLoaderMap.computeIfAbsent( plugin.getPluginType(), k -> new HashMap<>() ); ucl = classLoaders.get( plugin );
classLoaderMap.computeIfAbsent( plugin.getPluginType(), k -> new HashMap<>() ); ucl = classLoaders.get( plugin );
@Override Object doCall() throws Exception { List<PluginInterface> registered = new ArrayList<PluginInterface>( cycles ); try { for ( int i = 0; i < cycles; i++ ) { String id = nameSeed + '_' + i; PluginInterface mock = mock( PluginInterface.class ); when( mock.getName() ).thenReturn( id ); when( mock.getIds() ).thenReturn( new String[] { id } ); when( mock.getPluginType() ).thenAnswer( new Answer<Object>() { @Override public Object answer( InvocationOnMock invocation ) throws Throwable { return type; } } ); registered.add( mock ); PluginRegistry.getInstance().registerPlugin( type, mock ); } } finally { // push up registered instances for future clean-up addUsedPlugins( type, registered ); } return null; } }
@BeforeClass public static void setUpBeforeClass() throws Exception { KettleClientEnvironment.init(); dbMap.put( DatabaseInterface.class, DBMockIface.class.getName() ); dbMap.put( InfobrightDatabaseMeta.class, InfobrightDatabaseMeta.class.getName() ); PluginRegistry preg = PluginRegistry.getInstance(); mockDbPlugin = mock( PluginInterface.class ); when( mockDbPlugin.matches( anyString() ) ).thenReturn( true ); when( mockDbPlugin.isNativePlugin() ).thenReturn( true ); when( mockDbPlugin.getMainType() ).thenAnswer( (Answer<Class<?>>) invocation -> DatabaseInterface.class ); when( mockDbPlugin.getPluginType() ).thenAnswer( (Answer<Class<? extends PluginTypeInterface>>) invocation -> DatabasePluginType.class ); when( mockDbPlugin.getIds() ).thenReturn( new String[] { "Oracle", "mock-db-id" } ); when( mockDbPlugin.getName() ).thenReturn( "mock-db-name" ); when( mockDbPlugin.getClassMap() ).thenReturn( dbMap ); preg.registerPlugin( DatabasePluginType.class, mockDbPlugin ); }
T aClass = loadClass( plugin.getPluginType(), createSupplemantalKey( plugin.getPluginType().getName(), id ), pluginClass ); if ( aClass != null ) { return aClass;
if ( plugin.getPluginType().equals( StepPluginType.class ) ) { TransGraph transGraph = getActiveTransGraph(); if ( transGraph != null ) { if ( plugin.getPluginType().equals( JobEntryPluginType.class ) ) { JobGraph jobGraph = getActiveJobGraph(); if ( jobGraph != null ) {
/** * @param pluginType the type of plugin to get information for * @return a row buffer containing plugin information for the given plugin type * @throws KettlePluginException */ public RowBuffer getPluginInformation( Class<? extends PluginTypeInterface> pluginType ) throws KettlePluginException { RowBuffer rowBuffer = new RowBuffer( getPluginInformationRowMeta() ); for ( PluginInterface plugin : getPlugins( pluginType ) ) { Object[] row = new Object[getPluginInformationRowMeta().size()]; int rowIndex = 0; row[rowIndex++] = getPluginType( plugin.getPluginType() ).getName(); row[rowIndex++] = plugin.getIds()[0]; row[rowIndex++] = plugin.getName(); row[rowIndex++] = Const.NVL( plugin.getDescription(), "" ); row[rowIndex++] = Utils.isEmpty( plugin.getLibraries() ) ? "" : plugin.getLibraries().toString(); row[rowIndex++] = Const.NVL( plugin.getImageFile(), "" ); row[rowIndex++] = plugin.getClassMap().values().toString(); row[rowIndex] = Const.NVL( plugin.getCategory(), "" ); rowBuffer.getBuffer().add( row ); } return rowBuffer; }
public static ShowHelpDialog openHelpDialog( Shell shell, PluginInterface plugin ) { if ( shell == null || plugin == null ) { return null; } if ( isPluginDocumented( plugin ) ) { return openHelpDialog( shell, getHelpDialogTitle( plugin ), plugin.getDocumentationUrl(), plugin.getName() ); } else { MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_ERROR ); String msgKey = ""; // TODO currently support only Step and JobEntry - extend if required. if ( plugin.getPluginType().equals( StepPluginType.class ) ) { msgKey = "System.ShowHelpDialog.Step.HelpIsNotAvailable"; } else { msgKey = "System.ShowHelpDialog.JobEntry.HelpIsNotAvailable"; } mb.setMessage( BaseMessages.getString( PKG, msgKey, plugin.getName() ) ); mb.setText( BaseMessages.getString( PKG, "System.Dialog.Error.Title" ) ); mb.open(); } return null; }
Class<? extends PluginTypeInterface> pluginType = plugin.getPluginType(); if ( Const.classIsOrExtends( pluginType, StepPluginType.class ) ) { type = DragAndDropContainer.TYPE_BASE_STEP_TYPE;