@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2006 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -25,7 +25,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|||||||
* TargetSourceCreator that enforces a LazyInitTargetSource for each bean
|
* TargetSourceCreator that enforces a LazyInitTargetSource for each bean
|
||||||
* that is defined as "lazy-init". This will lead to a proxy created for
|
* that is defined as "lazy-init". This will lead to a proxy created for
|
||||||
* each of those beans, allowing to fetch a reference to such a bean
|
* each of those beans, allowing to fetch a reference to such a bean
|
||||||
* without actually initialized the target bean instance.
|
* without actually initializing the target bean instance.
|
||||||
*
|
*
|
||||||
* <p>To be registered as custom TargetSourceCreator for an auto-proxy creator,
|
* <p>To be registered as custom TargetSourceCreator for an auto-proxy creator,
|
||||||
* in combination with custom interceptors for specific beans or for the
|
* in combination with custom interceptors for specific beans or for the
|
||||||
@@ -60,7 +60,7 @@ public class LazyInitTargetSourceCreator extends AbstractBeanFactoryBasedTargetS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
|
||||||
Class beanClass, String beanName) {
|
Class<?> beanClass, String beanName) {
|
||||||
|
|
||||||
if (getBeanFactory() instanceof ConfigurableListableBeanFactory) {
|
if (getBeanFactory() instanceof ConfigurableListableBeanFactory) {
|
||||||
BeanDefinition definition =
|
BeanDefinition definition =
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -24,7 +24,6 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
import org.springframework.aop.TargetSource;
|
import org.springframework.aop.TargetSource;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
import org.springframework.beans.factory.BeanFactoryAware;
|
import org.springframework.beans.factory.BeanFactoryAware;
|
||||||
import org.springframework.util.ClassUtils;
|
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,8 +47,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
* @see ThreadLocalTargetSource
|
* @see ThreadLocalTargetSource
|
||||||
* @see CommonsPoolTargetSource
|
* @see CommonsPoolTargetSource
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBeanFactoryBasedTargetSource
|
public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSource, BeanFactoryAware, Serializable {
|
||||||
implements TargetSource, BeanFactoryAware, Serializable {
|
|
||||||
|
|
||||||
/** use serialVersionUID from Spring 1.2.7 for interoperability */
|
/** use serialVersionUID from Spring 1.2.7 for interoperability */
|
||||||
private static final long serialVersionUID = -4721607536018568393L;
|
private static final long serialVersionUID = -4721607536018568393L;
|
||||||
@@ -97,7 +95,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
|
|||||||
* <p>Default is to detect the type automatically, through a {@code getType}
|
* <p>Default is to detect the type automatically, through a {@code getType}
|
||||||
* call on the BeanFactory (or even a full {@code getBean} call as fallback).
|
* call on the BeanFactory (or even a full {@code getBean} call as fallback).
|
||||||
*/
|
*/
|
||||||
public void setTargetClass(Class targetClass) {
|
public void setTargetClass(Class<?> targetClass) {
|
||||||
this.targetClass = targetClass;
|
this.targetClass = targetClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +105,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
|
|||||||
*/
|
*/
|
||||||
public void setBeanFactory(BeanFactory beanFactory) {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
if (this.targetBeanName == null) {
|
if (this.targetBeanName == null) {
|
||||||
throw new IllegalStateException("Property'targetBeanName' is required");
|
throw new IllegalStateException("Property 'targetBeanName' is required");
|
||||||
}
|
}
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
}
|
}
|
||||||
@@ -181,8 +179,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder(getClass().getSimpleName());
|
||||||
sb.append(ClassUtils.getShortName(getClass()));
|
|
||||||
sb.append(" for target bean '").append(this.targetBeanName).append("'");
|
sb.append(" for target bean '").append(this.targetBeanName).append("'");
|
||||||
if (this.targetClass != null) {
|
if (this.targetClass != null) {
|
||||||
sb.append(" of type [").append(this.targetClass.getName()).append("]");
|
sb.append(" of type [").append(this.targetClass.getName()).append("]");
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class ExtendedBeanInfo implements BeanInfo {
|
|||||||
matches.add(method);
|
matches.add(method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// sort non-void returning write methods to guard against the ill effects of
|
// Sort non-void returning write methods to guard against the ill effects of
|
||||||
// non-deterministic sorting of methods returned from Class#getDeclaredMethods
|
// non-deterministic sorting of methods returned from Class#getDeclaredMethods
|
||||||
// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
|
// under JDK 7. See http://bugs.sun.com/view_bug.do?bug_id=7023180
|
||||||
Collections.sort(matches, new Comparator<Method>() {
|
Collections.sort(matches, new Comparator<Method>() {
|
||||||
@@ -428,24 +428,24 @@ class SimpleIndexedPropertyDescriptor extends IndexedPropertyDescriptor {
|
|||||||
* See java.beans.IndexedPropertyDescriptor#equals(java.lang.Object)
|
* See java.beans.IndexedPropertyDescriptor#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && obj instanceof IndexedPropertyDescriptor) {
|
if (!(other instanceof IndexedPropertyDescriptor)) {
|
||||||
IndexedPropertyDescriptor other = (IndexedPropertyDescriptor) obj;
|
return false;
|
||||||
if (!compareMethods(getIndexedReadMethod(), other.getIndexedReadMethod())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!compareMethods(getIndexedWriteMethod(), other.getIndexedWriteMethod())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getIndexedPropertyType() != other.getIndexedPropertyType()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return PropertyDescriptorUtils.equals(this, obj);
|
|
||||||
}
|
}
|
||||||
return false;
|
IndexedPropertyDescriptor otherPd = (IndexedPropertyDescriptor) other;
|
||||||
|
if (!compareMethods(getIndexedReadMethod(), otherPd.getIndexedReadMethod())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!compareMethods(getIndexedWriteMethod(), otherPd.getIndexedWriteMethod())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getIndexedPropertyType() != otherPd.getIndexedPropertyType()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return PropertyDescriptorUtils.equals(this, other);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -586,25 +586,23 @@ class PropertyDescriptorUtils {
|
|||||||
* editor and flags are equivalent.
|
* editor and flags are equivalent.
|
||||||
* @see PropertyDescriptor#equals(Object)
|
* @see PropertyDescriptor#equals(Object)
|
||||||
*/
|
*/
|
||||||
public static boolean equals(PropertyDescriptor pd1, Object obj) {
|
public static boolean equals(PropertyDescriptor pd, Object other) {
|
||||||
if (pd1 == obj) {
|
if (pd == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && obj instanceof PropertyDescriptor) {
|
if (!(other instanceof PropertyDescriptor)) {
|
||||||
PropertyDescriptor pd2 = (PropertyDescriptor) obj;
|
return false;
|
||||||
if (!compareMethods(pd1.getReadMethod(), pd2.getReadMethod())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!compareMethods(pd1.getWriteMethod(), pd2.getWriteMethod())) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (pd1.getPropertyType() == pd2.getPropertyType() &&
|
|
||||||
pd1.getPropertyEditorClass() == pd2.getPropertyEditorClass() &&
|
|
||||||
pd1.isBound() == pd2.isBound() && pd1.isConstrained() == pd2.isConstrained()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
PropertyDescriptor otherPd = (PropertyDescriptor) other;
|
||||||
|
if (!compareMethods(pd.getReadMethod(), otherPd.getReadMethod())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!compareMethods(pd.getWriteMethod(), otherPd.getWriteMethod())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (pd.getPropertyType() == otherPd.getPropertyType() &&
|
||||||
|
pd.getPropertyEditorClass() == otherPd.getPropertyEditorClass() &&
|
||||||
|
pd.isBound() == otherPd.isBound() && pd.isConstrained() == otherPd.isConstrained());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -101,6 +101,7 @@ public class ConfigurationClassPostConstructAndAutowiringTests {
|
|||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config2 {
|
static class Config2 {
|
||||||
|
|
||||||
TestBean testBean;
|
TestBean testBean;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ public class ImportBeanDefinitionRegistrarTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldInvokeAwareMethodsInImportBeanDefinitionRegistrar() {
|
public void shouldInvokeAwareMethodsInImportBeanDefinitionRegistrar() {
|
||||||
|
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
|
||||||
context.getBean(MessageSource.class);
|
context.getBean(MessageSource.class);
|
||||||
|
|
||||||
@@ -55,19 +54,20 @@ public class ImportBeanDefinitionRegistrarTests {
|
|||||||
assertThat(SampleRegistrar.resourceLoader, is(notNullValue()));
|
assertThat(SampleRegistrar.resourceLoader, is(notNullValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Sample
|
@Sample
|
||||||
@Configuration
|
@Configuration
|
||||||
static class Config {
|
static class Config {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Import(SampleRegistrar.class)
|
@Import(SampleRegistrar.class)
|
||||||
public static @interface Sample {
|
public static @interface Sample {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static class SampleRegistrar implements ImportBeanDefinitionRegistrar, BeanClassLoaderAware, ResourceLoaderAware,
|
static class SampleRegistrar implements ImportBeanDefinitionRegistrar, BeanClassLoaderAware, ResourceLoaderAware,
|
||||||
BeanFactoryAware {
|
BeanFactoryAware {
|
||||||
|
|
||||||
@@ -94,4 +94,5 @@ public class ImportBeanDefinitionRegistrarTests {
|
|||||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -67,7 +67,6 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*;
|
|||||||
import static org.springframework.context.ConfigurableApplicationContext.*;
|
import static org.springframework.context.ConfigurableApplicationContext.*;
|
||||||
import static org.springframework.core.env.EnvironmentIntegrationTests.Constants.*;
|
import static org.springframework.core.env.EnvironmentIntegrationTests.Constants.*;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Integration tests for container support of {@link Environment}
|
* Integration tests for container support of {@link Environment}
|
||||||
* interface.
|
* interface.
|
||||||
@@ -84,29 +83,15 @@ import static org.springframework.core.env.EnvironmentIntegrationTests.Constants
|
|||||||
*
|
*
|
||||||
* @author Chris Beams
|
* @author Chris Beams
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("resource")
|
||||||
public class EnvironmentIntegrationTests {
|
public class EnvironmentIntegrationTests {
|
||||||
|
|
||||||
private ConfigurableEnvironment prodEnv;
|
private ConfigurableEnvironment prodEnv;
|
||||||
|
|
||||||
private ConfigurableEnvironment devEnv;
|
private ConfigurableEnvironment devEnv;
|
||||||
|
|
||||||
private ConfigurableEnvironment prodWebEnv;
|
private ConfigurableEnvironment prodWebEnv;
|
||||||
|
|
||||||
/**
|
|
||||||
* Constants used both locally and in scan* sub-packages
|
|
||||||
*/
|
|
||||||
public static class Constants {
|
|
||||||
public static final String XML_PATH = "org/springframework/core/env/EnvironmentIntegrationTests-context.xml";
|
|
||||||
|
|
||||||
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
|
|
||||||
|
|
||||||
public static final String PROD_BEAN_NAME = "prodBean";
|
|
||||||
public static final String DEV_BEAN_NAME = "devBean";
|
|
||||||
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
|
|
||||||
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
|
|
||||||
|
|
||||||
public static final String PROD_ENV_NAME = "prod";
|
|
||||||
public static final String DEV_ENV_NAME = "dev";
|
|
||||||
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -122,9 +107,7 @@ public class EnvironmentIntegrationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void genericApplicationContext_standardEnv() {
|
public void genericApplicationContext_standardEnv() {
|
||||||
ConfigurableApplicationContext ctx =
|
ConfigurableApplicationContext ctx = new GenericApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
|
||||||
new GenericApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
|
|
||||||
|
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
|
|
||||||
assertHasStandardEnvironment(ctx);
|
assertHasStandardEnvironment(ctx);
|
||||||
@@ -134,8 +117,7 @@ public class EnvironmentIntegrationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void genericApplicationContext_customEnv() {
|
public void genericApplicationContext_customEnv() {
|
||||||
GenericApplicationContext ctx =
|
GenericApplicationContext ctx = new GenericApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
|
||||||
new GenericApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
|
|
||||||
ctx.setEnvironment(prodEnv);
|
ctx.setEnvironment(prodEnv);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
|
|
||||||
@@ -191,11 +173,8 @@ public class EnvironmentIntegrationTests {
|
|||||||
@Test
|
@Test
|
||||||
public void genericXmlApplicationContext() {
|
public void genericXmlApplicationContext() {
|
||||||
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
|
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
|
||||||
|
|
||||||
assertHasStandardEnvironment(ctx);
|
assertHasStandardEnvironment(ctx);
|
||||||
|
|
||||||
ctx.setEnvironment(prodEnv);
|
ctx.setEnvironment(prodEnv);
|
||||||
|
|
||||||
ctx.load(XML_PATH);
|
ctx.load(XML_PATH);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
|
|
||||||
@@ -208,8 +187,7 @@ public class EnvironmentIntegrationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void classPathXmlApplicationContext() {
|
public void classPathXmlApplicationContext() {
|
||||||
ConfigurableApplicationContext ctx =
|
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(XML_PATH);
|
||||||
new ClassPathXmlApplicationContext(new String[] { XML_PATH });
|
|
||||||
ctx.setEnvironment(prodEnv);
|
ctx.setEnvironment(prodEnv);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
|
|
||||||
@@ -228,7 +206,7 @@ public class EnvironmentIntegrationTests {
|
|||||||
|
|
||||||
// strange - FSXAC strips leading '/' unless prefixed with 'file:'
|
// strange - FSXAC strips leading '/' unless prefixed with 'file:'
|
||||||
ConfigurableApplicationContext ctx =
|
ConfigurableApplicationContext ctx =
|
||||||
new FileSystemXmlApplicationContext(new String[] { "file:"+tmpFile.getPath() }, false);
|
new FileSystemXmlApplicationContext(new String[] {"file:" + tmpFile.getPath()}, false);
|
||||||
ctx.setEnvironment(prodEnv);
|
ctx.setEnvironment(prodEnv);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
assertEnvironmentBeanRegistered(ctx);
|
assertEnvironmentBeanRegistered(ctx);
|
||||||
@@ -336,11 +314,8 @@ public class EnvironmentIntegrationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void webApplicationContext() {
|
public void webApplicationContext() {
|
||||||
GenericWebApplicationContext ctx =
|
GenericWebApplicationContext ctx = new GenericWebApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
|
||||||
new GenericWebApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
|
|
||||||
|
|
||||||
assertHasStandardServletEnvironment(ctx);
|
assertHasStandardServletEnvironment(ctx);
|
||||||
|
|
||||||
ctx.setEnvironment(prodWebEnv);
|
ctx.setEnvironment(prodWebEnv);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
|
|
||||||
@@ -588,7 +563,8 @@ public class EnvironmentIntegrationTests {
|
|||||||
try {
|
try {
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
fail("expected missing property exception");
|
fail("expected missing property exception");
|
||||||
} catch (MissingRequiredPropertiesException ex) {
|
}
|
||||||
|
catch (MissingRequiredPropertiesException ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -598,7 +574,6 @@ public class EnvironmentIntegrationTests {
|
|||||||
ctx.setEnvironment(new MockEnvironment().withProperty("foo", "fooValue"));
|
ctx.setEnvironment(new MockEnvironment().withProperty("foo", "fooValue"));
|
||||||
ctx.refresh(); // should succeed
|
ctx.refresh(); // should succeed
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -652,6 +627,7 @@ public class EnvironmentIntegrationTests {
|
|||||||
assertThat(ctx.getBean(EnvironmentAwareBean.class).environment, is(expectedEnv));
|
assertThat(ctx.getBean(EnvironmentAwareBean.class).environment, is(expectedEnv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class EnvironmentAwareBean implements EnvironmentAware {
|
private static class EnvironmentAwareBean implements EnvironmentAware {
|
||||||
|
|
||||||
public Environment environment;
|
public Environment environment;
|
||||||
@@ -660,9 +636,9 @@ public class EnvironmentIntegrationTests {
|
|||||||
public void setEnvironment(Environment environment) {
|
public void setEnvironment(Environment environment) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mirrors the structure of beans and environment-specific config files
|
* Mirrors the structure of beans and environment-specific config files
|
||||||
* in EnvironmentIntegrationTests-context.xml
|
* in EnvironmentIntegrationTests-context.xml
|
||||||
@@ -711,4 +687,25 @@ public class EnvironmentIntegrationTests {
|
|||||||
return new Object();
|
return new Object();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants used both locally and in scan* sub-packages
|
||||||
|
*/
|
||||||
|
public static class Constants {
|
||||||
|
|
||||||
|
public static final String XML_PATH = "org/springframework/core/env/EnvironmentIntegrationTests-context.xml";
|
||||||
|
|
||||||
|
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
|
||||||
|
|
||||||
|
public static final String PROD_BEAN_NAME = "prodBean";
|
||||||
|
public static final String DEV_BEAN_NAME = "devBean";
|
||||||
|
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
|
||||||
|
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
|
||||||
|
|
||||||
|
public static final String PROD_ENV_NAME = "prod";
|
||||||
|
public static final String DEV_ENV_NAME = "dev";
|
||||||
|
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user