@Override public <T> T loadClass( Class<T> pluginClass ) { if ( !factoryMap.containsKey( pluginClass ) ) { return null; } try { return (T) factoryMap.get( pluginClass ).call(); } catch ( Exception e ) { throw new RuntimeException( new KettlePluginException( "Error creating plugin class", e ) ); } }
public PluginTypeInterface getPluginType( Class<? extends PluginTypeInterface> pluginTypeClass ) throws KettlePluginException { try { // All these plugin type interfaces are singletons... // So we should call a static getInstance() method... // Method method = pluginTypeClass.getMethod( "getInstance", new Class<?>[0] ); return (PluginTypeInterface) method.invoke( null, new Object[0] ); } catch ( Exception e ) { throw new KettlePluginException( "Unable to get instance of plugin type: " + pluginTypeClass.getName(), e ); } }
public static ValueMetaInterface createValueMeta( String name, int type, int length, int precision ) throws KettlePluginException { PluginInterface stringPlugin = pluginRegistry.getPlugin( ValueMetaPluginType.class, String.valueOf( type ) ); if ( stringPlugin == null ) { throw new KettlePluginException( "Unable to locate value meta plugin of type (id) " + type ); } ValueMetaInterface valueMeta = pluginRegistry.loadClass( stringPlugin, ValueMetaInterface.class ); valueMeta.setName( name ); valueMeta.setLength( length, precision ); return valueMeta; }
throw new KettlePluginException( "Unable to find class loader for plugin: " + plugin ); throw new KettlePluginException( "Unexpected error loading class with name: " + className, e );
try { if ( plugin.getIds()[0] == null ) { throw new KettlePluginException( "Not a valid id specified in plugin :" + plugin );
protected void registerPluginJars() throws KettlePluginException { List<JarFileAnnotationPlugin> jarFilePlugins = findAnnotatedClassFiles( pluginType.getName() ); for ( JarFileAnnotationPlugin jarFilePlugin : jarFilePlugins ) { URLClassLoader urlClassLoader = createUrlClassLoader( jarFilePlugin.getJarFile(), getClass().getClassLoader() ); try { Class<?> clazz = urlClassLoader.loadClass( jarFilePlugin.getClassName() ); if ( clazz == null ) { throw new KettlePluginException( "Unable to load class: " + jarFilePlugin.getClassName() ); } List<String> libraries = Arrays.stream( urlClassLoader.getURLs() ) .map( URL::getFile ) .collect( Collectors.toList() ); Annotation annotation = clazz.getAnnotation( pluginType ); handlePluginAnnotation( clazz, annotation, libraries, false, jarFilePlugin.getPluginFolder() ); } catch ( Exception e ) { // Ignore for now, don't know if it's even possible. LogChannel.GENERAL.logError( "Unexpected error registering jar plugin file: " + jarFilePlugin.getJarFile(), e ); } finally { if ( urlClassLoader != null && urlClassLoader instanceof KettleURLClassLoader ) { ( (KettleURLClassLoader) urlClassLoader ).closeClassLoader(); } } } }
throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.NoValidStepOrPlugin.PLUGINREGISTRY001" ) ); throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.MalformedURL.PLUGINREGISTRY006" ), e ); } catch ( Throwable e ) { e.printStackTrace(); throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.UnExpectedCreatingClassLoader.PLUGINREGISTRY008" ), e );
public <T> T loadClass( PluginInterface plugin, Class<T> pluginClass ) throws KettlePluginException { if ( plugin == null ) { throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.NoValidStepOrPlugin.PLUGINREGISTRY001" ) ); throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.ClassNotFound.PLUGINREGISTRY003" ), e ); } catch ( InstantiationException e ) { throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.UnableToInstantiateClass.PLUGINREGISTRY004" ), e ); } catch ( IllegalAccessException e ) { throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.IllegalAccessToClass.PLUGINREGISTRY005" ), e ); } catch ( Throwable e ) { e.printStackTrace(); throw new KettlePluginException( BaseMessages.getString( PKG, "PluginRegistry.RuntimeError.UnExpectedErrorLoadingClass.PLUGINREGISTRY007" ), e );
throw new KettlePluginException( "Unable to find standard kettle variables definition file: " + Const.KETTLE_VARIABLES_FILE );
inputStream = getFileInputStreamExternal( xmlFile ); } catch ( Exception e ) { throw new KettlePluginException( "Unable to load native plugins '" + xmlFile + "'", e ); return; } else { throw new KettlePluginException( "Unable to find native plugins definition file: " + xmlFile ); throw new KettlePluginException( "Unable to read the kettle XML config file: " + xmlFile, e ); } finally { IOUtils.closeQuietly( inputStream );
throw new KettlePluginException( "No ID specified for plugin with class: " + clazz.getName() );
throw new KettlePluginException( BaseMessages.getString( PKG, "BasePluginType.RuntimeError.UnableToReadPluginXML.PLUGIN0001" ), e );
public static AuthenticationManager getAuthenticationManager() { AuthenticationManager manager = new AuthenticationManager(); manager.registerAuthenticationProvider( new NoAuthenticationAuthenticationProvider() ); // TODO: Register providers from metastore for ( PluginInterface plugin : PluginRegistry.getInstance().getPlugins( AuthenticationConsumerPluginType.class ) ) { try { Object pluginMain = PluginRegistry.getInstance().loadClass( plugin ); if ( pluginMain instanceof AuthenticationConsumerType ) { Class<? extends AuthenticationConsumer<?, ?>> consumerClass = ( (AuthenticationConsumerType) pluginMain ).getConsumerClass(); manager.registerConsumerClass( consumerClass ); } else { throw new KettlePluginException( BaseMessages.getString( PKG, "AuthenticationPersistenceManager.NotConsumerType", pluginMain, AuthenticationConsumerType.class ) ); } } catch ( KettlePluginException e ) { log.logError( e.getMessage(), e ); } catch ( AuthenticationFactoryException e ) { log.logError( e.getMessage(), e ); } } return manager; }
String driverClassName = getChildString( element, MetaStoreConst.DB_ATTR_DRIVER_CLASS ); if ( Utils.isEmpty( pluginId ) && Utils.isEmpty( driverClassName ) ) { throw new KettlePluginException( "The attributes 'plugin_id' and 'driver_class' can't be both empty" ); throw new KettlePluginException( "The 'plugin_id' attribute could not be determined using 'driver_class' value '" + driverClassName + "'" );
String idList = extractID( annotation ); if ( Const.isEmpty( idList ) ) { throw new KettlePluginException( "No ID specified for plugin with class: " + clazz.getName() ); urls[i] = new URL( URLDecoder.decode( jarfile.toURI().toURL().toString(), "UTF-8" ) ); } catch ( Exception e ) { throw new KettlePluginException( e ); throw new KettlePluginException( e );
pluginRegistry.wait(); } catch ( InterruptedException e ) { throw new KettlePluginException( e );