Author: akazakov
Date: 2010-05-19 15:41:00 -0400 (Wed, 19 May 2010)
New Revision: 22204
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerFieldBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerMethodBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerFieldBroken.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerMethodBroken.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.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/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: 1. Producer
method or fiels is annotated @Inject; 2. Non-static method of a session bean class is
annotated @Produces, and the method is not a business method of the session bean; 3.
Interceptor declares has a producer field or method.; 4. Decorator declares has a
producer field or method.
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-05-19
16:39:54 UTC (rev 22203)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIUtil.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -17,11 +17,16 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.wst.validation.internal.plugin.ValidationPlugin;
import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.jst.web.kb.IKbProject;
@@ -303,4 +308,55 @@
public static boolean isInterceptor(IBean bean) {
return bean instanceof IInterceptor || (bean instanceof IClassBean &&
bean.getAnnotation(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME)!=null);
}
+
+ /**
+ * Returns false if the method is a non-static method of the session bean class, and the
method is not a business method of the session bean.
+ *
+ * @param bean
+ * @param method
+ * @return
+ */
+ public static boolean isBusinessMethod(ISessionBean bean, IBeanMethod method) {
+ return getBusinessMethodDeclaration(bean, method)!=null;
+ }
+
+ /**
+ * Returns IMethod of @Local interface which is implemented by given business method.
+ * Returns null if the method is a non-static method of the session bean class, and the
method is not a business method of the session bean.
+ * If the method is a static one then returns this method.
+ *
+ * @param bean
+ * @param method
+ * @return
+ */
+ public static IMethod getBusinessMethodDeclaration(ISessionBean bean, IBeanMethod
method) {
+ try {
+ if (!Flags.isStatic(method.getMethod().getFlags())) {
+ Set<IParametedType> types = bean.getLegalTypes();
+ for (IParametedType type : types) {
+ IType sourceType = type.getType();
+ if (sourceType == null) {
+ continue;
+ }
+ IAnnotation annotation =
sourceType.getAnnotation(CDIConstants.LOCAL_ANNOTATION_TYPE_NAME);
+ if (annotation == null) {
+ annotation = sourceType.getAnnotation("Local"); //$NON-NLS-N1
+ }
+ if (annotation != null &&
CDIConstants.LOCAL_ANNOTATION_TYPE_NAME.equals(EclipseJavaUtil.resolveType(sourceType,
"Local"))) { //$NON-NLS-N1
+ IMethod[] methods = sourceType.getMethods();
+ for (IMethod iMethod : methods) {
+ if (method.getMethod().isSimilar(iMethod)) {
+ return iMethod;
+ }
+ }
+ break;
+ }
+ }
+ return null;
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ return method.getMethod();
+ }
}
\ No newline at end of file
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-19
16:39:54 UTC (rev 22203)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDICoreValidator.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.cdi.internal.core.validation;
import java.util.ArrayList;
@@ -27,7 +27,6 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.Flags;
-import org.eclipse.jdt.core.IAnnotation;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMemberValuePair;
import org.eclipse.jdt.core.IMethod;
@@ -63,7 +62,7 @@
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.core.preferences.CDIPreferences;
-import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.cdi.internal.core.impl.SessionBean;
import org.jboss.tools.common.text.ITextSourceReference;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
@@ -87,6 +86,7 @@
/*
* (non-Javadoc)
+ *
* @see org.jboss.tools.jst.web.kb.validation.IValidator#getId()
*/
public String getId() {
@@ -95,44 +95,50 @@
/*
* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.validation.IValidator#getValidatingProjects(org.eclipse.core.resources.IProject)
+ *
+ * @see
+ * org.jboss.tools.jst.web.kb.validation.IValidator#getValidatingProjects
+ * (org.eclipse.core.resources.IProject)
*/
public IValidatingProjectSet getValidatingProjects(IProject project) {
IValidationContext rootContext = null;
- IProject war = null; //TODO get war ?
- if(war != null && war.isAccessible()) {
+ IProject war = null; // TODO get war ?
+ if (war != null && war.isAccessible()) {
IKbProject kbProject = KbProjectFactory.getKbProject(war, false);
- if(kbProject!=null) {
+ if (kbProject != null) {
rootContext = kbProject.getValidationContext();
} else {
KbProject.checkKBBuilderInstalled(war);
CDICoreNature cdiProject = CDICorePlugin.getCDI(project, false);
- if(cdiProject != null) {
- rootContext = null; //cdiProject.getDelegate().getValidationContext();
+ if (cdiProject != null) {
+ rootContext = null; // cdiProject.getDelegate().getValidationContext();
}
}
}
- if(rootContext == null) {
+ if (rootContext == null) {
CDICoreNature cdiProject = CDICorePlugin.getCDI(project, false);
- if(cdiProject != null) {
+ if (cdiProject != null) {
rootContext = cdiProject.getValidationContext();
}
}
List<IProject> projects = new ArrayList<IProject>();
projects.add(project);
-// IProject[] array = set.getAllProjects();
-// for (int i = 0; i < array.length; i++) {
-// if(array[i].isAccessible()) {
-// projects.add(array[i]);
-// }
-// }
+ // IProject[] array = set.getAllProjects();
+ // for (int i = 0; i < array.length; i++) {
+ // if(array[i].isAccessible()) {
+ // projects.add(array[i]);
+ // }
+ // }
return new ValidatingProjectSet(project, projects, rootContext);
}
/*
* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.validation.IValidator#shouldValidate(org.eclipse.core.resources.IProject)
+ *
+ * @see
+ * org.jboss.tools.jst.web.kb.validation.IValidator#shouldValidate(org.eclipse
+ * .core.resources.IProject)
*/
public boolean shouldValidate(IProject project) {
try {
@@ -146,10 +152,18 @@
/*
* (non-Javadoc)
- * @see
org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager#init(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,
org.jboss.tools.jst.web.kb.validation.IValidationContext)
+ *
+ * @see
+ * org.jboss.tools.jst.web.kb.internal.validation.ValidationErrorManager
+ * #init(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,
+ * org.jboss.tools.jst.web.kb.validation.IValidationContext)
*/
@Override
- public void init(IProject project, ContextValidationHelper validationHelper,
org.eclipse.wst.validation.internal.provisional.core.IValidator manager, IReporter
reporter) {
+ public void init(IProject project, ContextValidationHelper validationHelper,
org.eclipse.wst.validation.internal.provisional.core.IValidator manager,
+ IReporter reporter) {
super.init(project, validationHelper, manager, reporter);
cdiProject = CDICorePlugin.getCDIProject(project, false);
projectName = project.getName();
@@ -157,29 +171,36 @@
/*
* (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)
+ *
+ * @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 {
+ 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) {
+ if (cdiProject == null) {
return OK_STATUS;
}
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- Set<IPath> resources = new HashSet<IPath>(); // Resources which we have to
validate.
- for(IFile currentFile : changedFiles) {
- if(reporter.isCancelled()) {
+ Set<IPath> resources = new HashSet<IPath>(); // Resources which we have
+ // to validate.
+ for (IFile currentFile : changedFiles) {
+ if (reporter.isCancelled()) {
break;
}
if (ValidationUtil.checkFileExtensionForJavaAndXml(currentFile)) {
resources.add(currentFile.getFullPath());
- // Get all the paths of related resources for given file. These links were saved in
previous validation process.
+ // Get all the paths of related resources for given file. These
+ // links were saved in previous validation process.
Set<String> oldReletedResources =
validationContext.getVariableNamesByCoreResource(currentFile.getFullPath(), false);
- if(oldReletedResources!=null) {
+ if (oldReletedResources != null) {
for (String resourcePath : oldReletedResources) {
resources.add(Path.fromOSString(resourcePath));
}
@@ -187,7 +208,8 @@
}
}
// Validate all collected linked resources.
- // Remove all links between collected resources because they will be linked again
during validation.
+ // Remove all links between collected resources because they will be
+ // linked again during validation.
validationContext.removeLinkedCoreResources(resources);
IFile[] filesToValidate = new IFile[resources.size()];
@@ -208,16 +230,21 @@
/*
* (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)
+ *
+ * @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 {
+ public IStatus validateAll(IProject project, ContextValidationHelper validationHelper,
ValidatorManager manager, IReporter reporter)
+ throws ValidationException {
init(project, validationHelper, manager, reporter);
- if(cdiProject == null) {
+ if (cdiProject == null) {
return OK_STATUS;
}
- displaySubtask(CDIValidationMessages.VALIDATING_PROJECT, new String[]{projectName});
+ displaySubtask(CDIValidationMessages.VALIDATING_PROJECT, new String[] { projectName
});
removeAllMessagesFromResource(cdiProject.getNature().getProject());
IBean[] beans = cdiProject.getBeans();
for (IBean bean : beans) {
@@ -225,7 +252,7 @@
}
IStereotype[] stereoTypes = cdiProject.getStereotypes();
- for (IStereotype type: stereoTypes) {
+ for (IStereotype type : stereoTypes) {
validateStereotype(type);
}
@@ -238,7 +265,7 @@
* @param file
*/
private void validateResource(IFile file) {
- if(reporter.isCancelled() || file==null || !file.isAccessible()) {
+ if (reporter.isCancelled() || file == null || !file.isAccessible()) {
return;
}
Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
@@ -255,26 +282,26 @@
* @param bean
*/
private void validateBean(IBean bean) {
- if(reporter.isCancelled()) {
+ if (reporter.isCancelled()) {
return;
}
// Collect all relations between the bean and other CDI elements.
String name = bean.getName();
- if(name!=null) {
+ if (name != null) {
validationContext.addVariableNameForELValidation(name);
}
String beanPath = bean.getResource().getFullPath().toOSString();
Set<IScopeDeclaration> scopeDeclarations = bean.getScopeDeclarations();
for (IScopeDeclaration scopeDeclaration : scopeDeclarations) {
IScope scope = scopeDeclaration.getScope();
- if(!scope.getSourceType().isReadOnly()) {
+ if (!scope.getSourceType().isReadOnly()) {
validationContext.addLinkedCoreResource(beanPath, scope.getResource().getFullPath(),
false);
}
}
Set<IStereotypeDeclaration> stereotypeDeclarations =
bean.getStereotypeDeclarations();
for (IStereotypeDeclaration stereotypeDeclaration : stereotypeDeclarations) {
IStereotype stereotype = stereotypeDeclaration.getStereotype();
- if(!stereotype.getSourceType().isReadOnly()) {
+ if (!stereotype.getSourceType().isReadOnly()) {
validationContext.addLinkedCoreResource(beanPath,
stereotype.getResource().getFullPath(), false);
}
}
@@ -283,8 +310,8 @@
validateTyped(bean);
validateBeanScope(bean);
- if(bean instanceof IProducer) {
- validateProducer((IProducer)bean);
+ if (bean instanceof IProducer) {
+ validateProducer((IProducer) bean);
}
Set<IInjectionPoint> points = bean.getInjectionPoints();
@@ -292,51 +319,53 @@
validateInjectionPoint(point);
}
- if(bean instanceof IInterceptor) {
- validateInterceptor((IInterceptor)bean);
+ if (bean instanceof IInterceptor) {
+ validateInterceptor((IInterceptor) bean);
}
- if(bean instanceof IDecorator) {
- validateDecorator((IDecorator)bean);
+ if (bean instanceof IDecorator) {
+ validateDecorator((IDecorator) bean);
}
- if(bean instanceof IClassBean) {
- validateClassBean((IClassBean)bean);
+ if (bean instanceof IClassBean) {
+ validateClassBean((IClassBean) bean);
}
}
private void validateClassBean(IClassBean bean) {
validateDisposers(bean);
- if(!(bean instanceof ISessionBean)) {
+ if (!(bean instanceof ISessionBean)) {
validateManagedBean(bean);
} else {
- validateSessionBean((ISessionBean)bean);
+ validateSessionBean((ISessionBean) bean);
}
validateMixedClassBean(bean);
}
private void validateDisposers(IClassBean bean) {
Set<IBeanMethod> disposers = bean.getDisposers();
- if(disposers.isEmpty()) {
+ if (disposers.isEmpty()) {
return;
}
Set<IBeanMethod> boundDisposers = new HashSet<IBeanMethod>();
Set<IProducer> producers = bean.getProducers();
for (IProducer producer : producers) {
- if(producer instanceof IProducerMethod) {
- IProducerMethod producerMethod = (IProducerMethod)producer;
- Set<IBeanMethod> disposerMethods =
producer.getCDIProject().resolveDisposers(producerMethod);
+ if (producer instanceof IProducerMethod) {
+ IProducerMethod producerMethod = (IProducerMethod) producer;
+ Set<IBeanMethod> disposerMethods =
producer.getCDIProject().resolveDisposers(producerMethod);
boundDisposers.addAll(disposerMethods);
- if(disposerMethods.size()>1) {
+ if (disposerMethods.size() > 1) {
/*
- * 3.3.7. Disposer method resolution
- * - there are multiple disposer methods for a single producer method
+ * 3.3.7. Disposer method resolution - there are multiple
+ * disposer methods for a single producer method
*/
for (IBeanMethod disposerMethod : disposerMethods) {
- Set<ITextSourceReference> disposerDeclarations =
CDIUtil.getAnnotationPossitions(disposerMethod,
CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+ Set<ITextSourceReference> disposerDeclarations =
CDIUtil.getAnnotationPossitions(disposerMethod,
+ CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
for (ITextSourceReference declaration : disposerDeclarations) {
- addError(CDIValidationMessages.MULTIPLE_DISPOSERS_FOR_PRODUCER,
CDIPreferences.MULTIPLE_DISPOSERS_FOR_PRODUCER, declaration, bean.getResource());
+ addError(CDIValidationMessages.MULTIPLE_DISPOSERS_FOR_PRODUCER,
CDIPreferences.MULTIPLE_DISPOSERS_FOR_PRODUCER, declaration, bean
+ .getResource());
}
}
}
@@ -347,54 +376,55 @@
List<IParameter> params = disposer.getParameters();
/*
- * 3.3.6. Declaring a disposer method
- * - method has more than one parameter annotated @Disposes
+ * 3.3.6. Declaring a disposer method - method has more than one
+ * parameter annotated @Disposes
*/
Set<ITextSourceReference> disposerDeclarations = new
HashSet<ITextSourceReference>();
for (IParameter param : params) {
ITextSourceReference declaration =
param.getAnnotationPosition(CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
- if(declaration!=null) {
+ if (declaration != null) {
disposerDeclarations.add(declaration);
}
}
- if(disposerDeclarations.size()>1) {
+ if (disposerDeclarations.size() > 1) {
for (ITextSourceReference declaration : disposerDeclarations) {
addError(CDIValidationMessages.MULTIPLE_DISPOSING_PARAMETERS,
CDIPreferences.MULTIPLE_DISPOSING_PARAMETERS, declaration, bean.getResource());
}
}
/*
- * 3.3.6. Declaring a disposer method
- * - a disposer method has a parameter annotated @Observes.
- *
- * 10.4.2. Declaring an observer method
- * - a observer method has a parameter annotated @Disposes.
+ * 3.3.6. Declaring a disposer method - a disposer method has a
+ * parameter annotated @Observes.
+ *
+ * 10.4.2. Declaring an observer method - a observer method has a
+ * parameter annotated @Disposes.
*/
Set<ITextSourceReference> declarations = new
HashSet<ITextSourceReference>();
boolean observesExists = false;
declarations.addAll(disposerDeclarations);
for (IParameter param : params) {
ITextSourceReference declaration =
param.getAnnotationPosition(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
- if(declaration!=null) {
+ if (declaration != null) {
declarations.add(declaration);
observesExists = true;
}
}
- if(observesExists) {
+ if (observesExists) {
for (ITextSourceReference declaration : declarations) {
- addError(CDIValidationMessages.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferences.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED, declaration, bean.getResource());
+ addError(CDIValidationMessages.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferences.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED, declaration,
+ bean.getResource());
}
}
/*
- * 3.3.6. Declaring a disposer method
- * - a disposer method is annotated @Inject.
- *
- * 3.9.1. Declaring an initializer method
- * - an initializer method has a parameter annotated @Disposes
+ * 3.3.6. Declaring a disposer method - a disposer method is
+ * annotated @Inject.
+ *
+ * 3.9.1. Declaring an initializer method - an initializer method
+ * has a parameter annotated @Disposes
*/
IAnnotationDeclaration injectDeclaration =
disposer.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
- if(injectDeclaration!=null) {
+ if (injectDeclaration != null) {
addError(CDIValidationMessages.DISPOSER_ANNOTATED_INJECT,
CDIPreferences.DISPOSER_ANNOTATED_INJECT, injectDeclaration, bean.getResource());
for (ITextSourceReference declaration : disposerDeclarations) {
addError(CDIValidationMessages.DISPOSER_ANNOTATED_INJECT,
CDIPreferences.DISPOSER_ANNOTATED_INJECT, declaration, bean.getResource());
@@ -402,42 +432,48 @@
}
/*
- * 3.3.6. Declaring a disposer method
- * - a non-static method of a session bean class has a parameter annotated @Disposes,
and the method is not a business method of the session bean
+ * 3.3.6. Declaring a disposer method - a non-static method of a
+ * session bean class has a parameter annotated @Disposes, and the
+ * method is not a business method of the session bean
*/
- validateSessionBeanMethod(bean, disposer, disposerDeclarations,
CDIValidationMessages.ILLEGAL_DISPOSER_IN_SESSION_BEAN,
CDIPreferences.ILLEGAL_DISPOSER_IN_SESSION_BEAN);
+ validateSessionBeanMethod(bean, disposer, disposerDeclarations,
CDIValidationMessages.ILLEGAL_DISPOSER_IN_SESSION_BEAN,
+ CDIPreferences.ILLEGAL_DISPOSER_IN_SESSION_BEAN);
/*
- * 3.3.6. Declaring a disposer method
- * - decorators may not declare disposer methods
+ * 3.3.6. Declaring a disposer method - decorators may not declare
+ * disposer methods
*/
- if(bean instanceof IDecorator) {
- IDecorator decorator = (IDecorator)bean;
+ if (bean instanceof IDecorator) {
+ IDecorator decorator = (IDecorator) bean;
IAnnotationDeclaration decoratorDeclaration = decorator.getDecoratorAnnotation();
- addError(CDIValidationMessages.DISPOSER_IN_DECORATOR,
CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, decoratorDeclaration,
bean.getResource());
+ addError(CDIValidationMessages.DISPOSER_IN_DECORATOR,
CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, decoratorDeclaration, bean
+ .getResource());
for (ITextSourceReference declaration : disposerDeclarations) {
addError(CDIValidationMessages.DISPOSER_IN_DECORATOR,
CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, declaration, bean.getResource());
}
}
/*
- * 3.3.6. Declaring a disposer method
- * - interceptors may not declare disposer methods
+ * 3.3.6. Declaring a disposer method - interceptors may not declare
+ * disposer methods
*/
- if(bean instanceof IInterceptor) {
- IInterceptor interceptor = (IInterceptor)bean;
+ if (bean instanceof IInterceptor) {
+ IInterceptor interceptor = (IInterceptor) bean;
IAnnotationDeclaration interceptorDeclaration =
interceptor.getInterceptorAnnotation();
- addError(CDIValidationMessages.DISPOSER_IN_INTERCEPTOR,
CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, interceptorDeclaration,
bean.getResource());
+ addError(CDIValidationMessages.DISPOSER_IN_INTERCEPTOR,
CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, interceptorDeclaration, bean
+ .getResource());
for (ITextSourceReference declaration : disposerDeclarations) {
- addError(CDIValidationMessages.DISPOSER_IN_INTERCEPTOR,
CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, declaration, bean.getResource());
+ addError(CDIValidationMessages.DISPOSER_IN_INTERCEPTOR,
CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR, declaration, bean
+ .getResource());
}
}
/*
- * 3.3.7. Disposer method resolution
- * - there is no producer method declared by the (same) bean class that is assignable
to the disposed parameter of a disposer method
+ * 3.3.7. Disposer method resolution - there is no producer method
+ * declared by the (same) bean class that is assignable to the
+ * disposed parameter of a disposer method
*/
- if(!boundDisposers.contains(disposer)) {
+ if (!boundDisposers.contains(disposer)) {
for (ITextSourceReference declaration : disposerDeclarations) {
addError(CDIValidationMessages.NO_PRODUCER_MATCHING_DISPOSER,
CDIPreferences.NO_PRODUCER_MATCHING_DISPOSER, declaration, bean.getResource());
}
@@ -446,7 +482,8 @@
}
/**
- * If the method is not a static method and is not a business method of the session bean
and is observer or disposer then mark it as incorrect.
+ * If the method is not a static method and is not a business method of the
+ * session bean and is observer or disposer then mark it as incorrect.
*
* @param bean
* @param method
@@ -454,109 +491,75 @@
* @param errorKey
*/
private void validateSessionBeanMethod(IClassBean bean, IBeanMethod method,
Set<ITextSourceReference> annotatedParams, String errorMessageKey, String
preferencesKey) {
- if(bean instanceof ISessionBean) {
- if(annotatedParams!=null) {
- try {
- if(!Flags.isStatic(method.getMethod().getFlags())) {
- ISessionBean sessionBean = (ISessionBean)bean;
- Set<IParametedType> types = sessionBean.getLegalTypes();
- boolean businessMethod = false;
- for (IParametedType type : types) {
- IType sourceType = type.getType();
- if(sourceType==null) {
- continue;
- }
- IAnnotation annotation =
sourceType.getAnnotation(CDIConstants.LOCAL_ANNOTATION_TYPE_NAME);
- if(annotation==null) {
- annotation = sourceType.getAnnotation("Local"); //$NON-NLS-N1
- }
- if(annotation!=null &&
CDIConstants.LOCAL_ANNOTATION_TYPE_NAME.equals(EclipseJavaUtil.resolveType(sourceType,
"Local"))) { //$NON-NLS-N1
- IMethod[] methods = sourceType.getMethods();
- for (IMethod iMethod : methods) {
- if(method.getMethod().isSimilar(iMethod)) {
- businessMethod = true;
- break;
- }
- }
- break;
- }
- }
- if(!businessMethod) {
- for (ITextSourceReference declaration : annotatedParams) {
- addError(errorMessageKey, preferencesKey, declaration, bean.getResource());
- }
- }
- }
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
+ if (bean instanceof ISessionBean && annotatedParams != null) {
+ IMethod iMethod = CDIUtil.getBusinessMethodDeclaration((SessionBean)bean, method);
+ if(iMethod==null) {
+ saveAllSuperTypesAsLinkedResources(bean);
+ for (ITextSourceReference declaration : annotatedParams) {
+ addError(errorMessageKey, preferencesKey, declaration, bean.getResource());
}
+ } else {
+ validationContext.addLinkedCoreResource(bean.getSourcePath().toOSString(),
iMethod.getResource().getFullPath(), false);
}
}
}
- private static final String[] RESOURCE_ANNOTATIONS =
{CDIConstants.RESOURCE_ANNOTATION_TYPE_NAME,
CDIConstants.WEB_SERVICE_REF_ANNOTATION_TYPE_NAME, CDIConstants.EJB_ANNOTATION_TYPE_NAME,
CDIConstants.PERSISTENCE_CONTEXT_ANNOTATION_TYPE_NAME,
CDIConstants.PERSISTENCE_UNIT_ANNOTATION_TYPE_NAME};
+ private static final String[] RESOURCE_ANNOTATIONS = {
CDIConstants.RESOURCE_ANNOTATION_TYPE_NAME,
CDIConstants.WEB_SERVICE_REF_ANNOTATION_TYPE_NAME, CDIConstants.EJB_ANNOTATION_TYPE_NAME,
CDIConstants.PERSISTENCE_CONTEXT_ANNOTATION_TYPE_NAME,
CDIConstants.PERSISTENCE_UNIT_ANNOTATION_TYPE_NAME };
private void validateProducer(IProducer producer) {
try {
- Set<ITypeDeclaration> typeDeclarations = producer
- .getAllTypeDeclarations();
+ Set<ITypeDeclaration> typeDeclarations = producer.getAllTypeDeclarations();
ITypeDeclaration typeDeclaration = null;
if (!typeDeclarations.isEmpty()) {
/*
- * 3.3. Producer methods
- * - producer method return type contains a wildcard type parameter
+ * 3.3. Producer methods - producer method return type contains
+ * a wildcard type parameter
*
- * 2.2.1 Legal bean types
- * - a parameterized type that contains a wildcard type parameter is not a legal
bean type.
+ * 2.2.1 Legal bean types - a parameterized type that contains a
+ * wildcard type parameter is not a legal bean type.
*
- * 3.4. Producer fields
- * - producer field type contains a wildcard type parameter
+ * 3.4. Producer fields - producer field type contains a
+ * wildcard type parameter
*/
- typeDeclaration = typeDeclarations.iterator()
- .next();
- String[] paramTypes = Signature
- .getTypeArguments(typeDeclaration.getSignature());
+ typeDeclaration = typeDeclarations.iterator().next();
+ String[] paramTypes = Signature.getTypeArguments(typeDeclaration.getSignature());
for (String paramType : paramTypes) {
if (Signature.getTypeSignatureKind(paramType) == Signature.WILDCARD_TYPE_SIGNATURE)
{
if (producer instanceof IProducerField) {
- addError(
- CDIValidationMessages.PRODUCER_FIELD_TYPE_HAS_WILDCARD,
- CDIPreferences.PRODUCER_FIELD_TYPE_HAS_WILDCARD,
- typeDeclaration, producer.getResource());
+ addError(CDIValidationMessages.PRODUCER_FIELD_TYPE_HAS_WILDCARD,
CDIPreferences.PRODUCER_FIELD_TYPE_HAS_WILDCARD, typeDeclaration,
+ producer.getResource());
} else {
- addError(
- CDIValidationMessages.PRODUCER_METHOD_RETURN_TYPE_HAS_WILDCARD,
- CDIPreferences.PRODUCER_METHOD_RETURN_TYPE_HAS_WILDCARD,
+ addError(CDIValidationMessages.PRODUCER_METHOD_RETURN_TYPE_HAS_WILDCARD,
CDIPreferences.PRODUCER_METHOD_RETURN_TYPE_HAS_WILDCARD,
typeDeclaration, producer.getResource());
}
}
}
/**
- * 3.3. Producer methods
- * - producer method with a parameterized return type with a type variable declares
any scope other than @Dependent
- *
- * 3.4. Producer fields
- * - producer field with a parameterized type with a type variable declares any
scope other than @Dependent
+ * 3.3. Producer methods - producer method with a parameterized
+ * return type with a type variable declares any scope other
+ * than @Dependent
+ *
+ * 3.4. Producer fields - producer field with a parameterized
+ * type with a type variable declares any scope other than @Dependent
*/
- if(paramTypes.length>0) {
+ if (paramTypes.length > 0) {
IAnnotationDeclaration scopeOrStereotypeDeclaration =
CDIUtil.getDifferentScopeDeclarationThanDepentend(producer);
- if(scopeOrStereotypeDeclaration!=null) {
+ if (scopeOrStereotypeDeclaration != null) {
boolean field = producer instanceof IProducerField;
- addError(
- field?CDIValidationMessages.ILLEGAL_SCOPE_FOR_PRODUCER_FIELD:CDIValidationMessages.ILLEGAL_SCOPE_FOR_PRODUCER_METHOD,
- field?CDIPreferences.ILLEGAL_SCOPE_FOR_PRODUCER_FIELD:CDIPreferences.ILLEGAL_SCOPE_FOR_PRODUCER_METHOD,
+ addError(field ? CDIValidationMessages.ILLEGAL_SCOPE_FOR_PRODUCER_FIELD :
CDIValidationMessages.ILLEGAL_SCOPE_FOR_PRODUCER_METHOD,
+ field ? CDIPreferences.ILLEGAL_SCOPE_FOR_PRODUCER_FIELD :
CDIPreferences.ILLEGAL_SCOPE_FOR_PRODUCER_METHOD,
scopeOrStereotypeDeclaration, producer.getResource());
}
}
}
/*
- * 3.3.2. Declaring a producer method
- * - producer method is annotated @Inject
+ * 3.3.2. Declaring a producer method - producer method is annotated
+ * @Inject
*/
IAnnotationDeclaration inject =
producer.getAnnotation(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
- if(inject!=null) {
+ if (inject != null) {
addError(CDIValidationMessages.PRODUCER_ANNOTATED_INJECT,
CDIPreferences.PRODUCER_ANNOTATED_INJECT, inject, producer.getResource());
}
@@ -564,93 +567,89 @@
if (producer instanceof IProducerField) {
/*
- * 3.5.1. Declaring a resource
- * - producer field declaration specifies an EL name (together with one of
@Resource, @PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
+ * 3.5.1. Declaring a resource - producer field declaration
+ * specifies an EL name (together with one of @Resource,
+ * @PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
*/
IProducerField producerField = (IProducerField) producer;
if (producerField.getName() != null) {
IAnnotationDeclaration declaration;
for (String annotationType : RESOURCE_ANNOTATIONS) {
- declaration = producerField
- .getAnnotation(annotationType);
+ declaration = producerField.getAnnotation(annotationType);
if (declaration != null) {
- IAnnotationDeclaration nameDeclaration = producerField
- .getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
+ IAnnotationDeclaration nameDeclaration =
producerField.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
if (nameDeclaration != null) {
declaration = nameDeclaration;
}
- addError(
- CDIValidationMessages.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME,
- CDIPreferences.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME,
+ addError(CDIValidationMessages.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME,
CDIPreferences.RESOURCE_PRODUCER_FIELD_SETS_EL_NAME,
declaration, producer.getResource());
}
}
}
/*
- * 3.4. Producer fields
- * - producer field type is a type variable
+ * 3.4. Producer fields - producer field type is a type variable
*/
- if(typeVariables.length>0) {
+ if (typeVariables.length > 0) {
String typeSign = producerField.getField().getTypeSignature();
String typeString = Signature.toString(typeSign);
for (String variableSig : typeVariables) {
String variableName = Signature.getTypeVariable(variableSig);
- if(typeString.equals(variableName)) {
- addError(
- CDIValidationMessages.PRODUCER_FIELD_TYPE_IS_VARIABLE,
- CDIPreferences.PRODUCER_FIELD_TYPE_IS_VARIABLE,
- typeDeclaration!=null?typeDeclaration:producer, producer.getResource());
+ if (typeString.equals(variableName)) {
+ addError(CDIValidationMessages.PRODUCER_FIELD_TYPE_IS_VARIABLE,
CDIPreferences.PRODUCER_FIELD_TYPE_IS_VARIABLE,
+ typeDeclaration != null ? typeDeclaration : producer, producer.getResource());
}
}
}
} else {
IProducerMethod producerMethod = (IProducerMethod) producer;
List<IParameter> params = producerMethod.getParameters();
- Set<ITextSourceReference> declarations = new
HashSet<ITextSourceReference>();
- declarations
- .add(producerMethod
- .getAnnotation(CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME));
+ Set<ITextSourceReference> observesDeclarations = new
HashSet<ITextSourceReference>();
+ Set<ITextSourceReference> disposalDeclarations = new
HashSet<ITextSourceReference>();
+ observesDeclarations.add(producerMethod.getAnnotation(CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME));
+ disposalDeclarations.add(producerMethod.getAnnotation(CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME));
for (IParameter param : params) {
/*
- * 3.3.6. Declaring a disposer method
- * - a disposer method is annotated @Produces.
+ * 3.3.6. Declaring a disposer method - a disposer method is
+ * annotated @Produces.
*
- * 3.3.2. Declaring a producer method
- * - a has a parameter annotated @Disposes
+ * 3.3.2. Declaring a producer method - a has a parameter
+ * annotated @Disposes
*/
- ITextSourceReference declaration = param
- .getAnnotationPosition(CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
+ ITextSourceReference declaration =
param.getAnnotationPosition(CDIConstants.DISPOSES_ANNOTATION_TYPE_NAME);
if (declaration != null) {
- declarations.add(declaration);
+ disposalDeclarations.add(declaration);
}
/*
- * 3.3.2. Declaring a producer method
- * - a has a parameter annotated @Observers
+ * 3.3.2. Declaring a producer method - a has a parameter
+ * annotated @Observers
*
- * 10.4.2. Declaring an observer method
- * - an observer method is annotated @Produces
+ * 10.4.2. Declaring an observer method - an observer method
+ * is annotated @Produces
*/
- declaration = param
- .getAnnotationPosition(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
+ declaration =
param.getAnnotationPosition(CDIConstants.OBSERVERS_ANNOTATION_TYPE_NAME);
if (declaration != null) {
- declarations.add(declaration);
+ observesDeclarations.add(declaration);
}
}
- if (declarations.size() > 1) {
- for (ITextSourceReference declaration : declarations) {
- addError(
- CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED,
- CDIPreferences.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED,
+ if (observesDeclarations.size() > 1) {
+ for (ITextSourceReference declaration : observesDeclarations) {
+ addError(CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_OBSERVES,
CDIPreferences.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED,
declaration, producer.getResource());
}
}
+ if (disposalDeclarations.size() > 1) {
+ for (ITextSourceReference declaration : disposalDeclarations) {
+ addError(CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_DISPOSES,
CDIPreferences.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED,
+ declaration, producer.getResource());
+ }
+ }
/*
- * 3.3. Producer methods
- * - producer method return type is a type variable
+ * 3.3. Producer methods - producer method return type is a type
+ * variable
*
- * 2.2.1 - Legal bean types
- * - a type variable is not a legal bean type
+ * 2.2.1 - Legal bean types - a type variable is not a legal
+ * bean type
*/
String typeSign = producerMethod.getMethod().getReturnType();
String typeString = Signature.toString(typeSign);
@@ -658,50 +657,72 @@
boolean marked = false;
for (ITypeParameter param : paramTypes) {
String variableName = param.getElementName();
- if(variableName.equals(typeString)) {
- addError(
- CDIValidationMessages.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
- CDIPreferences.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
- typeDeclaration!=null?typeDeclaration:producer, producer.getResource());
+ if (variableName.equals(typeString)) {
+ addError(CDIValidationMessages.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
CDIPreferences.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
+ typeDeclaration != null ? typeDeclaration : producer, producer.getResource());
marked = true;
}
}
- if(!marked && typeVariables.length>0) {
+ if (!marked && typeVariables.length > 0) {
for (String variableSig : typeVariables) {
String variableName = Signature.getTypeVariable(variableSig);
- if(typeString.equals(variableName)) {
- addError(
- CDIValidationMessages.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
- CDIPreferences.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
- typeDeclaration!=null?typeDeclaration:producer, producer.getResource());
+ if (typeString.equals(variableName)) {
+ addError(CDIValidationMessages.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
CDIPreferences.PRODUCER_METHOD_RETURN_TYPE_IS_VARIABLE,
+ typeDeclaration != null ? typeDeclaration : producer, producer.getResource());
}
}
}
+ /*
+ * 3.3.2. Declaring a producer method
+ * - non-static method of a session bean class is annotated @Produces, and the
method is not a business method of the session bean
+ */
+ IClassBean classBean = producer.getClassBean();
+ if(classBean instanceof ISessionBean) {
+ IMethod method = CDIUtil.getBusinessMethodDeclaration((SessionBean)classBean,
producerMethod);
+ if(method==null) {
+ addError(CDIValidationMessages.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN,
CDIPreferences.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN, producer.getProducesAnnotation(),
producer.getResource());
+ saveAllSuperTypesAsLinkedResources(classBean);
+ } else {
+ validationContext.addLinkedCoreResource(classBean.getSourcePath().toOSString(),
method.getResource().getFullPath(), false);
+ }
+ }
}
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
}
}
+ private void saveAllSuperTypesAsLinkedResources(IClassBean bean) {
+ Set<IParametedType> types = bean.getAllTypes();
+ for (IParametedType type : types) {
+ IType superType = type.getType();
+ if(superType!=null && !superType.isBinary() &&
superType.getResource()!=null && superType!=bean.getBeanClass()) {
+ validationContext.addLinkedCoreResource(bean.getSourcePath().toOSString(),
superType.getResource().getFullPath(), false);
+ }
+ }
+ }
+
private void validateInjectionPoint(IInjectionPoint injection) {
/*
- * 3.11. The qualifier @Named at injection points
- * - injection point other than injected field declares a @Named annotation that does
not specify the value member
+ * 3.11. The qualifier @Named at injection points - injection point
+ * other than injected field declares a @Named annotation that does not
+ * specify the value member
*/
- if(!(injection instanceof IInjectionPointField)) {
+ if (!(injection instanceof IInjectionPointField)) {
IAnnotationDeclaration named =
injection.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
- if(named!=null) {
+ if (named != null) {
try {
IMemberValuePair[] values = named.getDeclaration().getMemberValuePairs();
boolean valueExists = false;
for (IMemberValuePair pair : values) {
- if("value".equals(pair.getMemberName())) {
+ if ("value".equals(pair.getMemberName())) {
valueExists = true;
break;
}
}
- if(!valueExists) {
- addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME,
CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME, named, injection.getResource());
+ if (!valueExists) {
+ addError(CDIValidationMessages.PARAM_INJECTION_DECLARES_EMPTY_NAME,
CDIPreferences.PARAM_INJECTION_DECLARES_EMPTY_NAME, named,
+ injection.getResource());
}
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
@@ -711,8 +732,9 @@
}
/**
- * Validates class bean which may be both a session and decorator (or interceptor).
- *
+ * Validates class bean which may be both a session and decorator (or
+ * interceptor).
+ *
* @param bean
*/
private void validateMixedClassBean(IClassBean bean) {
@@ -720,59 +742,67 @@
ITextSourceReference decoratorDeclaration =
bean.getAnnotation(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
ITextSourceReference interceptorDeclaration =
bean.getAnnotation(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
- if(sessionDeclaration!=null) {
+ if (sessionDeclaration != null) {
/*
- * 3.2. Session beans
- * - bean class of a session bean is annotated @Decorator
+ * 3.2. Session beans - bean class of a session bean is annotated
+ * @Decorator
*/
- if(decoratorDeclaration!=null) {
- addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_DECORATOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR, sessionDeclaration,
bean.getResource());
- addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_DECORATOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR, decoratorDeclaration,
bean.getResource());
+ if (decoratorDeclaration != null) {
+ addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_DECORATOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR,
+ sessionDeclaration, bean.getResource());
+ addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_DECORATOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR,
+ decoratorDeclaration, bean.getResource());
}
/*
- * 3.2. Session beans
- * - bean class of a session bean is annotated @Interceptor
+ * 3.2. Session beans - bean class of a session bean is annotated
+ * @Interceptor
*/
- if(interceptorDeclaration!=null) {
- addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_INTERCEPTOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR, sessionDeclaration,
bean.getResource());
- addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_INTERCEPTOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR, interceptorDeclaration,
bean.getResource());
+ if (interceptorDeclaration != null) {
+ addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_INTERCEPTOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR,
+ sessionDeclaration, bean.getResource());
+ addError(CDIValidationMessages.SESSION_BEAN_ANNOTATED_INTERCEPTOR,
CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR,
+ interceptorDeclaration, bean.getResource());
}
}
}
private void validateSessionBean(ISessionBean bean) {
IAnnotationDeclaration declaration =
CDIUtil.getDifferentScopeDeclarationThanDepentend(bean);
- if(declaration!=null) {
+ if (declaration != null) {
IType type = bean.getBeanClass();
try {
/*
- * 3.2. Session beans
- * - session bean with a parameterized bean class declares any scope other than
@Dependent
+ * 3.2. Session beans - session bean with a parameterized bean
+ * class declares any scope other than @Dependent
*/
String[] typeVariables = type.getTypeParameterSignatures();
- if(typeVariables.length>0) {
- addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_SESSION_BEAN_WITH_GENERIC_TYPE,
CDIPreferences.ILLEGAL_SCOPE_FOR_SESSION_BEAN, declaration, bean.getResource());
+ if (typeVariables.length > 0) {
+ addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_SESSION_BEAN_WITH_GENERIC_TYPE,
CDIPreferences.ILLEGAL_SCOPE_FOR_SESSION_BEAN,
+ declaration, bean.getResource());
} else {
- if(bean.isStateless()) {
+ if (bean.isStateless()) {
/*
- * 3.2. Session beans
- * - session bean specifies an illegal scope
- * (a stateless session bean must belong to the @Dependent pseudo-scope)
+ * 3.2. Session beans - session bean specifies an
+ * illegal scope (a stateless session bean must belong
+ * to the @Dependent pseudo-scope)
*/
- if(declaration!=null) {
- addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_STATELESS_SESSION_BEAN,
CDIPreferences.ILLEGAL_SCOPE_FOR_SESSION_BEAN, declaration, bean.getResource());
+ if (declaration != null) {
+ addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_STATELESS_SESSION_BEAN,
CDIPreferences.ILLEGAL_SCOPE_FOR_SESSION_BEAN,
+ declaration, bean.getResource());
}
- } else if(bean.isSingleton()) {
+ } else if (bean.isSingleton()) {
/*
- * 3.2. Session beans
- * - session bean specifies an illegal scope
- * (a singleton bean must belong to either the @ApplicationScoped scope or to the
@Dependent pseudo-scope)
+ * 3.2. Session beans - session bean specifies an
+ * illegal scope (a singleton bean must belong to either
+ * the @ApplicationScoped scope or to the @Dependent
+ * pseudo-scope)
*/
- if(declaration!=null) {
+ if (declaration != null) {
declaration = CDIUtil.getDifferentScopeDeclarationThanApplicationScoped(bean);
}
- if(declaration!=null) {
- addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_SINGLETON_SESSION_BEAN,
CDIPreferences.ILLEGAL_SCOPE_FOR_SESSION_BEAN, declaration, bean.getResource());
+ if (declaration != null) {
+ addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_SINGLETON_SESSION_BEAN,
CDIPreferences.ILLEGAL_SCOPE_FOR_SESSION_BEAN,
+ declaration, bean.getResource());
}
}
}
@@ -781,93 +811,101 @@
}
}
/*
- * 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
*/
IAnnotationDeclaration specializesDeclaration =
bean.getSpecializesAnnotationDeclaration();
- if(specializesDeclaration!=null) {
+ if (specializesDeclaration != null) {
+ saveAllSuperTypesAsLinkedResources(bean);
IBean sBean = bean.getSpecializedBean();
- if(sBean==null) {
+ 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());
+ 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) {
/*
- * 3.1. Managed beans
- * - the bean class of a managed bean is annotated with both the @Interceptor and
@Decorator stereotypes
+ * 3.1. Managed beans - the bean class of a managed bean is annotated with both the
@Interceptor and @Decorator stereotypes
*/
IAnnotationDeclaration decorator =
bean.getAnnotation(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
IAnnotationDeclaration interceptor =
bean.getAnnotation(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
- if(decorator!=null && interceptor!=null) {
+ if (decorator != null && interceptor != null) {
addError(CDIValidationMessages.BOTH_INTERCEPTOR_AND_DECORATOR,
CDIPreferences.BOTH_INTERCEPTOR_AND_DECORATOR, decorator, bean.getResource());
addError(CDIValidationMessages.BOTH_INTERCEPTOR_AND_DECORATOR,
CDIPreferences.BOTH_INTERCEPTOR_AND_DECORATOR, interceptor, bean.getResource());
}
IAnnotationDeclaration declaration =
CDIUtil.getDifferentScopeDeclarationThanDepentend(bean);
- if(declaration!=null) {
+ if (declaration != null) {
IType type = bean.getBeanClass();
try {
/*
- * 3.1. Managed beans
- * - managed bean with a public field declares any scope other than @Dependent
+ * 3.1. Managed beans - managed bean with a public field declares any scope other
than @Dependent
*/
IField[] fields = type.getFields();
for (IField field : fields) {
- if(Flags.isPublic(field.getFlags()) && !Flags.isStatic(field.getFlags())) {
- addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD,
CDIPreferences.ILLEGAL_SCOPE_FOR_MANAGED_BEAN, declaration, bean.getResource());
+ if (Flags.isPublic(field.getFlags()) && !Flags.isStatic(field.getFlags()))
{
+ addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_PUBLIC_FIELD,
CDIPreferences.ILLEGAL_SCOPE_FOR_MANAGED_BEAN,
+ declaration, bean.getResource());
break;
}
}
/*
- * 3.1. Managed beans
- * - managed bean with a parameterized bean class declares any scope other than
@Dependent
+ * 3.1. Managed beans - managed bean with a parameterized bean class declares any
scope other than @Dependent
*/
String[] typeVariables = type.getTypeParameterSignatures();
- if(typeVariables.length>0) {
- addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_GENERIC_TYPE,
CDIPreferences.ILLEGAL_SCOPE_FOR_MANAGED_BEAN, declaration, bean.getResource());
+ if (typeVariables.length > 0) {
+ addError(CDIValidationMessages.ILLEGAL_SCOPE_FOR_MANAGED_BEAN_WITH_GENERIC_TYPE,
CDIPreferences.ILLEGAL_SCOPE_FOR_MANAGED_BEAN,
+ declaration, bean.getResource());
}
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
}
}
/*
- * 3.1.4. Specializing a managed bean
- * - managed bean class annotated @Specializes does not directly extend the bean class
of another managed bean
+ * 3.1.4. Specializing a managed bean - managed bean class annotated @Specializes does
not directly extend the bean class of another managed bean
*/
IAnnotationDeclaration specializesDeclaration =
bean.getSpecializesAnnotationDeclaration();
- if(specializesDeclaration!=null) {
+ if (specializesDeclaration != null) {
+ saveAllSuperTypesAsLinkedResources(bean);
try {
IBean sBean = bean.getSpecializedBean();
- if(sBean!=null) {
- if(sBean instanceof ISessionBean ||
sBean.getAnnotation(CDIConstants.STATELESS_ANNOTATION_TYPE_NAME)!=null ||
sBean.getAnnotation(CDIConstants.SINGLETON_ANNOTATION_TYPE_NAME)!=null) {
+ if (sBean != null) {
+ if (sBean instanceof ISessionBean ||
sBean.getAnnotation(CDIConstants.STATELESS_ANNOTATION_TYPE_NAME) != null
+ || sBean.getAnnotation(CDIConstants.SINGLETON_ANNOTATION_TYPE_NAME) != null) {
// The specializing bean directly extends an enterprise bean class
- addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, specializesDeclaration,
bean.getResource());
+ addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
+ specializesDeclaration, bean.getResource());
} else {
// Validate the specializing bean extends a non simple bean
boolean hasDefaultConstructor = true;
IMethod[] methods = sBean.getBeanClass().getMethods();
for (IMethod method : methods) {
- if(method.isConstructor()) {
- if(Flags.isPublic(method.getFlags()) &&
method.getParameterNames().length==0) {
+ if (method.isConstructor()) {
+ if (Flags.isPublic(method.getFlags()) &&
method.getParameterNames().length == 0) {
hasDefaultConstructor = true;
break;
}
hasDefaultConstructor = false;
}
}
- if(!hasDefaultConstructor) {
- addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, specializesDeclaration,
bean.getResource());
+ if (!hasDefaultConstructor) {
+ addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
+ specializesDeclaration, bean.getResource());
}
}
} else {
// The specializing bean extends nothing
- addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, specializesDeclaration,
bean.getResource());
+ addError(CDIValidationMessages.ILLEGAL_SPECIALIZING_MANAGED_BEAN,
CDIPreferences.ILLEGAL_SPECIALIZING_MANAGED_BEAN, specializesDeclaration,
+ bean.getResource());
}
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
@@ -877,84 +915,103 @@
private void validateInterceptor(IInterceptor interceptor) {
/*
- * 2.5.3. Beans with no EL name
- * - interceptor has a name (Non-Portable behavior)
+ * 2.5.3. Beans with no EL name - interceptor has a name (Non-Portable behavior)
*/
- if(interceptor.getName()!=null) {
+ if (interceptor.getName() != null) {
ITextSourceReference declaration =
interceptor.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
if (declaration == null) {
declaration =
interceptor.getAnnotation(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
}
- if(declaration==null) {
+ if (declaration == null) {
declaration = CDIUtil.getNamedStereotypeDeclaration(interceptor);
}
addError(CDIValidationMessages.INTERCEPTOR_HAS_NAME,
CDIPreferences.INTERCEPTOR_HAS_NAME, declaration, interceptor.getResource());
}
/*
- * 2.6.1. Declaring an alternative
- * - interceptor is an alternative (Non-Portable behavior)
+ * 2.6.1. Declaring an alternative - interceptor is an alternative (Non-Portable
behavior)
*/
- if(interceptor.isAlternative()) {
+ if (interceptor.isAlternative()) {
ITextSourceReference declaration = interceptor.getAlternativeDeclaration();
- if(declaration==null) {
+ if (declaration == null) {
declaration = interceptor.getInterceptorAnnotation();
}
- addError(CDIValidationMessages.INTERCEPTOR_IS_ALTERNATIVE,
CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE, declaration,
interceptor.getResource());
+ addError(CDIValidationMessages.INTERCEPTOR_IS_ALTERNATIVE,
CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE, declaration, interceptor
+ .getResource());
}
+ /*
+ * 3.3.2. Declaring a producer method
+ * - interceptor has a method annotated @Produces
+ *
+ * 3.4.2. Declaring a producer field
+ * - interceptor has a field annotated @Produces
+ */
+ Set<IProducer> producers = interceptor.getProducers();
+ for (IProducer producer : producers) {
+ addError(CDIValidationMessages.PRODUCER_IN_INTERCEPTOR,
CDIPreferences.PRODUCER_IN_INTERCEPTOR_OR_DECORATOR, producer.getProducesAnnotation(),
interceptor.getResource());
+ }
}
private void validateDecorator(IDecorator decorator) {
/*
- * 2.5.3. Beans with no EL name
- * - decorator has a name (Non-Portable behavior)
+ * 2.5.3. Beans with no EL name - decorator has a name (Non-Portable behavior)
*/
- if(decorator.getName()!=null) {
+ if (decorator.getName() != null) {
ITextSourceReference declaration =
decorator.getAnnotation(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
if (declaration == null) {
declaration = decorator.getAnnotation(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
}
- if(declaration==null) {
+ if (declaration == null) {
declaration = CDIUtil.getNamedStereotypeDeclaration(decorator);
}
addError(CDIValidationMessages.DECORATOR_HAS_NAME, CDIPreferences.DECORATOR_HAS_NAME,
declaration, decorator.getResource());
}
/*
- * 2.6.1. Declaring an alternative
- * - decorator is an alternative (Non-Portable behavior)
+ * 2.6.1. Declaring an alternative - decorator is an alternative (Non-Portable
behavior)
*/
- if(decorator.isAlternative()) {
+ if (decorator.isAlternative()) {
ITextSourceReference declaration = decorator.getAlternativeDeclaration();
- if(declaration==null) {
+ if (declaration == null) {
declaration = decorator.getDecoratorAnnotation();
}
addError(CDIValidationMessages.DECORATOR_IS_ALTERNATIVE,
CDIPreferences.INTERCEPTOR_OR_DECORATOR_IS_ALTERNATIVE, declaration,
decorator.getResource());
}
+
+ /*
+ * 3.3.2. Declaring a producer method
+ * - decorator has a method annotated @Produces
+ *
+ * 3.4.2. Declaring a producer field
+ * - decorator has a field annotated @Produces
+ */
+ Set<IProducer> producers = decorator.getProducers();
+ for (IProducer producer : producers) {
+ addError(CDIValidationMessages.PRODUCER_IN_DECORATOR,
CDIPreferences.PRODUCER_IN_INTERCEPTOR_OR_DECORATOR, producer.getProducesAnnotation(),
decorator.getResource());
+ }
}
/*
- * 2.2.2. Restricting the bean types of a bean
- * - bean class or producer method or field specifies a @Typed annotation,
- * and the value member specifies a class which does not correspond to a type
- * in the unrestricted set of bean types of a bean
+ * 2.2.2. Restricting the bean types of a bean - bean class or producer method or field
specifies a @Typed annotation,
+ * and the value member specifies a class which does not correspond to a type in
the unrestricted set of bean types of a bean
*/
private void validateTyped(IBean bean) {
Set<ITypeDeclaration> typedDeclarations = bean.getRestrictedTypeDeclaratios();
- if(!typedDeclarations.isEmpty()) {
+ if (!typedDeclarations.isEmpty()) {
Set<IParametedType> allTypes = bean.getAllTypes();
for (ITypeDeclaration typedDeclaration : typedDeclarations) {
IType typedType = typedDeclaration.getType();
- if(typedType!=null) {
+ if (typedType != null) {
boolean typeWasFound = false;
for (IParametedType type : allTypes) {
- if(type!=null &&
typedType.getFullyQualifiedName().equals(type.getType().getFullyQualifiedName())) {
+ if (type != null &&
typedType.getFullyQualifiedName().equals(type.getType().getFullyQualifiedName())) {
typeWasFound = true;
break;
}
}
- if(!typeWasFound) {
- addError(CDIValidationMessages.ILLEGAL_TYPE_IN_TYPED_DECLARATION,
CDIPreferences.ILLEGAL_TYPE_IN_TYPED_DECLARATION, typedDeclaration, bean.getResource());
+ if (!typeWasFound) {
+ addError(CDIValidationMessages.ILLEGAL_TYPE_IN_TYPED_DECLARATION,
CDIPreferences.ILLEGAL_TYPE_IN_TYPED_DECLARATION, typedDeclaration,
+ bean.getResource());
}
}
}
@@ -963,49 +1020,54 @@
private void validateBeanScope(IBean bean) {
Set<IScopeDeclaration> scopes = bean.getScopeDeclarations();
- // 2.4.3. Declaring the bean scope
- // - bean class or producer method or field specifies multiple scope type
annotations
+ // 2.4.3. Declaring the bean scope
+ // - bean class or producer method or field specifies multiple scope type
annotations
//
- if(scopes.size()>1) {
+ if (scopes.size() > 1) {
for (IScopeDeclaration scope : scopes) {
addError(CDIValidationMessages.MULTIPLE_SCOPE_TYPE_ANNOTATIONS,
CDIPreferences.MULTIPLE_SCOPE_TYPE_ANNOTATIONS, scope, bean.getResource());
}
}
// 2.4.4. Default scope
- // - bean does not explicitly declare a scope when there is no default scope
- // (there are two different stereotypes declared by the bean that declare
different default scopes)
+ // - bean does not explicitly declare a scope when there is no default
+ // scope
+ // (there are two different stereotypes declared by the bean that
+ // declare different default scopes)
//
- // Such bean definitions are invalid because they declares two stereotypes that
have different default scopes and the bean does not explictly define a scope to resolve
the conflict.
+ // Such bean definitions are invalid because they declares two
+ // stereotypes that have different default scopes and the bean does not
+ // explictly define a scope to resolve the conflict.
Set<IStereotypeDeclaration> stereotypeDeclarations =
bean.getStereotypeDeclarations();
- if(!stereotypeDeclarations.isEmpty() && scopes.isEmpty()) {
+ if (!stereotypeDeclarations.isEmpty() && scopes.isEmpty()) {
Map<String, IStereotypeDeclaration> declarationMap = new HashMap<String,
IStereotypeDeclaration>();
for (IStereotypeDeclaration stereotypeDeclaration : stereotypeDeclarations) {
IStereotype stereotype = stereotypeDeclaration.getStereotype();
IScope scope = stereotype.getScope();
- if(scope!=null) {
+ if (scope != null) {
declarationMap.put(scope.getSourceType().getFullyQualifiedName(),
stereotypeDeclaration);
}
}
- if(declarationMap.size()>1) {
+ if (declarationMap.size() > 1) {
for (IStereotypeDeclaration stereotypeDeclaration : declarationMap.values()) {
- addError(CDIValidationMessages.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE,
CDIPreferences.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE, stereotypeDeclaration,
bean.getResource());
+ addError(CDIValidationMessages.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE,
CDIPreferences.MISSING_SCOPE_WHEN_THERE_IS_NO_DEFAULT_SCOPE,
+ stereotypeDeclaration, bean.getResource());
}
}
}
/*
- * 2.4.1. Built-in scope types
- * - interceptor or decorator has any scope other than @Dependent (Non-Portable
behavior)
+ * 2.4.1. Built-in scope types - interceptor or decorator has any scope
+ * other than @Dependent (Non-Portable behavior)
*/
boolean interceptor = bean instanceof IInterceptor;
boolean decorator = bean instanceof IDecorator;
- if(interceptor || decorator) {
+ if (interceptor || decorator) {
IAnnotationDeclaration scopeOrStereotypeDeclaration =
CDIUtil.getDifferentScopeDeclarationThanDepentend(bean);
- if(scopeOrStereotypeDeclaration!=null) {
+ if (scopeOrStereotypeDeclaration != null) {
String key = CDIPreferences.ILLEGAL_SCOPE_FOR_DECORATOR;
String message = CDIValidationMessages.ILLEGAL_SCOPE_FOR_DECORATOR;
- if(interceptor) {
+ if (interceptor) {
key = CDIPreferences.ILLEGAL_SCOPE_FOR_INTERCEPTOR;
message = CDIValidationMessages.ILLEGAL_SCOPE_FOR_INTERCEPTOR;
}
@@ -1021,59 +1083,61 @@
*/
private void validateStereotype(IStereotype stereotype) {
// 2.7.1.3. Declaring a @Named stereotype
- // - stereotype declares a non-empty @Named annotation (Non-Portable
behavior)
- // - stereotype declares any other qualifier annotation
- // - stereotype is annotated @Typed
+ // - stereotype declares a non-empty @Named annotation (Non-Portable
+ // behavior)
+ // - stereotype declares any other qualifier annotation
+ // - stereotype is annotated @Typed
- if(stereotype == null) {
+ if (stereotype == null) {
return;
}
IResource resource = stereotype.getResource();
- if(resource == null || !resource.getName().toLowerCase().endsWith(".java"))
{
- //validate sources only
+ if (resource == null || !resource.getName().toLowerCase().endsWith(".java"))
{
+ // validate sources only
return;
}
List<IAnnotationDeclaration> as = stereotype.getAnnotationDeclarations();
// 1. non-empty name
IAnnotationDeclaration nameDeclaration = stereotype.getNameDeclaration();
- if(nameDeclaration != null) {
+ if (nameDeclaration != null) {
IMemberValuePair[] ps = null;
try {
ps = nameDeclaration.getDeclaration().getMemberValuePairs();
} catch (JavaModelException e) {
CDICorePlugin.getDefault().logError(e);
}
- if(ps != null && ps.length > 0) {
+ if (ps != null && ps.length > 0) {
Object name = ps[0].getValue();
- if(name != null && name.toString().length() > 0) {
+ if (name != null && name.toString().length() > 0) {
ITextSourceReference location = nameDeclaration;
addError(CDIValidationMessages.STEREOTYPE_DECLARES_NON_EMPTY_NAME,
CDIPreferences.STEREOTYPE_DECLARES_NON_EMPTY_NAME, location, resource);
}
}
}
- // 2. typed annotation
+ // 2. typed annotation
IAnnotationDeclaration typedDeclaration =
stereotype.getAnnotationDeclaration(CDIConstants.TYPED_ANNOTATION_TYPE_NAME);
- if(typedDeclaration != null) {
+ if (typedDeclaration != null) {
ITextSourceReference location = typedDeclaration;
addError(CDIValidationMessages.STEREOTYPE_IS_ANNOTATED_TYPED,
CDIPreferences.STEREOTYPE_IS_ANNOTATED_TYPED, location, resource);
}
// 3. Qualifier other than @Named
- for (IAnnotationDeclaration a: as) {
- if(a instanceof IQualifierDeclaration && a != nameDeclaration) {
+ for (IAnnotationDeclaration a : as) {
+ if (a instanceof IQualifierDeclaration && a != nameDeclaration) {
ITextSourceReference location = a;
addError(CDIValidationMessages.ILLEGAL_QUALIFIER_IN_STEREOTYPE,
CDIPreferences.ILLEGAL_QUALIFIER_IN_STEREOTYPE, location, resource);
}
}
// 2.7.1.1. Declaring the default scope for a stereotype
- // - stereotype declares more than one scope
+ // - stereotype declares more than one scope
Set<IScopeDeclaration> scopeDeclarations = stereotype.getScopeDeclarations();
- if(scopeDeclarations.size()>1) {
+ if (scopeDeclarations.size() > 1) {
for (IScopeDeclaration scope : scopeDeclarations) {
- addError(CDIValidationMessages.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE,
CDIPreferences.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE, scope, stereotype.getResource());
+ addError(CDIValidationMessages.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE,
CDIPreferences.STEREOTYPE_DECLARES_MORE_THAN_ONE_SCOPE, scope,
+ stereotype.getResource());
}
}
}
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-05-19
16:39:54 UTC (rev 22203)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/CDIValidationMessages.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -53,7 +53,8 @@
public static String ILLEGAL_SCOPE_FOR_DECORATOR;
public static String PRODUCER_ANNOTATED_INJECT;
- public static String PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED;
+ public static String PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_DISPOSES;
+ public static String PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_OBSERVES;
public static String OBSERVER_ANNOTATED_INJECT;
public static String OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED;
public static String ILLEGAL_PRODUCER_METHOD_IN_SESSION_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-19
16:39:54 UTC (rev 22203)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/errorList.txt 2010-05-19
19:41:00 UTC (rev 22204)
@@ -57,9 +57,6 @@
any scope other than @Dependent
- producer method return type is a type variable
-
-
-
3.3.2. Declaring a producer method
- producer method is annotated @Inject
- producer method has a parameter annotated @Disposes
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-05-19
16:39:54 UTC (rev 22203)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/validation/messages.properties 2010-05-19
19:41:00 UTC (rev 22204)
@@ -32,7 +32,8 @@
ILLEGAL_SCOPE_FOR_DECORATOR=Decorator has any scope other than @Dependent
PRODUCER_ANNOTATED_INJECT=Producer method or field is annotated @Inject
-PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED=Producer method has a parameter annotated
@Disposes or @Observes
+PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_DISPOSES=Producer method has a parameter annotated
@Disposes
+PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_OBSERVES=Producer method has a parameter annotated
@Observes
OBSERVER_ANNOTATED_INJECT=Observer method is annotated @Inject
OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED=Observer method has a parameter annotated
@Disposes
ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN=Non-static method of a session bean class is
annotated @Produces, and the method is not a business method of the session bean
@@ -52,8 +53,8 @@
BOTH_INTERCEPTOR_AND_DECORATOR=The bean class of a managed bean is annotated with both
the @Interceptor and @Decorator stereotypes
SESSION_BEAN_ANNOTATED_INTERCEPTOR=Bean class of a session bean is annotated
@Interceptor
SESSION_BEAN_ANNOTATED_DECORATOR=Bean class of a session bean is annotated @Decorator
-PRODUCER_IN_INTERCEPTOR=Interceptor has a member annotated @Produces
-PRODUCER_IN_DECORATOR=Decorator has a member annotated @Produces
+PRODUCER_IN_INTERCEPTOR=Producer cannot be declared in an interceptor
+PRODUCER_IN_DECORATOR=Producer cannot be declared in a decorator
DISPOSER_IN_INTERCEPTOR=Interceptor has a method annotated @Disposes
DISPOSER_IN_DECORATOR=Decorator has a method annotated @Disposes
MULTIPLE_DELEGATE=Decorator has more than one delegate injection point
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-19
16:39:54 UTC (rev 22203)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/preferences/CDIConfigurationBlock.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -80,7 +80,7 @@
{CDIPreferences.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerParameterIllegallyAnnotated_label},
// {CDIPreferences.OBSERVER_ANNOTATED_INJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerAnnotatedInject_label},
{CDIPreferences.OBSERVER_PARAMETER_ILLEGALLY_ANNOTATED,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_observerParameterIllegallyAnnotated_label},
-// {CDIPreferences.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalProducerMethodInSessionBean_label},
+ {CDIPreferences.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalProducerMethodInSessionBean_label},
{CDIPreferences.MULTIPLE_DISPOSING_PARAMETERS,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleDisposingParameters_label},
{CDIPreferences.DISPOSER_ANNOTATED_INJECT,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_disposerAnnotatedInject_label},
{CDIPreferences.ILLEGAL_DISPOSER_IN_SESSION_BEAN,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_illegalDisposerInSessionBean_label},
@@ -102,7 +102,7 @@
new String[][]{
{CDIPreferences.BOTH_INTERCEPTOR_AND_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_bothInterceptorAndDecorator_label},
{CDIPreferences.SESSION_BEAN_ANNOTATED_INTERCEPTOR_OR_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_sessionBeanAnnotatedInterceptorOrDecorator_label},
-// {CDIPreferences.PRODUCER_IN_INTERCEPTOR_OR_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerInInterceptorOrDecorator_label},
+ {CDIPreferences.PRODUCER_IN_INTERCEPTOR_OR_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_producerInInterceptorOrDecorator_label},
{CDIPreferences.DISPOSER_IN_INTERCEPTOR_OR_DECORATOR,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_disposerInInterceptorOrDecorator_label},
// {CDIPreferences.MULTIPLE_DELEGATE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_multipleDelegate_label},
// {CDIPreferences.MISSING_DELEGATE,
CDIPreferencesMessages.CDIValidatorConfigurationBlock_pb_missingDelegate_label},
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerFieldBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerFieldBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerFieldBroken.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -0,0 +1,10 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.producers;
+
+import javax.decorator.Decorator;
+import javax.enterprise.inject.Produces;
+
+@Decorator
+public class DecoratorHasProducerFieldBroken {
+
+ @Produces public FunnelWeaver<String> getAnotherFunnelWeaver;
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerFieldBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerMethodBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerMethodBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerMethodBroken.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.producers;
+
+import javax.decorator.Decorator;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+@Decorator
+public class DecoratorHasProducerMethodBroken {
+
+ @Produces
+ public FunnelWeaver<String> create2(InjectionPoint point) {
+ return null;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/DecoratorHasProducerMethodBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerFieldBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerFieldBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerFieldBroken.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.producers;
+
+import javax.enterprise.inject.Produces;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+public class InterceptorHasProducerFieldBroken {
+
+ @AroundInvoke
+ public Object alwaysReturnThis(InvocationContext ctx) throws Exception {
+ return ctx.proceed();
+ }
+
+ @Produces public FunnelWeaver<String> anotherFunnelWeaver;
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerFieldBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerMethodBroken.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerMethodBroken.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerMethodBroken.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.jbt.validation.producers;
+
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+public class InterceptorHasProducerMethodBroken {
+
+ @AroundInvoke
+ public Object alwaysReturnThis(InvocationContext ctx) throws Exception {
+ return ctx.proceed();
+ }
+
+ @Produces
+ public FunnelWeaver<String> create2(InjectionPoint point) {
+ return null;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/jbt/validation/producers/InterceptorHasProducerMethodBroken.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-19
16:39:54 UTC (rev 22203)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/ValidationTest.java 2010-05-19
19:41:00 UTC (rev 22204)
@@ -479,7 +479,7 @@
*/
public void testProducerMethodWithParameterAnnotatedDisposes() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/implementation/producer/method/broken/parameterAnnotatedDisposes/SpiderProducer_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED, 25, 26);
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_DISPOSES, 25, 26);
}
/**
@@ -490,10 +490,43 @@
*/
public void testProducerMethodWithParameterAnnotatedObserves() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/implementation/producer/method/broken/parameterAnnotatedObserves/SpiderProducer_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED, 25, 26);
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_OBSERVES, 25, 26);
}
/**
+ * 3.3.2. Declaring a producer method
+ * - non-static method of a session bean class is annotated @Produces, and the method
is not a business method of the session bean
+ *
+ * @throws Exception
+ */
+ public void testProducerMethodOnSessionBeanMustBeBusinessMethod() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/implementation/producer/method/broken/enterprise/nonbusiness/FooProducer.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.ILLEGAL_PRODUCER_METHOD_IN_SESSION_BEAN, 25);
+ }
+
+ /**
+ * 3.3.2. Declaring a producer method
+ * - decorator has a method annotated @Produces
+ *
+ * @throws Exception
+ */
+ public void testDecoratorMustNotHaveProducerMethod() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/producers/DecoratorHasProducerMethodBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.PRODUCER_IN_DECORATOR, 10);
+ }
+
+ /**
+ * 3.3.2. Declaring a producer method
+ * - interceptor has a method annotated @Produces
+ *
+ * @throws Exception
+ */
+ public void testInterceptorMustNotHaveProducerMethod() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/producers/InterceptorHasProducerMethodBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.PRODUCER_IN_INTERCEPTOR,
17);
+ }
+
+ /**
* 3.5.1. Declaring a resource
* - producer field declaration specifies an EL name (together with one of @Resource,
@PersistenceContext, @PersistenceUnit, @EJB, @WebServiceRef)
*
@@ -534,7 +567,7 @@
*/
public void testProducesUnallowed() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/implementation/disposal/method/definition/broken/producesUnallowed/SpiderProducer_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED, 30, 31);
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_DISPOSES, 30, 31);
}
/**
@@ -655,6 +688,28 @@
}
/**
+ * 3.4.2. Declaring a producer field
+ * - decorator has a field annotated @Produces
+ *
+ * @throws Exception
+ */
+ public void testDecoratorMustNotHaveProducerField() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/producers/DecoratorHasProducerFieldBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.PRODUCER_IN_DECORATOR, 9);
+ }
+
+ /**
+ * 3.4.2. Declaring a producer field
+ * - interceptor has a field annotated @Produces
+ *
+ * @throws Exception
+ */
+ public void testInterceptorMustNotHaveProducerField() throws Exception {
+ IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/jbt/validation/producers/InterceptorHasProducerFieldBroken.java");
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE, CDIValidationMessages.PRODUCER_IN_INTERCEPTOR,
16);
+ }
+
+ /**
* 3.9.1. Declaring an initializer method
* - an initializer method has a parameter annotated @Disposes
*
@@ -674,7 +729,7 @@
*/
public void testObserverMethodAnnotatedProducesFails() throws Exception {
IFile file =
tckProject.getFile("JavaSource/org/jboss/jsr299/tck/tests/event/broken/observer/isProducer/BorderTerrier_Broken.java");
- AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED, 25, 25);
+ AbstractResourceMarkerTest.assertMarkerIsCreated(file,
AbstractResourceMarkerTest.MARKER_TYPE,
CDIValidationMessages.PRODUCER_PARAMETER_ILLEGALLY_ANNOTATED_OBSERVES, 25, 25);
}
/**