Author: akazakov
Date: 2010-06-28 15:58:45 -0400 (Mon, 28 Jun 2010)
New Revision: 23069
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InterceptorStereotype.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/NoInterceptorBinfdingsInInterceptor.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2708 Added new validation rule: - interceptor
declared using @Interceptor does not declare any interceptor binding (Non-Portable
behavior)
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2010-06-28
19:55:57 UTC (rev 23068)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBeanManager.java 2010-06-28
19:58:45 UTC (rev 23069)
@@ -191,7 +191,13 @@
*/
IStereotype getStereotype(IPath path);
+ /**
+ * Returns all the available intercepter binding types.
+ *
+ * @return all the available intercepter binding types
+ */
IInterceptorBinding[] getInterceptorBindings();
+
/**
* Returns interceptor binding model element for fully qualified name of
* interceptor binding annotation type
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-06-28
19:55:57 UTC (rev 23068)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-06-28
19:58:45 UTC (rev 23069)
@@ -55,6 +55,7 @@
import org.jboss.tools.cdi.core.IInjectionPointMethod;
import org.jboss.tools.cdi.core.IInjectionPointParameter;
import org.jboss.tools.cdi.core.IInterceptor;
+import org.jboss.tools.cdi.core.IInterceptorBindingDeclaration;
import org.jboss.tools.cdi.core.IParametedType;
import org.jboss.tools.cdi.core.IParameter;
import org.jboss.tools.cdi.core.IProducer;
@@ -1240,6 +1241,17 @@
for (IProducer producer : producers) {
addError(CDIValidationMessages.PRODUCER_IN_INTERCEPTOR,
CDIPreferences.PRODUCER_IN_INTERCEPTOR_OR_DECORATOR, producer.getProducesAnnotation(),
interceptor.getResource());
}
+ /*
+ * 9.2. Declaring the interceptor bindings of an interceptor
+ * - interceptor declared using @Interceptor does not declare any interceptor binding
(Non-Portable behavior)
+ */
+ Set<IInterceptorBindingDeclaration> bindings =
interceptor.getInterceptorBindings();
+ if(bindings.isEmpty()) {
+ ITextSourceReference declaration =
interceptor.getAnnotation(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
+ if(declaration!=null) {
+ addError(CDIValidationMessages.MISSING_INTERCEPTOR_BINDING,
CDIPreferences.MISSING_INTERCEPTOR_BINDING, declaration, interceptor.getResource());
+ }
+ }
}
private void validateDecorator(IDecorator decorator) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-06-28
19:55:57 UTC (rev 23068)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-06-28
19:58:45 UTC (rev 23069)
@@ -75,7 +75,7 @@
OBSERVER_IN_INTERCEPTOR_OR_DECORATOR=Interceptor or decorator has a method with a
parameter annotated @Observes
INTERCEPTOR_IS_ALTERNATIVE=Interceptor is an alternative
DECORATOR_IS_ALTERNATIVE=Decorator is an alternative
-MISSING_INTERCEPTOR_BINDING=Interceptor declared using @Interceptor does not declare any
interceptor binding
+MISSING_INTERCEPTOR_BINDING=Interceptor declared using @Interceptor should specify at
least one interceptor binding [JSR-299 �9.2]
INJECTED_DECORATOR=Injection point resolves to a decorator
INJECTED_INTERCEPTOR=Injection point resolves to an interceptor
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-06-28
19:55:57 UTC (rev 23068)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-06-28
19:58:45 UTC (rev 23069)
@@ -117,7 +117,7 @@
// {CDIPreferences.CONFLICTING_INTERCEPTOR_BINDINGS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_conflictingInterceptorBindings_label},
// {CDIPreferences.OBSERVER_IN_INTERCEPTOR_OR_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerInInterceptorOrDecorator_label},
{CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_interceptorOrDecoratorIsAlternative_label},
-// {CDIPreferences.MISSING_INTERCEPTOR_BINDING,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label},
+ {CDIPreferences.MISSING_INTERCEPTOR_BINDING,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingInterceptorBinding_label},
{CDIPreferences.INJECTED_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectedDecorator_label},
{CDIPreferences.INJECTED_INTERCEPTOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_injectedInterceptor_label},
},
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InterceptorStereotype.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InterceptorStereotype.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InterceptorStereotype.java 2010-06-28
19:58:45 UTC (rev 23069)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.interceptors;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+@Stereotype
+@CatInterceptorBinding
+@Target({ TYPE })
+@Retention(RUNTIME)
+@Documented
+public @interface InterceptorStereotype {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/InterceptorStereotype.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/NoInterceptorBinfdingsInInterceptor.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/NoInterceptorBinfdingsInInterceptor.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/NoInterceptorBinfdingsInInterceptor.java 2010-06-28
19:58:45 UTC (rev 23069)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.interceptors;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+public class NoInterceptorBinfdingsInInterceptor {
+
+ @AroundInvoke
+ public Object intercept(InvocationContext ctx) throws Exception {
+ return ctx.proceed();
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/NoInterceptorBinfdingsInInterceptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml 2010-06-28
19:55:57 UTC (rev 23068)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/interceptors/beans.xml 2010-06-28
19:58:45 UTC (rev 23069)
@@ -5,5 +5,6 @@
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.InterceptorWithWrongScopeBroken</class>
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.AlternativeInterceptorBroken</class>
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.CatInterceptor</class>
+
<class>org.jboss.jsr299.tck.tests.jdt.validation.interceptors.NoInterceptorBinfdingsInInterceptor</class>
</interceptors>
</beans>
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-06-28
19:55:57 UTC (rev 23068)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-06-28
19:58:45 UTC (rev 23069)
@@ -1156,6 +1156,20 @@
}
/**
+ * 9.2. Declaring the interceptor bindings of an interceptor
+ * - interceptor declared using @Interceptor does not declare any interceptor binding
(Non-Portable behavior)
+ *
+ * @throws Exception
+ */
+ public void testNoInterceptorBinfdingsInInterceptor() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/interceptors/NoInterceptorBinfdingsInInterceptor.java");
+ assertMarkerIsCreated(file, CDIValidationMessages.MISSING_INTERCEPTOR_BINDING, 7);
+
+ file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/interceptors/definition/SecureTransaction.java");
+ assertMarkerIsNotCreated(file, CDIValidationMessages.MISSING_INTERCEPTOR_BINDING);
+ }
+
+ /**
* 10.4.2. Declaring an observer method
* - method has more than one parameter annotated @Observes
*