/** * This method allows for custom registration of plugins that are on the main classpath. This was originally created * so that test environments could register test plugins programmatically. * * @param clazz * the plugin implementation to register * @param cat * the category of the plugin * @param id * the id for the plugin * @param name * the name for the plugin * @param desc * the description for the plugin * @param image * the image for the plugin * @throws KettlePluginException */ public void registerCustom( Class<?> clazz, String cat, String id, String name, String desc, String image ) throws KettlePluginException { Class<? extends PluginTypeInterface> pluginType = getClass(); Map<Class<?>, String> classMap = new HashMap<>(); PluginMainClassType mainClassTypesAnnotation = pluginType.getAnnotation( PluginMainClassType.class ); classMap.put( mainClassTypesAnnotation.value(), clazz.getName() ); PluginInterface stepPlugin = new Plugin( new String[] { id }, pluginType, mainClassTypesAnnotation.value(), cat, name, desc, image, false, false, classMap, new ArrayList<String>(), null, null, null, null, null ); registry.registerPlugin( pluginType, stepPlugin ); }
@BeforeClass public static void setUpBeforeClass() throws Exception { KettleEnvironment.init(); // PluginRegistry.addPluginType(ValueMetaPluginType.getInstance()); PluginRegistry.getInstance().registerPluginType( ValueMetaPluginType.class ); Map<Class<?>, String> classes = new HashMap<Class<?>, String>(); classes.put( ValueMetaInterface.class, "org.pentaho.di.core.row.value.ValueMetaString" ); p1 = new Plugin( new String[] { "2" }, ValueMetaPluginType.class, ValueMetaInterface.class, "", "", "", "", false, true, classes, null, null, null ); classes = new HashMap<Class<?>, String>(); classes.put( ValueMetaInterface.class, "org.pentaho.di.core.row.value.ValueMetaInteger" ); p2 = new Plugin( new String[] { "5" }, ValueMetaPluginType.class, ValueMetaInterface.class, "", "", "", "", false, true, classes, null, null, null ); PluginRegistry.getInstance().registerPlugin( ValueMetaPluginType.class, p1 ); PluginRegistry.getInstance().registerPlugin( ValueMetaPluginType.class, p2 ); }
/** * Add a Class Mapping + factory for a plugin. This allows extra classes to be added to existing plugins. * * @param pluginType Type of plugin * @param tClass Class to factory * @param id ID of the plugin to extend * @param callable Factory Callable * @param <T> Type of the object factoried * @throws KettlePluginException */ public <T> void addClassFactory( Class<? extends PluginTypeInterface> pluginType, Class<T> tClass, String id, Callable<T> callable ) throws KettlePluginException { String key = createSupplemantalKey( pluginType.getName(), id ); SupplementalPlugin supplementalPlugin = (SupplementalPlugin) getPlugin( pluginType, key ); if ( supplementalPlugin == null ) { supplementalPlugin = new SupplementalPlugin( pluginType, key ); registerPlugin( pluginType, supplementalPlugin ); } supplementalPlugin.addFactory( tClass, callable ); }
@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 ); }
@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; } }
registry.addParentClassLoaderPatterns( plugin, parentFirstAnnotation.patterns() ); registry.registerPlugin( this.getClass(), plugin );
iconFilename, false, nativePlugin, classMap, jarFiles, errorHelpFileFull, pluginFolder, documentationUrl, casesUrl, forumUrl, suggestion ); registry.registerPlugin( pluginType, pluginInterface );
PluginRegistry.getInstance().registerPlugin( RepositoryPluginType.class, mockRepositoryPlugin );
PluginRegistry.getInstance().removePlugin( RepositoryPluginType.class, registeredPlugin ); PluginRegistry.getInstance().registerPlugin( RepositoryPluginType.class, mockRepositoryPlugin );
protected void registerExtraDatabaseType( String id, String description, String mainClass ) throws KettlePluginException { Map<Class<?>, String> classMap = new HashMap<Class<?>, String>(); classMap.put( DatabaseInterface.class, mainClass ); PluginInterface dbPlugin = new Plugin( new String[] { id }, DatabasePluginType.class, DatabaseInterface.class, "", description, description, null, false, false, classMap, new ArrayList<String>(), null, null, null, null, null ); PluginRegistry.getInstance().addClassLoader( (URLClassLoader) Thread.currentThread().getContextClassLoader().getParent(), dbPlugin ); PluginRegistry.getInstance().registerPlugin( DatabasePluginType.class, dbPlugin ); }
protected void registerExtraDatabaseType( String id, String description, String mainClass ) throws KettlePluginException { Map<Class<?>, String> classMap = new HashMap<Class<?>, String>(); classMap.put( DatabaseInterface.class, mainClass ); PluginInterface dbPlugin = new Plugin( new String[] { id }, DatabasePluginType.class, DatabaseInterface.class, "", description, description, null, false, false, classMap, new ArrayList<String>(), null, null, null, null, null ); PluginRegistry.getInstance().addClassLoader( (URLClassLoader) Thread.currentThread().getContextClassLoader().getParent(), dbPlugin ); PluginRegistry.getInstance().registerPlugin( DatabasePluginType.class, dbPlugin ); }
protected void registerExtraDatabaseType( String id, String description, String mainClass ) throws KettlePluginException { Map<Class<?>, String> classMap = new HashMap<Class<?>, String>(); classMap.put( DatabaseInterface.class, mainClass ); PluginInterface dbPlugin = new Plugin( new String[] { id }, DatabasePluginType.class, DatabaseInterface.class, "", description, description, null, false, false, classMap, new ArrayList<String>(), null, null, null, null, null ); PluginRegistry.getInstance().addClassLoader( (URLClassLoader) Thread.currentThread().getContextClassLoader().getParent(), dbPlugin ); PluginRegistry.getInstance().registerPlugin( DatabasePluginType.class, dbPlugin ); }
protected void registerExtraDatabaseType( String id, String description, String mainClass ) throws KettlePluginException { Map<Class<?>, String> classMap = new HashMap<Class<?>, String>(); classMap.put( DatabaseInterface.class, mainClass ); PluginInterface dbPlugin = new Plugin( new String[] { id }, DatabasePluginType.class, DatabaseInterface.class, "", description, description, null, false, false, classMap, new ArrayList<String>(), null, null, null, null, null ); PluginRegistry.getInstance().addClassLoader( (URLClassLoader) Thread.currentThread().getContextClassLoader().getParent(), dbPlugin ); PluginRegistry.getInstance().registerPlugin( DatabasePluginType.class, dbPlugin ); }