+ Eliminated .util package
+ Renamed DefaultScopes -> Scopes + Renamed MalformedJavaConfigurationException -> MalformedConfigurationException
This commit is contained in:
parent
f43e1110e9
commit
c0c8117d51
|
|
@ -26,16 +26,16 @@ import java.util.List;
|
|||
* @author Chris Beams
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MalformedJavaConfigurationException extends RuntimeException {
|
||||
public class MalformedConfigurationException extends RuntimeException {
|
||||
|
||||
private final List<? extends UsageError> errors;
|
||||
|
||||
public MalformedJavaConfigurationException(String message) {
|
||||
public MalformedConfigurationException(String message) {
|
||||
super(message);
|
||||
this.errors = new ArrayList<UsageError>();
|
||||
}
|
||||
|
||||
public MalformedJavaConfigurationException(UsageError... errors) {
|
||||
public MalformedConfigurationException(UsageError... errors) {
|
||||
super(toString(errors));
|
||||
this.errors = Arrays.asList(errors);
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -13,22 +13,26 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.config.java.util;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
package org.springframework.config.java;
|
||||
|
||||
|
||||
/**
|
||||
* Constant class contains the names of the scopes supported out of the box in Spring 2.0.
|
||||
* Enumerates the names of the scopes supported out of the box in Spring.
|
||||
* <p>
|
||||
* Not modeled as an actual java enum because annotations that accept a scope
|
||||
* attribute must allow for user-defined scope names. Given that java
|
||||
* enums are not extensible, these must remain simple string constants.
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Chris Beams
|
||||
* @since 3.0
|
||||
*/
|
||||
public abstract class DefaultScopes {
|
||||
public class Scopes {
|
||||
|
||||
private Scopes() { }
|
||||
|
||||
public static final String SINGLETON = BeanDefinition.SCOPE_SINGLETON;
|
||||
public static final String SINGLETON = "singleton"; // see BeanDefinition.SCOPE_SINGLETON;
|
||||
|
||||
public static final String PROTOTYPE = BeanDefinition.SCOPE_PROTOTYPE;
|
||||
public static final String PROTOTYPE = "prototype"; // see BeanDefinition.SCOPE_PROTOTYPE;
|
||||
|
||||
public static final String REQUEST = "request"; // see WebApplicationContext.SCOPE_REQUEST;
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ package org.springframework.config.java;
|
|||
* possible usage errors.
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @see MalformedJavaConfigurationException
|
||||
* @see MalformedConfigurationException
|
||||
*/
|
||||
public abstract class UsageError {
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.springframework.config.java.ConfigurationClass;
|
|||
import org.springframework.config.java.ConfigurationModel;
|
||||
import org.springframework.config.java.Factory;
|
||||
import org.springframework.config.java.ModelMethod;
|
||||
import org.springframework.config.java.Scopes;
|
||||
import org.springframework.config.java.UsageError;
|
||||
import org.springframework.config.java.Validator;
|
||||
|
||||
|
|
@ -90,7 +91,7 @@ public @interface Bean {
|
|||
* Scope: whether the bean is a singleton, prototype or custom scope.
|
||||
* Default is singleton.
|
||||
*/
|
||||
String scope() default BeanDefinition.SCOPE_SINGLETON;
|
||||
String scope() default Scopes.SINGLETON;
|
||||
|
||||
/**
|
||||
* Bean autowire strategy.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
|
|||
import org.springframework.config.java.BeanDefinitionRegistrar;
|
||||
import org.springframework.config.java.Configuration;
|
||||
import org.springframework.config.java.ConfigurationClass;
|
||||
import org.springframework.config.java.MalformedJavaConfigurationException;
|
||||
import org.springframework.config.java.MalformedConfigurationException;
|
||||
import org.springframework.config.java.ModelMethod;
|
||||
import org.springframework.config.java.UsageError;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
|
|
@ -72,7 +72,7 @@ class BeanRegistrar implements BeanDefinitionRegistrar {
|
|||
// ensure that overriding is ok
|
||||
if (bean.allowOverriding() == false) {
|
||||
UsageError error = configClass.new IllegalBeanOverrideError(null, method);
|
||||
throw new MalformedJavaConfigurationException(error);
|
||||
throw new MalformedConfigurationException(error);
|
||||
}
|
||||
|
||||
// overriding is legal, return immediately
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.config.java.Configuration;
|
||||
import org.springframework.config.java.ConfigurationModel;
|
||||
import org.springframework.config.java.MalformedJavaConfigurationException;
|
||||
import org.springframework.config.java.MalformedConfigurationException;
|
||||
import org.springframework.config.java.UsageError;
|
||||
import org.springframework.config.java.internal.enhancement.ConfigurationEnhancer;
|
||||
import org.springframework.config.java.internal.parsing.ConfigurationParser;
|
||||
|
|
@ -102,7 +102,7 @@ public class ConfigurationPostProcessor implements Ordered, BeanFactoryPostProce
|
|||
ArrayList<UsageError> errors = new ArrayList<UsageError>();
|
||||
model.validate(errors);
|
||||
if (errors.size() > 0)
|
||||
throw new MalformedJavaConfigurationException(errors.toArray(new UsageError[] { }));
|
||||
throw new MalformedConfigurationException(errors.toArray(new UsageError[] { }));
|
||||
|
||||
modelBeanDefinitionReader.loadBeanDefinitions(model);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostP
|
|||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.config.java.Configuration;
|
||||
import org.springframework.config.java.Scopes;
|
||||
import org.springframework.config.java.ext.Bean;
|
||||
import org.springframework.config.java.support.ConfigurationPostProcessor;
|
||||
import org.springframework.config.java.util.DefaultScopes;
|
||||
|
||||
import test.beans.ITestBean;
|
||||
import test.beans.TestBean;
|
||||
|
|
@ -89,7 +89,7 @@ public class BasicTests {
|
|||
return bar;
|
||||
}
|
||||
|
||||
@Bean(scope=DefaultScopes.PROTOTYPE)
|
||||
@Bean(scope=Scopes.PROTOTYPE)
|
||||
public TestBean baz() {
|
||||
return new TestBean("bar");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue