@@ -53,6 +53,7 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
|
||||
* Name of the ConversionService bean in the factory.
|
||||
* If none is supplied, default conversion rules apply.
|
||||
* @see org.springframework.core.convert.ConversionService
|
||||
* @since 3.0
|
||||
*/
|
||||
String CONVERSION_SERVICE_BEAN_NAME = "conversionService";
|
||||
|
||||
@@ -60,12 +61,14 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
|
||||
* Name of the LoadTimeWeaver bean in the factory. If such a bean is supplied,
|
||||
* the context will use a temporary ClassLoader for type matching, in order
|
||||
* to allow the LoadTimeWeaver to process all actual bean classes.
|
||||
* @since 2.5
|
||||
* @see org.springframework.instrument.classloading.LoadTimeWeaver
|
||||
*/
|
||||
String LOAD_TIME_WEAVER_BEAN_NAME = "loadTimeWeaver";
|
||||
|
||||
/**
|
||||
* Name of the {@link Environment} bean in the factory.
|
||||
* @since 3.1
|
||||
*/
|
||||
String ENVIRONMENT_BEAN_NAME = "environment";
|
||||
|
||||
@@ -84,6 +87,7 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
|
||||
|
||||
/**
|
||||
* Set the unique id of this application context.
|
||||
* @since 3.0
|
||||
*/
|
||||
void setId(String id);
|
||||
|
||||
@@ -99,12 +103,14 @@ public interface ConfigurableApplicationContext extends ApplicationContext, Life
|
||||
|
||||
/**
|
||||
* Return the Environment for this application context in configurable form.
|
||||
* @since 3.1
|
||||
*/
|
||||
ConfigurableEnvironment getEnvironment();
|
||||
|
||||
/**
|
||||
* Set the {@code Environment} for this application context.
|
||||
* @param environment the new environment
|
||||
* @since 3.1
|
||||
*/
|
||||
void setEnvironment(ConfigurableEnvironment environment);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -35,24 +35,24 @@ import java.util.Map;
|
||||
*
|
||||
* <h4>Example: adding a new property source with highest search priority</h4>
|
||||
* <pre class="code">
|
||||
* ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
* MutablePropertySources propertySources = environment.getPropertySources();
|
||||
* Map<String, String> myMap = new HashMap<String, String>();
|
||||
* myMap.put("xyz", "myValue");
|
||||
* propertySources.addFirst(new MapPropertySource("MY_MAP", myMap));
|
||||
* ConfigurableEnvironment environment = new StandardEnvironment();
|
||||
* MutablePropertySources propertySources = environment.getPropertySources();
|
||||
* Map<String, String> myMap = new HashMap<String, String>();
|
||||
* myMap.put("xyz", "myValue");
|
||||
* propertySources.addFirst(new MapPropertySource("MY_MAP", myMap));
|
||||
* </pre>
|
||||
*
|
||||
* <h4>Example: removing the default system properties property source</h4>
|
||||
* <pre class="code">
|
||||
* MutablePropertySources propertySources = environment.getPropertySources();
|
||||
* propertySources.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)
|
||||
* MutablePropertySources propertySources = environment.getPropertySources();
|
||||
* propertySources.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)
|
||||
* </pre>
|
||||
*
|
||||
* <h4>Example: mocking the system environment for testing purposes</h4>
|
||||
* <pre class="code">
|
||||
* MutablePropertySources propertySources = environment.getPropertySources();
|
||||
* MockPropertySource mockEnvVars = new MockPropertySource().withProperty("xyz", "myValue");
|
||||
* propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
|
||||
* MutablePropertySources propertySources = environment.getPropertySources();
|
||||
* MockPropertySource mockEnvVars = new MockPropertySource().withProperty("xyz", "myValue");
|
||||
* propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
|
||||
* </pre>
|
||||
*
|
||||
* When an {@link Environment} is being used by an {@code ApplicationContext}, it is
|
||||
@@ -64,7 +64,6 @@ import java.util.Map;
|
||||
* org.springframework.context.support.PropertySourcesPlaceholderConfigurer property
|
||||
* placeholder configurers}.
|
||||
*
|
||||
*
|
||||
* @author Chris Beams
|
||||
* @since 3.1
|
||||
* @see StandardEnvironment
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -77,8 +77,8 @@ public interface Environment extends PropertyResolver {
|
||||
* activated by setting {@linkplain AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
|
||||
* "spring.profiles.active"} as a system property or by calling
|
||||
* {@link ConfigurableEnvironment#setActiveProfiles(String...)}.
|
||||
* <p>If no profiles have explicitly been specified as active, then any {@linkplain
|
||||
* #getDefaultProfiles() default profiles} will automatically be activated.
|
||||
* <p>If no profiles have explicitly been specified as active, then any
|
||||
* {@linkplain #getDefaultProfiles() default profiles} will automatically be activated.
|
||||
* @see #getDefaultProfiles
|
||||
* @see ConfigurableEnvironment#setActiveProfiles
|
||||
* @see AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -25,23 +25,25 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
|
||||
/**
|
||||
* XStream {@link Converter} that supports all classes, but throws exceptions for
|
||||
* (un)marshalling.
|
||||
* <p>Main purpose of this class is to
|
||||
*
|
||||
* <p>The main purpose of this class is to
|
||||
* {@linkplain com.thoughtworks.xstream.XStream#registerConverter(com.thoughtworks.xstream.converters.Converter, int) register}
|
||||
* this converter as a catchall last converter with a
|
||||
* this converter as a catch-all last converter with a
|
||||
* {@linkplain com.thoughtworks.xstream.XStream#PRIORITY_NORMAL normal}
|
||||
* or higher priority, in addition to converters that explicitly support the domain
|
||||
* classes that should be supported. As a result, default XStream converters with lower
|
||||
* priorities and possible security vulnerabilities do not get invoked.
|
||||
* <p>For instance:</p>
|
||||
* or higher priority, in addition to converters that explicitly handle the domain
|
||||
* classes that should be supported. As a result, default XStream converters with
|
||||
* lower priorities and possible security vulnerabilities do not get invoked.
|
||||
*
|
||||
* <p>For instance:
|
||||
* <pre class="code">
|
||||
* XStreamMarshaller unmarshaller = new XStreamMarshaller();
|
||||
* unmarshaller.getXStream().registerConverter(new MyDomainClassConverter(), XStream.PRIORITY_VERY_HIGH);
|
||||
* unmarshaller.getXStream().registerConverter(new CatchAllConverter(), XStream.PRIORITY_NORMAL);
|
||||
* MyDomainClass o = unmarshaller.unmarshal(source);
|
||||
* MyDomainClass myObject = unmarshaller.unmarshal(source);
|
||||
* </pre
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @since 3.2.5
|
||||
*/
|
||||
public class CatchAllConverter implements Converter {
|
||||
|
||||
@@ -51,14 +53,13 @@ public class CatchAllConverter implements Converter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(Object source, HierarchicalStreamWriter writer,
|
||||
MarshallingContext context) {
|
||||
throw new UnsupportedOperationException("marshalling not supported");
|
||||
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
|
||||
throw new UnsupportedOperationException("Marshalling not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object unmarshal(HierarchicalStreamReader reader,
|
||||
UnmarshallingContext context) {
|
||||
throw new UnsupportedOperationException("unmarshalling not supported");
|
||||
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
|
||||
throw new UnsupportedOperationException("Unmarshalling not supported");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user