private void registerScrComponentsIfNeeded()

in knights/winegrower-knight/src/main/java/org/apache/geronimo/arthur/knight/winegrower/WinegrowerExtension.java [287:306]


    private void registerScrComponentsIfNeeded(final String source, final InputStream stream, final Collection<Class<?>> classes,
                                               final Context context) {
        try {
            ensureXmlIsInitialized();

            final Document document = documentBuilderFactory.newDocumentBuilder().parse(stream);

            xpath.reset();
            final String implementation = xpath.evaluate("/*[local-name()='component']/implementation/@class", document.getDocumentElement());
            if (implementation != null && !implementation.isEmpty()) {
                context.findHierarchy(context.loadClass(implementation)).forEach(classes::add);
            }
        } catch (final XPathExpressionException | ParserConfigurationException | IOException e) {
            throw new IllegalStateException(e);
        } catch (final SAXException sax) {
            log.warn("Can't read xml {}", source);
        } catch (final IllegalStateException e) {
            log.info("Missing class: {}", e.getMessage());
        }
    }