diff --git a/org.springframework.config.java/.classpath b/org.springframework.config.java/.classpath index c978df07108..67c0c4a333e 100644 --- a/org.springframework.config.java/.classpath +++ b/org.springframework.config.java/.classpath @@ -1,5 +1,6 @@ + @@ -12,5 +13,6 @@ + diff --git a/org.springframework.config.java/.project b/org.springframework.config.java/.project index d73d5ca3e59..4607e560c88 100644 --- a/org.springframework.config.java/.project +++ b/org.springframework.config.java/.project @@ -10,11 +10,21 @@ + + com.cenqua.clover.core.prejavabuilder + + + org.eclipse.jdt.core.javabuilder + + com.cenqua.clover.core.postjavabuilder + + + org.eclipse.wst.validation.validationbuilder @@ -32,5 +42,6 @@ org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.jem.workbench.JavaEMFNature + com.cenqua.clover.core.clovernature diff --git a/org.springframework.config.java/ivy.xml b/org.springframework.config.java/ivy.xml index 12c95fc021b..6c62bd00512 100644 --- a/org.springframework.config.java/ivy.xml +++ b/org.springframework.config.java/ivy.xml @@ -28,6 +28,7 @@ + diff --git a/org.springframework.config.java/src/main/java/org/springframework/config/java/BeanMethod.java b/org.springframework.config.java/src/main/java/org/springframework/config/java/BeanMethod.java index 23f5508a12a..606ee570351 100644 --- a/org.springframework.config.java/src/main/java/org/springframework/config/java/BeanMethod.java +++ b/org.springframework.config.java/src/main/java/org/springframework/config/java/BeanMethod.java @@ -33,7 +33,6 @@ public final class BeanMethod implements Validatable { private final List annotations = new ArrayList(); private transient ConfigurationClass declaringClass; private transient int lineNumber; - private transient final List validators = new ArrayList(); public BeanMethod(String name, int modifiers, ModelClass returnType, Annotation... annotations) { Assert.hasText(name); @@ -117,10 +116,6 @@ public final class BeanMethod implements Validatable { return lineNumber; } - public void registerValidator(Validator validator) { - validators.add(validator); - } - public void validate(List errors) { if (Modifier.isPrivate(getModifiers())) @@ -129,33 +124,16 @@ public final class BeanMethod implements Validatable { if (Modifier.isFinal(getModifiers())) errors.add(new FinalMethodError()); - new BeanValidator().validate(this, errors); + if (this.getAnnotation(ScopedProxy.class) == null) + return; + + Bean bean =this.getRequiredAnnotation(Bean.class); + + if (bean.scope().equals(StandardScopes.SINGLETON) + || bean.scope().equals(StandardScopes.PROTOTYPE)) + errors.add(new InvalidScopedProxyDeclarationError(this)); } -// public BeanDefinitionRegistrar getRegistrar() { -// return getInstance(factoryAnno.registrar()); -// } - -// public Set getValidators() { -// HashSet validators = new HashSet(); -// -//// for (Class validatorType : factoryAnno.validators()) -//// validator.add(getInstance(validatorType)); -// -// validators.add(IllegalB) -// -// return validators; -// } - -// public Callback getCallback() { -// Class callbackType = factoryAnno.interceptor(); -// -// if (callbackType.equals(NoOpInterceptor.class)) -// return NoOpInterceptor.INSTANCE; -// -// return getInstance(callbackType); -// } -// @Override public String toString() { String returnTypeName = returnType == null ? "" : returnType.getSimpleName(); @@ -227,31 +205,4 @@ public final class BeanMethod implements Validatable { } } -} - -/** - * Detects any user errors when declaring {@link Bean}-annotated methods. - * - * @author Chris Beams - */ -class BeanValidator implements Validator { - - public boolean supports(Object object) { - return object instanceof BeanMethod; - } - - public void validate(Object object, List errors) { - BeanMethod method = (BeanMethod) object; - - if (method.getAnnotation(ScopedProxy.class) == null) - return; - - Bean bean = method.getRequiredAnnotation(Bean.class); - - if (bean.scope().equals(StandardScopes.SINGLETON) - || bean.scope().equals(StandardScopes.PROTOTYPE)) - errors.add(new InvalidScopedProxyDeclarationError(method)); - } - -} - +} \ No newline at end of file diff --git a/org.springframework.config.java/src/main/java/org/springframework/config/java/ConfigurationModel.java b/org.springframework.config.java/src/main/java/org/springframework/config/java/ConfigurationModel.java index cd59c970943..9a8403ff8b6 100644 --- a/org.springframework.config.java/src/main/java/org/springframework/config/java/ConfigurationModel.java +++ b/org.springframework.config.java/src/main/java/org/springframework/config/java/ConfigurationModel.java @@ -43,7 +43,6 @@ public final class ConfigurationModel implements Validatable { /* list is used because order and collection equality matters. */ private final ArrayList configurationClasses = new ArrayList(); - private final ArrayList validators = new ArrayList(); /** * Add a {@link Configuration @Configuration} class to the model. Classes may be added @@ -57,10 +56,6 @@ public final class ConfigurationModel implements Validatable { return this; } - public void registerValidator(Validator validator) { - validators.add(validator); - } - /** * Return configuration classes that have been directly added to this model. * @@ -96,7 +91,6 @@ public final class ConfigurationModel implements Validatable { * * @see ConfigurationClass#validate(java.util.List) * @see BeanMethod#validate(java.util.List) - * @see Validator * @see UsageError */ public void validate(List errors) { @@ -104,27 +98,20 @@ public final class ConfigurationModel implements Validatable { if (configurationClasses.isEmpty()) errors.add(new EmptyModelError()); - // cascade through model and allow handlers to register validators - // depending on where they are registered (with the model, the class, or the method) - // they will be called directly or indirectly below -// for (ConfigurationClass configClass : getAllConfigurationClasses()) { -// for (BeanMethod method : configClass.getMethods()) { -// for (Validator validator : method.getValidators()) { -// if (validator.supports(method)) -// method.registerValidator(validator); -// // TODO: support class-level validation -// // if(validator.supports(configClass)) -// // configClass.registerValidator(validator); -// if (validator.supports(this)) -// this.registerValidator(validator); -// } -// } -// } - - // process any validators registered directly with this model object -// for (Validator validator : validators) -// validator.validate(this, errors); - new IllegalBeanOverrideValidator().validate(this, errors); + // check for any illegal @Bean overriding + ConfigurationClass[] allClasses = getAllConfigurationClasses(); + for (int i = 0; i < allClasses.length; i++) { + for (BeanMethod method : allClasses[i].getMethods()) { + Bean bean = method.getAnnotation(Bean.class); + + if (bean == null || bean.allowOverriding()) + continue; + + for (int j = i + 1; j < allClasses.length; j++) + if (allClasses[j].hasMethod(method.getName())) + errors.add(allClasses[i].new IllegalBeanOverrideError(allClasses[j], method)); + } + } // each individual configuration class must be well-formed // note that each configClass detects usage errors on its imports recursively @@ -176,39 +163,4 @@ public final class ConfigurationModel implements Validatable { } } -} - -/** - * Detects any illegally-overridden {@link Bean} definitions within a particular - * {@link ConfigurationModel} - * - * @see Bean#allowOverriding() - * - * @author Chris Beams - */ -class IllegalBeanOverrideValidator implements Validator { - - public boolean supports(Object object) { - return object instanceof ConfigurationModel; - } - - public void validate(Object object, List errors) { - ConfigurationModel model = (ConfigurationModel) object; - - ConfigurationClass[] allClasses = model.getAllConfigurationClasses(); - - for (int i = 0; i < allClasses.length; i++) { - for (BeanMethod method : allClasses[i].getMethods()) { - Bean bean = method.getAnnotation(Bean.class); - - if (bean == null || bean.allowOverriding()) - continue; - - for (int j = i + 1; j < allClasses.length; j++) - if (allClasses[j].hasMethod(method.getName())) - errors.add(allClasses[i].new IllegalBeanOverrideError(allClasses[j], method)); - } - } - } - -} +} \ No newline at end of file diff --git a/org.springframework.config.java/src/main/java/org/springframework/config/java/Validatable.java b/org.springframework.config.java/src/main/java/org/springframework/config/java/Validatable.java index 8eecc4076de..b2260baadea 100644 --- a/org.springframework.config.java/src/main/java/org/springframework/config/java/Validatable.java +++ b/org.springframework.config.java/src/main/java/org/springframework/config/java/Validatable.java @@ -6,8 +6,6 @@ import java.util.List; /** * Indicates a type is able to be validated for errors. * - * @see Validator - * * @author Chris Beams */ interface Validatable { diff --git a/org.springframework.config.java/src/main/java/org/springframework/config/java/Validator.java b/org.springframework.config.java/src/main/java/org/springframework/config/java/Validator.java deleted file mode 100644 index e0b6b5f5952..00000000000 --- a/org.springframework.config.java/src/main/java/org/springframework/config/java/Validator.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.springframework.config.java; - -import java.util.List; - - -interface Validator { - boolean supports(Object object); - - void validate(Object object, List errors); -}