+ public static Set<String> getQNames(final Set<ServiceInterfaceAnnotation> siAnnotations) {
+ Set<String> names = new HashSet<>();
+ for (ServiceInterfaceAnnotation sia : siAnnotations) {
+ names.add(sia.value());
+ }
+ return ImmutableSet.copyOf(names);
+ }
+
+ public static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(final ModuleFactory factory) {
+ Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces = Collections
+ .unmodifiableSet(factory.getImplementedServiceIntefaces());
+ return getServiceInterfaceAnnotations(implementedServiceIntefaces);
+ }
+
+ private static Set<ServiceInterfaceAnnotation> getServiceInterfaceAnnotations(
+ final Set<Class<? extends AbstractServiceInterface>> implementedServiceIntefaces) {
+ Set<Class<? extends AbstractServiceInterface>> inspected = getAllAbstractServiceInterfaceClasses(
+ implementedServiceIntefaces);
+ Set<ServiceInterfaceAnnotation> result = new HashSet<>();
+ // SIs can form hierarchies, inspect superclass until it does not extend
+ // AbstractSI
+ for (Class<?> clazz : inspected) {
+ ServiceInterfaceAnnotation annotation = clazz.getAnnotation(ServiceInterfaceAnnotation.class);
+ if (annotation != null) {
+ result.add(annotation);
+ }
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ static Set<Class<? extends AbstractServiceInterface>> getAllAbstractServiceInterfaceClasses(
+ final Set<Class<? extends AbstractServiceInterface>> directlyImplementedAbstractSIs) {
+
+ Set<Class<?>> allInterfaces = getAllSuperInterfaces(directlyImplementedAbstractSIs);
+ Set<Class<? extends AbstractServiceInterface>> result = new HashSet<>();
+ for (Class<?> ifc : allInterfaces) {
+ if (AbstractServiceInterface.class.isAssignableFrom(ifc) && !ifc.equals(AbstractServiceInterface.class)) {
+ result.add((Class<? extends AbstractServiceInterface>) ifc);
+ }
+ }
+ return result;
+ }