/** * Load step attributes. * * @throws KettleException the kettle exception */ protected void loadStepAttributes() throws KettleException { try { InputStream inputStream = getClass().getResourceAsStream(STEP_ATTRIBUTES_FILE); if (inputStream != null) { Document document = XMLHandler.loadXMLFile(inputStream); Node attrsNode = XMLHandler.getSubNode(document, "attributes"); List<Node> nodes = XMLHandler.getNodes(attrsNode, "attribute"); attributes = new ArrayList<KettleAttributeInterface>(); for (Node node : nodes) { String key = XMLHandler.getTagAttribute(node, "id"); String xmlCode = XMLHandler.getTagValue(node, "xmlcode"); String repCode = XMLHandler.getTagValue(node, "repcode"); String description = XMLHandler.getTagValue(node, "description"); String tooltip = XMLHandler.getTagValue(node, "tooltip"); int valueType = ValueMeta.getType(XMLHandler.getTagValue(node, "valuetype")); String parentId = XMLHandler.getTagValue(node, "parentid"); KettleAttribute attribute = new KettleAttribute( key, xmlCode, repCode, description, tooltip, valueType, findParent(attributes, parentId)); attributes.add(attribute); } } } catch (Exception e) { throw new KettleException("Unable to load file " + STEP_ATTRIBUTES_FILE, e); } }
protected void registerXmlPlugins() throws KettlePluginException { for (PluginFolderInterface folder : pluginFolders) { if (folder.isPluginXmlFolder()) { List<FileObject> pluginXmlFiles = findPluginXmlFiles(folder.getFolder()); for (FileObject file : pluginXmlFiles) { try { Document document = XMLHandler.loadXMLFile(file); Node pluginNode = XMLHandler.getSubNode(document, "plugin"); if (pluginNode != null) { registerPluginFromXmlResource( pluginNode, KettleVFS.getFilename(file.getParent()), this.getClass(), false, file.getParent().getURL()); } } catch (Exception e) { // We want to report this plugin.xml error, perhaps an XML typo or something like // that... // log.logError( "Error found while reading step plugin.xml file: " + file.getName().toString(), e); } } } } }
/** Scan & register internal step plugins */ protected void registerNatives() throws KettlePluginException { // Scan the native steps... // String kettleStepsXmlFile = Const.XML_FILE_KETTLE_STEPS; String alternative = System.getProperty(Const.KETTLE_CORE_STEPS_FILE, null); if (!Const.isEmpty(alternative)) { kettleStepsXmlFile = alternative; } // Load the plugins for this file... // try { InputStream inputStream = getClass().getResourceAsStream(kettleStepsXmlFile); if (inputStream == null) { inputStream = getClass().getResourceAsStream("/" + kettleStepsXmlFile); } // Retry to load a regular file... if (inputStream == null && !Const.isEmpty(alternative)) { try { inputStream = new FileInputStream(kettleStepsXmlFile); } catch (Exception e) { throw new KettlePluginException( "Unable to load native step plugins '" + kettleStepsXmlFile + "'", e); } } if (inputStream == null) { throw new KettlePluginException( "Unable to find native step definition file: " + Const.XML_FILE_KETTLE_STEPS); } Document document = XMLHandler.loadXMLFile(inputStream, null, true, false); // Document document = XMLHandler.loadXMLFile(kettleStepsXmlFile); Node stepsNode = XMLHandler.getSubNode(document, "steps"); List<Node> stepNodes = XMLHandler.getNodes(stepsNode, "step"); for (Node stepNode : stepNodes) { registerPluginFromXmlResource(stepNode, null, this.getClass(), true, null); } } catch (KettleXMLException e) { throw new KettlePluginException( "Unable to read the kettle steps XML config file: " + kettleStepsXmlFile, e); } }