[jbosstools-commits] JBoss Tools SVN: r24472 - in trunk/cdi: plugins/org.jboss.tools.cdi.core/META-INF and 5 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Aug 26 09:43:13 EDT 2010


Author: akazakov
Date: 2010-08-26 09:43:12 -0400 (Thu, 26 Aug 2010)
New Revision: 24472

Added:
   trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidator.java
Modified:
   trunk/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF
   trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml
   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/resources/tck/tests/jbt/validation/decorators/beans.xml
   trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/disposers/beans.xml
Log:
https://jira.jboss.org/browse/JBIDE-6523 beans.xml validation

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/META-INF/MANIFEST.MF	2010-08-26 13:43:12 UTC (rev 24472)
@@ -19,7 +19,8 @@
  org.jboss.tools.common.el.core,
  org.eclipse.ltk.core.refactoring,
  org.eclipse.jface.text,
- org.eclipse.equinox.preferences
+ org.eclipse.equinox.preferences,
+ org.eclipse.wst.sse.core
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-Vendor: JBoss by Red Hat

Modified: trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/plugin.xml	2010-08-26 13:43:12 UTC (rev 24472)
@@ -102,6 +102,10 @@
                class="org.jboss.tools.cdi.internal.core.validation.CDICoreValidator"
                id="org.jboss.tools.cdi.core.CoreValidator">
          </validator>
+         <!--validator
+               class="org.jboss.tools.cdi.internal.core.validation.BeansXmlValidator"
+               id="org.jboss.tools.cdi.core.BeansXmlValidator">
+         </validator-->
    </extension>
 
 <!-- Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=315390 -->

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	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/preferences/CDIPreferences.java	2010-08-26 13:43:12 UTC (rev 24472)
@@ -223,6 +223,15 @@
 	public static final String ILLEGAL_QUALIFIER_IN_STEREOTYPE = INSTANCE.createSeverityOption("illegalQualifierInStereotype"); //$NON-NLS-1$
 //	- bean class is deployed in two different bean archives (12.1 non-portable)
 	// ? is it a definition problem
+
+// - Each child <class> element must specify the name of an alternative/decorator/interceptor bean class/stereotype annotation. If there is no class with the specified
+//	  name, or if the class with the specified name is not alternative/decorator/interceptor bean class/stereotype annotation, the container automatically detects the problem
+//	  and treats it as a deployment problem.
+	public static final String ILLEGAL_TYPE_NAME_IN_BEANS_XML = INSTANCE.createSeverityOption("illegalTypeInBeansXml"); //$NON-NLS-1$
+//	- If the same type is listed twice under the <alternatives>, <decorators> or <interceptors> element, the container automatically detects the problem and
+//	  treats it as a deployment problem.
+	public static final String DUPLICATE_TYPE_IN_BEANS_XML = INSTANCE.createSeverityOption("duplicateTypeInBeansXml"); //$NON-NLS-1$
+
 	/**
 	 * @return the only instance of CDIPreferences
 	 */
@@ -263,6 +272,10 @@
 		return true;
 	}
 
+	public static boolean shouldValidateBeansXml(IProject project) {
+		return !(CDIPreferences.IGNORE.equals(INSTANCE.getProjectPreference(project, ILLEGAL_TYPE_NAME_IN_BEANS_XML)) && CDIPreferences.IGNORE.equals(INSTANCE.getProjectPreference(project, DUPLICATE_TYPE_IN_BEANS_XML)));
+	}
+
 	public static boolean isValidationEnabled(IProject project) {
 		return INSTANCE.isEnabled(project);
 	}

Added: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidator.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidator.java	                        (rev 0)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidator.java	2010-08-26 13:43:12 UTC (rev 24472)
@@ -0,0 +1,204 @@
+/******************************************************************************* 
+ * Copyright (c) 2010 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.internal.core.validation;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
+import org.eclipse.wst.validation.internal.core.ValidationException;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.preferences.CDIPreferences;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper;
+import org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author Alexey Kazakov
+ */
+public class BeansXmlValidator extends CDICoreValidator {
+
+	public String ENT_CDI_BEANS = "FileCDIBeans"; //$NON-NLS-1$
+	public static final String ID = "org.jboss.tools.cdi.core.BeansXmlValidator"; //$NON-NLS-1$
+
+	private IJavaProject javaProject;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.jboss.tools.jst.web.kb.validation.IValidator#getId()
+	 */
+	public String getId() {
+		return ID;
+	}
+
+	@Override
+	public void init(IProject project, ContextValidationHelper validationHelper, org.eclipse.wst.validation.internal.provisional.core.IValidator manager,
+			IReporter reporter) {
+		super.init(project, validationHelper, manager, reporter);
+		javaProject = EclipseUtil.getJavaProject(project);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.jboss.tools.cdi.internal.core.validation.CDICoreValidator#shouldValidate(org.eclipse.core.resources.IProject)
+	 */
+	@Override
+	public boolean shouldValidate(IProject project) {
+		return super.shouldValidate(project) && CDIPreferences.shouldValidateBeansXml(project);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.jboss.tools.jst.web.kb.validation.IValidator#validate(java.util.Set,
+	 * org.eclipse.core.resources.IProject,
+	 * org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper,
+	 * org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager,
+	 * org.eclipse.wst.validation.internal.provisional.core.IReporter)
+	 */
+	public IStatus validate(Set<IFile> changedFiles, IProject project, ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter)
+			throws ValidationException {
+		init(project, validationHelper, manager, reporter);
+		displaySubtask(CDIValidationMessages.SEARCHING_RESOURCES);
+
+		if (cdiProject == null) {
+			return OK_STATUS;
+		}
+		IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+		for (IFile currentFile : changedFiles) {
+			if (reporter.isCancelled()) {
+				break;
+			}
+			// Check if it's a beans.xml
+			XModelObject xmo = EclipseResourceUtil.createObjectForResource(currentFile);
+			if(xmo != null && xmo.getModelEntity().getName().startsWith(ENT_CDI_BEANS)) {
+				validateBeansXml(currentFile);
+			}
+		}
+
+		return OK_STATUS;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.jboss.tools.jst.web.kb.validation.IValidator#validateAll(org.eclipse
+	 * .core.resources.IProject,
+	 * org.jboss.tools.jst.web.kb.internal.validation.ContextValidationHelper,
+	 * org.jboss.tools.jst.web.kb.internal.validation.ValidatorManager,
+	 * org.eclipse.wst.validation.internal.provisional.core.IReporter)
+	 */
+	public IStatus validateAll(IProject project, ContextValidationHelper validationHelper, ValidatorManager manager, IReporter reporter)
+			throws ValidationException {
+		init(project, validationHelper, manager, reporter);
+		if (cdiProject == null) {
+			return OK_STATUS;
+		}
+		displaySubtask(CDIValidationMessages.VALIDATING_PROJECT, new String[] { projectName });
+		removeAllMessagesFromResource(cdiProject.getNature().getProject());
+
+		// TODO get all the beans.xml and validate them
+		
+		return OK_STATUS;
+	}
+
+	private void validateBeansXml(IFile beansXml) {
+		IModelManager manager = StructuredModelManager.getModelManager();
+		if(manager == null) {
+			// this may happen if plug-in org.eclipse.wst.sse.core 
+			// is stopping or un-installed, that is Eclipse is shutting down.
+			// there is no need to report it, just stop validation.
+			return;
+		}
+
+		IStructuredModel model = null;
+		try {
+			model = manager.getModelForRead(beansXml);
+			if (model instanceof IDOMModel) {
+				IDOMModel domModel = (IDOMModel) model;
+				IDOMDocument document = domModel.getDocument();
+
+				NodeList list = document.getElementsByTagName("class");
+				for (int i = 0; i < list.getLength(); i++) {
+					Node classNode = list.item(i);
+					NodeList children = classNode.getChildNodes();
+
+					boolean empty = true;
+					for (int j = 0; j < children.getLength(); j++) {
+						Node node = children.item(j);
+						if(node.getNodeType() == Node.TEXT_NODE) {
+							String value = node.getNodeValue();
+							if(value!=null) {
+								String className = value.trim();
+								if(className.length()==0) {
+									continue;
+								}
+								empty = false;
+								if(node instanceof IndexedRegion) {
+									int start = ((IndexedRegion)node).getStartOffset() + value.indexOf(className);
+									int length = className.length();
+									IType type = EclipseJavaUtil.findType(javaProject, className);
+									if(type==null) {
+										if(node instanceof IndexedRegion) {
+											addError(CDIValidationMessages.CONFLICTING_INTERCEPTOR_BINDINGS, CDIPreferences.CONFLICTING_INTERCEPTOR_BINDINGS,
+													new String[]{}, length, start, beansXml);
+											break;
+										}
+									}
+								}
+							}
+						}
+					}
+
+					if(empty) {
+						if(classNode instanceof IndexedRegion) {
+							int start = ((IndexedRegion)classNode).getStartOffset();
+							int end = ((IndexedRegion)classNode).getEndOffset();
+							int length = end - start;
+							addError(CDIValidationMessages.CONFLICTING_INTERCEPTOR_BINDINGS, CDIPreferences.CONFLICTING_INTERCEPTOR_BINDINGS,
+									new String[]{}, length, start, beansXml);
+						}
+					}
+				}
+			}
+		} catch (CoreException e) {
+			CDICorePlugin.getDefault().logError(e);
+        } catch (IOException e) {
+        	CDICorePlugin.getDefault().logError(e);
+		} finally {
+			if (model != null) {
+				model.releaseFromRead();
+			}
+		}
+	}
+}
\ No newline at end of file


Property changes on: trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/BeansXmlValidator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

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-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java	2010-08-26 13:43:12 UTC (rev 24472)
@@ -1821,7 +1821,7 @@
 					           {TARGET_METHOD, TARGET_FIELD},
 					           {TARGET_TYPE}, {TARGET_METHOD}, {TARGET_FIELD}};
 		validateTargetAnnotation(stereotype, variants, CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_STEREOTYPE_TYPE, resource);
-		
+
 		/*
 		 * Stereotype annotation type should be annotated with @Retention(RUNTIME)
 		 */
@@ -1849,7 +1849,7 @@
 			CDICorePlugin.getDefault().logError(e);
 		}
 	}
-	
+
 	private void validateScopeAnnotationTypeAnnotations(IScope scope, IResource resource) throws JavaModelException {
 		/*
 		 * Scope annotation type should be annotated with @Target({TYPE, METHOD, FIELD})
@@ -1863,8 +1863,6 @@
 		validateRetentionAnnotation(scope, CDIValidationMessages.MISSING_RETENTION_ANNOTATION_IN_SCOPE_TYPE, resource);
 	}
 
-
-
 	void validateRetentionAnnotation(ICDIAnnotation type, String message, IResource resource) throws JavaModelException {
 		IAnnotationDeclaration retention = type.getAnnotationDeclaration(CDIConstants.RETENTION_ANNOTATION_TYPE_NAME);
 		if(retention == null) {
@@ -1888,7 +1886,7 @@
 			}
 		}
 	}
-	
+
 	Set<String> getTargetAnnotationValues(IAnnotationDeclaration target) throws JavaModelException {
 		Set<String> result = new HashSet<String>();
 		IMemberValuePair[] ps = target.getDeclaration().getMemberValuePairs();
@@ -1913,7 +1911,6 @@
 		return result;
 	}
 
-
 	/**
 	 * Validates a qualifier.
 	 * 
@@ -1943,7 +1940,7 @@
 			CDICorePlugin.getDefault().logError(e);
 		}
 	}
-	
+
 	static String TARGET_METHOD = "METHOD";
 	static String TARGET_FIELD = "FIELD";
 	static String TARGET_PARAMETER = "PARAMETER";
@@ -1957,7 +1954,7 @@
 		String[][] variants = {{TARGET_METHOD, TARGET_FIELD, TARGET_PARAMETER, TARGET_TYPE}, 
 				               {TARGET_FIELD, TARGET_PARAMETER}};
 		validateTargetAnnotation(qualifier, variants, CDIValidationMessages.MISSING_TARGET_ANNOTATION_IN_QUALIFIER_TYPE, resource);
-		
+
 		/*
 		 * Qualifier annotation type should be annotated with @Retention(RUNTIME)
 		 */
@@ -1991,7 +1988,6 @@
 				addError(message, CDIPreferences.MISSING_OR_INCORRECT_TARGET_OR_RETENTION_IN_ANNOTATION_TYPE, target, resource);
 			}
 		}
-		
 	}
 
 	private void validateInterceptorBinding(IInterceptorBinding binding) {

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	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java	2010-08-26 13:43:12 UTC (rev 24472)
@@ -124,10 +124,22 @@
 	public static String ILLEGAL_INJECTING_USERTRANSACTION_TYPE;
 	public static String ILLEGAL_INJECTING_INJECTIONPOINT_TYPE;
 	public static String ILLEGAL_QUALIFIER_IN_STEREOTYPE;
+	public static String UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME;
+	public static String ILLEGAL_ALTERNATIVE_BEAN_CLASS;
+	public static String UNKNOWN_ALTERNATIVE_ANNOTATION_NAME;
+	public static String ILLEGAL_ALTERNATIVE_ANNOTATION;
+	public static String DUPLICATE_ALTERNATIVE_TYPE;
+	public static String UNKNOWN_DECORATOR_BEAN_CLASS_NAME;
+	public static String ILLEGAL_DECORATOR_BEAN_CLASS;
+	public static String DUPLICATE_DECORATOR_CLASS;
+	public static String UNKNOWN_INTERCEPTOR_CLASS_NAME;
+	public static String ILLEGAL_INTERCEPTOR_CLASS;
+	public static String DUPLICATE_INTERCEPTOR_CLASS;
 
 	public static String SEARCHING_RESOURCES;
 	public static String VALIDATING_RESOURCE;
 	public static String VALIDATING_PROJECT;
+	public static String VALIDATING_BEANS_XML;
 
 	static {
 		NLS.initializeMessages(BUNDLE_NAME, CDIValidationMessages.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	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt	2010-08-26 13:43:12 UTC (rev 24472)
@@ -122,21 +122,12 @@
 - X specializes Y and Y has a name and X declares a name explicitly, using @Named
 - interceptor or decorator is annotated @Specializes (Non-Portable behavior)
 
-5.2.1. Unsatisfied and ambiguous dependencies
-- If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and
-  treats it as a deployment problem.
-
-5.2.2. Legal injection point types
-- injection point type is a type variable
-
 5.1.4. Inter-module injection
 - a decorator can not be injected
 - an interceptor can not be injected
 
-5.2.4. Primitive types and null values
-- if an 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, the container automatically detects the problem
-  and treats it as a deployment problem.
+5.2.2. Legal injection point types
+- injection point type is a type variable
 
 5.2.5. Qualifier annotations with members
 - array-valued or annotation-valued member of a qualifier type is not annotated @Nonbinding (Non-Portable behavior)
@@ -188,4 +179,45 @@
 - bean with scope @Dependent has an observer method declared notifyObserver=IF_EXISTS
 
 12.1. Bean archives
-- bean class is deployed in two different bean archives (Non-Portable behavior) - (JBT: let's ignore this rule so far since we don't have any good tool to recognize such components)
\ No newline at end of file
+- bean class is deployed in two different bean archives (Non-Portable behavior) - (JBT: let's ignore this rule so far since we don't have any good tool to recognize such components)
+
+
+
+Deployment problems
+
+5.2.1. Unsatisfied and ambiguous dependencies
+- If an unsatisfied or unresolvable ambiguous dependency exists, the container automatically detects the problem and
+  treats it as a deployment problem.
+  
+5.2.4. Primitive types and null values
+- if an 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, the container automatically detects the problem
+  and treats it as a deployment problem.
+
+
+
+Beans.xml
+
+5.1.1. Declaring selected alternatives for a bean archive
+- Each child <class> element must specify the name of an alternative bean class. If there is no class with the specified
+  name, or if the class with the specified name is not an alternative bean class, the container automatically detects the problem
+  and treats it as a deployment problem.
+- Each child <stereotype> element must specify the name of an @Alternative stereotype annotation. If there is no annotation
+  with the specified name, or the annotation is not an @Alternative stereotype, the container automatically detects the
+  problem and treats it as a deployment problem.
+- If the same type is listed twice under the <alternatives> element, the container automatically detects the problem and
+  treats it as a deployment problem.
+
+8.2. Decorator enablement and ordering
+- Each child <class> element must specify the name of a decorator bean class. If there is no class with the specified name,
+  or if the class with the specified name is not a decorator bean class, the container automatically detects the problem and
+  treats it as a deployment problem.
+- If the same class is listed twice under the <decorators> element, the container automatically detects the problem and
+  treats it as a deployment problem.
+   
+9.4. Interceptor enablement and ordering
+- Each child <class> element must specify the name of an interceptor class. If there is no class with the specified name, or if
+  the class with the specified name is not an interceptor class, the container automatically detects the problem and treats it as
+  a deployment problem.
+- If the same class is listed twice under the <interceptors> element, the container automatically detects the problem and treats it as
+  a deployment problem.
\ No newline at end of file

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-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties	2010-08-26 13:43:12 UTC (rev 24472)
@@ -105,7 +105,22 @@
 ILLEGAL_INJECTING_INJECTIONPOINT_TYPE=Java EE component class supporting injection that is not a bean has an injection point of type InjectionPoint and qualifier @Default [JSR-299 §5.5.7]
 ILLEGAL_QUALIFIER_IN_STEREOTYPE=Stereotypes cannot declare qualifier annotations (except @Named) [JSR-299 §2.7.1.3]
 
+#Beans.xml
+
+UNKNOWN_ALTERNATIVE_BEAN_CLASS_NAME=There is no class with the specified name [JSR-299 §5.1.1]
+ILLEGAL_ALTERNATIVE_BEAN_CLASS=<class> element must specify the name of an alternative bean class [JSR-299 §5.1.1]
+UNKNOWN_ALTERNATIVE_ANNOTATION_NAME=There is no annotation with the specified name [JSR-299 §5.1.1]
+ILLEGAL_ALTERNATIVE_ANNOTATION=<stereotype> element must specify the name of an @Alternative stereotype annotation [JSR-299 §5.1.1]
+DUPLICATE_ALTERNATIVE_TYPE=The same type cannot be listed more than once under the <alternatives> element [JSR-299 §5.1.1]
+UNKNOWN_DECORATOR_BEAN_CLASS_NAME=There is no class with the specified name [JSR-299 §8.2]
+ILLEGAL_DECORATOR_BEAN_CLASS=<class> element must specify the name of a decorator bean class [JSR-299 §8.2]
+DUPLICATE_DECORATOR_CLASS=The same class cannot be listed more then once under the <decorators> element [JSR-299 §8.2]
+UNKNOWN_INTERCEPTOR_CLASS_NAME=There is no class with the specified name [JSR-299 §9.4]
+ILLEGAL_INTERCEPTOR_CLASS=<class> element must specify the name of an interceptor class [JSR-299 §9.4]
+DUPLICATE_INTERCEPTOR_CLASS=The same class cannot be listed more then once under the <interceptors> element [JSR-299 §9.4]
+
 #Messages for Progress Monitor
 SEARCHING_RESOURCES=project "{0}"; searching resources for validation (CDI Validator).
 VALIDATING_RESOURCE=project "{0}"; resource "{1}" (CDI Validator)
-VALIDATING_PROJECT=project "{0}" (CDI Validator)
\ No newline at end of file
+VALIDATING_PROJECT=project "{0}" (CDI Validator)
+VALIDATING_BEANS_XML=project "{0}"; validating beans.xml (CDI beans.xml Validator).
\ No newline at end of file

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-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java	2010-08-26 13:43:12 UTC (rev 24472)
@@ -144,6 +144,15 @@
 		CDICorePlugin.PLUGIN_ID
 	);
 
+	private static SectionDescription SECTION_BEANSXML = new SectionDescription(
+			CDIPreferencesMessages.CDIValidatorConfigurationBlock_section_beansxml,
+			new String[][]{
+				{CDIPreferences.ILLEGAL_TYPE_NAME_IN_BEANS_XML, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalTypeInBeansXml_label},
+				{CDIPreferences.DUPLICATE_TYPE_IN_BEANS_XML, CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_duplicateTypeInBeansXml_label},
+			},
+			CDICorePlugin.PLUGIN_ID
+		);
+
 	private static SectionDescription[] ALL_SECTIONS = new SectionDescription[]{
 		SECTION_NAME,
 		SECTION_TYPE,
@@ -151,7 +160,8 @@
 		SECTION_MEMBER,
 		SECTION_INTERCEPTOR,
 		SECTION_SPECIALIZATION,
-		SECTION_MISCELLANEOUS
+		SECTION_MISCELLANEOUS,
+		SECTION_BEANSXML
 	};
 
 	private static Key[] getKeys() {

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	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.java	2010-08-26 13:43:12 UTC (rev 24472)
@@ -126,6 +126,10 @@
 	public static String CDIValidatorConfigurationBlock_pb_illegalInjectingInjectionPointType_label;
 	public static String CDIValidatorConfigurationBlock_pb_illegalQualifierInStereotype_label;
 
+	// Beans.xml
+	public static String CDIValidatorConfigurationBlock_section_beansxml;
+	public static String CDIValidatorConfigurationBlock_pb_illegalTypeInBeansXml_label;
+	public static String CDIValidatorConfigurationBlock_pb_duplicateTypeInBeansXml_label;
 
 	public static String CDI_VALIDATOR_PREFERENCE_PAGE_CDI_VALIDATOR;
 

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	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIPreferencesMessages.properties	2010-08-26 13:43:12 UTC (rev 24472)
@@ -110,5 +110,9 @@
 CDIValidatorConfigurationBlock_pb_illegalInjectingInjectionPointType_label=Illegal injecting injection point type:
 CDIValidatorConfigurationBlock_pb_illegalQualifierInStereotype_label=Illegal qualifier in stereotype:
 
+##Beans.xml
+CDIValidatorConfigurationBlock_section_beansxml=beans.xml
+CDIValidatorConfigurationBlock_pb_illegalTypeInBeansXml_label=Illegal type name:
+CDIValidatorConfigurationBlock_pb_duplicateTypeInBeansXml_label=Duplicate type name:
 
 CDI_VALIDATOR_PREFERENCE_PAGE_CDI_VALIDATOR=CDI Validator

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/decorators/beans.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/decorators/beans.xml	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/decorators/beans.xml	2010-08-26 13:43:12 UTC (rev 24472)
@@ -1,8 +1,8 @@
 <beans> 
    <decorators>
-      <class>org.jboss.jsr299.tck.tests.jdt.validation.decorators.NamedDecoratorBroken</class>
-      <class>org.jboss.jsr299.tck.tests.jdt.validation.decorators.DecoratorWithWrongScopeBroken</class>
-      <class>org.jboss.jsr299.tck.tests.jdt.validation.decorators.AlternativeDecoratorBroken</class>
-      <class>org.jboss.jsr299.tck.tests.jdt.validation.decorators.ObserverMethodInDecoratorBroken</class>
+      <class>org.jboss.jsr299.tck.tests.jbt.validation.decorators.NamedDecoratorBroken</class>
+      <class>org.jboss.jsr299.tck.tests.jbt.validation.decorators.DecoratorWithWrongScopeBroken</class>
+      <class>org.jboss.jsr299.tck.tests.jbt.validation.decorators.AlternativeDecoratorBroken</class>
+      <class>org.jboss.jsr299.tck.tests.jbt.validation.decorators.ObserverMethodInDecoratorBroken</class>
    </decorators>
 </beans>
\ No newline at end of file

Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/disposers/beans.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/disposers/beans.xml	2010-08-26 13:32:45 UTC (rev 24471)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/disposers/beans.xml	2010-08-26 13:43:12 UTC (rev 24472)
@@ -1,5 +1,5 @@
 <beans> 
    <decorators>
-      <class>org.jboss.jsr299.tck.tests.jdt.validation.disposers.TimestampLogger</class>
+      <class>org.jboss.jsr299.tck.tests.jbt.validation.disposers.TimestampLogger</class>
    </decorators>
 </beans>



More information about the jbosstools-commits mailing list