winegrower-cepages/winegrower-cepage-osgi-cdi/src/main/java/org/apache/winegrower/scanner/manifest/OSGiCDIManifestContributor.java
private String findCdiExtensions(final AnnotationFinder finder) {
        try {
            final ClassLoader loader = ofNullable(Thread.currentThread().getContextClassLoader())
                    .orElseGet(ClassLoader::getSystemClassLoader);
            final Class<? extends Annotation> singular = (Class<? extends Annotation>)
                    loader.loadClass("org.apache.aries.cdi.extra.RequireCDIExtension");
            final Class<? extends Annotation> plural = (Class<? extends Annotation>)
                    loader.loadClass("org.apache.aries.cdi.extra.RequireCDIExtensions");
            final Method value = singular.getMethod("value");
            return Stream.concat(
                    finder.findAnnotatedClasses(plural).stream(),
                    finder.findAnnotatedClasses(singular).stream())
                    .distinct()
                    .flatMap(c -> Stream.of(c.getAnnotationsByType(singular)))
                    .map(rce -> {
                        try {
                            final Object extension = value.invoke(rce);
                            return "osgi.cdi.extension;filter:=\"(osgi.cdi.extension=" + extension + ")\"";
                        } catch (final IllegalAccessException e) {
                            throw new IllegalStateException(e);
                        } catch (final InvocationTargetException e) {
                            throw new IllegalStateException(e.getTargetException());
                        }
                    })
                    .collect(joining(","));
        } catch (final Exception cnfe) {
            return null;
        }
    }
// todo: drop and handle @Requirement transitively in core
drop and handle @Requirement transitively in core
drop and handle @Requirement transitively in core
private String findCdiExtensions(final AnnotationFinder finder) {
        try {
            final ClassLoader loader = ofNullable(Thread.currentThread().getContextClassLoader())
                    .orElseGet(ClassLoader::getSystemClassLoader);
            final Class<? extends Annotation> singular = (Class<? extends Annotation>)
                    loader.loadClass("org.apache.aries.cdi.extra.RequireCDIExtension");
            final Class<? extends Annotation> plural = (Class<? extends Annotation>)
                    loader.loadClass("org.apache.aries.cdi.extra.RequireCDIExtensions");
            final Method value = singular.getMethod("value");
            return Stream.concat(
                    finder.findAnnotatedClasses(plural).stream(),
                    finder.findAnnotatedClasses(singular).stream())
                    .distinct()
                    .flatMap(c -> Stream.of(c.getAnnotationsByType(singular)))
                    .map(rce -> {
                        try {
                            final Object extension = value.invoke(rce);
                            return "osgi.cdi.extension;filter:=\"(osgi.cdi.extension=" + extension + ")\"";
                        } catch (final IllegalAccessException e) {
                            throw new IllegalStateException(e);
                        } catch (final InvocationTargetException e) {
                            throw new IllegalStateException(e.getTargetException());
                        }
                    })
                    .collect(joining(","));
        } catch (final Exception cnfe) {
            return null;
        }
    }
private String findCdiExtensions ( final AnnotationFinder finder ) { try { final ClassLoader loader = ofNullable ( Thread . currentThread ( ) . getContextClassLoader ( ) ) . orElseGet ( ClassLoader :: getSystemClassLoader ) ; final Class < ? extends Annotation > singular = ( Class < ? extends Annotation > ) loader . loadClass ( "org.apache.aries.cdi.extra.RequireCDIExtension" ) ; final Class < ? extends Annotation > plural = ( Class < ? extends Annotation > ) loader . loadClass ( "org.apache.aries.cdi.extra.RequireCDIExtensions" ) ; final Method value = singular . getMethod ( "value" ) ; return Stream . concat ( finder . findAnnotatedClasses ( plural ) . stream ( ) , finder . findAnnotatedClasses ( singular ) . stream ( ) ) . distinct ( ) . flatMap ( c -> Stream . of ( c . getAnnotationsByType ( singular ) ) ) . map ( rce -> { try { final Object extension = value . invoke ( rce ) ; return "osgi.cdi.extension;filter:=\"(osgi.cdi.extension=" + extension + ")\"" ; } catch ( final IllegalAccessException e ) { throw new IllegalStateException ( e ) ; } catch ( final InvocationTargetException e ) { throw new IllegalStateException ( e . getTargetException ( ) ) ; } } ) . collect ( joining ( "," ) ) ; } catch ( final Exception cnfe ) { return null ; } }
todo: drop and handle @Requirement transitively in core
todo : drop and handle @Requirement transitively in core