public Optional<Document> getPomXmlContent(BiConsumer<String, Throwable> context, DeployLogger logger, JarFile jar) {
        return jar.stream()
                .filter(f -> POM_FILE_LOCATION.matcher(f.getName()).matches())
                .findFirst()
                .map(f -> {
                    try {
                        String text = new String(jar.getInputStream(f).readAllBytes());
                        return XML.getDocumentBuilder(false)
                                .parse(new InputSource(new StringReader(text)));
                    } catch (SAXException e) {
                        String message = String.format("Unable to parse pom.xml from %s", filename(jar));
                        logger.log(Level.SEVERE, message);
                        context.accept(message, e);
                    } catch (IOException e) {
                        logger.log(Level.INFO,
                                String.format("Unable to read '%s' from '%s'", f.getName(), jar.getName()));
                    }
                    return null;
                });
    }
Base class for OSGi bundle validator.

@author bjorncs
config-model/src/main/java/com/yahoo/vespa/model/application/validation/AbstractBundleValidator.java