[weld-commits] Weld SVN: r6058 - in core/trunk/impl/src/main: java/org/jboss/weld/logging/messages and 1 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Mar 18 19:11:16 EDT 2010


Author: nickarls
Date: 2010-03-18 19:11:16 -0400 (Thu, 18 Mar 2010)
New Revision: 6058

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
   core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java
   core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties
Log:
WELD-397

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java	2010-03-17 20:32:20 UTC (rev 6057)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/Validator.java	2010-03-18 23:11:16 UTC (rev 6058)
@@ -16,6 +16,9 @@
  */
 package org.jboss.weld.bootstrap;
 
+import static org.jboss.weld.logging.Category.BOOTSTRAP;
+import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
+import static org.jboss.weld.logging.messages.ValidatorMessage.SCOPE_ANNOTATION_ON_INJECTION_POINT;
 import static org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_BEAN_CLASS_NOT_ANNOTATED;
 import static org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_BEAN_CLASS_SPECIFIED_MULTIPLE_TIMES;
 import static org.jboss.weld.logging.messages.ValidatorMessage.ALTERNATIVE_STEREOTYPE_NOT_ANNOTATED;
@@ -64,6 +67,7 @@
 import java.util.Set;
 
 import javax.enterprise.context.Dependent;
+import javax.enterprise.context.NormalScope;
 import javax.enterprise.event.Event;
 import javax.enterprise.inject.Alternative;
 import javax.enterprise.inject.Disposes;
@@ -76,6 +80,7 @@
 import javax.enterprise.inject.spi.InjectionTarget;
 import javax.enterprise.inject.spi.Interceptor;
 import javax.inject.Named;
+import javax.inject.Scope;
 
 import org.jboss.interceptor.model.InterceptionModel;
 import org.jboss.weld.bean.AbstractClassBean;
@@ -100,6 +105,7 @@
 import org.jboss.weld.util.Beans;
 import org.jboss.weld.util.Proxies;
 import org.jboss.weld.util.reflection.Reflections;
+import org.slf4j.cal10n.LocLogger;
 
 import com.google.common.base.Supplier;
 import com.google.common.collect.Multimaps;
@@ -114,6 +120,8 @@
 public class Validator implements Service
 {
 
+   private static final LocLogger log = loggerFactory().getLogger(BOOTSTRAP);   
+   
    private void validateBean(Bean<?> bean, BeanManagerImpl beanManager)
    {
       for (InjectionPoint ij : bean.getInjectionPoints())
@@ -206,7 +214,7 @@
          {
             for (SerializableContextual<Interceptor<?>, ?> serializableContextual : interceptors)
             {
-               if (!((InterceptorImpl<?>)serializableContextual.get()).isSerializable())
+               if (!((InterceptorImpl<?>) serializableContextual.get()).isSerializable())
                {
                   throw new DeploymentException(PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR, classBean, serializableContextual.get());
                }
@@ -224,7 +232,7 @@
    {
       for (Decorator<?> decorator : classBean.getDecorators())
       {
-         if (!((WeldDecorator<?>)decorator).getWeldAnnotated().isSerializable())
+         if (!((WeldDecorator<?>) decorator).getWeldAnnotated().isSerializable())
          {
             throw new UnserializableDependencyException(PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR, classBean, decorator);
          }
@@ -266,6 +274,7 @@
       {
          throw new DefinitionException(NON_FIELD_INJECTION_POINT_CANNOT_USE_NAMED, ij);
       }
+      checkScopeAnnotations(ij, beanManager.getServices().get(MetaAnnotationStore.class));
       checkFacadeInjectionPoint(ij, Instance.class);
       checkFacadeInjectionPoint(ij, Event.class);
       Annotation[] bindings = ij.getQualifiers().toArray(new Annotation[0]);
@@ -297,6 +306,23 @@
       }
    }
 
+   private void checkScopeAnnotations(InjectionPoint ij, MetaAnnotationStore metaAnnotationStore)
+   {
+      for (Annotation annotation : ij.getAnnotated().getAnnotations())
+      {
+         if (hasScopeMetaAnnotation(annotation))
+         {
+            log.warn(SCOPE_ANNOTATION_ON_INJECTION_POINT, annotation, ij);
+         }
+      }
+   }
+
+   private boolean hasScopeMetaAnnotation(Annotation annotation)
+   {
+      Class<? extends Annotation> annotationType = annotation.annotationType();
+      return annotationType.isAnnotationPresent(Scope.class) || annotationType.isAnnotationPresent(NormalScope.class);
+   }
+
    public void validateInjectionPointPassivationCapable(InjectionPoint ij, Bean<?> resolvedBean, BeanManagerImpl beanManager)
    {
       if (!ij.isTransient() && !Beans.isPassivationCapableDependency(resolvedBean))
@@ -340,7 +366,8 @@
    {
       for (Interceptor<?> interceptor : interceptors)
       {
-         // TODO: confirm that producer methods, fields and disposers can be only found on Weld interceptors?
+         // TODO: confirm that producer methods, fields and disposers can be
+         // only found on Weld interceptors?
          if (interceptor instanceof InterceptorImpl)
          {
             if (!((InterceptorImpl<?>) interceptor).getWeldAnnotated().getWeldMethods(Produces.class).isEmpty())
@@ -532,7 +559,7 @@
       }
 
    }
-   
+
    private static boolean isInjectionPointSatisfied(InjectionPoint ij, Set<?> resolvedBeans, BeanManagerImpl beanManager)
    {
       if (ij.getBean() instanceof Decorator<?>)

Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java	2010-03-17 20:32:20 UTC (rev 6057)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ValidatorMessage.java	2010-03-18 23:11:16 UTC (rev 6058)
@@ -17,10 +17,7 @@
 
 package org.jboss.weld.logging.messages;
 
-import java.lang.reflect.Modifier;
-
 import org.jboss.weld.logging.MessageId;
-import org.jboss.weld.util.reflection.Reflections;
 
 import ch.qos.cal10n.BaseName;
 import ch.qos.cal10n.Locale;
@@ -40,7 +37,6 @@
  */
 public enum ValidatorMessage
 {
-//   @MessageId("001400") NOT_PROXYABLE,
    @MessageId("001401") BEAN_SPECIALIZED_TOO_MANY_TIMES,
    @MessageId("001402") PASSIVATING_BEAN_WITH_NONSERIALIZABLE_INTERCEPTOR,
    @MessageId("001403") PASSIVATING_BEAN_WITH_NONSERIALIZABLE_DECORATOR,
@@ -79,5 +75,6 @@
    @MessageId("001436") NOT_PROXYABLE_PRIVATE_CONSTRUCTOR,
    @MessageId("001437") NOT_PROXYABLE_FINAL_TYPE_OR_METHOD,
    @MessageId("001438") NOT_PROXYABLE_PRIMITIVE,
-   @MessageId("001439") NOT_PROXYABLE_ARRAY_TYPE;   
+   @MessageId("001439") NOT_PROXYABLE_ARRAY_TYPE,
+   @MessageId("001440") SCOPE_ANNOTATION_ON_INJECTION_POINT;
 }

Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties	2010-03-17 20:32:20 UTC (rev 6057)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/validator_en.properties	2010-03-18 23:11:16 UTC (rev 6058)
@@ -36,4 +36,5 @@
 NOT_PROXYABLE_PRIVATE_CONSTRUCTOR=Normal scoped bean {0} is not proxyable because it has a private no-args constructor {1}.
 NOT_PROXYABLE_FINAL_TYPE_OR_METHOD=Normal scoped bean {0} is not proxyable because the type is private or it contains a prive method {1}.
 NOT_PROXYABLE_PRIMITIVE=Normal scoped bean {0} is not proxyable because it is a primitive
-NOT_PROXYABLE_ARRAY_TYPE=Normal scoped bean {0} is not proxyable because it is an array type
\ No newline at end of file
+NOT_PROXYABLE_ARRAY_TYPE=Normal scoped bean {0} is not proxyable because it is an array type
+SCOPE_ANNOTATION_ON_INJECTION_POINT=Scope type {0} used on injection point {1}
\ No newline at end of file



More information about the weld-commits mailing list