private void tryToRegisterSPI()

in knights/derby-knight/src/main/java/org/apache/geronimo/arthur/knight/derby/DerbyExtension.java [370:402]


    private void tryToRegisterSPI(final Context context) {
        final ClassLoader loader = Thread.currentThread().getContextClassLoader();
        ofNullable(loader.getResourceAsStream("org/apache/derby/modules.properties"))
                .map(res -> {
                    final Properties properties = new Properties();
                    try (final InputStream s = res) {
                        properties.load(s);
                    } catch (final IOException e) {
                        throw new IllegalStateException(e);
                    }
                    return properties;
                })
                .ifPresent(props -> props.stringPropertyNames().stream()
                        .map(props::getProperty)
                        .flatMap(it -> Stream.of(it.split(",")))
                        .map(String::trim)
                        .filter(it -> !it.isEmpty())
                        .map(it -> {
                            try {
                                return context.loadClass(it);
                            } catch (final IllegalStateException ise) {
                                return null;
                            }
                        })
                        .filter(Objects::nonNull)
                        .flatMap(context::findHierarchy)
                        .forEach(it -> {
                            final ClassReflectionModel model = new ClassReflectionModel();
                            model.setName(it.getName());
                            model.setAllDeclaredConstructors(true);
                            context.register(model);
                        }));
    }