예제 #1
0
 private <X> boolean validateGenericProducer(
     Annotation genericConfiguration, Bean<?> bean, AnnotatedMember<X> member) {
   Class<?> configType =
       genericConfiguration.annotationType().getAnnotation(GenericType.class).value();
   boolean valid = false;
   for (Type type : bean.getTypes()) {
     if (type instanceof Class<?>) {
       Class<?> clazz = (Class<?>) type;
       if (configType.isAssignableFrom(clazz)) {
         valid = true;
         break;
       }
     }
   }
   if (!valid) {
     AnnotatedType<X> declaringType = member.getDeclaringType();
     errors.add(
         "Generic producer method is not of correct type. Producer: "
             + declaringType.getJavaClass().getName()
             + "."
             + member.getJavaMember().getName()
             + ". Expected producer to be of type "
             + configType
             + " but was actually "
             + member.getBaseType());
   }
   return valid;
 }
 void processProducers(@Observes ProcessProducer<?, ?> event) {
   AnnotatedMember<?> member = event.getAnnotatedMember();
   if (RemoteCacheProducer.class.equals(member.getDeclaringType().getBaseType())) {
     remoteCacheProducer = (Producer<RemoteCache<?, ?>>) event.getProducer();
   }
 }