Author: akazakov
Date: 2011-03-10 14:31:11 -0500 (Thu, 10 Mar 2011)
New Revision: 29662
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.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/CDIValidationMessages.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.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/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/WeldJarTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
Log:
https://issues.jboss.org/browse/JBIDE-3126: Validate the serializability of beans injected
into passivating-scoped beans.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferenceInitializer.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -51,6 +51,7 @@
defaultPreferences.put(CDIPreferences.ILLEGAL_CONDITIONAL_OBSERVER,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIPreferences.WARNING);
defaultPreferences.put(CDIPreferences.DECORATOR_RESOLVES_TO_FINAL_BEAN,
CDIPreferences.WARNING);
+ defaultPreferences.put(CDIPreferences.NOT_PASSIVATION_CAPABLE_BEAN,
CDIPreferences.WARNING);
// defaultPreferences.put(CDIPreferences.INCONSISTENT_SPECIALIZATION,
CDIPreferences.WARNING);
defaultPreferences.putInt(SeverityPreferences.MAX_NUMBER_OF_MARKERS_PREFERENCE_NAME,
SeverityPreferences.DEFAULT_MAX_NUMBER_OF_MARKERS_PER_FILE);
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -81,7 +81,10 @@
public static final String MISSING_NONBINDING_IN_INTERCEPTOR_BINDING_TYPE_MEMBER =
INSTANCE.createSeverityOption("missingNonbindingInInterceptorBindingTypeMember");
//$NON-NLS-1$
public static final String MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE =
INSTANCE.createSeverityOption("missingOrIncorrectTargetOrRetentionInAnnotationType");
//$NON-NLS-1$
-
+// Section 6.6.4 - Validation of passivation capable beans and dependencies
+// - If a managed bean which declares a passivating scope is not passivation capable,
then the container automatically detects the problem and treats it as a deployment
problem.
+ public static final String NOT_PASSIVATION_CAPABLE_BEAN =
INSTANCE.createSeverityOption("notPassivationCapableBean"); //$NON-NLS-1$
+
//Scope group
// - bean class or producer method or field specifies multiple scope type annotations
(2.4.3)
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 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -1689,12 +1689,13 @@
CDICorePlugin.getDefault().logError(e);
}
}
- /*
- * 9.3. Binding an interceptor to a bean
- * - managed bean has a class level interceptor binding and is declared final or has a
non-static, non-private, final method
- * - non-static, non-private, final method of a managed bean has a method level
interceptor binding
- */
+
try {
+ /*
+ * 9.3. Binding an interceptor to a bean
+ * - managed bean has a class level interceptor binding and is declared final or has
a non-static, non-private, final method
+ * - non-static, non-private, final method of a managed bean has a method level
interceptor binding
+ */
Set<IInterceptorBinding> bindings = bean.getInterceptorBindings();
if(!bindings.isEmpty()) {
if(Flags.isFinal(bean.getBeanClass().getFlags())) {
@@ -1728,6 +1729,42 @@
}
}
}
+
+ /*
+ * 6.6.4 Validation of passivation capable beans and dependencies
+ * - If a managed bean which declares a passivating scope is not passivation capable,
then the container automatically detects the problem and treats it as a deployment
problem.
+ */
+ IScope scope = bean.getScope();
+ if(scope!=null && scope.isNorlmalScope()) {
+ IAnnotationDeclaration normalScopeDeclaration =
scope.getAnnotationDeclaration(CDIConstants.NORMAL_SCOPE_ANNOTATION_TYPE_NAME);
+ if(normalScopeDeclaration!=null) {
+ IAnnotation annt = normalScopeDeclaration.getDeclaration();
+ if(annt!=null) {
+ boolean passivatingScope = false;
+ IMemberValuePair[] pairs = annt.getMemberValuePairs();
+ for (IMemberValuePair pair : pairs) {
+ if("passivating".equals(pair.getMemberName()) &&
"true".equalsIgnoreCase("" + pair.getValue())) {
+ passivatingScope = true;
+ break;
+ }
+ }
+ if(passivatingScope) {
+ boolean passivatingCapable = false;
+ Set<IParametedType> supers = bean.getAllTypes();
+ for (IParametedType type : supers) {
+ if("java.io.Serializable".equals(type.getType().getFullyQualifiedName()))
{
+ passivatingCapable = true;
+ break;
+ }
+ }
+ if(!passivatingCapable) {
+ ITextSourceReference reference =
CDIUtil.convertToSourceReference(bean.getBeanClass().getNameRange());
+ addError(MessageFormat.format(CDIValidationMessages.NOT_PASSIVATION_CAPABLE_BEAN,
bean.getSimpleJavaName(), scope.getSourceType().getElementName()),
CDIPreferences.NOT_PASSIVATION_CAPABLE_BEAN, reference, bean.getResource());
+ }
+ }
+ }
+ }
+ }
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -65,6 +65,7 @@
public static String ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF;
public static String ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE;
public static String ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE;
+ public static String NOT_PASSIVATION_CAPABLE_BEAN;
public static String MULTIPLE_SCOPE_TYPE_ANNOTATIONS;
public static String MULTIPLE_SCOPE_TYPE_ANNOTATIONS_IN_BEAN_CLASS;
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 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2011-03-10
19:31:11 UTC (rev 29662)
@@ -211,6 +211,9 @@
c) Primitive types cannot be proxied by the container.
d) Array types cannot be proxied by the container.
+6.6.4 Validation of passivation capable beans and dependencies
+- If a managed bean which declares a passivating scope is not passivation capable, then
the container automatically detects the problem and treats it as a deployment problem.
+
8.3. Decorator resolution
- If a decorator matches a managed bean, and the managed bean class is declared final,
the container automatically detects
the problem and treats it as a deployment problem.
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 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2011-03-10
19:31:11 UTC (rev 29662)
@@ -44,6 +44,7 @@
ILLEGAL_TARGET_IN_STEREOTYPE_TYPE_MF=Stereotype {0} is defined as @Target(TYPE) and may
not be applied to stereotype {1} which is defined as @Target('{METHOD, FIELD}')
[JSR-299 �2.7.1.5]
ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE=Interceptor binding type {0} is defined as
@Target(TYPE) and may not be applied to interceptor binding type {1} which is defined as
@Target('{TYPE, METHOD}') [JSR-299 �9.1.1]
ILLEGAL_TARGET_IN_INTERCEPTOR_BINDING_TYPE_FOR_STEREOTYPE=Stereotype {0} must be defined
as @Target(TYPE) since it declares interceptor bindings ({1}) [JSR-299 �9.1.2]
+NOT_PASSIVATION_CAPABLE_BEAN=Managed bean {0} which declares a passivating scope {1} must
be passivation capable [JSR-299 �6.6.4]
MULTIPLE_SCOPE_TYPE_ANNOTATIONS=Bean class or producer method or field specifies multiple
scope type annotations [JSR-299 �2.4.3]
MULTIPLE_SCOPE_TYPE_ANNOTATIONS_IN_BEAN_CLASS=Bean class specifies multiple scope type
annotations [JSR-299 �2.4.3]
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 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -57,6 +57,7 @@
{CDIPreferences.MISSING_NONBINDING_IN_QUALIFIER_TYPE_MEMBER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label},
{CDIPreferences.MISSING_NONBINDING_IN_INTERCEPTOR_BINDING_TYPE_MEMBER,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingNonbindingInInterceptorBindingTypeMember_label},
{CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingOrIncorrectTargetOrRetentionInAnnotationType_label},
+ {CDIPreferences.NOT_PASSIVATION_CAPABLE_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_notPassivationCapableBean_label},
},
CDICorePlugin.PLUGIN_ID
);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -56,6 +56,7 @@
public static String
CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label;
public static String
CDIValidatorConfigurationBlock_pb_missingNonbindingInInterceptorBindingTypeMember_label;
public static String
CDIValidatorConfigurationBlock_pb_missingOrIncorrectTargetOrRetentionInAnnotationType_label;
+ public static String CDIValidatorConfigurationBlock_pb_notPassivationCapableBean_label;
// Scope
public static String CDIValidatorConfigurationBlock_section_scope;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties 2011-03-10
19:31:11 UTC (rev 29662)
@@ -45,6 +45,7 @@
CDIValidatorConfigurationBlock_pb_missingNonbindingInQualifierTypeMember_label=Missing
@Nonbinding in qualifier type member:
CDIValidatorConfigurationBlock_pb_missingNonbindingInInterceptorBindingTypeMember_label=Missing
@Nonbinding in interceptor binding type member:
CDIValidatorConfigurationBlock_pb_missingOrIncorrectTargetOrRetentionInAnnotationType_label=Missing
or incorrect @Target or @Retention in an annotation type:
+CDIValidatorConfigurationBlock_pb_notPassivationCapableBean_label=Not passivation capable
managed bean w/ passivating scope:
##Scope
CDIValidatorConfigurationBlock_section_scope=Scope
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/WeldJarTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/WeldJarTest.java 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/WeldJarTest.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -1,7 +1,5 @@
package org.jboss.tools.cdi.core.test;
-
-
import java.io.IOException;
import java.util.Set;
@@ -9,7 +7,6 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -32,7 +29,6 @@
public WeldJarTest() {}
public void setUp() throws Exception {
- System.out.println("setUUUUUUUUUUUp");
project1 = ResourcesUtils.importProject(PLUGIN_ID, "/projects/CDITest1");
JobUtils.waitForIdle();
project1.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-03-10
10:34:47 UTC (rev 29661)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/validation/DeploymentProblemsValidationTests.java 2011-03-10
19:31:11 UTC (rev 29662)
@@ -281,4 +281,16 @@
ResourcesUtils.setBuildAutomatically(saveAutoBuild);
JobUtils.waitForIdle();
}
+
+ /**
+ * 6.6.4 Validation of passivation capable beans and dependencies
+ * - If a managed bean which declares a passivating scope is not passivation capable,
then the container automatically detects the problem and treats it as a deployment
problem.
+ *
+ * See
https://issues.jboss.org/browse/JBIDE-3126
+ * @throws Exception
+ */
+ public void testSimpleWebBeanWithNonSerializableImplementationClassFails() throws
Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/context/passivating/broken/nonPassivationCapableManagedBeanHasPassivatingScope/Hamina_Broken.java");
+ assertMarkerIsCreated(file,
MessageFormat.format(CDIValidationMessages.NOT_PASSIVATION_CAPABLE_BEAN,
"Hamina_Broken", "SessionScoped"), 22);
+ }
}
\ No newline at end of file