Search in sources :

Example 1 with ExtensionPoint

use of org.apache.hop.core.extension.ExtensionPoint in project hop by apache.

the class BeamHop method init.

public static final void init(List<String> transformPluginClasses, List<String> xpPluginClasses) throws HopException {
    PluginRegistry registry = PluginRegistry.getInstance();
    synchronized (registry) {
        // Don't create hop config files everywhere...
        // 
        System.setProperty(Const.HOP_AUTO_CREATE_CONFIG, "N");
        // Load Hop base plugins
        // 
        HopEnvironment.init();
        XmlHandlerCache.getInstance();
        // Register extra classes from the plugins...
        // If they're already in the classpath, this should be fast.
        // 
        TransformPluginType transformPluginType = (TransformPluginType) registry.getPluginType(TransformPluginType.class);
        for (String transformPluginClassName : transformPluginClasses) {
            try {
                // Only register if it doesn't exist yet.  This is not ideal if we want to replace old
                // transforms with bug fixed new ones.
                // 
                IPlugin exists = findPlugin(registry, TransformPluginType.class, transformPluginClassName);
                if (exists == null) {
                    // Class should be in the classpath since we put it there
                    // 
                    Class<?> transformPluginClass = Class.forName(transformPluginClassName);
                    Transform annotation = transformPluginClass.getAnnotation(Transform.class);
                    // The plugin class is already in the classpath so we simply call Class.forName() on it.
                    // 
                    transformPluginType.handlePluginAnnotation(transformPluginClass, annotation, new ArrayList<>(), true, null);
                } else {
                    LOG.debug("Plugin " + transformPluginClassName + " is already registered");
                }
            } catch (Exception e) {
                LOG.error("Error registering transform plugin class : " + transformPluginClassName, e);
            }
        }
        ExtensionPointPluginType xpPluginType = (ExtensionPointPluginType) registry.getPluginType(ExtensionPointPluginType.class);
        for (String xpPluginClassName : xpPluginClasses) {
            try {
                IPlugin exists = findPlugin(registry, ExtensionPointPluginType.class, xpPluginClassName);
                // 
                if (exists == null) {
                    // Class should be in the classpath since we put it there
                    // 
                    Class<?> xpPluginClass = Class.forName(xpPluginClassName);
                    ExtensionPoint annotation = xpPluginClass.getAnnotation(ExtensionPoint.class);
                    // The plugin class is already in the classpath so we simply call Class.forName() on it.
                    xpPluginType.handlePluginAnnotation(xpPluginClass, annotation, new ArrayList<>(), true, null);
                } else {
                    LOG.debug("Plugin " + xpPluginClassName + " is already registered");
                }
            } catch (Exception e) {
                LOG.error("Error registering transform plugin class : " + xpPluginClassName, e);
            }
        }
    }
}
Also used : ExtensionPointPluginType(org.apache.hop.core.extension.ExtensionPointPluginType) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) Transform(org.apache.hop.core.annotations.Transform) HopException(org.apache.hop.core.exception.HopException)

Aggregations

Transform (org.apache.hop.core.annotations.Transform)1 HopException (org.apache.hop.core.exception.HopException)1 ExtensionPoint (org.apache.hop.core.extension.ExtensionPoint)1 ExtensionPointPluginType (org.apache.hop.core.extension.ExtensionPointPluginType)1