[jbosstools-commits] JBoss Tools SVN: r22088 - in trunk/cdi: plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences and 1 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Fri May 14 10:55:26 EDT 2010
Author: akazakov
Date: 2010-05-14 10:55:26 -0400 (Fri, 14 May 2010)
New Revision: 22088
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/errorList.txt
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/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2708 Added new CDI validation rule: session bean class annotated @Specializes does not directly extend the bean class of another session bean
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-05-14 14:11:58 UTC (rev 22087)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-14 14:55:26 UTC (rev 22088)
@@ -771,6 +771,21 @@
CDICorePlugin.getDefault().logError(e);
}
}
+ /*
+ * 3.2.4. Specializing a session bean
+ * - session bean class annotated @Specializes does not directly extend the bean class of another session bean
+ */
+ IAnnotationDeclaration specializesDeclaration = bean.getSpecializesAnnotationDeclaration();
+ if(specializesDeclaration!=null) {
+ IBean sBean = bean.getSpecializedBean();
+ if(sBean==null) {
+ // The specializing bean extends nothing
+ addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_SESSION_BEAN, CDIPreferences.ILLEGAL_SPECIALIZING_SESSION_BEAN, specializesDeclaration, bean.getResource());
+ } else if(!CDIUtil.isSessionBean(sBean)) {
+ // The specializing bean directly extends a non-session bean class
+ addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_SESSION_BEAN, CDIPreferences.ILLEGAL_SPECIALIZING_SESSION_BEAN, specializesDeclaration, bean.getResource());
+ }
+ }
}
private void validateManagedBean(IClassBean bean) {
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-05-14 14:11:58 UTC (rev 22087)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-05-14 14:55:26 UTC (rev 22088)
@@ -39,11 +39,6 @@
- managed bean class annotated @Specializes does not directly extend
the bean class of another managed bean
-
-
-
-
-
3.2. Session beans
- session bean specifies an illegal scope (a stateless session bean must belong
to the @Dependent pseudo-scope; a singleton bean must belong to either the
@@ -52,14 +47,14 @@
- bean class of a session bean is annotated @Interceptor or @Decorator
- session bean with a parameterized bean class declares any scope other than @Dependent
+3.2.4. Specializing a session bean
+- session bean class annotated @Specializes does not directly extend
+ the bean class of another session bean
-3.2.4. Specializing a session bean
-- session bean class annotated @Specializes does not directly extend
- the bean class of another session bean
3.3. Producer methods
- producer method return type contains a wildcard type parameter
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-05-14 14:11:58 UTC (rev 22087)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-14 14:55:26 UTC (rev 22088)
@@ -123,7 +123,7 @@
CDIPreferencesMessages.CDIValidatorConfigurationBlock_section_specializing,
new String[][]{
{CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalSpecializingManagedBean_label},
-// {CDIPreferences.ILLEGAL_SPECIALIZING_SESSION_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalSpecializingSessionBean_label},
+ {CDIPreferences.ILLEGAL_SPECIALIZING_SESSION_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalSpecializingSessionBean_label},
// {CDIPreferences.ILLEGAL_SPECIALIZING_PRODUCER, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalSpecializingProducer_label},
// {CDIPreferences.MISSING_TYPE_IN_SPECIALIZING_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingTypeInSpecializingBean_label},
// {CDIPreferences.CONFLICTING_NAME_IN_SPECIALIZING_BEAN, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_conflictingNameInSpecializingBean_label},
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-05-14 14:11:58 UTC (rev 22087)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-14 14:55:26 UTC (rev 22088)
@@ -384,6 +384,39 @@
}
/**
+ * 3.2.4. Specializing a session bean
+ * - session bean class annotated @Specializes does not directly extend the bean class of another session bean
+ *
+ * @throws Exception
+ */
+ public void testSpecializingClassDirectlyExtendsSimpleBean() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/inheritance/specialization/enterprise/broken/directlyExtendsSimpleBean/Tractor_Broken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.ILLEGAL_SPECIALIZING_SESSION_BEAN, 22);
+ }
+
+ /**
+ * 3.2.4. Specializing a session bean
+ * - session bean class annotated @Specializes does not directly extend the bean class of another session bean
+ *
+ * @throws Exception
+ */
+ public void testSpecializingEnterpriseClassImplementsInterfaceAndExtendsNothing() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/inheritance/specialization/enterprise/broken/implementInterfaceAndExtendsNothing/Donkey_Broken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.ILLEGAL_SPECIALIZING_SESSION_BEAN, 22);
+ }
+
+ /**
+ * 3.2.4. Specializing a session bean
+ * - session bean class annotated @Specializes does not directly extend the bean class of another session bean
+ *
+ * @throws Exception
+ */
+ public void testSpecializingEnterpriseClassDirectlyExtendsNothing() throws Exception {
+ IFile file = tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/inheritance/specialization/enterprise/broken/directlyExtendsNothing/Cow_Broken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file, AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.ILLEGAL_SPECIALIZING_SESSION_BEAN, 22);
+ }
+
+ /**
* 3.5.1. Declaring a resource
* - producer field declaration specifies an EL name (together with one of @Resource, @PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
*
More information about the jbosstools-commits
mailing list