Author: akazakov
Date: 2011-07-27 20:27:03 -0400 (Wed, 27 Jul 2011)
New Revision: 33285
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IInjectionPointValidatorFeature.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/servlet/
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/servlet/SeamServletExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/src/org/jboss/tools/cdi/seam/faces/core/SeamFacesExtension.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/CDIExtensionManager.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.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.seam.core/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/META-INF/MANIFEST.MF
trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/plugin.xml
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/ExtensionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamConfigTest.java
trunk/cdi/tests/org.jboss.tools.cdi.seam.faces.core.test/src/org/jboss/tools/cdi/seam/faces/core/test/CDISeamFacesCoreAllTests.java
Log:
https://issues.jboss.org/browse/JBIDE-9389
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -98,9 +98,6 @@
public String WELD_BEAN_MANAGER_TYPE_NAME =
"org.jboss.weld.manager.BeanManagerImpl";
- public String SEAM_FACES_INPUT_FIELD_TYPE_NAME =
"org.jboss.seam.faces.validation.InputField";
- public String SEAM_FACES_INPUT_ELEMENT_TYPE_NAME =
"org.jboss.seam.faces.validation.InputElement";
-
public String ELEMENT_TYPE_TYPE_NAME =
"java.lang.annotation.ElementType.TYPE";
public String ELEMENT_TYPE_METHOD_NAME =
"java.lang.annotation.ElementType.METHOD";
public String ELEMENT_TYPE_FIELD_NAME =
"java.lang.annotation.ElementType.FIELD";
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDICoreBuilder.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -161,7 +161,7 @@
}
if(isClassPathUpdated || buildParticipants == null) {
//3. Install extensions. That should be done before constructing working copy of
context.
- buildParticipants = n.getExtensionManager().getBuildParticipantFeature();
+ buildParticipants = n.getExtensionManager().getBuildParticipantFeatures();
buildParticipants2 = new HashSet<IBuildParticipant2Feature>();
Set<IDefinitionContextExtension> es = new
HashSet<IDefinitionContextExtension>();
for (IBuildParticipantFeature p: buildParticipants) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/CDIExtensionManager.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/CDIExtensionManager.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/CDIExtensionManager.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.cdi.core.extension;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -138,30 +137,30 @@
return featureToExtensions.containsKey(feature) ? featureToExtensions.get(feature) :
EMPTY;
}
- public Set<IProcessAnnotatedMemberFeature> getProcessAnnotatedMemberFeature() {
- return getFeature(IProcessAnnotatedMemberFeature.class);
+ public Set<IProcessAnnotatedMemberFeature> getProcessAnnotatedMemberFeatures() {
+ return getFeatures(IProcessAnnotatedMemberFeature.class);
}
- public Set<IProcessAnnotatedTypeFeature> getProcessAnnotatedTypeFeature() {
- return getFeature(IProcessAnnotatedTypeFeature.class);
+ public Set<IProcessAnnotatedTypeFeature> getProcessAnnotatedTypeFeatures() {
+ return getFeatures(IProcessAnnotatedTypeFeature.class);
}
- public Set<IBuildParticipantFeature> getBuildParticipantFeature() {
+ public Set<IBuildParticipantFeature> getBuildParticipantFeatures() {
if(!featureStorage.containsKey(IBuildParticipantFeature.class)) {
- Set<IBuildParticipantFeature> result =
getFeature(IBuildParticipantFeature.class);
+ Set<IBuildParticipantFeature> result =
getFeatures(IBuildParticipantFeature.class);
for (IBuildParticipantFeature f: result) {
f.setProject(n);
}
}
- return getFeature(IBuildParticipantFeature.class);
+ return getFeatures(IBuildParticipantFeature.class);
}
- public Set<IAmbiguousBeanResolverFeature> getAmbiguousBeanResolverFeature() {
- return getFeature(IAmbiguousBeanResolverFeature.class);
+ public Set<IAmbiguousBeanResolverFeature> getAmbiguousBeanResolverFeatures() {
+ return getFeatures(IAmbiguousBeanResolverFeature.class);
}
- public Set<IValidatorFeature> getValidatorFeature() {
- return getFeature(IValidatorFeature.class);
+ public Set<IValidatorFeature> getValidatorFeatures() {
+ return getFeatures(IValidatorFeature.class);
}
/**
@@ -170,7 +169,8 @@
* @param cls
* @return set of feature implementation objects by feature class
*/
- public <F extends ICDIFeature> Set<F> getFeature(Class<F> cls) {
+ public <F extends ICDIFeature> Set<F> getFeatures(Class<F> cls) {
+ @SuppressWarnings("unchecked")
Set<F> result = (Set<F>)featureStorage.get(cls);
if(result == null) {
result = new HashSet<F>();
@@ -187,5 +187,4 @@
}
return result;
}
-
-}
+}
\ No newline at end of file
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IInjectionPointValidatorFeature.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IInjectionPointValidatorFeature.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IInjectionPointValidatorFeature.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core.extension.feature;
+
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+
+/**
+ * @author Alexey Kazakov
+ */
+public interface IInjectionPointValidatorFeature extends ICDIFeature {
+
+ /**
+ * Returns true if CDI Validator should ignore the injection point during lookup
validation.
+ * @param typeOfInjectionPoint
+ * @param injection
+ * @return
+ */
+ boolean shouldIgnoreInjection(IType typeOfInjectionPoint, IInjectionPoint injection);
+}
\ No newline at end of file
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/extension/feature/IInjectionPointValidatorFeature.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -257,7 +257,7 @@
}
if(result.size() > 1) {
- Set<IAmbiguousBeanResolverFeature> extensions =
getExtensionManager().getAmbiguousBeanResolverFeature();
+ Set<IAmbiguousBeanResolverFeature> extensions =
getExtensionManager().getAmbiguousBeanResolverFeatures();
for (IAmbiguousBeanResolverFeature e: extensions) {
result = e.getResolvedBeans(result);
if(result.size() < 2) return result;
@@ -1034,7 +1034,7 @@
rebuildAnnotationTypes();
rebuildBeans();
- Set<IBuildParticipantFeature> buildParticipants =
n.getExtensionManager().getBuildParticipantFeature();
+ Set<IBuildParticipantFeature> buildParticipants =
n.getExtensionManager().getBuildParticipantFeatures();
for (IBuildParticipantFeature p: buildParticipants) p.buildBeans();
CDICoreNature[] ps = n.getDependentProjects().toArray(new CDICoreNature[0]);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -363,7 +363,7 @@
packageDefinitions = workingCopy.packageDefinitions;
beanXMLs = workingCopy.beanXMLs;
- Set<IProcessAnnotatedTypeFeature> fs =
project.getExtensionManager().getProcessAnnotatedTypeFeature();
+ Set<IProcessAnnotatedTypeFeature> fs =
project.getExtensionManager().getProcessAnnotatedTypeFeatures();
if(fs != null && !fs.isEmpty()) {
for (TypeDefinition nd: newTypeDefinitions) {
for (IProcessAnnotatedTypeFeature f: fs) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -49,7 +49,7 @@
//provide initialization
context.getAnnotationKind(a.getType());
}
- Set<IProcessAnnotatedMemberFeature> extensions =
context.getProject().getExtensionManager().getProcessAnnotatedMemberFeature();
+ Set<IProcessAnnotatedMemberFeature> extensions =
context.getProject().getExtensionManager().getProcessAnnotatedMemberFeatures();
IField[] fs = getType().getFields();
for (int i = 0; i < fs.length; i++) {
FieldDefinition f = newFieldDefinition();
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-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -80,6 +80,7 @@
import org.jboss.tools.cdi.core.IStereotype;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.IStereotyped;
+import org.jboss.tools.cdi.core.extension.feature.IInjectionPointValidatorFeature;
import org.jboss.tools.cdi.core.extension.feature.IValidatorFeature;
import org.jboss.tools.cdi.core.preferences.CDIPreferences;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
@@ -111,8 +112,10 @@
String projectName;
IValidatingProjectTree projectTree;
IValidatingProjectSet projectSet;
- Set<IFolder> sourceFolders = null;
+ Set<IFolder> sourceFolders;
+ private Set<IInjectionPointValidatorFeature> injectionValidationFeatures;
+
private BeansXmlValidationDelegate beansXmlValidator = new
BeansXmlValidationDelegate(this);
private AnnotationValidationDelegate annotationValidator = new
AnnotationValidationDelegate(this);
@@ -199,12 +202,14 @@
setMessageIdQuickFixAttributeName(MESSAGE_ID_ATTRIBUTE_NAME);
projectTree =
validationHelper.getValidationContextManager().getValidatingProjectTree(this);
projectSet = projectTree.getBrunches().get(rootProject);
+ cdiProject = null;
CDICoreNature nature = CDICorePlugin.getCDI(projectSet.getRootProject(), false);
if(nature!=null) {
cdiProject = nature.getDelegate();
if(cdiProject==null) {
CDICorePlugin.getDefault().logError("Trying to validate " + rootProject +
" but CDI Tools model for the project is not buit.");
}
+ injectionValidationFeatures =
nature.getExtensionManager().getFeatures(IInjectionPointValidatorFeature.class);
}
projectName = projectSet.getRootProject().getName();
sourceFolders = null;
@@ -445,7 +450,7 @@
IInterceptorBinding binding = cdiProject.getInterceptorBinding(file.getFullPath());
validateInterceptorBinding(binding);
}
- Set<IValidatorFeature> extensions =
cdiProject.getNature().getExtensionManager().getValidatorFeature();
+ Set<IValidatorFeature> extensions =
cdiProject.getNature().getExtensionManager().getValidatorFeatures();
for (IValidatorFeature v: extensions) {
setSeverityPreferences(v.getSeverityPreferences());
v.validateResource(file, this);
@@ -1429,6 +1434,21 @@
}
}
+ /**
+ * Checks if the injection point injects some bean from a CDI extension and should be
ignored by the validator during lookup validation.
+ * @param typeOfInjectionPoint
+ * @param injection
+ * @return
+ */
+ private boolean shouldIgnoreInjection(IType typeOfInjectionPoint, IInjectionPoint
injection) {
+ for (IInjectionPointValidatorFeature feature : injectionValidationFeatures) {
+ if(feature.shouldIgnoreInjection(typeOfInjectionPoint, injection)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private void validateInjectionPoint(IInjectionPoint injection) {
/*
* 3.11. The qualifier @Named at injection points
@@ -1491,127 +1511,117 @@
* - If an unsatisfied or unresolvable ambiguous dependency exists, the container
automatically detects the problem and treats it as a deployment problem.
*/
IType type = getTypeOfInjection(injection);
- // If the injection point annotated @InputField then don't try to resolve it. Also
ignore @Inject InputElement field.
- // Despite this annotation is from Seam Faces module and is not part of JSR-299
it's much easy to check this annotation here instead of moving this check to Seam
Faces plug-in.
- // See
https://issues.jboss.org/browse/JBIDE-8576
- if(type==null ||
!CDIConstants.SEAM_FACES_INPUT_ELEMENT_TYPE_NAME.equals(type.getFullyQualifiedName())) {
- IAnnotationDeclaration faces =
injection.getAnnotation(CDIConstants.SEAM_FACES_INPUT_FIELD_TYPE_NAME);
- if(faces==null && injection instanceof IInjectionPointParameter) {
- IInjectionPointParameter param = (IInjectionPointParameter)injection;
- faces =
param.getBeanMethod().getAnnotation(CDIConstants.SEAM_FACES_INPUT_FIELD_TYPE_NAME);
+ if(!shouldIgnoreInjection(type, injection)) {
+ boolean instance = type!=null &&
CDIConstants.INSTANCE_TYPE_NAME.equals(type.getFullyQualifiedName());
+ Set<IBean> allBeans = cdiProject.getBeans(false, injection);
+ for (IBean bean : allBeans) {
+ if(!bean.getBeanClass().isReadOnly()) {
+ getValidationContext().addLinkedCoreResource(SHORT_ID,
injection.getSourcePath().toOSString(), bean.getResource().getFullPath(), false);
+ }
}
- if(faces==null) {
- boolean instance = type!=null &&
CDIConstants.INSTANCE_TYPE_NAME.equals(type.getFullyQualifiedName());
- Set<IBean> allBeans = cdiProject.getBeans(false, injection);
- for (IBean bean : allBeans) {
- if(!bean.getBeanClass().isReadOnly()) {
- getValidationContext().addLinkedCoreResource(SHORT_ID,
injection.getSourcePath().toOSString(), bean.getResource().getFullPath(), false);
+ if(type!=null && beans.isEmpty() && !instance) {
+ addError(CDIValidationMessages.UNSATISFIED_INJECTION_POINTS,
CDIPreferences.UNSATISFIED_OR_AMBIGUOUS_INJECTION_POINTS, reference,
injection.getResource(), UNSATISFIED_INJECTION_POINTS_ID);
+ } else if(beans.size()>1 && !instance) {
+ addError(CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS,
CDIPreferences.UNSATISFIED_OR_AMBIGUOUS_INJECTION_POINTS, reference,
injection.getResource(), AMBIGUOUS_INJECTION_POINTS_ID);
+ } else if(beans.size()==1) {
+ IBean bean = beans.iterator().next();
+ if(!bean.getBeanClass().isReadOnly()) {
+ /*
+ * 5.2.4. Primitive types and null values
+ * - injection point of primitive type resolves to a bean that may have null
values, such as a producer method with a non-primitive return type or a producer field
with a non-primitive type
+ */
+ if(bean.isNullable() && injection.getType()!=null &&
injection.getType().isPrimitive()) {
+ addError(CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN,
CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, reference, injection.getResource());
}
- }
- if(type!=null && beans.isEmpty() && !instance) {
- addError(CDIValidationMessages.UNSATISFIED_INJECTION_POINTS,
CDIPreferences.UNSATISFIED_OR_AMBIGUOUS_INJECTION_POINTS, reference,
injection.getResource(), UNSATISFIED_INJECTION_POINTS_ID);
- } else if(beans.size()>1 && !instance) {
- addError(CDIValidationMessages.AMBIGUOUS_INJECTION_POINTS,
CDIPreferences.UNSATISFIED_OR_AMBIGUOUS_INJECTION_POINTS, reference,
injection.getResource(), AMBIGUOUS_INJECTION_POINTS_ID);
- } else if(beans.size()==1) {
- IBean bean = beans.iterator().next();
- if(!bean.getBeanClass().isReadOnly()) {
- /*
- * 5.2.4. Primitive types and null values
- * - injection point of primitive type resolves to a bean that may have null
values, such as a producer method with a non-primitive return type or a producer field
with a non-primitive type
- */
- if(bean.isNullable() && injection.getType()!=null &&
injection.getType().isPrimitive()) {
- addError(CDIValidationMessages.INJECT_RESOLVES_TO_NULLABLE_BEAN,
CDIPreferences.INJECT_RESOLVES_TO_NULLABLE_BEAN, reference, injection.getResource());
- }
- /*
- * 5.1.4. Inter-module injection
- * - a decorator can not be injected
- * - an interceptor can not be injected
- * It is not an error - container just never attempts to inject them.
- */
+ /*
+ * 5.1.4. Inter-module injection
+ * - a decorator can not be injected
+ * - an interceptor can not be injected
+ * It is not an error - container just never attempts to inject them.
+ */
- /*
- * 5.4.1. Unproxyable bean types
- * - If an injection point whose declared type cannot be proxied by the container
resolves to a bean with a normal scope,
- * the container automatically detects the problem and treats it as a
deployment problem.
- */
- if(bean.getScope()!=null && bean.getScope().isNorlmalScope() &&
injection.getType()!=null) {
- // - Array types cannot be proxied by the container.
- String typeSignature = injection.getType().getSignature();
- int kind = Signature.getTypeSignatureKind(typeSignature);
- if(kind == Signature.ARRAY_TYPE_SIGNATURE) {
- addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
- } else if(injection.getType().isPrimitive()) {
- // - Primitive types cannot be proxied by the container.
- addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
- } else if(bean instanceof IClassBean) {
- try {
- if(Flags.isFinal(bean.getBeanClass().getFlags())) {
- // - Classes which are declared final cannot be proxied by the container.
- addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
- } else {
- IMethod[] methods = bean.getBeanClass().getMethods();
- boolean hasDefaultConstructor = false;
- boolean hasConstructor = false;
- for (IMethod method : methods) {
- hasConstructor = hasConstructor || method.isConstructor();
- hasDefaultConstructor = hasDefaultConstructor || (method.isConstructor()
&& !Flags.isPrivate(method.getFlags()) &&
method.getParameterNames().length==0);
- if(Flags.isFinal(method.getFlags())) {
- // - Classes which have final methods cannot be proxied by the container.
- addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
- hasDefaultConstructor = true;
- break;
- }
+ /*
+ * 5.4.1. Unproxyable bean types
+ * - If an injection point whose declared type cannot be proxied by the container
resolves to a bean with a normal scope,
+ * the container automatically detects the problem and treats it as a deployment
problem.
+ */
+ if(bean.getScope()!=null && bean.getScope().isNorlmalScope() &&
injection.getType()!=null) {
+ // - Array types cannot be proxied by the container.
+ String typeSignature = injection.getType().getSignature();
+ int kind = Signature.getTypeSignatureKind(typeSignature);
+ if(kind == Signature.ARRAY_TYPE_SIGNATURE) {
+ addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_ARRAY_TYPE,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
+ } else if(injection.getType().isPrimitive()) {
+ // - Primitive types cannot be proxied by the container.
+ addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_PRIMITIVE_TYPE,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
+ } else if(bean instanceof IClassBean) {
+ try {
+ if(Flags.isFinal(bean.getBeanClass().getFlags())) {
+ // - Classes which are declared final cannot be proxied by the container.
+ addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_FINAL_TYPE,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
+ } else {
+ IMethod[] methods = bean.getBeanClass().getMethods();
+ boolean hasDefaultConstructor = false;
+ boolean hasConstructor = false;
+ for (IMethod method : methods) {
+ hasConstructor = hasConstructor || method.isConstructor();
+ hasDefaultConstructor = hasDefaultConstructor || (method.isConstructor()
&& !Flags.isPrivate(method.getFlags()) &&
method.getParameterNames().length==0);
+ if(Flags.isFinal(method.getFlags())) {
+ // - Classes which have final methods cannot be proxied by the container.
+ addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_FM,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
+ hasDefaultConstructor = true;
+ break;
}
- if(!hasDefaultConstructor && hasConstructor) {
- // - Classes which don't have a non-private constructor with no
parameters cannot be proxied by the container.
- addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
- }
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
+ if(!hasDefaultConstructor && hasConstructor) {
+ // - Classes which don't have a non-private constructor with no parameters
cannot be proxied by the container.
+ addError(MessageFormat.format(CDIValidationMessages.UNPROXYABLE_BEAN_TYPE_WITH_NPC,
injection.getType().getSimpleName(), bean.getSimpleJavaName()),
CDIPreferences.UNPROXYABLE_BEAN_TYPE, reference, injection.getResource());
+ }
}
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
}
}
- if(injection.getClassBean() instanceof IDecorator &&
injection.isDelegate() && bean instanceof IClassBean) {
- try {
- IType beanClass = bean.getBeanClass();
- if(Flags.isFinal(beanClass.getFlags())) {
- // 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.
- addError(MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_CLASS,
bean.getSimpleJavaName()), CDIPreferences.DECORATOR_RESOLVES_TO_FINAL_BEAN, reference,
injection.getResource());
- } else {
- // 8.3. Decorator resolution
- // - If a decorator matches a managed bean with a non-static, non-private,
final method, and the decorator also implements that method,
- // the container automatically detects the problem and treats it as a
deployment problem.
- IType decoratorClass = injection.getClassBean().getBeanClass();
- IMethod[] methods = decoratorClass.getMethods();
- boolean reported = false;
- if(methods!=null) {
- for (IMethod method : methods) {
- if(!Flags.isPrivate(method.getFlags()) &&
!Flags.isStatic(method.getFlags())) {
- IMethod[] beanMethods = beanClass.findMethods(method);
- if(beanMethods!=null) {
- for (IMethod beanMethod : beanMethods) {
- int flags = beanMethod.getFlags();
- if(!Flags.isPrivate(flags) && !Flags.isStatic(flags) &&
Flags.isFinal(flags)) {
- String methodName = Signature.toString(beanMethod.getSignature(),
beanMethod.getElementName(), beanMethod.getParameterNames(), false, false);
- addError(MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_METHOD,
bean.getSimpleJavaName(), methodName), CDIPreferences.DECORATOR_RESOLVES_TO_FINAL_BEAN,
reference, injection.getResource());
- reported = true;
- break;
- }
- }
- if(reported) {
+ }
+ if(injection.getClassBean() instanceof IDecorator && injection.isDelegate()
&& bean instanceof IClassBean) {
+ try {
+ IType beanClass = bean.getBeanClass();
+ if(Flags.isFinal(beanClass.getFlags())) {
+ // 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.
+ addError(MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_CLASS,
bean.getSimpleJavaName()), CDIPreferences.DECORATOR_RESOLVES_TO_FINAL_BEAN, reference,
injection.getResource());
+ } else {
+ // 8.3. Decorator resolution
+ // - If a decorator matches a managed bean with a non-static, non-private, final
method, and the decorator also implements that method,
+ // the container automatically detects the problem and treats it as a
deployment problem.
+ IType decoratorClass = injection.getClassBean().getBeanClass();
+ IMethod[] methods = decoratorClass.getMethods();
+ boolean reported = false;
+ if(methods!=null) {
+ for (IMethod method : methods) {
+ if(!Flags.isPrivate(method.getFlags()) &&
!Flags.isStatic(method.getFlags())) {
+ IMethod[] beanMethods = beanClass.findMethods(method);
+ if(beanMethods!=null) {
+ for (IMethod beanMethod : beanMethods) {
+ int flags = beanMethod.getFlags();
+ if(!Flags.isPrivate(flags) && !Flags.isStatic(flags) &&
Flags.isFinal(flags)) {
+ String methodName = Signature.toString(beanMethod.getSignature(),
beanMethod.getElementName(), beanMethod.getParameterNames(), false, false);
+ addError(MessageFormat.format(CDIValidationMessages.DECORATOR_RESOLVES_TO_FINAL_METHOD,
bean.getSimpleJavaName(), methodName), CDIPreferences.DECORATOR_RESOLVES_TO_FINAL_BEAN,
reference, injection.getResource());
+ reported = true;
break;
}
}
+ if(reported) {
+ break;
+ }
}
}
}
}
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
}
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
}
}
}
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/plugin.xml 2011-07-28 00:19:59 UTC
(rev 33284)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/plugin.xml 2011-07-28 00:27:03 UTC
(rev 33285)
@@ -17,4 +17,12 @@
runtime="org.jboss.seam.international.status.TypedStatusMessageBundleExtension">
</cdiextension>
</extension>
-</plugin>
+
+ <extension
+ point="org.jboss.tools.cdi.core.cdiextensions">
+ <cdiextension
+ class="org.jboss.tools.cdi.seam.core.servlet.SeamServletExtension"
+ runtime="org.jboss.seam.servlet.ServletExtension">
+ </cdiextension>
+ </extension>
+</plugin>
\ No newline at end of file
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/servlet/SeamServletExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/servlet/SeamServletExtension.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/servlet/SeamServletExtension.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam.core.servlet;
+
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.extension.ICDIExtension;
+import org.jboss.tools.cdi.core.extension.feature.IInjectionPointValidatorFeature;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class SeamServletExtension implements
ICDIExtension, IInjectionPointValidatorFeature {
+
+ private final static String SEAM_SERVLET_REQUEST_PARAM_TYPE_NAME =
"org.jboss.seam.servlet.http.RequestParam";
+ private final static String SEAM_SERVLET_HEADER_PARAM_TYPE_NAME =
"org.jboss.seam.servlet.http.HeaderParam";
+ private final static String SEAM_SERVLET_COOKIE_PARAM_TYPE_NAME =
"org.jboss.seam.servlet.http.CookieParam";
+
+ /**
+ * If the injection point annotated @RequestParam, @HeaderParam or @CookieParam then
don't try to resolve it.
+ * See
https://issues.jboss.org/browse/JBIDE-9389
+ *
+ * @see
org.jboss.tools.cdi.core.extension.feature.IInjectionPointValidatorFeature#shouldIgnoreInjection(org.eclipse.jdt.core.IType,
org.jboss.tools.cdi.core.IInjectionPoint)
+ */
+ @Override
+ public boolean shouldIgnoreInjection(IType typeOfInjectionPoint, IInjectionPoint
injection) {
+ return injection.getAnnotation(SEAM_SERVLET_COOKIE_PARAM_TYPE_NAME) != null
+ || injection.getAnnotation(SEAM_SERVLET_HEADER_PARAM_TYPE_NAME) != null
+ || injection.getAnnotation(SEAM_SERVLET_REQUEST_PARAM_TYPE_NAME) != null;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/servlet/SeamServletExtension.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/META-INF/MANIFEST.MF 2011-07-28
00:19:59 UTC (rev 33284)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/META-INF/MANIFEST.MF 2011-07-28
00:27:03 UTC (rev 33285)
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
-Bundle-Name: Core
+Bundle-Name: Seam Faces Core
Bundle-SymbolicName: org.jboss.tools.cdi.seam.faces.core;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: org.jboss.tools.cdi.seam.faces.core.SeamFacesCorePlugin
@@ -8,7 +8,9 @@
Require-Bundle: org.eclipse.ui;bundle-version="3.7.0",
org.eclipse.core.runtime;bundle-version="3.7.0",
org.jboss.tools.common,
- org.jboss.tools.jst.web.kb
+ org.jboss.tools.jst.web.kb,
+ org.jboss.tools.cdi.core,
+ org.eclipse.jdt.core;bundle-version="3.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.jboss.tools.cdi.seam.faces.core
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/plugin.xml 2011-07-28 00:19:59
UTC (rev 33284)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/plugin.xml 2011-07-28 00:27:03
UTC (rev 33285)
@@ -1,11 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
- <extension
+ <extension
point="org.jboss.tools.jst.web.kb.tagLib">
- <tag-lib
+ <tag-lib
location="platform:/plugin/org.jboss.tools.cdi.seam.faces.core/taglibs/JBossSeamFaces.xml"
name="JBoss Seam Faces"
uri="http://jboss.org/seam/faces"/>
- </extension>
+ </extension>
+ <extension
+ point="org.jboss.tools.cdi.core.cdiextensions">
+ <cdiextension
+ class="org.jboss.tools.cdi.seam.faces.core.SeamFacesExtension"
+
runtime="org.jboss.seam.faces.component.FormValidationTypeOverrideExtension">
+ </cdiextension>
+ </extension>
</plugin>
\ No newline at end of file
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/src/org/jboss/tools/cdi/seam/faces/core/SeamFacesExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/src/org/jboss/tools/cdi/seam/faces/core/SeamFacesExtension.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/src/org/jboss/tools/cdi/seam/faces/core/SeamFacesExtension.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam.faces.core;
+
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInjectionPointParameter;
+import org.jboss.tools.cdi.core.extension.ICDIExtension;
+import org.jboss.tools.cdi.core.extension.feature.IInjectionPointValidatorFeature;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class SeamFacesExtension implements ICDIExtension, IInjectionPointValidatorFeature
{
+
+ private final static String SEAM_FACES_INPUT_FIELD_TYPE_NAME =
"org.jboss.seam.faces.validation.InputField";
+ private final static String SEAM_FACES_INPUT_ELEMENT_TYPE_NAME =
"org.jboss.seam.faces.validation.InputElement";
+
+ /**
+ * If the injection point annotated @InputField then don't try to resolve it. Also
ignore @Inject InputElement field.
+ * See
https://issues.jboss.org/browse/JBIDE-8576
+ *
+ * @see
org.jboss.tools.cdi.core.extension.feature.IInjectionPointValidatorFeature#shouldIgnoreInjection(org.eclipse.jdt.core.IType,
org.jboss.tools.cdi.core.IInjectionPoint)
+ */
+ @Override
+ public boolean shouldIgnoreInjection(IType typeOfInjectionPoint, IInjectionPoint
injection) {
+ if(typeOfInjectionPoint!=null) {
+ if(SEAM_FACES_INPUT_ELEMENT_TYPE_NAME.equals(typeOfInjectionPoint.getFullyQualifiedName())
|| injection.getAnnotation(SEAM_FACES_INPUT_FIELD_TYPE_NAME)!=null) {
+ return true;
+ }
+ if(injection instanceof IInjectionPointParameter) {
+ IInjectionPointParameter param = (IInjectionPointParameter)injection;
+ if(param.getBeanMethod().getAnnotation(SEAM_FACES_INPUT_FIELD_TYPE_NAME)!=null) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.faces.core/src/org/jboss/tools/cdi/seam/faces/core/SeamFacesExtension.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/ExtensionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/ExtensionTest.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/ExtensionTest.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -29,7 +29,7 @@
public void testExtension() throws CoreException, IOException {
ICDIProject cdi = CDICorePlugin.getCDIProject(project, true);
- Set<IBuildParticipantFeature> bp =
cdi.getNature().getExtensionManager().getBuildParticipantFeature();
+ Set<IBuildParticipantFeature> bp =
cdi.getNature().getExtensionManager().getBuildParticipantFeatures();
System.out.println(bp.size());
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamConfigTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamConfigTest.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.config.core.test/src/org/jboss/tools/cdi/seam/config/core/test/SeamConfigTest.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -72,7 +72,7 @@
}
protected CDISeamConfigExtension getConfigExtension(ICDIProject cdi) {
- Set<IBuildParticipantFeature> bp =
cdi.getNature().getExtensionManager().getBuildParticipantFeature();
+ Set<IBuildParticipantFeature> bp =
cdi.getNature().getExtensionManager().getBuildParticipantFeatures();
for (IBuildParticipantFeature p: bp) {
if(p instanceof CDISeamConfigExtension) {
return (CDISeamConfigExtension)p;
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam.faces.core.test/src/org/jboss/tools/cdi/seam/faces/core/test/CDISeamFacesCoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam.faces.core.test/src/org/jboss/tools/cdi/seam/faces/core/test/CDISeamFacesCoreAllTests.java 2011-07-28
00:19:59 UTC (rev 33284)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam.faces.core.test/src/org/jboss/tools/cdi/seam/faces/core/test/CDISeamFacesCoreAllTests.java 2011-07-28
00:27:03 UTC (rev 33285)
@@ -29,6 +29,6 @@
suite.addTestSuite(SeamFacesValidationTest.class);
suiteAll.addTest(new SeamFacesTestSetup(suite));
suiteAll.addTestSuite(SeamFacesTagLibTest.class);
- return suite;
+ return suiteAll;
}
}
\ No newline at end of file