Removed deprecated helper classes and methods (that have been deprecated since 3.0 or before)

This commit is contained in:
Juergen Hoeller 2013-05-02 17:25:10 +02:00
parent 17610c2523
commit 0a8f5b2919
28 changed files with 19 additions and 1918 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -79,28 +79,6 @@ public abstract class AopNamespaceUtils {
registerComponentIfNecessary(beanDefinition, parserContext);
}
/**
* @deprecated since Spring 2.5, in favor of
* {@link #registerAutoProxyCreatorIfNecessary(ParserContext, Element)} and
* {@link AopConfigUtils#registerAutoProxyCreatorIfNecessary(BeanDefinitionRegistry, Object)}
*/
@Deprecated
public static void registerAutoProxyCreatorIfNecessary(ParserContext parserContext, Object source) {
BeanDefinition beanDefinition = AopConfigUtils.registerAutoProxyCreatorIfNecessary(
parserContext.getRegistry(), source);
registerComponentIfNecessary(beanDefinition, parserContext);
}
/**
* @deprecated since Spring 2.5, in favor of
* {@link AopConfigUtils#forceAutoProxyCreatorToUseClassProxying(BeanDefinitionRegistry)}
*/
@Deprecated
public static void forceAutoProxyCreatorToUseClassProxying(BeanDefinitionRegistry registry) {
AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
}
private static void useClassProxyingIfNecessary(BeanDefinitionRegistry registry, Element sourceElement) {
if (sourceElement != null) {
boolean proxyTargetClass = Boolean.valueOf(sourceElement.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE));

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -309,16 +309,6 @@ public class AdvisedSupport extends ProxyConfig implements Advised {
return true;
}
/**
* Add all of the given advisors to this proxy configuration.
* @param advisors the advisors to register
* @deprecated as of Spring 3.0, in favor of {@link #addAdvisors}
*/
@Deprecated
public void addAllAdvisors(Advisor[] advisors) {
addAdvisors(Arrays.asList(advisors));
}
/**
* Add all of the given advisors to this proxy configuration.
* @param advisors the advisors to register

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -95,21 +95,6 @@ public class PropertiesFactoryBean extends PropertiesLoaderSupport
* @see #mergeProperties()
*/
protected Properties createProperties() throws IOException {
return (Properties) createInstance();
}
/**
* Template method that subclasses may override to construct the object
* returned by this factory. The default implementation returns the
* plain merged Properties instance.
* <p>Invoked on initialization of this FactoryBean in case of a
* shared singleton; else, on each {@link #getObject()} call.
* @return the object returned by this factory
* @throws IOException if an exception occured during properties loading
* @deprecated as of Spring 3.0, in favor of {@link #createProperties()}
*/
@Deprecated
protected Object createInstance() throws IOException {
return mergeProperties();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -204,17 +204,6 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
setPropertyValues(pvs);
}
/**
* Create a new AbstractBeanDefinition as a deep copy of the given
* bean definition.
* @param original the original bean definition to copy from
* @deprecated since Spring 2.5, in favor of {@link #AbstractBeanDefinition(BeanDefinition)}
*/
@Deprecated
protected AbstractBeanDefinition(AbstractBeanDefinition original) {
this((BeanDefinition) original);
}
/**
* Create a new AbstractBeanDefinition as a deep copy of the given
* bean definition.
@ -261,17 +250,6 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
}
/**
* Override settings in this bean definition (presumably a copied parent
* from a parent-child inheritance relationship) from the given bean
* definition (presumably the child).
* @deprecated since Spring 2.5, in favor of {@link #overrideFrom(BeanDefinition)}
*/
@Deprecated
public void overrideFrom(AbstractBeanDefinition other) {
overrideFrom((BeanDefinition) other);
}
/**
* Override settings in this bean definition (presumably a copied parent
* from a parent-child inheritance relationship) from the given bean

View File

@ -138,22 +138,6 @@ public class FreeMarkerConfigurationFactory {
this.defaultEncoding = defaultEncoding;
}
/**
* Set a List of {@code TemplateLoader}s that will be used to search
* for templates. For example, one or more custom loaders such as database
* loaders could be configured and injected here.
* @deprecated as of Spring 2.0.1, in favor of the "preTemplateLoaders"
* and "postTemplateLoaders" properties
* @see #setPreTemplateLoaders
* @see #setPostTemplateLoaders
*/
@Deprecated
public void setTemplateLoaders(TemplateLoader... templateLoaders) {
if (templateLoaders != null) {
this.templateLoaders.addAll(Arrays.asList(templateLoaders));
}
}
/**
* Set a List of {@code TemplateLoader}s that will be used to search
* for templates. For example, one or more custom loaders such as database

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -890,20 +890,6 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
}
}
/**
* Subclasses can invoke this method to register a listener.
* Any beans in the context that are listeners are automatically added.
* <p>Note: This method only works within an active application context,
* i.e. when an ApplicationEventMulticaster is already available. Generally
* prefer the use of {@link #addApplicationListener} which is more flexible.
* @param listener the listener to register
* @deprecated as of Spring 3.0, in favor of {@link #addApplicationListener}
*/
@Deprecated
protected void addListener(ApplicationListener<?> listener) {
getApplicationEventMulticaster().addApplicationListener(listener);
}
/**
* Finish the initialization of this context's bean factory,
* initializing all remaining singleton beans.

View File

@ -22,7 +22,6 @@ import java.net.SocketException;
import java.rmi.ConnectException;
import java.rmi.ConnectIOException;
import java.rmi.NoSuchObjectException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.StubNotFoundException;
import java.rmi.UnknownHostException;
@ -54,43 +53,6 @@ public abstract class RmiClientInterceptorUtils {
private static final Log logger = LogFactory.getLog(RmiClientInterceptorUtils.class);
/**
* Apply the given method invocation to the given RMI stub.
* <p>Delegates to the corresponding method if the RMI stub does not directly
* implement the invoked method. This typically happens when a non-RMI service
* interface is used for an RMI service. The methods of such a service interface
* have to match the RMI stub methods, but they typically don't declare
* {@code java.rmi.RemoteException}: A RemoteException thrown by the RMI stub
* will be automatically converted to Spring's RemoteAccessException.
* @deprecated as of Spring 2.5, in favor of {@link #invokeRemoteMethod}
*/
@Deprecated
public static Object invoke(MethodInvocation invocation, Remote stub, String serviceName) throws Throwable {
try {
return invokeRemoteMethod(invocation, stub);
}
catch (InvocationTargetException ex) {
Throwable targetEx = ex.getTargetException();
if (targetEx instanceof RemoteException) {
RemoteException rex = (RemoteException) targetEx;
throw convertRmiAccessException(invocation.getMethod(), rex, serviceName);
}
else {
throw targetEx;
}
}
}
/**
* Perform a raw method invocation on the given RMI stub,
* letting reflection exceptions through as-is.
* @deprecated as of Spring 2.5, in favor of {@link #invokeRemoteMethod}
*/
@Deprecated
public static Object doInvoke(MethodInvocation invocation, Remote stub) throws InvocationTargetException {
return invokeRemoteMethod(invocation, stub);
}
/**
* Perform a raw method invocation on the given RMI stub,
* letting reflection exceptions through as-is.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -145,37 +145,4 @@ public class ModelMap extends LinkedHashMap<String, Object> {
return containsKey(attributeName);
}
/**
* @deprecated as of Spring 2.5, in favor of {@link #addAttribute(String, Object)}
*/
@Deprecated
public ModelMap addObject(String modelName, Object modelObject) {
return addAttribute(modelName, modelObject);
}
/**
* @deprecated as of Spring 2.5, in favor of {@link #addAttribute(Object)}
*/
@Deprecated
public ModelMap addObject(Object modelObject) {
return addAttribute(modelObject);
}
/**
* @deprecated as of Spring 2.5, in favor of {@link #addAllAttributes(Collection)}
*/
@Deprecated
public ModelMap addAllObjects(Collection objects) {
return addAllAttributes(objects);
}
/**
* @deprecated as of Spring 2.5, in favor of {@link #addAllAttributes(Map)}
*/
@Deprecated
public ModelMap addAllObjects(Map objects) {
return addAllAttributes(objects);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -322,22 +322,6 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
return getInternalBindingResult();
}
/**
* Return the Errors instance for this data binder.
* @return the Errors instance, to be treated as Errors or as BindException
* @deprecated in favor of {@link #getBindingResult()}.
* Use the {@link BindException#BindException(BindingResult)} constructor
* to create a BindException instance if still needed.
* @see #getBindingResult()
*/
@Deprecated
public BindException getErrors() {
if (this.bindException == null) {
this.bindException = new BindException(getBindingResult());
}
return this.bindException;
}
/**
* Set whether to ignore unknown fields, that is, whether to ignore bind

View File

@ -1,311 +0,0 @@
/*
* Copyright 2002-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.util;
import java.io.Serializable;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
/**
* A simple decorator for a Map, encapsulating the workflow for caching
* expensive values in a target Map. Supports caching weak or strong keys.
*
* <p>This class is an abstract template. Caching Map implementations
* should subclass and override the {@code create(key)} method which
* encapsulates expensive creation of a new object.
*
* @author Keith Donald
* @author Juergen Hoeller
* @since 1.2.2
* @deprecated as of Spring 3.2, to be removed along with LabeledEnum support
*/
@Deprecated
@SuppressWarnings("serial")
public abstract class CachingMapDecorator<K, V> implements Map<K, V>, Serializable {
private static Object NULL_VALUE = new Object();
private final Map<K, Object> targetMap;
private final boolean synchronize;
private final boolean weak;
/**
* Create a CachingMapDecorator with strong keys,
* using an underlying synchronized Map.
*/
public CachingMapDecorator() {
this(false);
}
/**
* Create a CachingMapDecorator,
* using an underlying synchronized Map.
* @param weak whether to use weak references for keys and values
*/
public CachingMapDecorator(boolean weak) {
Map<K, Object> internalMap = (weak ? new WeakHashMap<K, Object>() : new HashMap<K, Object>());
this.targetMap = Collections.synchronizedMap(internalMap);
this.synchronize = true;
this.weak = weak;
}
/**
* Create a CachingMapDecorator with initial size,
* using an underlying synchronized Map.
* @param weak whether to use weak references for keys and values
* @param size the initial cache size
*/
public CachingMapDecorator(boolean weak, int size) {
Map<K, Object> internalMap = weak ? new WeakHashMap<K, Object> (size) : new HashMap<K, Object>(size);
this.targetMap = Collections.synchronizedMap(internalMap);
this.synchronize = true;
this.weak = weak;
}
/**
* Create a CachingMapDecorator for the given Map.
* <p>The passed-in Map won't get synchronized explicitly,
* so make sure to pass in a properly synchronized Map, if desired.
* @param targetMap the Map to decorate
*/
public CachingMapDecorator(Map<K, V> targetMap) {
this(targetMap, false, false);
}
/**
* Create a CachingMapDecorator for the given Map.
* <p>The passed-in Map won't get synchronized explicitly unless
* you specify "synchronize" as "true".
* @param targetMap the Map to decorate
* @param synchronize whether to synchronize on the given Map
* @param weak whether to use weak references for values
*/
@SuppressWarnings("unchecked")
public CachingMapDecorator(Map<K, V> targetMap, boolean synchronize, boolean weak) {
Assert.notNull(targetMap, "'targetMap' must not be null");
this.targetMap = (Map<K, Object>) (synchronize ? Collections.synchronizedMap(targetMap) : targetMap);
this.synchronize = synchronize;
this.weak = weak;
}
public int size() {
return this.targetMap.size();
}
public boolean isEmpty() {
return this.targetMap.isEmpty();
}
public boolean containsKey(Object key) {
return this.targetMap.containsKey(key);
}
public boolean containsValue(Object value) {
Object valueToCheck = (value != null ? value : NULL_VALUE);
if (this.synchronize) {
synchronized (this.targetMap) {
return containsValueOrReference(valueToCheck);
}
}
else {
return containsValueOrReference(valueToCheck);
}
}
private boolean containsValueOrReference(Object value) {
if (this.targetMap.containsValue(value)) {
return true;
}
for (Object mapVal : this.targetMap.values()) {
if (mapVal instanceof Reference && value.equals(((Reference) mapVal).get())) {
return true;
}
}
return false;
}
public V remove(Object key) {
return unwrapReturnValue(this.targetMap.remove(key));
}
@SuppressWarnings("unchecked")
private V unwrapReturnValue(Object value) {
Object returnValue = value;
if (returnValue instanceof Reference) {
returnValue = ((Reference) returnValue).get();
}
return (returnValue == NULL_VALUE ? null : (V) returnValue);
}
public void putAll(Map<? extends K, ? extends V> map) {
this.targetMap.putAll(map);
}
public void clear() {
this.targetMap.clear();
}
public Set<K> keySet() {
if (this.synchronize) {
synchronized (this.targetMap) {
return new LinkedHashSet<K>(this.targetMap.keySet());
}
}
else {
return new LinkedHashSet<K>(this.targetMap.keySet());
}
}
public Collection<V> values() {
if (this.synchronize) {
synchronized (this.targetMap) {
return valuesCopy();
}
}
else {
return valuesCopy();
}
}
@SuppressWarnings("unchecked")
private Collection<V> valuesCopy() {
LinkedList<V> values = new LinkedList<V>();
for (Iterator<Object> it = this.targetMap.values().iterator(); it.hasNext();) {
Object value = it.next();
if (value instanceof Reference) {
value = ((Reference) value).get();
if (value == null) {
it.remove();
continue;
}
}
values.add(value == NULL_VALUE ? null : (V) value);
}
return values;
}
public Set<Map.Entry<K, V>> entrySet() {
if (this.synchronize) {
synchronized (this.targetMap) {
return entryCopy();
}
}
else {
return entryCopy();
}
}
@SuppressWarnings("unchecked")
private Set<Map.Entry<K, V>> entryCopy() {
Map<K,V> entries = new LinkedHashMap<K, V>();
for (Iterator<Entry<K, Object>> it = this.targetMap.entrySet().iterator(); it.hasNext();) {
Entry<K, Object> entry = it.next();
Object value = entry.getValue();
if (value instanceof Reference) {
value = ((Reference) value).get();
if (value == null) {
it.remove();
continue;
}
}
entries.put(entry.getKey(), value == NULL_VALUE ? null : (V) value);
}
return entries.entrySet();
}
/**
* Put an object into the cache, possibly wrapping it with a weak
* reference.
* @see #useWeakValue(Object, Object)
*/
public V put(K key, V value) {
Object newValue = value;
if (value == null) {
newValue = NULL_VALUE;
}
else if (useWeakValue(key, value)) {
newValue = new WeakReference<Object>(newValue);
}
return unwrapReturnValue(this.targetMap.put(key, newValue));
}
/**
* Decide whether to use a weak reference for the value of
* the given key-value pair.
* @param key the candidate key
* @param value the candidate value
* @return {@code true} in order to use a weak reference;
* {@code false} otherwise.
*/
protected boolean useWeakValue(K key, V value) {
return this.weak;
}
/**
* Get value for key.
* Creates and caches value if it doesn't already exist in the cache.
* <p>This implementation is <i>not</i> synchronized: This is highly
* concurrent but does not guarantee unique instances in the cache,
* as multiple values for the same key could get created in parallel.
* Consider overriding this method to synchronize it, if desired.
* @see #create(Object)
*/
@SuppressWarnings("unchecked")
public V get(Object key) {
Object value = this.targetMap.get(key);
if (value instanceof Reference) {
value = ((Reference) value).get();
}
if (value == null) {
V newValue = create((K) key);
put((K) key, newValue);
return newValue;
}
return (value == NULL_VALUE ? null : (V) value);
}
/**
* Create a value to cache for the given key.
* Called by {@code get} if there is no value cached already.
* @param key the cache key
* @see #get(Object)
*/
protected abstract V create(K key);
@Override
public String toString() {
return "CachingMapDecorator [" + getClass().getName() + "]:" + this.targetMap;
}
}

View File

@ -188,25 +188,6 @@ public abstract class ClassUtils {
}
}
/**
* Replacement for {@code Class.forName()} that also returns Class instances
* for primitives (like "int") and array class names (like "String[]").
* <p>Always uses the default class loader: that is, preferably the thread context
* class loader, or the ClassLoader that loaded the ClassUtils class as fallback.
* @param name the name of the Class
* @return Class instance for the supplied name
* @throws ClassNotFoundException if the class was not found
* @throws LinkageError if the class file could not be loaded
* @see Class#forName(String, boolean, ClassLoader)
* @see #getDefaultClassLoader()
* @deprecated as of Spring 3.0, in favor of specifying a ClassLoader explicitly:
* see {@link #forName(String, ClassLoader)}
*/
@Deprecated
public static Class<?> forName(String name) throws ClassNotFoundException, LinkageError {
return forName(name, getDefaultClassLoader());
}
/**
* Replacement for {@code Class.forName()} that also returns Class instances
* for primitives (e.g."int") and array class names (e.g. "String[]").
@ -322,19 +303,6 @@ public abstract class ClassUtils {
return result;
}
/**
* Determine whether the {@link Class} identified by the supplied name is present
* and can be loaded. Will return {@code false} if either the class or
* one of its dependencies is not present or cannot be loaded.
* @param className the name of the class to check
* @return whether the specified class is present
* @deprecated as of Spring 2.5, in favor of {@link #isPresent(String, ClassLoader)}
*/
@Deprecated
public static boolean isPresent(String className) {
return isPresent(className, getDefaultClassLoader());
}
/**
* Determine whether the {@link Class} identified by the supplied name is present
* and can be loaded. Will return {@code false} if either the class or

View File

@ -1,116 +0,0 @@
/*
* Copyright 2002-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.util;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import junit.framework.TestCase;
/**
* @author Keith Donald
* @author Juergen Hoeller
*/
@Deprecated
public class CachingMapDecoratorTests extends TestCase {
public void testValidCache() {
MyCachingMap cache = new MyCachingMap();
assertFalse(cache.containsKey("value key"));
assertFalse(cache.containsValue("expensive value to cache"));
Object value = cache.get("value key");
assertTrue(cache.createCalled());
assertEquals(value, "expensive value to cache");
assertTrue(cache.containsKey("value key"));
assertTrue(cache.containsValue("expensive value to cache"));
assertFalse(cache.containsKey("value key 2"));
value = cache.get("value key 2");
assertTrue(cache.createCalled());
assertEquals(value, "expensive value to cache");
assertTrue(cache.containsKey("value key 2"));
value = cache.get("value key");
assertFalse(cache.createCalled());
assertEquals(value, "expensive value to cache");
cache.get("value key 2");
assertFalse(cache.createCalled());
assertEquals(value, "expensive value to cache");
assertFalse(cache.containsKey(null));
assertFalse(cache.containsValue(null));
value = cache.get(null);
assertTrue(cache.createCalled());
assertNull(value);
assertTrue(cache.containsKey(null));
assertTrue(cache.containsValue(null));
value = cache.get(null);
assertFalse(cache.createCalled());
assertNull(value);
Set<String> keySet = cache.keySet();
assertEquals(3, keySet.size());
assertTrue(keySet.contains("value key"));
assertTrue(keySet.contains("value key 2"));
assertTrue(keySet.contains(null));
Collection<String> values = cache.values();
assertEquals(3, values.size());
assertTrue(values.contains("expensive value to cache"));
assertTrue(values.contains(null));
Set<Map.Entry<String, String>> entrySet = cache.entrySet();
assertEquals(3, entrySet.size());
keySet = new HashSet<String>();
values = new HashSet<String>();
for (Map.Entry<String, String> entry : entrySet) {
keySet.add(entry.getKey());
values.add(entry.getValue());
}
assertTrue(keySet.contains("value key"));
assertTrue(keySet.contains("value key 2"));
assertTrue(keySet.contains(null));
assertEquals(2, values.size());
assertTrue(values.contains("expensive value to cache"));
assertTrue(values.contains(null));
}
@SuppressWarnings("serial")
private static class MyCachingMap extends CachingMapDecorator<String, String> {
private boolean createCalled;
@Override
protected String create(String key) {
createCalled = true;
return (key != null ? "expensive value to cache" : null);
}
public boolean createCalled() {
boolean c = createCalled;
this.createCalled = false;
return c;
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -37,16 +37,4 @@ public class CannotGetJdbcConnectionException extends DataAccessResourceFailureE
super(msg, ex);
}
/**
* Constructor for CannotGetJdbcConnectionException.
* @param msg the detail message
* @param ex ClassNotFoundException root cause
* @deprecated since Spring 2.5, in favor of throwing an
* IllegalStateException in case of the driver not being found
*/
@Deprecated
public CannotGetJdbcConnectionException(String msg, ClassNotFoundException ex) {
super(msg, ex);
}
}

View File

@ -226,15 +226,6 @@ public abstract class AbstractJdbcCall {
}
}
/**
* Add a {@link org.springframework.jdbc.core.RowMapper} for the specified parameter or column.
* @deprecated in favor of {@link #addDeclaredRowMapper(String, org.springframework.jdbc.core.RowMapper)}
*/
@Deprecated
public void addDeclaredRowMapper(String parameterName, ParameterizedRowMapper rowMapper) {
addDeclaredRowMapper(parameterName, (RowMapper) rowMapper);
}
/**
* Get the call string that should be used based on parameters and meta data.
*/

View File

@ -125,15 +125,6 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
return this;
}
/**
* @deprecated in favor of {@link #returningResultSet(String, org.springframework.jdbc.core.RowMapper)}
*/
@Deprecated
public SimpleJdbcCall returningResultSet(String parameterName, ParameterizedRowMapper rowMapper) {
addDeclaredRowMapper(parameterName, rowMapper);
return this;
}
public SimpleJdbcCall withoutProcedureColumnMetaDataAccess() {
setAccessCallParameterMetaData(false);
return this;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -94,17 +94,6 @@ public interface SimpleJdbcCallOperations {
* */
SimpleJdbcCallOperations returningResultSet(String parameterName, RowMapper rowMapper);
/**
* Used to specify when a ResultSet is returned by the stored procedure and you want it mapped
* by a RowMapper. The results will be returned using the parameter name specified. Multiple
* ResultSets must be declared in the correct order. If the database you are using uses ref cursors
* then the name specified must match the name of the parameter declared for the procedure in the
* database.
* @deprecated in favor of {@link #returningResultSet(String, org.springframework.jdbc.core.RowMapper)}
*/
@Deprecated
SimpleJdbcCallOperations returningResultSet(String parameterName, ParameterizedRowMapper rowMapper);
/**
* Turn off any processing of parameter meta data information obtained via JDBC.
* @return the instance of this SimpleJdbcCall

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -107,26 +107,6 @@ public class DriverManagerDataSource extends AbstractDriverBasedDataSource {
setConnectionProperties(conProps);
}
/**
* Create a new DriverManagerDataSource with the given standard
* DriverManager parameters.
* @param driverClassName the JDBC driver class name
* @param url the JDBC URL to use for accessing the DriverManager
* @param username the JDBC username to use for accessing the DriverManager
* @param password the JDBC password to use for accessing the DriverManager
* @deprecated since Spring 2.5. DriverManagerDataSource is primarily
* intended for accessing <i>pre-registered</i> JDBC drivers.
* If you need to register a new driver, consider using
* {@link SimpleDriverDataSource} instead.
*/
@Deprecated
public DriverManagerDataSource(String driverClassName, String url, String username, String password) {
setDriverClassName(driverClassName);
setUrl(url);
setUsername(username);
setPassword(password);
}
/**
* Set the JDBC driver class name. This driver will get initialized

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -80,28 +80,6 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
public SingleConnectionDataSource() {
}
/**
* Create a new SingleConnectionDataSource with the given standard
* DriverManager parameters.
* @param driverClassName the JDBC driver class name
* @param url the JDBC URL to use for accessing the DriverManager
* @param username the JDBC username to use for accessing the DriverManager
* @param password the JDBC password to use for accessing the DriverManager
* @param suppressClose if the returned Connection should be a
* close-suppressing proxy or the physical Connection
* @deprecated since Spring 2.5. Driver parameter usage is generally not recommended
* for a SingleConnectionDataSource. If you insist on using driver parameters
* directly, set up the Driver class manually before invoking this DataSource.
* @see java.sql.DriverManager#getConnection(String, String, String)
*/
@Deprecated
public SingleConnectionDataSource(
String driverClassName, String url, String username, String password, boolean suppressClose) {
super(driverClassName, url, username, password);
this.suppressClose = suppressClose;
}
/**
* Create a new SingleConnectionDataSource with the given standard
* DriverManager parameters.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -119,7 +119,6 @@ public class WebDataBinder extends DataBinder {
* As the marker parameter is sent in any case, the data binder can
* detect an empty field and automatically reset its value.
* @see #DEFAULT_FIELD_MARKER_PREFIX
* @see org.springframework.web.servlet.mvc.BaseCommandController#onBind
*/
public void setFieldMarkerPrefix(String fieldMarkerPrefix) {
this.fieldMarkerPrefix = fieldMarkerPrefix;
@ -145,7 +144,6 @@ public class WebDataBinder extends DataBinder {
* <p>The presence of a default parameter preempts the behavior of a field
* marker for the given field.
* @see #DEFAULT_FIELD_DEFAULT_PREFIX
* @see org.springframework.web.servlet.mvc.BaseCommandController#onBind
*/
public void setFieldDefaultPrefix(String fieldDefaultPrefix) {
this.fieldDefaultPrefix = fieldDefaultPrefix;
@ -267,30 +265,6 @@ public class WebDataBinder extends DataBinder {
}
}
/**
* Bind the multipart files contained in the given request, if any
* (in case of a multipart request).
* <p>Multipart files will only be added to the property values if they
* are not empty or if we're configured to bind empty multipart files too.
* @param multipartFiles Map of field name String to MultipartFile object
* @param mpvs the property values to be bound (can be modified)
* @see org.springframework.web.multipart.MultipartFile
* @see #setBindEmptyMultipartFiles
* @deprecated as of Spring 3.0, in favor of {@link #bindMultipart} which binds
* all multipart files, even if more than one sent for the same name
*/
@Deprecated
protected void bindMultipartFiles(Map<String, MultipartFile> multipartFiles, MutablePropertyValues mpvs) {
for (Map.Entry<String, MultipartFile> entry : multipartFiles.entrySet()) {
String key = entry.getKey();
MultipartFile value = entry.getValue();
if (isBindEmptyMultipartFiles() || !value.isEmpty()) {
mpvs.add(key, value);
}
}
}
/**
* Bind all multipart files contained in the given request, if any
* (in case of a multipart request).

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -40,9 +40,6 @@ import javax.servlet.ServletContextListener;
*/
public class ContextLoaderListener extends ContextLoader implements ServletContextListener {
private ContextLoader contextLoader;
/**
* Create a new {@code ContextLoaderListener} that will create a web application
* context based on the "contextClass" and "contextConfigLocation" servlet
@ -105,33 +102,7 @@ public class ContextLoaderListener extends ContextLoader implements ServletConte
* Initialize the root web application context.
*/
public void contextInitialized(ServletContextEvent event) {
this.contextLoader = createContextLoader();
if (this.contextLoader == null) {
this.contextLoader = this;
}
this.contextLoader.initWebApplicationContext(event.getServletContext());
}
/**
* Create the ContextLoader to use. Can be overridden in subclasses.
* @return the new ContextLoader
* @deprecated in favor of simply subclassing ContextLoaderListener itself
* (which extends ContextLoader, as of Spring 3.0)
*/
@Deprecated
protected ContextLoader createContextLoader() {
return null;
}
/**
* Return the ContextLoader used by this listener.
* @return the current ContextLoader
* @deprecated in favor of simply subclassing ContextLoaderListener itself
* (which extends ContextLoader, as of Spring 3.0)
*/
@Deprecated
public ContextLoader getContextLoader() {
return this.contextLoader;
initWebApplicationContext(event.getServletContext());
}
@ -139,9 +110,7 @@ public class ContextLoaderListener extends ContextLoader implements ServletConte
* Close the root web application context.
*/
public void contextDestroyed(ServletContextEvent event) {
if (this.contextLoader != null) {
this.contextLoader.closeWebApplicationContext(event.getServletContext());
}
closeWebApplicationContext(event.getServletContext());
ContextCleanupListener.cleanupAttributes(event.getServletContext());
}

View File

@ -1,69 +0,0 @@
/*
* Copyright 2002-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.context.support;
import javax.servlet.ServletContext;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.web.context.ServletContextAware;
/**
* {@link FactoryBean} that exposes the ServletContext for bean references.
* Can be used as alternative to implementing the ServletContextAware
* callback interface. Allows for passing the ServletContext reference
* to a constructor argument or any custom bean property.
*
* <p>Note that there's a special FactoryBean for exposing a specific
* ServletContext attribute, named ServletContextAttributeFactoryBean.
* So if all you need from the ServletContext is access to a specific
* attribute, ServletContextAttributeFactoryBean allows you to expose
* a constructor argument or bean property of the attribute type,
* which is a preferable to a dependency on the full ServletContext.
*
* @author Juergen Hoeller
* @since 1.1.4
* @see javax.servlet.ServletContext
* @see org.springframework.web.context.ServletContextAware
* @see ServletContextAttributeFactoryBean
* @see org.springframework.web.context.WebApplicationContext#SERVLET_CONTEXT_BEAN_NAME
* @deprecated as of Spring 3.0, since "servletContext" is now available
* as a default bean in every WebApplicationContext
*/
@Deprecated
public class ServletContextFactoryBean implements FactoryBean<ServletContext>, ServletContextAware {
private ServletContext servletContext;
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
public ServletContext getObject() {
return this.servletContext;
}
public Class<? extends ServletContext> getObjectType() {
return (this.servletContext != null ? this.servletContext.getClass() : ServletContext.class);
}
public boolean isSingleton() {
return true;
}
}

View File

@ -893,7 +893,7 @@ public class DispatcherServlet extends FrameworkServlet {
multipartRequestParsed = processedRequest != request;
// Determine handler for the current request.
mappedHandler = getHandler(processedRequest, false);
mappedHandler = getHandler(processedRequest);
if (mappedHandler == null || mappedHandler.getHandler() == null) {
noHandlerFound(processedRequest, response);
return;
@ -1063,19 +1063,6 @@ public class DispatcherServlet extends FrameworkServlet {
}
}
/**
* Return the HandlerExecutionChain for this request. Try all handler mappings in order.
* @param request current HTTP request
* @param cache whether to cache the HandlerExecutionChain in a request attribute
* @return the HandlerExecutionChain, or {@code null} if no handler could be found
* @deprecated as of Spring 3.0.4, in favor of {@link #getHandler(javax.servlet.http.HttpServletRequest)},
* with this method's cache attribute now effectively getting ignored
*/
@Deprecated
protected HandlerExecutionChain getHandler(HttpServletRequest request, boolean cache) throws Exception {
return getHandler(request);
}
/**
* Return the HandlerExecutionChain for this request.
* <p>Tries all handler mappings in order.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@ -17,14 +17,12 @@
package org.springframework.web.servlet.tags.form;
import java.beans.PropertyEditor;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import org.springframework.beans.PropertyAccessor;
import org.springframework.core.Conventions;
import org.springframework.util.StringUtils;
import org.springframework.web.servlet.support.BindStatus;
import org.springframework.web.servlet.support.RequestDataValueProcessor;
@ -52,15 +50,6 @@ public abstract class AbstractDataBoundFormElementTag extends AbstractFormTag im
*/
protected static final String NESTED_PATH_VARIABLE_NAME = NestedPathTag.NESTED_PATH_VARIABLE_NAME;
/**
* The name of the {@link javax.servlet.jsp.PageContext} attribute under which the
* command object name is exposed.
* @deprecated as of Spring 2.5, in favor of {@link FormTag#MODEL_ATTRIBUTE_VARIABLE_NAME}
*/
@Deprecated
public static final String COMMAND_NAME_VARIABLE_NAME =
Conventions.getQualifiedAttributeName(AbstractFormTag.class, "commandName");
/**
* The property path from the {@link FormTag#setModelAttribute form object}.

View File

@ -17,7 +17,6 @@
package org.springframework.web.servlet.tags.form;
import java.util.Map;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
@ -42,17 +41,11 @@ import org.springframework.web.util.HtmlUtils;
* populating the data for their view. The name of this form object can be
* configured using the {@link #setModelAttribute "modelAttribute"} property.
*
* <p>The default value for the {@link #setModelAttribute "modelAttribute"}
* property is '{@code command}' which corresponds to the default name
* when using the
* {@link org.springframework.web.servlet.mvc.SimpleFormController SimpleFormController}.
*
* @author Rob Harrop
* @author Juergen Hoeller
* @author Scott Andrews
* @author Rossen Stoyanchev
* @since 2.0
* @see org.springframework.web.servlet.mvc.SimpleFormController
*/
@SuppressWarnings("serial")
public class FormTag extends AbstractHtmlElementTag {
@ -360,7 +353,6 @@ public class FormTag extends AbstractHtmlElementTag {
// Expose the form object name for nested tags...
String modelAttribute = resolveModelAttribute();
this.pageContext.setAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, modelAttribute, PageContext.REQUEST_SCOPE);
this.pageContext.setAttribute(COMMAND_NAME_VARIABLE_NAME, modelAttribute, PageContext.REQUEST_SCOPE);
// Save previous nestedPath value, build and expose current nestedPath value.
// Use request scope to expose nestedPath to included pages too.
@ -487,7 +479,6 @@ public class FormTag extends AbstractHtmlElementTag {
public void doFinally() {
super.doFinally();
this.pageContext.removeAttribute(MODEL_ATTRIBUTE_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
this.pageContext.removeAttribute(COMMAND_NAME_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
if (this.previousNestedPath != null) {
// Expose previous nestedPath value.
this.pageContext.setAttribute(NESTED_PATH_VARIABLE_NAME, this.previousNestedPath, PageContext.REQUEST_SCOPE);

View File

@ -1,579 +0,0 @@
/*
* Copyright 2002-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.view.xslt;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.URIResolver;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Node;
import org.springframework.context.ApplicationContextException;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.xml.SimpleTransformErrorListener;
import org.springframework.util.xml.TransformerUtils;
import org.springframework.web.servlet.view.AbstractView;
import org.springframework.web.util.NestedServletException;
/**
* Convenient superclass for views rendered using an XSLT stylesheet.
*
* <p>Subclasses typically must provide the {@link Source} to transform
* by overriding {@link #createXsltSource}. Subclasses do not need to
* concern themselves with XSLT other than providing a valid stylesheet location.
*
* <p>Properties:
* <ul>
* <li>{@link #setStylesheetLocation(org.springframework.core.io.Resource) stylesheetLocation}:
* a {@link Resource} pointing to the XSLT stylesheet
* <li>{@link #setRoot(String) root}: the name of the root element; defaults to {@link #DEFAULT_ROOT "DocRoot"}
* <li>{@link #setUriResolver(javax.xml.transform.URIResolver) uriResolver}:
* the {@link URIResolver} to be used in the transform
* <li>{@link #setErrorListener(javax.xml.transform.ErrorListener) errorListener} (optional):
* the {@link ErrorListener} implementation instance for custom handling of warnings and errors during TransformerFactory operations
* <li>{@link #setIndent(boolean) indent} (optional): whether additional whitespace
* may be added when outputting the result; defaults to {@code true}
* <li>{@link #setCache(boolean) cache} (optional): are templates to be cached; debug setting only; defaults to {@code true}
* </ul>
*
* <p>Note that setting {@link #setCache(boolean) "cache"} to {@code false}
* will cause the template objects to be reloaded for each rendering. This is
* useful during development, but will seriously affect performance in production
* and is not thread-safe.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @author Darren Davison
* @deprecated since Spring 2.5; superseded by {@link XsltView} and its
* more flexible {@link XsltView#locateSource} mechanism
*/
@Deprecated
public abstract class AbstractXsltView extends AbstractView {
/** The default content type if no stylesheet specified */
public static final String XML_CONTENT_TYPE = "text/xml;charset=ISO-8859-1";
/** The default document root name */
public static final String DEFAULT_ROOT = "DocRoot";
private boolean customContentTypeSet = false;
private Class transformerFactoryClass;
private Resource stylesheetLocation;
private String root = DEFAULT_ROOT;
private boolean useSingleModelNameAsRoot = true;
private URIResolver uriResolver;
private ErrorListener errorListener = new SimpleTransformErrorListener(logger);
private boolean indent = true;
private Properties outputProperties;
private boolean cache = true;
private TransformerFactory transformerFactory;
private volatile Templates cachedTemplates;
/**
* This constructor sets the content type to "text/xml;charset=ISO-8859-1"
* by default. This will be switched to the standard web view default
* "text/html;charset=ISO-8859-1" if a stylesheet location has been specified.
* <p>A specific content type can be configured via the
* {@link #setContentType "contentType"} bean property.
*/
protected AbstractXsltView() {
super.setContentType(XML_CONTENT_TYPE);
}
@Override
public void setContentType(String contentType) {
super.setContentType(contentType);
this.customContentTypeSet = true;
}
/**
* Specify the XSLT TransformerFactory class to use.
* <p>The default constructor of the specified class will be called
* to build the TransformerFactory for this view.
*/
public void setTransformerFactoryClass(Class transformerFactoryClass) {
Assert.isAssignable(TransformerFactory.class, transformerFactoryClass);
this.transformerFactoryClass = transformerFactoryClass;
}
/**
* Set the location of the XSLT stylesheet.
* <p>If the {@link TransformerFactory} used by this instance has already
* been initialized then invoking this setter will result in the
* {@link TransformerFactory#newTemplates(javax.xml.transform.Source) attendant templates}
* being re-cached.
* @param stylesheetLocation the location of the XSLT stylesheet
* @see org.springframework.context.ApplicationContext#getResource
*/
public void setStylesheetLocation(Resource stylesheetLocation) {
this.stylesheetLocation = stylesheetLocation;
// Re-cache templates if transformer factory already initialized.
resetCachedTemplates();
}
/**
* Return the location of the XSLT stylesheet, if any.
*/
protected Resource getStylesheetLocation() {
return this.stylesheetLocation;
}
/**
* The document root element name. Default is {@link #DEFAULT_ROOT "DocRoot"}.
* <p>Only used if we're not passed a single {@link Node} as the model.
* @param root the document root element name
* @see #DEFAULT_ROOT
*/
public void setRoot(String root) {
this.root = root;
}
/**
* Set whether to use the name of a given single model object as the
* document root element name.
* <p>Default is {@code true} : If you pass in a model with a single object
* named "myElement", then the document root will be named "myElement"
* as well. Set this flag to {@code false} if you want to pass in a single
* model object while still using the root element name configured
* through the {@link #setRoot(String) "root" property}.
* @param useSingleModelNameAsRoot {@code true} if the name of a given single
* model object is to be used as the document root element name
* @see #setRoot
*/
public void setUseSingleModelNameAsRoot(boolean useSingleModelNameAsRoot) {
this.useSingleModelNameAsRoot = useSingleModelNameAsRoot;
}
/**
* Set the URIResolver used in the transform.
* <p>The URIResolver handles calls to the XSLT {@code document()} function.
*/
public void setUriResolver(URIResolver uriResolver) {
this.uriResolver = uriResolver;
}
/**
* Set an implementation of the {@link javax.xml.transform.ErrorListener}
* interface for custom handling of transformation errors and warnings.
* <p>If not set, a default
* {@link org.springframework.util.xml.SimpleTransformErrorListener} is
* used that simply logs warnings using the logger instance of the view class,
* and rethrows errors to discontinue the XML transformation.
* @see org.springframework.util.xml.SimpleTransformErrorListener
*/
public void setErrorListener(ErrorListener errorListener) {
this.errorListener = errorListener;
}
/**
* Set whether the XSLT transformer may add additional whitespace when
* outputting the result tree.
* <p>Default is {@code true} (on); set this to {@code false} (off)
* to not specify an "indent" key, leaving the choice up to the stylesheet.
* @see javax.xml.transform.OutputKeys#INDENT
*/
public void setIndent(boolean indent) {
this.indent = indent;
}
/**
* Set arbitrary transformer output properties to be applied to the stylesheet.
* <p>Any values specified here will override defaults that this view sets
* programmatically.
* @see javax.xml.transform.Transformer#setOutputProperty
*/
public void setOutputProperties(Properties outputProperties) {
this.outputProperties = outputProperties;
}
/**
* Set whether to activate the template cache for this view.
* <p>Default is {@code true}. Turn this off to refresh
* the Templates object on every access, e.g. during development.
* @see #resetCachedTemplates()
*/
public void setCache(boolean cache) {
this.cache = cache;
}
/**
* Reset the cached Templates object, if any.
* <p>The Templates object will subsequently be rebuilt on next
* {@link #getTemplates() access}, if caching is enabled.
* @see #setCache
*/
public final void resetCachedTemplates() {
this.cachedTemplates = null;
}
/**
* Here we load our template, as we need the
* {@link org.springframework.context.ApplicationContext} to do it.
*/
@Override
protected final void initApplicationContext() throws ApplicationContextException {
this.transformerFactory = newTransformerFactory(this.transformerFactoryClass);
this.transformerFactory.setErrorListener(this.errorListener);
if (this.uriResolver != null) {
this.transformerFactory.setURIResolver(this.uriResolver);
}
if (getStylesheetLocation() != null && !this.customContentTypeSet) {
// Use "text/html" as default (instead of "text/xml") if a stylesheet
// has been configured but no custom content type has been set.
super.setContentType(DEFAULT_CONTENT_TYPE);
}
try {
getTemplates();
}
catch (TransformerConfigurationException ex) {
throw new ApplicationContextException("Cannot load stylesheet for XSLT view '" + getBeanName() + "'", ex);
}
}
/**
* Instantiate a new TransformerFactory for this view.
* <p>The default implementation simply calls
* {@link javax.xml.transform.TransformerFactory#newInstance()}.
* If a {@link #setTransformerFactoryClass "transformerFactoryClass"}
* has been specified explicitly, the default constructor of the
* specified class will be called instead.
* <p>Can be overridden in subclasses.
* @param transformerFactoryClass the specified factory class (if any)
* @return the new TransactionFactory instance
* @throws TransformerFactoryConfigurationError in case of instantiation failure
* @see #setTransformerFactoryClass
* @see #getTransformerFactory()
*/
protected TransformerFactory newTransformerFactory(Class transformerFactoryClass) {
if (transformerFactoryClass != null) {
try {
return (TransformerFactory) transformerFactoryClass.newInstance();
}
catch (Exception ex) {
throw new TransformerFactoryConfigurationError(ex, "Could not instantiate TransformerFactory");
}
}
else {
return TransformerFactory.newInstance();
}
}
/**
* Return the TransformerFactory used by this view.
* Available once the View object has been fully initialized.
*/
protected final TransformerFactory getTransformerFactory() {
return this.transformerFactory;
}
@Override
protected final void renderMergedOutputModel(
Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setContentType(getContentType());
Source source = null;
String docRoot = null;
// Value of a single element in the map, if there is one.
Object singleModel = null;
if (this.useSingleModelNameAsRoot && model.size() == 1) {
docRoot = model.keySet().iterator().next();
if (logger.isDebugEnabled()) {
logger.debug("Single model object received, key [" + docRoot + "] will be used as root tag");
}
singleModel = model.get(docRoot);
}
// Handle special case when we have a single node.
if (singleModel instanceof Node || singleModel instanceof Source) {
// Don't domify if the model is already an XML node/source.
// We don't need to worry about model name, either:
// we leave the Node alone.
logger.debug("No need to domify: was passed an XML Node or Source");
source = (singleModel instanceof Node ? new DOMSource((Node) singleModel) : (Source) singleModel);
}
else {
// docRoot local variable takes precedence
source = createXsltSource(model, (docRoot != null ? docRoot : this.root), request, response);
}
doTransform(model, source, request, response);
}
/**
* Return the XML {@link Source} to transform.
* @param model the model Map
* @param root name for root element. This can be supplied as a bean property
* to concrete subclasses within the view definition file, but will be overridden
* in the case of a single object in the model map to be the key for that object.
* If no root property is specified and multiple model objects exist, a default
* root tag name will be supplied.
* @param request HTTP request. Subclasses won't normally use this, as
* request processing should have been complete. However, we might want to
* create a RequestContext to expose as part of the model.
* @param response HTTP response. Subclasses won't normally use this,
* however there may sometimes be a need to set cookies.
* @return the XSLT Source to transform
* @throws Exception if an error occurs
*/
protected Source createXsltSource(
Map<String, Object> model, String root, HttpServletRequest request, HttpServletResponse response)
throws Exception {
return null;
}
/**
* Perform the actual transformation, writing to the HTTP response.
* <p>The default implementation delegates to the
* {@link #doTransform(javax.xml.transform.Source, java.util.Map, javax.xml.transform.Result, String)}
* method, building a StreamResult for the ServletResponse OutputStream
* or for the ServletResponse Writer (according to {@link #useWriter()}).
* @param model the model Map
* @param source the Source to transform
* @param request current HTTP request
* @param response current HTTP response
* @throws Exception if an error occurs
* @see javax.xml.transform.stream.StreamResult
* @see javax.servlet.ServletResponse#getOutputStream()
* @see javax.servlet.ServletResponse#getWriter()
* @see #useWriter()
*/
protected void doTransform(
Map<String, Object> model, Source source, HttpServletRequest request, HttpServletResponse response)
throws Exception {
Map<String, Object> parameters = getParameters(model, request);
Result result = (useWriter() ?
new StreamResult(response.getWriter()) :
new StreamResult(new BufferedOutputStream(response.getOutputStream())));
String encoding = response.getCharacterEncoding();
doTransform(source, parameters, result, encoding);
}
/**
* Return a Map of transformer parameters to be applied to the stylesheet.
* <p>Subclasses can override this method in order to apply one or more
* parameters to the transformation process.
* <p>The default implementation delegates to the
* {@link #getParameters(HttpServletRequest)} variant.
* @param model the model Map
* @param request current HTTP request
* @return a Map of parameters to apply to the transformation process
* @see javax.xml.transform.Transformer#setParameter
*/
protected Map getParameters(Map<String, Object> model, HttpServletRequest request) {
return getParameters(request);
}
/**
* Return a Map of transformer parameters to be applied to the stylesheet.
* <p>Subclasses can override this method in order to apply one or more
* parameters to the transformation process.
* <p>The default implementation simply returns {@code null}.
* @param request current HTTP request
* @return a Map of parameters to apply to the transformation process
* @see #getParameters(Map, HttpServletRequest)
* @see javax.xml.transform.Transformer#setParameter
*/
protected Map getParameters(HttpServletRequest request) {
return null;
}
/**
* Return whether to use a {@code java.io.Writer} to write text content
* to the HTTP response. Else, a {@code java.io.OutputStream} will be used,
* to write binary content to the response.
* <p>The default implementation returns {@code false}, indicating a
* a {@code java.io.OutputStream}.
* @return whether to use a Writer ({@code true}) or an OutputStream
* ({@code false})
* @see javax.servlet.ServletResponse#getWriter()
* @see javax.servlet.ServletResponse#getOutputStream()
*/
protected boolean useWriter() {
return false;
}
/**
* Perform the actual transformation, writing to the given result.
* @param source the Source to transform
* @param parameters a Map of parameters to be applied to the stylesheet
* (as determined by {@link #getParameters(Map, HttpServletRequest)})
* @param result the result to write to
* @param encoding the preferred character encoding that the underlying Transformer should use
* @throws Exception if an error occurs
*/
protected void doTransform(Source source, Map<String, Object> parameters, Result result, String encoding)
throws Exception {
try {
Transformer trans = buildTransformer(parameters);
// Explicitly apply URIResolver to every created Transformer.
if (this.uriResolver != null) {
trans.setURIResolver(this.uriResolver);
}
// Specify default output properties.
trans.setOutputProperty(OutputKeys.ENCODING, encoding);
if (this.indent) {
TransformerUtils.enableIndenting(trans);
}
// Apply any arbitrary output properties, if specified.
if (this.outputProperties != null) {
Enumeration propsEnum = this.outputProperties.propertyNames();
while (propsEnum.hasMoreElements()) {
String propName = (String) propsEnum.nextElement();
trans.setOutputProperty(propName, this.outputProperties.getProperty(propName));
}
}
// Perform the actual XSLT transformation.
trans.transform(source, result);
}
catch (TransformerConfigurationException ex) {
throw new NestedServletException(
"Couldn't create XSLT transformer in XSLT view with name [" + getBeanName() + "]", ex);
}
catch (TransformerException ex) {
throw new NestedServletException(
"Couldn't perform transform in XSLT view with name [" + getBeanName() + "]", ex);
}
}
/**
* Build a Transformer object for immediate use, based on the
* given parameters.
* @param parameters a Map of parameters to be applied to the stylesheet
* (as determined by {@link #getParameters(Map, HttpServletRequest)})
* @return the Transformer object (never {@code null})
* @throws TransformerConfigurationException if the Transformer object
* could not be built
*/
protected Transformer buildTransformer(Map<String, Object> parameters) throws TransformerConfigurationException {
Templates templates = getTemplates();
Transformer transformer =
(templates != null ? templates.newTransformer() : getTransformerFactory().newTransformer());
applyTransformerParameters(parameters, transformer);
return transformer;
}
/**
* Obtain the Templates object to use, based on the configured
* stylesheet, either a cached one or a freshly built one.
* <p>Subclasses may override this method e.g. in order to refresh
* the Templates instance, calling {@link #resetCachedTemplates()}
* before delegating to this {@code getTemplates()} implementation.
* @return the Templates object (or {@code null} if there is
* no stylesheet specified)
* @throws TransformerConfigurationException if the Templates object
* could not be built
* @see #setStylesheetLocation
* @see #setCache
* @see #resetCachedTemplates
*/
protected Templates getTemplates() throws TransformerConfigurationException {
if (this.cachedTemplates != null) {
return this.cachedTemplates;
}
Resource location = getStylesheetLocation();
if (location != null) {
Templates templates = getTransformerFactory().newTemplates(getStylesheetSource(location));
if (this.cache) {
this.cachedTemplates = templates;
}
return templates;
}
return null;
}
/**
* Apply the specified parameters to the given Transformer.
* @param parameters the transformer parameters
* (as determined by {@link #getParameters(Map, HttpServletRequest)})
* @param transformer the Transformer to aply the parameters
*/
protected void applyTransformerParameters(Map<String, Object> parameters, Transformer transformer) {
if (parameters != null) {
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
transformer.setParameter(entry.getKey(), entry.getValue());
}
}
}
/**
* Load the stylesheet from the specified location.
* @param stylesheetLocation the stylesheet resource to be loaded
* @return the stylesheet source
* @throws ApplicationContextException if the stylesheet resource could not be loaded
*/
protected Source getStylesheetSource(Resource stylesheetLocation) throws ApplicationContextException {
if (logger.isDebugEnabled()) {
logger.debug("Loading XSLT stylesheet from " + stylesheetLocation);
}
try {
URL url = stylesheetLocation.getURL();
String urlPath = url.toString();
String systemId = urlPath.substring(0, urlPath.lastIndexOf('/') + 1);
return new StreamSource(url.openStream(), systemId);
}
catch (IOException ex) {
throw new ApplicationContextException("Can't load XSLT stylesheet from " + stylesheetLocation, ex);
}
}
}

View File

@ -53,21 +53,6 @@ import org.springframework.mock.web.test.MockServletContext;
*/
public class ServletContextSupportTests {
@Test
@Deprecated
public void testServletContextFactoryBean() {
MockServletContext sc = new MockServletContext();
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
wac.registerSingleton("servletContext", ServletContextFactoryBean.class, pvs);
wac.refresh();
Object value = wac.getBean("servletContext");
assertEquals(sc, value);
}
@Test
public void testServletContextAttributeFactoryBean() {
MockServletContext sc = new MockServletContext();
@ -101,7 +86,7 @@ public class ServletContextSupportTests {
catch (BeanCreationException ex) {
// expected
assertTrue(ex.getCause() instanceof IllegalStateException);
assertTrue(ex.getCause().getMessage().indexOf("myAttr") != -1);
assertTrue(ex.getCause().getMessage().contains("myAttr"));
}
}
@ -138,7 +123,7 @@ public class ServletContextSupportTests {
catch (BeanCreationException ex) {
// expected
assertTrue(ex.getCause() instanceof IllegalStateException);
assertTrue(ex.getCause().getMessage().indexOf("myParam") != -1);
assertTrue(ex.getCause().getMessage().contains("myParam"));
}
}

View File

@ -45,18 +45,6 @@ import org.springframework.ui.freemarker.SpringTemplateLoader;
*/
public class FreeMarkerConfigurerTests extends TestCase {
public void testTemplateLoaders() throws Exception {
FreeMarkerConfigurer fc = new FreeMarkerConfigurer();
fc.setTemplateLoaders(new TemplateLoader[] {});
fc.afterPropertiesSet();
assertTrue(fc.getConfiguration().getTemplateLoader() instanceof ClassTemplateLoader);
fc = new FreeMarkerConfigurer();
fc.setTemplateLoaders(new TemplateLoader[] {new ClassTemplateLoader()});
fc.afterPropertiesSet();
assertTrue(fc.getConfiguration().getTemplateLoader() instanceof MultiTemplateLoader);
}
public void testFreemarkerConfigurationFactoryBeanWithConfigLocation() throws TemplateException {
FreeMarkerConfigurationFactoryBean fcfb = new FreeMarkerConfigurationFactoryBean();
fcfb.setConfigLocation(new FileSystemResource("myprops.properties"));

View File

@ -1,406 +0,0 @@
/*
* Copyright 2002-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.servlet.view.xslt;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import junit.framework.TestCase;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.springframework.context.ApplicationContextException;
import org.springframework.core.JdkVersion;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.mock.web.test.MockHttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
/**
* Unit tests for the {@link AbstractXsltView} class.
*
* @author Darren Davison
* @author Rick Evans
* @author Juergen Hoeller
* @since 11.03.2005
*/
@Deprecated
public class TestXsltViewTests extends TestCase {
private TestXsltView view;
private int warnings = 0;
private int errors = 0;
private int fatal = 0;
@Override
public void setUp() {
this.view = new TestXsltView();
}
public void testNoSuchStylesheet() {
view.setStylesheetLocation(new FileSystemResource("/does/not/exist.xsl"));
try {
view.initApplicationContext();
fail("Must have thrown ApplicationContextException");
}
catch (ApplicationContextException expected) {
}
}
public void testCustomErrorListener() {
view.setErrorListener(new ErrorListener() {
@Override
public void warning(TransformerException ex) {
incWarnings();
}
@Override
public void error(TransformerException ex) {
incErrors();
}
@Override
public void fatalError(TransformerException ex) {
incFatals();
}
});
// loaded stylesheet is not well formed
view.setStylesheetLocation(new ClassPathResource("org/springframework/web/servlet/view/xslt/errors.xsl"));
try {
view.initApplicationContext();
}
catch (ApplicationContextException ex) {
// shouldn't really happen, but can be let through by XSLT engine
assertTrue(ex.getCause() instanceof TransformerException);
}
assertEquals(1, fatal);
assertEquals(1, errors);
assertEquals(0, warnings);
}
public void testRender() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
AbstractXsltView view = new AbstractXsltView() {
@Override
protected Source createXsltSource(Map model, String root, HttpServletRequest request, HttpServletResponse response) throws Exception {
Hero hero = (Hero) model.get("hero");
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement(root);
node.setAttribute("name", hero.getName());
node.setAttribute("age", hero.getAge() + "");
node.setAttribute("catchphrase", hero.getCatchphrase());
return new DOMSource(node);
}
};
view.setStylesheetLocation(new ClassPathResource("org/springframework/web/servlet/view/xslt/sunnyDay.xsl"));
view.setIndent(true);
view.initApplicationContext();
view.render(new ModelAndView().addObject("hero", new Hero("Jet", 24, "BOOM")).getModel(), request, response);
assertEquals("text/html;charset=ISO-8859-1", response.getContentType());
String text = response.getContentAsString();
assertEquals("<hero name=\"Jet\" age=\"24\" catchphrase=\"BOOM\" sex=\"Female\"/>", text.trim());
}
public void testRenderWithCustomContentType() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
AbstractXsltView view = new AbstractXsltView() {
@Override
protected Source createXsltSource(Map model, String root, HttpServletRequest request, HttpServletResponse response) throws Exception {
Hero hero = (Hero) model.get("hero");
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement(root);
node.setAttribute("name", hero.getName());
node.setAttribute("age", hero.getAge() + "");
node.setAttribute("catchphrase", hero.getCatchphrase());
return new DOMSource(node);
}
};
view.setContentType("text/plain");
view.setStylesheetLocation(new ClassPathResource("org/springframework/web/servlet/view/xslt/sunnyDay.xsl"));
view.setIndent(true);
view.initApplicationContext();
view.render(new ModelAndView().addObject("hero", new Hero("Jet", 24, "BOOM")).getModel(), request, response);
assertEquals("text/plain", response.getContentType());
String text = response.getContentAsString();
assertEquals("<hero name=\"Jet\" age=\"24\" catchphrase=\"BOOM\" sex=\"Female\"/>", text.trim());
}
public void testRenderWithSingleSourceInModel() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
AbstractXsltView view = new AbstractXsltView() {
@Override
protected Map getParameters(HttpServletRequest request) {
Map parameters = new HashMap();
parameters.put("sex", "Male");
return parameters;
}
};
view.setStylesheetLocation(new ClassPathResource("org/springframework/web/servlet/view/xslt/sunnyDay.xsl"));
Properties outputProperties = new Properties();
outputProperties.setProperty("indent", "false");
view.setOutputProperties(outputProperties);
view.initApplicationContext();
Hero hero = new Hero("Jet", 24, "BOOM");
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement("hero");
node.setAttribute("name", hero.getName());
node.setAttribute("age", hero.getAge() + "");
node.setAttribute("catchphrase", hero.getCatchphrase());
view.render(new ModelAndView().addObject("hero", new DOMSource(node)).getModel(), request, response);
assertEquals("text/html;charset=ISO-8859-1", response.getContentType());
String text = response.getContentAsString();
assertEquals("<hero name=\"Jet\" age=\"24\" catchphrase=\"BOOM\" sex=\"Male\"/>", text.trim());
}
public void testRenderWithSingleNodeInModel() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
response.setWriterAccessAllowed(false);
AbstractXsltView view = new AbstractXsltView() {
@Override
protected Map getParameters(HttpServletRequest request) {
Map parameters = new HashMap();
parameters.put("sex", "Male");
return parameters;
}
};
view.setStylesheetLocation(new ClassPathResource("org/springframework/web/servlet/view/xslt/sunnyDay.xsl"));
view.initApplicationContext();
Hero hero = new Hero("Jet", 24, "BOOM");
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement("hero");
node.setAttribute("name", hero.getName());
node.setAttribute("age", hero.getAge() + "");
node.setAttribute("catchphrase", hero.getCatchphrase());
view.render(new ModelAndView().addObject("hero", node).getModel(), request, response);
String text = response.getContentAsString();
assertEquals("<hero name=\"Jet\" age=\"24\" catchphrase=\"BOOM\" sex=\"Male\"/>", text.trim());
}
public void testRenderWithNoStylesheetSpecified() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
AbstractXsltView view = new AbstractXsltView() {
@Override
protected Map getParameters(HttpServletRequest request) {
Map parameters = new HashMap();
parameters.put("sex", "Male");
return parameters;
}
};
Properties outputProperties = new Properties();
outputProperties.setProperty("indent", "false");
view.setOutputProperties(outputProperties);
view.initApplicationContext();
Hero hero = new Hero("Jet", 24, "BOOM");
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement("hero");
node.setAttribute("name", hero.getName());
node.setAttribute("age", hero.getAge() + "");
node.setAttribute("catchphrase", hero.getCatchphrase());
view.render(new ModelAndView().addObject("hero", new DOMSource(node)).getModel(), request, response);
assertEquals("text/xml;charset=ISO-8859-1", response.getContentType());
String text = response.getContentAsString().trim();
assertTrue(text.startsWith("<?xml"));
assertTrue(text.indexOf("<hero") != -1);
assertTrue(text.indexOf("age=\"24\"") != -1);
assertTrue(text.indexOf("catchphrase=\"BOOM\"") != -1);
assertTrue(text.indexOf("name=\"Jet\"") != -1);
}
public void testRenderSingleNodeInModelWithExplicitDocRootName() throws Exception {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
response.setOutputStreamAccessAllowed(false);
AbstractXsltView view = new AbstractXsltView() {
@Override
protected Source createXsltSource(Map model, String root, HttpServletRequest request, HttpServletResponse response) throws Exception {
Hero hero = (Hero) model.get("hero");
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element node = document.createElement(root);
node.setAttribute("name", hero.getName());
node.setAttribute("age", hero.getAge() + "");
node.setAttribute("catchphrase", hero.getCatchphrase());
return new DOMSource(node);
}
@Override
protected Map getParameters(HttpServletRequest request) {
Map parameters = new HashMap();
parameters.put("sex", "Male");
return parameters;
}
@Override
protected boolean useWriter() {
return true;
}
};
view.setStylesheetLocation(new ClassPathResource("org/springframework/web/servlet/view/xslt/sunnyDayExplicitRoot.xsl"));
view.setUseSingleModelNameAsRoot(false);
view.setRoot("baddie");
view.initApplicationContext();
view.render(new ModelAndView().addObject("hero", new Hero("Jet", 24, "BOOM")).getModel(), request, response);
String text = response.getContentAsString();
assertTrue(text.trim().startsWith("<baddie "));
}
/**
* Not a test per-se, but rather only here to validate the example
* given in the reference documentation.
*/
public void testMyFirstWordsExampleFromTheReferenceDocumentation() throws Exception {
// TODO: Why does this test not even work on JDK 1.4?
// Maybe because of the Xalan version there?
if (JdkVersion.getMajorJavaVersion() < JdkVersion.JAVA_15) {
return;
}
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
AbstractXsltView view = new AbstractXsltView() {
@Override
protected Source createXsltSource(
Map model, String rootName, HttpServletRequest request, HttpServletResponse response)
throws Exception {
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
Element root = document.createElement(rootName);
List words = (List) model.get("wordList");
for (Iterator it = words.iterator(); it.hasNext();) {
String nextWord = (String) it.next();
Element wordNode = document.createElement("word");
Text textNode = document.createTextNode(nextWord);
wordNode.appendChild(textNode);
root.appendChild(wordNode);
}
return new DOMSource(root);
}
};
view.setStylesheetLocation(new ClassPathResource("org/springframework/web/servlet/view/xslt/firstWords.xsl"));
view.setIndent(true);
view.initApplicationContext();
Map map = new HashMap();
List wordList = new ArrayList();
wordList.add("hello");
wordList.add("world");
map.put("wordList", wordList);
view.render(new ModelAndView("home", map).getModel(), request, response);
String text = response.getContentAsString();
assertTrue(text.trim().startsWith("<html"));
}
private void incWarnings() {
warnings++;
}
private void incErrors() {
errors++;
}
private void incFatals() {
fatal++;
}
private static final class TestXsltView extends AbstractXsltView {
}
private static final class Hero {
private String name;
private int age;
private String catchphrase;
public Hero() {
}
public Hero(String name, int age, String catchphrase) {
this.name = name;
this.age = age;
this.catchphrase = catchphrase;
}
public String getCatchphrase() {
return catchphrase;
}
public void setCatchphrase(String catchphrase) {
this.catchphrase = catchphrase;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
}