Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
(cherry picked from commit 6e5b873)
  • Loading branch information
jhoeller committed Dec 20, 2016
1 parent 6bdc5bf commit bd282e6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,22 @@ 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";

/**
* 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";

Expand All @@ -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);

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -35,24 +35,24 @@
*
* <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
Expand All @@ -64,7 +64,6 @@
* org.springframework.context.support.PropertySourcesPlaceholderConfigurer property
* placeholder configurers}.
*
*
* @author Chris Beams
* @since 3.1
* @see StandardEnvironment
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -25,23 +25,25 @@
/**
* 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 {

Expand All @@ -51,14 +53,13 @@ public boolean canConvert(Class type) {
}

@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");
}

}

0 comments on commit bd282e6

Please sign in to comment.