@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 ) ); } }
@Override public void pluginAdded( Object serviceObject ) { KettleLifecycleListener listener = null; try { listener = (KettleLifecycleListener) registry.loadClass( (PluginInterface) serviceObject ); } catch ( KettlePluginException e ) { e.printStackTrace(); return; } kettleLifecycleListeners.put( listener, false ); if ( initialized.get() ) { try { onEnvironmentInit( listener ); } catch ( Throwable e ) { // Exception is unexpected and couldn't recover Throwables.propagate( 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; }
throw new KettleStepException(e.getMessage(), e);
private Map<String, DatabaseInterface> doCreate() { LogChannelInterface log = LogChannel.GENERAL; PluginRegistry registry = PluginRegistry.getInstance(); List<PluginInterface> plugins = registry.getPlugins( DatabasePluginType.class ); HashMap<String, DatabaseInterface> tmpAllDatabaseInterfaces = new HashMap<>(); for ( PluginInterface plugin : plugins ) { try { DatabaseInterface databaseInterface = (DatabaseInterface) registry.loadClass( plugin ); databaseInterface.setPluginId( plugin.getIds()[ 0 ] ); databaseInterface.setPluginName( plugin.getName() ); tmpAllDatabaseInterfaces.put( plugin.getIds()[ 0 ], databaseInterface ); } catch ( KettlePluginException cnfe ) { // System.out.println( "Could not create connection entry for " + plugin.getName() + ". " + cnfe.getCause().getClass().getName() ); log.logError( "Could not create connection entry for " + plugin.getName() + ". " + cnfe.getCause().getClass().getName() ); if ( log.isDebug() ) { log.logDebug( "Debug-Error loading plugin: " + plugin, cnfe ); } } catch ( Exception e ) { log.logError( "Error loading plugin: " + plugin, e ); } } return Collections.unmodifiableMap( tmpAllDatabaseInterfaces ); }
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 List<SpoonUiExtenderPluginInterface> getRelevantExtenders( Class<?> clazz, String uiEvent ) { PluginRegistry instance = PluginRegistry.getInstance(); List<PluginInterface> pluginInterfaces = instance.getPlugins( SpoonUiExtenderPluginType.class ); List<SpoonUiExtenderPluginInterface> relevantPluginInterfaces = new ArrayList<SpoonUiExtenderPluginInterface>( ); if ( pluginInterfaces != null ) { for ( PluginInterface pluginInterface : pluginInterfaces ) { try { Object loadClass = instance.loadClass( pluginInterface ); SpoonUiExtenderPluginInterface spoonUiExtenderPluginInterface = (SpoonUiExtenderPluginInterface) loadClass; Set<String> events = spoonUiExtenderPluginInterface.respondsTo().get( clazz ); if ( events != null && events.contains( uiEvent ) ) { relevantPluginInterfaces.add( spoonUiExtenderPluginInterface ); } } catch ( KettlePluginException e ) { e.printStackTrace(); } } } return relevantPluginInterfaces; }
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; }
@Override public void pluginAdded( final Object serviceObject ) { try { SpoonPluginInterface spoonPluginInterface = (SpoonPluginInterface) getPluginRegistry().loadClass( (PluginInterface) serviceObject ); if ( plugins.get( serviceObject ) != null ) { return; } SpoonPluginCategories categories = spoonPluginInterface.getClass().getAnnotation( SpoonPluginCategories.class ); if ( categories != null ) { for ( String cat : categories.value() ) { List<SpoonPluginInterface> categoryList = pluginCategoryMap.get( cat ); if ( categoryList == null ) { categoryList = new ArrayList<>(); pluginCategoryMap.put( cat, categoryList ); } categoryList.add( spoonPluginInterface ); } } if ( spoonPluginInterface.getPerspective() != null ) { getSpoonPerspectiveManager().addPerspective( spoonPluginInterface.getPerspective() ); } plugins.put( serviceObject, spoonPluginInterface ); } catch ( KettlePluginException e ) { e.printStackTrace(); } }
throw new KettlePluginException( "Unable to find class loader for plugin: " + plugin ); throw new KettlePluginException( "Unexpected error loading class with name: " + className, e );
public void pluginAdded( Object serviceObject ) { LifecycleListener listener = null; try { listener = (LifecycleListener) PluginRegistry.getInstance().loadClass( (PluginInterface) serviceObject ); } catch ( KettlePluginException e ) { e.printStackTrace(); return; } lifeListeners.add( listener ); if ( started ) { try { listener.onStart( handler ); } catch ( LifecycleException e ) { e.printStackTrace(); } } }
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 );