Search in sources :

Example 1 with Activators

use of org.qi4j.api.activation.Activators in project qi4j-sdk by Qi4j.

the class ServiceAssemblyImpl method activatorsDeclarations.

protected Iterable<Class<? extends Activator<?>>> activatorsDeclarations(Iterable<? extends Class<?>> typess) {
    // Find activator declarations
    ArrayList<Type> allTypes = new ArrayList<Type>();
    for (Class<?> type : typess) {
        Iterable<Type> types = Classes.typesOf(type);
        Iterables.addAll(allTypes, types);
    }
    // Find all activators and flattern them into an iterable
    Function<Type, Iterable<Class<? extends Activator<?>>>> function = new Function<Type, Iterable<Class<? extends Activator<?>>>>() {

        @Override
        public Iterable<Class<? extends Activator<?>>> map(Type type) {
            Activators activators = Annotations.annotationOn(type, Activators.class);
            if (activators == null) {
                return Iterables.empty();
            } else {
                return Iterables.iterable(activators.value());
            }
        }
    };
    Iterable<Class<? extends Activator<?>>> flatten = Iterables.flattenIterables(Iterables.map(function, allTypes));
    return Iterables.toList(flatten);
}
Also used : Function(org.qi4j.functional.Function) Type(java.lang.reflect.Type) Activators(org.qi4j.api.activation.Activators) Activator(org.qi4j.api.activation.Activator) ArrayList(java.util.ArrayList)

Aggregations

Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Activator (org.qi4j.api.activation.Activator)1 Activators (org.qi4j.api.activation.Activators)1 Function (org.qi4j.functional.Function)1