Consistent bracket alignment
This commit is contained in:
@@ -21,13 +21,10 @@ import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.ProjectDependency;
|
||||
import org.gradle.api.artifacts.maven.Conf2ScopeMapping
|
||||
import org.gradle.api.plugins.MavenPlugin
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.plugins.ide.eclipse.EclipsePlugin
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseClasspath;
|
||||
import org.gradle.plugins.ide.idea.IdeaPlugin
|
||||
import org.gradle.api.invocation.*
|
||||
|
||||
|
||||
/**
|
||||
* Gradle plugin that allows projects to merged together. Primarily developed to
|
||||
* allow Spring to support multiple incompatible versions of third-party
|
||||
@@ -76,13 +73,13 @@ class MergePlugin implements Plugin<Project> {
|
||||
|
||||
// Hook to perform the actual merge logic
|
||||
project.afterEvaluate{
|
||||
if(it.merge.into != null) {
|
||||
if (it.merge.into != null) {
|
||||
setup(it)
|
||||
}
|
||||
}
|
||||
|
||||
// Hook to build runtimeMerge dependencies
|
||||
if(!attachedProjectsEvaluated) {
|
||||
if (!attachedProjectsEvaluated) {
|
||||
project.gradle.projectsEvaluated{
|
||||
postProcessProjects(it)
|
||||
}
|
||||
@@ -102,7 +99,7 @@ class MergePlugin implements Plugin<Project> {
|
||||
// invoking a task will invoke the task with the same name on 'into' project
|
||||
["sourcesJar", "jar", "javadocJar", "javadoc", "install", "artifactoryPublish"].each {
|
||||
def task = project.tasks.findByPath(it)
|
||||
if(task) {
|
||||
if (task) {
|
||||
task.enabled = false
|
||||
task.dependsOn(project.merge.into.tasks.findByPath(it))
|
||||
}
|
||||
@@ -120,7 +117,7 @@ class MergePlugin implements Plugin<Project> {
|
||||
private void setupMaven(Project project) {
|
||||
project.configurations.each { configuration ->
|
||||
Conf2ScopeMapping mapping = project.conf2ScopeMappings.getMapping([configuration])
|
||||
if(mapping.scope) {
|
||||
if (mapping.scope) {
|
||||
Configuration intoConfiguration = project.merge.into.configurations.create(
|
||||
project.name + "-" + configuration.name)
|
||||
configuration.excludeRules.each {
|
||||
@@ -131,7 +128,7 @@ class MergePlugin implements Plugin<Project> {
|
||||
configuration.dependencies.each {
|
||||
def intoCompile = project.merge.into.configurations.getByName("compile")
|
||||
// Protect against changing a compile scope dependency (SPR-10218)
|
||||
if(!intoCompile.dependencies.contains(it)) {
|
||||
if (!intoCompile.dependencies.contains(it)) {
|
||||
intoConfiguration.dependencies.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -21,7 +21,6 @@ import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Configuration;
|
||||
import org.gradle.api.artifacts.ProjectDependency;
|
||||
|
||||
|
||||
/**
|
||||
* Gradle plugin that automatically updates testCompile dependencies to include
|
||||
* the test source sets of project dependencies.
|
||||
@@ -43,9 +42,9 @@ class TestSourceSetDependenciesPlugin implements Plugin<Project> {
|
||||
|
||||
private void collectProjectDependencies(Set<ProjectDependency> projectDependencies,
|
||||
Project project) {
|
||||
for(def configurationName in ["compile", "optional", "provided", "testCompile"]) {
|
||||
for (def configurationName in ["compile", "optional", "provided", "testCompile"]) {
|
||||
Configuration configuration = project.getConfigurations().findByName(configurationName)
|
||||
if(configuration) {
|
||||
if (configuration) {
|
||||
configuration.dependencies.findAll { it instanceof ProjectDependency }.each {
|
||||
projectDependencies.add(it)
|
||||
collectProjectDependencies(projectDependencies, it.dependencyProject)
|
||||
|
||||
@@ -215,8 +215,10 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
|
||||
// is type-compatible. Note that we can't help if the target sets
|
||||
// a reference to itself in another returned object.
|
||||
retVal = proxy;
|
||||
} else if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) {
|
||||
throw new AopInvocationException("Null return value from advice does not match primitive return type for: " + method);
|
||||
}
|
||||
else if (retVal == null && returnType != Void.TYPE && returnType.isPrimitive()) {
|
||||
throw new AopInvocationException(
|
||||
"Null return value from advice does not match primitive return type for: " + method);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
return returnValue;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
if(stopWatch.isRunning()) {
|
||||
if (stopWatch.isRunning()) {
|
||||
stopWatch.stop();
|
||||
}
|
||||
exitThroughException = true;
|
||||
@@ -268,7 +268,7 @@ public class CustomizableTraceInterceptor extends AbstractTraceInterceptor {
|
||||
}
|
||||
finally {
|
||||
if (!exitThroughException) {
|
||||
if(stopWatch.isRunning()) {
|
||||
if (stopWatch.isRunning()) {
|
||||
stopWatch.stop();
|
||||
}
|
||||
writeToLog(logger,
|
||||
|
||||
@@ -46,7 +46,7 @@ public abstract aspect AbstractDependencyInjectionAspect {
|
||||
* Select join points in beans to be configured prior to construction?
|
||||
* By default, use post-construction injection matching the default in the Configurable annotation.
|
||||
*/
|
||||
public pointcut preConstructionConfiguration() : if(false);
|
||||
public pointcut preConstructionConfiguration() : if (false);
|
||||
|
||||
/**
|
||||
* Select the most-specific initialization join point
|
||||
@@ -54,7 +54,7 @@ public abstract aspect AbstractDependencyInjectionAspect {
|
||||
*/
|
||||
@CodeGenerationHint(ifNameSuffix="6f1")
|
||||
public pointcut mostSpecificSubTypeConstruction() :
|
||||
if(thisJoinPoint.getSignature().getDeclaringType() == thisJoinPoint.getThis().getClass());
|
||||
if (thisJoinPoint.getSignature().getDeclaringType() == thisJoinPoint.getThis().getClass());
|
||||
|
||||
/**
|
||||
* Select least specific super type that is marked for DI (so that injection occurs only once with pre-construction inejection
|
||||
|
||||
@@ -79,7 +79,7 @@ public aspect AnnotationBeanConfigurerAspect
|
||||
* An intermediary to match preConstructionConfiguration signature (that doesn't expose the annotation object)
|
||||
*/
|
||||
@CodeGenerationHint(ifNameSuffix="bb0")
|
||||
private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if(c.preConstruction());
|
||||
private pointcut preConstructionConfigurationSupport(Configurable c) : @this(c) && if (c.preConstruction());
|
||||
|
||||
/*
|
||||
* This declaration shouldn't be needed,
|
||||
|
||||
@@ -55,7 +55,8 @@ public aspect JCacheCacheAspect extends JCacheAspectSupport {
|
||||
public Object invoke() {
|
||||
try {
|
||||
return proceed(cachedObject);
|
||||
} catch (Throwable ex) {
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
throw new ThrowableWrapper(ex);
|
||||
}
|
||||
}
|
||||
@@ -120,4 +121,4 @@ public aspect JCacheCacheAspect extends JCacheAspectSupport {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +378,8 @@ public class BeanWrapperImpl extends AbstractPropertyAccessor implements BeanWra
|
||||
if (pd.getReadMethod() != null || pd.getWriteMethod() != null) {
|
||||
return TypeDescriptor.nested(property(pd), tokens.keys.length);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (pd.getReadMethod() != null || pd.getWriteMethod() != null) {
|
||||
return new TypeDescriptor(property(pd));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* {@link PropertyAccessor} implementation that directly accesses instance fields.
|
||||
* Allows for direct binding to fields instead of going through JavaBean setters.
|
||||
*
|
||||
* <p>Since 4.1 this implementation supports nested fields traversing.
|
||||
* <p>As of Spring 4.1, this implementation supports nested field traversal.
|
||||
*
|
||||
* <p>A DirectFieldAccessor's default for the "extractOldValueForEditor" setting
|
||||
* is "true", since a field can always be read without side effects.
|
||||
@@ -188,7 +188,6 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
|
||||
/**
|
||||
* Create a root {@link FieldAccessor}.
|
||||
*
|
||||
* @param canonicalName the full expression for the field to access
|
||||
* @param actualName the name of the local (root) property
|
||||
* @param field the field accessing the property
|
||||
@@ -212,13 +211,13 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
private final Field field;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
* Create a new FieldAccessor instance.
|
||||
* @param parent the parent accessor, if any
|
||||
* @param canonicalName the full expression for the field to access
|
||||
* @param actualName the name of the partial expression for this property
|
||||
* @param field the field accessing the property
|
||||
*/
|
||||
private FieldAccessor(FieldAccessor parent, String canonicalName, String actualName, Field field) {
|
||||
public FieldAccessor(FieldAccessor parent, String canonicalName, String actualName, Field field) {
|
||||
Assert.notNull(canonicalName, "Expression must no be null");
|
||||
Assert.notNull(field, "Field must no be null");
|
||||
this.parents = buildParents(parent);
|
||||
@@ -229,7 +228,6 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
|
||||
/**
|
||||
* Create a child instance.
|
||||
*
|
||||
* @param actualName the name of the child property
|
||||
* @param field the field accessing the child property
|
||||
*/
|
||||
@@ -238,7 +236,7 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
}
|
||||
|
||||
public Field getField() {
|
||||
return field;
|
||||
return this.field;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
@@ -252,9 +250,8 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
try {
|
||||
this.field.set(localTarget, value);
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
throw new InvalidPropertyException(localTarget.getClass(), canonicalName,
|
||||
"Field is not accessible", e);
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new InvalidPropertyException(localTarget.getClass(), canonicalName, "Field is not accessible", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,8 +272,8 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
localTarget = autoGrowIfNecessary(parent, parent.getParentValue(localTarget));
|
||||
if (localTarget == null) { // Could not traverse the graph any further
|
||||
throw new NullValueInNestedPathException(getRootClass(), parent.actualName,
|
||||
"Cannot access indexed value of property referenced in indexed " +
|
||||
"property path '" + getField().getName() + "': returned null");
|
||||
"Cannot access indexed value of property referenced in indexed property path '" +
|
||||
getField().getName() + "': returned null");
|
||||
}
|
||||
}
|
||||
return localTarget;
|
||||
@@ -287,10 +284,10 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
try {
|
||||
return type.newInstance();
|
||||
}
|
||||
catch (Exception e) {
|
||||
catch (Exception ex) {
|
||||
throw new NullValueInNestedPathException(getRootClass(), this.actualName,
|
||||
"Could not instantiate property type [" + type.getName() + "] to " +
|
||||
"auto-grow nested property path: " + e);
|
||||
"Could not instantiate property type [" + type.getName() +
|
||||
"] to auto-grow nested property path: " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +308,6 @@ public class DirectFieldAccessor extends AbstractPropertyAccessor {
|
||||
}
|
||||
return parents;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -172,7 +172,8 @@ final class PropertyMatches {
|
||||
char t_j = s2.charAt(j - 1);
|
||||
if (s_i == t_j) {
|
||||
cost = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cost = 1;
|
||||
}
|
||||
d[i][j] = Math.min(Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1),
|
||||
|
||||
@@ -316,12 +316,12 @@ class TypeConverterDelegate {
|
||||
convertedValue = enumField.get(null);
|
||||
}
|
||||
catch (ClassNotFoundException ex) {
|
||||
if(logger.isTraceEnabled()) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Enum class [" + enumType + "] cannot be loaded", ex);
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
if(logger.isTraceEnabled()) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Field [" + fieldName + "] isn't an enum value for type [" + enumType + "]", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1028,7 +1028,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
if (this.dependencyComparator instanceof OrderProviderComparator) {
|
||||
((OrderProviderComparator) this.dependencyComparator)
|
||||
.sortArray(items, createFactoryAwareOrderProvider(matchingBeans));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Arrays.sort(items, this.dependencyComparator);
|
||||
}
|
||||
}
|
||||
@@ -1037,7 +1038,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
if (this.dependencyComparator instanceof OrderProviderComparator) {
|
||||
((OrderProviderComparator) this.dependencyComparator)
|
||||
.sortList(items, createFactoryAwareOrderProvider(matchingBeans));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Collections.sort(items, this.dependencyComparator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB
|
||||
*/
|
||||
protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) {
|
||||
boolean eligible = isEligibleAttribute(attribute);
|
||||
if(!eligible) {
|
||||
if (!eligible) {
|
||||
String fullName = attribute.getName();
|
||||
eligible = (!fullName.equals("xmlns") && !fullName.startsWith("xmlns:") &&
|
||||
isEligibleAttribute(parserContext.getDelegate().getLocalName(attribute)));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,29 +13,30 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.beans.factory.xml;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Simple {@code NamespaceHandler} implementation that maps custom
|
||||
* attributes directly through to bean properties. An important point to note is
|
||||
* that this {@code NamespaceHandler} does not have a corresponding schema
|
||||
* since there is no way to know in advance all possible attribute names.
|
||||
*
|
||||
* <p>
|
||||
* An example of the usage of this {@code NamespaceHandler} is shown below:
|
||||
* <p>An example of the usage of this {@code NamespaceHandler} is shown below:
|
||||
*
|
||||
* <pre class="code">
|
||||
* <bean id="author" class="..TestBean" c:name="Enescu" c:work-ref="compositions"/>
|
||||
@@ -51,14 +52,17 @@ import org.w3c.dom.Node;
|
||||
* support for indexes or types. Further more, the names are used as hints by
|
||||
* the container which, by default, does type introspection.
|
||||
*
|
||||
* @see SimplePropertyNamespaceHandler
|
||||
* @author Costin Leau
|
||||
* @since 3.1
|
||||
* @see SimplePropertyNamespaceHandler
|
||||
*/
|
||||
public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
|
||||
|
||||
private static final String REF_SUFFIX = "-ref";
|
||||
|
||||
private static final String DELIMITER_PREFIX = "_";
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
@@ -102,7 +106,8 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
|
||||
int index = -1;
|
||||
try {
|
||||
index = Integer.parseInt(arg);
|
||||
} catch (NumberFormatException ex) {
|
||||
}
|
||||
catch (NumberFormatException ex) {
|
||||
parserContext.getReaderContext().error(
|
||||
"Constructor argument '" + argName + "' specifies an invalid integer", attr);
|
||||
}
|
||||
@@ -136,11 +141,8 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
|
||||
}
|
||||
|
||||
private boolean containsArgWithName(String name, ConstructorArgumentValues cvs) {
|
||||
if (!checkName(name, cvs.getGenericArgumentValues())) {
|
||||
return checkName(name, cvs.getIndexedArgumentValues().values());
|
||||
}
|
||||
|
||||
return true;
|
||||
return (checkName(name, cvs.getGenericArgumentValues()) ||
|
||||
checkName(name, cvs.getIndexedArgumentValues().values()));
|
||||
}
|
||||
|
||||
private boolean checkName(String name, Collection<ValueHolder> values) {
|
||||
@@ -151,4 +153,5 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package org.springframework.beans.propertyeditors;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.beans.PropertyEditorSupport;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@link java.beans.PropertyEditor} implementation for
|
||||
* {@link java.util.ResourceBundle ResourceBundles}.
|
||||
@@ -87,7 +87,8 @@ public class ResourceBundleEditor extends PropertyEditorSupport {
|
||||
int indexOfBaseNameSeparator = rawBaseName.indexOf(BASE_NAME_SEPARATOR);
|
||||
if (indexOfBaseNameSeparator == -1) {
|
||||
bundle = ResourceBundle.getBundle(rawBaseName);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// it potentially has locale information
|
||||
String baseName = rawBaseName.substring(0, indexOfBaseNameSeparator);
|
||||
if (!StringUtils.hasText(baseName)) {
|
||||
|
||||
@@ -20,6 +20,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.beans.factory.parsing.ReaderContext;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -37,7 +39,6 @@ import org.springframework.cache.interceptor.CacheableOperation;
|
||||
import org.springframework.cache.interceptor.NameMatchCacheOperationSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* {@link org.springframework.beans.factory.xml.BeanDefinitionParser
|
||||
@@ -75,7 +76,8 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
||||
// Using attributes source.
|
||||
List<RootBeanDefinition> attributeSourceDefinitions = parseDefinitionsSources(cacheDefs, parserContext);
|
||||
builder.addPropertyValue("cacheOperationSources", attributeSourceDefinitions);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Assume annotations source.
|
||||
builder.addPropertyValue("cacheOperationSources", new RootBeanDefinition(
|
||||
AnnotationCacheOperationSource.class));
|
||||
@@ -178,8 +180,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* Simple, reusable class used for overriding defaults.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
private static class Props {
|
||||
|
||||
@@ -195,7 +195,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
private String[] caches = null;
|
||||
|
||||
|
||||
Props(Element root) {
|
||||
String defaultCache = root.getAttribute("cache");
|
||||
key = root.getAttribute("key");
|
||||
@@ -209,7 +208,6 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<T extends CacheOperation> T merge(Element element, ReaderContext readerCtx, T op) {
|
||||
String cache = element.getAttribute("cache");
|
||||
|
||||
@@ -217,7 +215,8 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
||||
String[] localCaches = caches;
|
||||
if (StringUtils.hasText(cache)) {
|
||||
localCaches = StringUtils.commaDelimitedListToStringArray(cache.trim());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (caches == null) {
|
||||
readerCtx.error("No cache specified specified for " + element.getNodeName(), element);
|
||||
}
|
||||
@@ -240,16 +239,16 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
|
||||
String merge(Element element, ReaderContext readerCtx) {
|
||||
String m = element.getAttribute(METHOD_ATTRIBUTE);
|
||||
|
||||
if (StringUtils.hasText(m)) {
|
||||
return m.trim();
|
||||
}
|
||||
String method = element.getAttribute(METHOD_ATTRIBUTE);
|
||||
if (StringUtils.hasText(method)) {
|
||||
return method;
|
||||
return method.trim();
|
||||
}
|
||||
if (StringUtils.hasText(this.method)) {
|
||||
return this.method;
|
||||
}
|
||||
readerCtx.error("No method specified for " + element.getNodeName(), element);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,14 +65,11 @@ class ExpressionEvaluator {
|
||||
// shared param discoverer since it caches data internally
|
||||
private final ParameterNameDiscoverer paramNameDiscoverer = new DefaultParameterNameDiscoverer();
|
||||
|
||||
private final Map<ExpressionKey, Expression> keyCache
|
||||
= new ConcurrentHashMap<ExpressionKey, Expression>(64);
|
||||
private final Map<ExpressionKey, Expression> keyCache = new ConcurrentHashMap<ExpressionKey, Expression>(64);
|
||||
|
||||
private final Map<ExpressionKey, Expression> conditionCache
|
||||
= new ConcurrentHashMap<ExpressionKey, Expression>(64);
|
||||
private final Map<ExpressionKey, Expression> conditionCache = new ConcurrentHashMap<ExpressionKey, Expression>(64);
|
||||
|
||||
private final Map<ExpressionKey, Expression> unlessCache
|
||||
= new ConcurrentHashMap<ExpressionKey, Expression>(64);
|
||||
private final Map<ExpressionKey, Expression> unlessCache = new ConcurrentHashMap<ExpressionKey, Expression>(64);
|
||||
|
||||
private final Map<MethodCacheKey, Method> targetMethodCache = new ConcurrentHashMap<MethodCacheKey, Method>(64);
|
||||
|
||||
@@ -83,32 +80,32 @@ class ExpressionEvaluator {
|
||||
*/
|
||||
public EvaluationContext createEvaluationContext(Collection<? extends Cache> caches,
|
||||
Method method, Object[] args, Object target, Class<?> targetClass) {
|
||||
return createEvaluationContext(caches, method, args, target, targetClass,
|
||||
NO_RESULT);
|
||||
|
||||
return createEvaluationContext(caches, method, args, target, targetClass, NO_RESULT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an {@link EvaluationContext}.
|
||||
*
|
||||
* @param caches the current caches
|
||||
* @param method the method
|
||||
* @param args the method arguments
|
||||
* @param target the target object
|
||||
* @param targetClass the target class
|
||||
* @param result the return value (can be {@code null}) or
|
||||
* {@link #NO_RESULT} if there is no return at this time
|
||||
* {@link #NO_RESULT} if there is no return at this time
|
||||
* @return the evaluation context
|
||||
*/
|
||||
public EvaluationContext createEvaluationContext(Collection<? extends Cache> caches,
|
||||
Method method, Object[] args, Object target, Class<?> targetClass,
|
||||
final Object result) {
|
||||
Method method, Object[] args, Object target, Class<?> targetClass, Object result) {
|
||||
|
||||
CacheExpressionRootObject rootObject = new CacheExpressionRootObject(caches,
|
||||
method, args, target, targetClass);
|
||||
CacheEvaluationContext evaluationContext = new CacheEvaluationContext(rootObject,
|
||||
this.paramNameDiscoverer, method, args, targetClass, this.targetMethodCache);
|
||||
if (result == RESULT_UNAVAILABLE) {
|
||||
evaluationContext.addUnavailableVariable(RESULT_VARIABLE);
|
||||
} else if (result != NO_RESULT) {
|
||||
}
|
||||
else if (result != NO_RESULT) {
|
||||
evaluationContext.setVariable(RESULT_VARIABLE, result);
|
||||
}
|
||||
return evaluationContext;
|
||||
@@ -119,23 +116,21 @@ class ExpressionEvaluator {
|
||||
}
|
||||
|
||||
public boolean condition(String conditionExpression, MethodCacheKey methodKey, EvaluationContext evalContext) {
|
||||
return getExpression(this.conditionCache, conditionExpression, methodKey).getValue(
|
||||
evalContext, boolean.class);
|
||||
return getExpression(this.conditionCache, conditionExpression, methodKey).getValue(evalContext, boolean.class);
|
||||
}
|
||||
|
||||
public boolean unless(String unlessExpression, MethodCacheKey methodKey, EvaluationContext evalContext) {
|
||||
return getExpression(this.unlessCache, unlessExpression, methodKey).getValue(
|
||||
evalContext, boolean.class);
|
||||
return getExpression(this.unlessCache, unlessExpression, methodKey).getValue(evalContext, boolean.class);
|
||||
}
|
||||
|
||||
private Expression getExpression(Map<ExpressionKey, Expression> cache, String expression, MethodCacheKey methodKey) {
|
||||
ExpressionKey key = createKey(methodKey, expression);
|
||||
Expression rtn = cache.get(key);
|
||||
if (rtn == null) {
|
||||
rtn = this.parser.parseExpression(expression);
|
||||
cache.put(key, rtn);
|
||||
Expression expr = cache.get(key);
|
||||
if (expr == null) {
|
||||
expr = this.parser.parseExpression(expression);
|
||||
cache.put(key, expr);
|
||||
}
|
||||
return rtn;
|
||||
return expr;
|
||||
}
|
||||
|
||||
private ExpressionKey createKey(MethodCacheKey methodCacheKey, String expression) {
|
||||
@@ -144,10 +139,12 @@ class ExpressionEvaluator {
|
||||
|
||||
|
||||
private static class ExpressionKey {
|
||||
|
||||
private final MethodCacheKey methodCacheKey;
|
||||
|
||||
private final String expression;
|
||||
|
||||
private ExpressionKey(MethodCacheKey methodCacheKey, String expression) {
|
||||
public ExpressionKey(MethodCacheKey methodCacheKey, String expression) {
|
||||
this.methodCacheKey = methodCacheKey;
|
||||
this.expression = expression;
|
||||
}
|
||||
@@ -161,8 +158,8 @@ class ExpressionEvaluator {
|
||||
return false;
|
||||
}
|
||||
ExpressionKey otherKey = (ExpressionKey) other;
|
||||
return (this.methodCacheKey.equals(otherKey.methodCacheKey)
|
||||
&& ObjectUtils.nullSafeEquals(this.expression, otherKey.expression));
|
||||
return (this.methodCacheKey.equals(otherKey.methodCacheKey) &&
|
||||
ObjectUtils.nullSafeEquals(this.expression, otherKey.expression));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,32 +39,38 @@ class WebLogicClassPreProcessorAdapter implements InvocationHandler {
|
||||
|
||||
private final ClassLoader loader;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link WebLogicClassPreProcessorAdapter}.
|
||||
* @param transformer the {@link ClassFileTransformer} to be adapted (must
|
||||
* not be {@code null})
|
||||
* @param transformer the {@link ClassFileTransformer} to be adapted
|
||||
* (must not be {@code null})
|
||||
*/
|
||||
public WebLogicClassPreProcessorAdapter(ClassFileTransformer transformer, ClassLoader loader) {
|
||||
this.transformer = transformer;
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
String name = method.getName();
|
||||
|
||||
if ("equals".equals(name)) {
|
||||
return (Boolean.valueOf(proxy == args[0]));
|
||||
} else if ("hashCode".equals(name)) {
|
||||
return (proxy == args[0]);
|
||||
}
|
||||
else if ("hashCode".equals(name)) {
|
||||
return hashCode();
|
||||
} else if ("toString".equals(name)) {
|
||||
}
|
||||
else if ("toString".equals(name)) {
|
||||
return toString();
|
||||
} else if ("initialize".equals(name)) {
|
||||
}
|
||||
else if ("initialize".equals(name)) {
|
||||
initialize((Hashtable<?, ?>) args[0]);
|
||||
return null;
|
||||
} else if ("preProcess".equals(name)) {
|
||||
}
|
||||
else if ("preProcess".equals(name)) {
|
||||
return preProcess((String) args[0], (byte[]) args[1]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Unknown method: " + method);
|
||||
}
|
||||
}
|
||||
@@ -76,16 +82,15 @@ class WebLogicClassPreProcessorAdapter implements InvocationHandler {
|
||||
try {
|
||||
byte[] result = this.transformer.transform(this.loader, className, null, null, classBytes);
|
||||
return (result != null ? result : classBytes);
|
||||
} catch (IllegalClassFormatException ex) {
|
||||
}
|
||||
catch (IllegalClassFormatException ex) {
|
||||
throw new IllegalStateException("Cannot transform due to illegal class format", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder(getClass().getName());
|
||||
builder.append(" for transformer: ");
|
||||
builder.append(this.transformer);
|
||||
return builder.toString();
|
||||
return getClass().getName() + " for transformer: " + this.transformer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class AnnotationJmxAttributeSource implements JmxAttributeSource, BeanFac
|
||||
@Override
|
||||
public ManagedNotification[] getManagedNotifications(Class<?> clazz) throws InvalidMetadataException {
|
||||
ManagedNotifications notificationsAnn = clazz.getAnnotation(ManagedNotifications.class);
|
||||
if(notificationsAnn == null) {
|
||||
if (notificationsAnn == null) {
|
||||
return new ManagedNotification[0];
|
||||
}
|
||||
Annotation[] notifications = notificationsAnn.value();
|
||||
|
||||
@@ -514,7 +514,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
|
||||
|
||||
MBeanParameterInfo[] info = new MBeanParameterInfo[paramNames.length];
|
||||
Class<?>[] typeParameters = method.getParameterTypes();
|
||||
for(int i = 0; i < info.length; i++) {
|
||||
for (int i = 0; i < info.length; i++) {
|
||||
info[i] = new MBeanParameterInfo(paramNames[i], typeParameters[i].getName(), paramNames[i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
||||
protected boolean includeOperation(Method method, String beanKey) {
|
||||
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
|
||||
if (pd != null) {
|
||||
if(hasManagedAttribute(method)) {
|
||||
if (hasManagedAttribute(method)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -334,7 +334,7 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
||||
*/
|
||||
@Override
|
||||
protected void populateAttributeDescriptor(Descriptor desc, Method getter, Method setter, String beanKey) {
|
||||
if(getter != null && hasManagedMetric(getter)) {
|
||||
if (getter != null && hasManagedMetric(getter)) {
|
||||
populateMetricDescriptor(desc, this.attributeSource.getManagedMetric(getter));
|
||||
}
|
||||
else {
|
||||
@@ -376,11 +376,11 @@ public class MetadataMBeanInfoAssembler extends AbstractReflectiveMBeanInfoAssem
|
||||
desc.setField(FIELD_DISPLAY_NAME, metric.getDisplayName());
|
||||
}
|
||||
|
||||
if(StringUtils.hasLength(metric.getUnit())) {
|
||||
if (StringUtils.hasLength(metric.getUnit())) {
|
||||
desc.setField(FIELD_UNITS, metric.getUnit());
|
||||
}
|
||||
|
||||
if(StringUtils.hasLength(metric.getCategory())) {
|
||||
if (StringUtils.hasLength(metric.getCategory())) {
|
||||
desc.setField(FIELD_METRIC_CATEGORY, metric.getCategory());
|
||||
}
|
||||
|
||||
|
||||
@@ -83,8 +83,10 @@ public class AsyncResult<V> implements ListenableFuture<V> {
|
||||
public void addCallback(SuccessCallback<? super V> successCallback, FailureCallback failureCallback) {
|
||||
try {
|
||||
successCallback.onSuccess(this.value);
|
||||
} catch(Throwable t) {
|
||||
}
|
||||
catch (Throwable t) {
|
||||
failureCallback.onFailure(t);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
|
||||
public static String toDelimitedString(String... elements) {
|
||||
StringBuilder rtn = new StringBuilder();
|
||||
for (String element : elements) {
|
||||
if(StringUtils.hasLength(element)) {
|
||||
if (StringUtils.hasLength(element)) {
|
||||
rtn.append(rtn.length() == 0 ? "" : CODE_SEPARATOR);
|
||||
rtn.append(element);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class MethodValidationPostProcessor extends AbstractAdvisingBeanPostProce
|
||||
* <p>Default is the default ValidatorFactory's default Validator.
|
||||
*/
|
||||
public void setValidator(Validator validator) {
|
||||
if(validator instanceof LocalValidatorFactoryBean) {
|
||||
if (validator instanceof LocalValidatorFactoryBean) {
|
||||
this.validator = ((LocalValidatorFactoryBean) validator).getValidator();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -155,7 +155,7 @@ abstract class SerializableTypeWrapper {
|
||||
return provider.getType();
|
||||
}
|
||||
Type cached = cache.get(provider.getType());
|
||||
if(cached != null) {
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
for (Class<?> type : SUPPORTED_SERIALIZABLE_TYPES) {
|
||||
|
||||
@@ -118,7 +118,7 @@ public final class Property {
|
||||
}
|
||||
|
||||
Annotation[] getAnnotations() {
|
||||
if(this.annotations == null) {
|
||||
if (this.annotations == null) {
|
||||
this.annotations = resolveAnnotations();
|
||||
}
|
||||
return this.annotations;
|
||||
@@ -192,7 +192,7 @@ public final class Property {
|
||||
|
||||
private Annotation[] resolveAnnotations() {
|
||||
Annotation[] annotations = annotationCache.get(this);
|
||||
if(annotations == null) {
|
||||
if (annotations == null) {
|
||||
Map<Class<? extends Annotation>, Annotation> annotationMap = new LinkedHashMap<Class<? extends Annotation>, Annotation>();
|
||||
addAnnotationsToMap(annotationMap, getReadMethod());
|
||||
addAnnotationsToMap(annotationMap, getWriteMethod());
|
||||
|
||||
@@ -78,7 +78,7 @@ final class MapToMapConverter implements ConditionalGenericConverter {
|
||||
copyRequired = true;
|
||||
}
|
||||
}
|
||||
if(!copyRequired) {
|
||||
if (!copyRequired) {
|
||||
return sourceMap;
|
||||
}
|
||||
Map<Object, Object> targetMap = CollectionFactory.createMap(targetType.getType(), sourceMap.size());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,7 +28,8 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Converts a comma-delimited String to a Collection.
|
||||
* If the target collection element type is declared, only matches if String.class can be converted to it.
|
||||
* If the target collection element type is declared, only matches if
|
||||
* {@code String.class} can be converted to it.
|
||||
*
|
||||
* @author Keith Donald
|
||||
* @since 3.0
|
||||
@@ -37,10 +38,12 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
|
||||
private final ConversionService conversionService;
|
||||
|
||||
|
||||
public StringToCollectionConverter(ConversionService conversionService) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<ConvertiblePair> getConvertibleTypes() {
|
||||
return Collections.singleton(new ConvertiblePair(String.class, Collection.class));
|
||||
@@ -48,11 +51,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
|
||||
@Override
|
||||
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (targetType.getElementTypeDescriptor() != null) {
|
||||
return this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return (targetType.getElementTypeDescriptor() == null ||
|
||||
this.conversionService.canConvert(sourceType, targetType.getElementTypeDescriptor()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -67,7 +67,8 @@ final class StringToCollectionConverter implements ConditionalGenericConverter {
|
||||
for (String field : fields) {
|
||||
target.add(field.trim());
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
for (String field : fields) {
|
||||
Object targetElement = this.conversionService.convert(field.trim(), sourceType, targetType.getElementTypeDescriptor());
|
||||
target.add(targetElement);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.core.convert.support;
|
||||
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Converts from a String to a java.lang.Enum by calling {@link Enum#valueOf(Class, String)}.
|
||||
@@ -32,14 +31,16 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
|
||||
@Override
|
||||
public <T extends Enum> Converter<String, T> getConverter(Class<T> targetType) {
|
||||
Class<?> enumType = targetType;
|
||||
while(enumType != null && !enumType.isEnum()) {
|
||||
while (enumType != null && !enumType.isEnum()) {
|
||||
enumType = enumType.getSuperclass();
|
||||
}
|
||||
Assert.notNull(enumType, "The target type " + targetType.getName()
|
||||
+ " does not refer to an enum");
|
||||
if (enumType == null) {
|
||||
throw new IllegalArgumentException("The target type " + targetType.getName() + " does not refer to an enum");
|
||||
}
|
||||
return new StringToEnum(enumType);
|
||||
}
|
||||
|
||||
|
||||
private class StringToEnum<T extends Enum> implements Converter<String, T> {
|
||||
|
||||
private final Class<T> enumType;
|
||||
|
||||
@@ -31,7 +31,7 @@ final class StringToUUIDConverter implements Converter<String, UUID> {
|
||||
|
||||
@Override
|
||||
public UUID convert(String source) {
|
||||
if(StringUtils.hasLength(source)) {
|
||||
if (StringUtils.hasLength(source)) {
|
||||
return UUID.fromString(source.trim());
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -129,7 +129,7 @@ public abstract class AbstractResource implements Resource {
|
||||
long size = 0;
|
||||
byte[] buf = new byte[255];
|
||||
int read;
|
||||
while((read = is.read(buf)) != -1) {
|
||||
while ((read = is.read(buf)) != -1) {
|
||||
size += read;
|
||||
}
|
||||
return size;
|
||||
|
||||
@@ -226,7 +226,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
*/
|
||||
@Override
|
||||
public OutputStream getOutputStream() throws IOException {
|
||||
if(Files.isDirectory(this.path)) {
|
||||
if (Files.isDirectory(this.path)) {
|
||||
throw new FileNotFoundException(getPath() + " (is a directory)");
|
||||
}
|
||||
return Files.newOutputStream(this.path);
|
||||
|
||||
@@ -709,16 +709,16 @@ public class AntPathMatcher implements PathMatcher {
|
||||
protected void initCounters() {
|
||||
int pos = 0;
|
||||
while (pos < this.pattern.length()) {
|
||||
if(this.pattern.charAt(pos) == '{') {
|
||||
if (this.pattern.charAt(pos) == '{') {
|
||||
this.uriVars++;
|
||||
pos++;
|
||||
}
|
||||
else if(this.pattern.charAt(pos) == '*') {
|
||||
if(pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') {
|
||||
else if (this.pattern.charAt(pos) == '*') {
|
||||
if (pos + 1 < this.pattern.length() && this.pattern.charAt(pos + 1) == '*') {
|
||||
this.doubleWildcards++;
|
||||
pos += 2;
|
||||
}
|
||||
else if(!this.pattern.substring(pos - 1).equals(".*")) {
|
||||
else if (!this.pattern.substring(pos - 1).equals(".*")) {
|
||||
this.singleWildcards++;
|
||||
pos++;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public abstract class ObjectUtils {
|
||||
*/
|
||||
public static <E extends Enum<?>> E caseInsensitiveValueOf(E[] enumValues, String constant) {
|
||||
for (E candidate : enumValues) {
|
||||
if(candidate.toString().equalsIgnoreCase(constant)) {
|
||||
if (candidate.toString().equalsIgnoreCase(constant)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,25 +58,18 @@ public abstract class SocketUtils {
|
||||
/**
|
||||
* Although {@code SocketUtils} consists solely of static utility methods,
|
||||
* this constructor is intentionally {@code public}.
|
||||
*
|
||||
* <h4>Rationale</h4>
|
||||
*
|
||||
* <p>Static methods from this class may be invoked from within XML
|
||||
* configuration files using the Spring Expression Language (SpEL) and the
|
||||
* following syntax.
|
||||
*
|
||||
* <pre><code><bean id="bean1" ... p:port="#{T(org.springframework.util.SocketUtils).findAvailableTcpPort(12000)}" /></code></pre>
|
||||
*
|
||||
* If this constructor were {@code private}, you would be required to supply
|
||||
* the fully qualified class name to SpEL's {@code T()} function for each usage.
|
||||
* Thus, the fact that this constructor is {@code public} allows you to reduce
|
||||
* boilerplate configuration with SpEL as can be seen in the following example.
|
||||
*
|
||||
* <pre><code><bean id="socketUtils" class="org.springframework.util.SocketUtils" />
|
||||
*
|
||||
*<bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" />
|
||||
*
|
||||
*<bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" /></code></pre>
|
||||
* <bean id="bean1" ... p:port="#{socketUtils.findAvailableTcpPort(12000)}" />
|
||||
* <bean id="bean2" ... p:port="#{socketUtils.findAvailableTcpPort(30000)}" /></code></pre>
|
||||
*/
|
||||
public SocketUtils() {
|
||||
/* no-op */
|
||||
@@ -271,7 +264,8 @@ public abstract class SocketUtils {
|
||||
maxPort, searchCounter));
|
||||
}
|
||||
candidatePort = findRandomPort(minPort, maxPort);
|
||||
} while (!isPortAvailable(candidatePort));
|
||||
}
|
||||
while (!isPortAvailable(candidatePort));
|
||||
|
||||
return candidatePort;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -229,7 +229,8 @@ public class StopWatch {
|
||||
sb.append('\n');
|
||||
if (!this.keepTaskList) {
|
||||
sb.append("No task info kept");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sb.append("-----------------------------------------\n");
|
||||
sb.append("ms % Task name\n");
|
||||
sb.append("-----------------------------------------\n");
|
||||
@@ -261,7 +262,8 @@ public class StopWatch {
|
||||
long percent = Math.round((100.0 * task.getTimeSeconds()) / getTotalTimeSeconds());
|
||||
sb.append(" = ").append(percent).append("%");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sb.append("; no task info kept");
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
@@ -60,7 +60,7 @@ public class InstanceComparator<T> implements Comparator<T> {
|
||||
}
|
||||
|
||||
private int getOrder(T object) {
|
||||
if(object != null) {
|
||||
if (object != null) {
|
||||
for (int i = 0; i < instanceOrder.length; i++) {
|
||||
if (instanceOrder[i].isInstance(object)) {
|
||||
return i;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,10 +29,10 @@ import org.springframework.util.Assert;
|
||||
* #get()} and {@link #get(long, TimeUnit)} call {@link #adapt(Object)} on the adaptee's
|
||||
* result.
|
||||
*
|
||||
* @param <T> the type of this {@code Future}
|
||||
* @param <S> the type of the adaptee's {@code Future}
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
* @param <T> the type of this {@code Future}
|
||||
* @param <S> the type of the adaptee's {@code Future}
|
||||
*/
|
||||
public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
|
||||
@@ -44,6 +44,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
|
||||
private final Object mutex = new Object();
|
||||
|
||||
|
||||
/**
|
||||
* Constructs a new {@code FutureAdapter} with the given adaptee.
|
||||
* @param adaptee the future to delegate to
|
||||
@@ -53,6 +54,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
this.adaptee = adaptee;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the adaptee.
|
||||
*/
|
||||
@@ -81,28 +83,28 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(long timeout, TimeUnit unit)
|
||||
throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return adaptInternal(adaptee.get(timeout, unit));
|
||||
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
return adaptInternal(this.adaptee.get(timeout, unit));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final T adaptInternal(S adapteeResult) throws ExecutionException {
|
||||
synchronized (mutex) {
|
||||
switch (state) {
|
||||
synchronized (this.mutex) {
|
||||
switch (this.state) {
|
||||
case SUCCESS:
|
||||
return (T) result;
|
||||
return (T) this.result;
|
||||
case FAILURE:
|
||||
throw (ExecutionException) result;
|
||||
throw (ExecutionException) this.result;
|
||||
case NEW:
|
||||
try {
|
||||
T adapted = adapt(adapteeResult);
|
||||
result = adapted;
|
||||
state = State.SUCCESS;
|
||||
this.result = adapted;
|
||||
this.state = State.SUCCESS;
|
||||
return adapted;
|
||||
} catch (ExecutionException ex) {
|
||||
result = ex;
|
||||
state = State.FAILURE;
|
||||
}
|
||||
catch (ExecutionException ex) {
|
||||
this.result = ex;
|
||||
this.state = State.FAILURE;
|
||||
throw ex;
|
||||
}
|
||||
default:
|
||||
@@ -117,6 +119,7 @@ public abstract class FutureAdapter<T, S> implements Future<T> {
|
||||
*/
|
||||
protected abstract T adapt(S adapteeResult) throws ExecutionException;
|
||||
|
||||
|
||||
private enum State {NEW, SUCCESS, FAILURE}
|
||||
|
||||
}
|
||||
|
||||
@@ -219,47 +219,48 @@ public class CodeFlow implements Opcodes {
|
||||
* @return the JVM descriptor for the class
|
||||
*/
|
||||
public static String toJVMDescriptor(Class<?> clazz) {
|
||||
StringBuilder s= new StringBuilder();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (clazz.isArray()) {
|
||||
while (clazz.isArray()) {
|
||||
s.append("[");
|
||||
sb.append("[");
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
}
|
||||
if (clazz.isPrimitive()) {
|
||||
if (clazz == Void.TYPE) {
|
||||
s.append('V');
|
||||
sb.append('V');
|
||||
}
|
||||
else if (clazz == Integer.TYPE) {
|
||||
s.append('I');
|
||||
sb.append('I');
|
||||
}
|
||||
else if (clazz == Boolean.TYPE) {
|
||||
s.append('Z');
|
||||
sb.append('Z');
|
||||
}
|
||||
else if (clazz == Character.TYPE) {
|
||||
s.append('C');
|
||||
sb.append('C');
|
||||
}
|
||||
else if (clazz == Long.TYPE) {
|
||||
s.append('J');
|
||||
sb.append('J');
|
||||
}
|
||||
else if (clazz == Double.TYPE) {
|
||||
s.append('D');
|
||||
sb.append('D');
|
||||
}
|
||||
else if (clazz == Float.TYPE) {
|
||||
s.append('F');
|
||||
sb.append('F');
|
||||
}
|
||||
else if (clazz == Byte.TYPE) {
|
||||
s.append('B');
|
||||
sb.append('B');
|
||||
}
|
||||
else if (clazz == Short.TYPE) {
|
||||
s.append('S');
|
||||
sb.append('S');
|
||||
}
|
||||
} else {
|
||||
s.append("L");
|
||||
s.append(clazz.getName().replace('.', '/'));
|
||||
s.append(";");
|
||||
}
|
||||
return s.toString();
|
||||
else {
|
||||
sb.append("L");
|
||||
sb.append(clazz.getName().replace('.', '/'));
|
||||
sb.append(";");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -283,7 +283,8 @@ public class Indexer extends SpelNodeImpl {
|
||||
}
|
||||
if (member instanceof Field) {
|
||||
mv.visitFieldInsn(isStatic?GETSTATIC:GETFIELD,memberDeclaringClassSlashedDescriptor,member.getName(),CodeFlow.toJVMDescriptor(((Field) member).getType()));
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mv.visitMethodInsn(isStatic?INVOKESTATIC:INVOKEVIRTUAL, memberDeclaringClassSlashedDescriptor, member.getName(),CodeFlow.createSignatureDescriptor((Method)member),false);
|
||||
}
|
||||
}
|
||||
@@ -556,12 +557,12 @@ public class Indexer extends SpelNodeImpl {
|
||||
Member member = optimalAccessor.member;
|
||||
if (member instanceof Field) {
|
||||
Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(((Field)member).getType());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(((Method)member).getReturnType());
|
||||
}
|
||||
}
|
||||
TypedValue value = accessor.read(this.evaluationContext, this.targetObject, this.name);
|
||||
return value;
|
||||
return accessor.read(this.evaluationContext, this.targetObject, this.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -679,7 +680,7 @@ public class Indexer extends SpelNodeImpl {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.COLLECTION_INDEX_OUT_OF_BOUNDS,
|
||||
this.collection.size(), this.index);
|
||||
}
|
||||
if(this.index >= this.maximumSize) {
|
||||
if (this.index >= this.maximumSize) {
|
||||
throw new SpelEvaluationException(getStartPosition(), SpelMessage.UNABLE_TO_GROW_COLLECTION);
|
||||
}
|
||||
if (this.collectionEntryDescriptor.getElementTypeDescriptor() == null) {
|
||||
|
||||
@@ -105,7 +105,8 @@ public class OpEQ extends Operator {
|
||||
else {
|
||||
throw new IllegalStateException("Unexpected descriptor "+leftDesc);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
getLeftOperand().generateCode(mv, codeflow);
|
||||
getRightOperand().generateCode(mv, codeflow);
|
||||
Label leftNotNull = new Label();
|
||||
|
||||
@@ -193,7 +193,8 @@ public class OpMinus extends Operator {
|
||||
default:
|
||||
throw new IllegalStateException("Unrecognized exit descriptor: '"+this.exitTypeDescriptor+"'");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
switch (this.exitTypeDescriptor.charAt(0)) {
|
||||
case 'I':
|
||||
mv.visitInsn(INEG);
|
||||
|
||||
@@ -105,7 +105,8 @@ public class OpNE extends Operator {
|
||||
else {
|
||||
throw new IllegalStateException("Unexpected descriptor "+leftDesc);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
getLeftOperand().generateCode(mv, codeflow);
|
||||
getRightOperand().generateCode(mv, codeflow);
|
||||
mv.visitJumpInsn(IF_ACMPEQ, elseTarget);
|
||||
|
||||
@@ -66,7 +66,8 @@ public class OperatorInstanceof extends Operator {
|
||||
Class<?> rightClass = (Class<?>) rightValue;
|
||||
if (leftValue == null) {
|
||||
result = BooleanTypedValue.FALSE; // null is not an instanceof anything
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
result = BooleanTypedValue.forValue(rightClass.isAssignableFrom(leftValue.getClass()));
|
||||
}
|
||||
this.type = rightClass;
|
||||
@@ -76,7 +77,7 @@ public class OperatorInstanceof extends Operator {
|
||||
|
||||
@Override
|
||||
public boolean isCompilable() {
|
||||
return this.exitTypeDescriptor != null && getLeftOperand().isCompilable();
|
||||
return (this.exitTypeDescriptor != null && getLeftOperand().isCompilable());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,4 +86,5 @@ public class OperatorInstanceof extends Operator {
|
||||
mv.visitTypeInsn(INSTANCEOF,Type.getInternalName(this.type));
|
||||
codeflow.pushDescriptor(getExitDescriptor());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public class TypeReference extends SpelNodeImpl {
|
||||
|
||||
private transient Class<?> type;
|
||||
|
||||
|
||||
public TypeReference(int pos, SpelNodeImpl qualifiedId) {
|
||||
this(pos,qualifiedId,0);
|
||||
}
|
||||
@@ -50,7 +51,7 @@ public class TypeReference extends SpelNodeImpl {
|
||||
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
||||
// TODO possible optimization here if we cache the discovered type reference, but can we do that?
|
||||
String typename = (String) this.children[0].getValueInternal(state).getValue();
|
||||
if (typename.indexOf(".") == -1 && Character.isLowerCase(typename.charAt(0))) {
|
||||
if (typename.indexOf('.') == -1 && Character.isLowerCase(typename.charAt(0))) {
|
||||
TypeCode tc = TypeCode.valueOf(typename.toUpperCase());
|
||||
if (tc != TypeCode.OBJECT) {
|
||||
// it is a primitive type
|
||||
@@ -69,10 +70,10 @@ public class TypeReference extends SpelNodeImpl {
|
||||
}
|
||||
|
||||
private Class<?> makeArrayIfNecessary(Class<?> clazz) {
|
||||
if (this.dimensions!=0) {
|
||||
for (int i=0;i<this.dimensions;i++) {
|
||||
Object o = Array.newInstance(clazz, 0);
|
||||
clazz = o.getClass();
|
||||
if (this.dimensions != 0) {
|
||||
for (int i = 0; i < this.dimensions; i++) {
|
||||
Object array = Array.newInstance(clazz, 0);
|
||||
clazz = array.getClass();
|
||||
}
|
||||
}
|
||||
return clazz;
|
||||
@@ -92,7 +93,7 @@ public class TypeReference extends SpelNodeImpl {
|
||||
|
||||
@Override
|
||||
public boolean isCompilable() {
|
||||
return this.exitTypeDescriptor != null;
|
||||
return (this.exitTypeDescriptor != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -101,21 +102,29 @@ public class TypeReference extends SpelNodeImpl {
|
||||
if (type.isPrimitive()) {
|
||||
if (type == Integer.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Integer", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Boolean.TYPE) {
|
||||
}
|
||||
else if (type == Boolean.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Byte.TYPE) {
|
||||
}
|
||||
else if (type == Byte.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Byte", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Short.TYPE) {
|
||||
}
|
||||
else if (type == Short.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Short", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Double.TYPE) {
|
||||
}
|
||||
else if (type == Double.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Double", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Character.TYPE) {
|
||||
}
|
||||
else if (type == Character.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Character", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Float.TYPE) {
|
||||
}
|
||||
else if (type == Float.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Float", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Long.TYPE) {
|
||||
}
|
||||
else if (type == Long.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Long", "TYPE", "Ljava/lang/Class;");
|
||||
} else if (type == Boolean.TYPE) {
|
||||
}
|
||||
else if (type == Boolean.TYPE) {
|
||||
mv.visitFieldInsn(GETSTATIC, "java/lang/Boolean", "TYPE", "Ljava/lang/Class;");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,8 @@ public class VariableReference extends SpelNodeImpl {
|
||||
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
|
||||
if (this.name.equals(ROOT)) {
|
||||
mv.visitVarInsn(ALOAD,1);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
mv.visitVarInsn(ALOAD, 2);
|
||||
mv.visitLdcInsn(name);
|
||||
mv.visitMethodInsn(INVOKEINTERFACE, "org/springframework/expression/EvaluationContext", "lookupVariable", "(Ljava/lang/String;)Ljava/lang/Object;",true);
|
||||
|
||||
@@ -357,13 +357,15 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
SpelNodeImpl expr = null;
|
||||
if (peekToken(TokenKind.DOT,TokenKind.SAFE_NAVI)) {
|
||||
expr = eatDottedNode();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
expr = maybeEatNonDottedNode();
|
||||
}
|
||||
|
||||
if (expr==null) {
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
push(expr);
|
||||
return true;
|
||||
}
|
||||
@@ -613,7 +615,8 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
List<SpelNodeImpl> listElements = new ArrayList<SpelNodeImpl>();
|
||||
do {
|
||||
listElements.add(eatExpression());
|
||||
} while (peekToken(TokenKind.COMMA,true));
|
||||
}
|
||||
while (peekToken(TokenKind.COMMA,true));
|
||||
|
||||
closingCurly = eatToken(TokenKind.RCURLY);
|
||||
expr = new InlineList(toPos(t.startpos,closingCurly.endpos),listElements.toArray(new SpelNodeImpl[listElements.size()]));
|
||||
@@ -640,7 +643,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
}
|
||||
nextToken();
|
||||
SpelNodeImpl expr = eatExpression();
|
||||
if(expr == null) {
|
||||
if (expr == null) {
|
||||
raiseInternalException(toPos(t), SpelMessage.MISSING_SELECTION_EXPRESSION);
|
||||
}
|
||||
eatToken(TokenKind.RSQUARE);
|
||||
@@ -665,13 +668,13 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
Token node = peekToken();
|
||||
while (isValidQualifiedId(node)) {
|
||||
nextToken();
|
||||
if(node.kind != TokenKind.DOT) {
|
||||
if (node.kind != TokenKind.DOT) {
|
||||
qualifiedIdPieces.add(new Identifier(node.stringValue(),toPos(node)));
|
||||
}
|
||||
node = peekToken();
|
||||
}
|
||||
if(qualifiedIdPieces.isEmpty()) {
|
||||
if(node == null) {
|
||||
if (qualifiedIdPieces.isEmpty()) {
|
||||
if (node == null) {
|
||||
raiseInternalException( this.expressionString.length(), SpelMessage.OOD);
|
||||
}
|
||||
raiseInternalException(node.startpos, SpelMessage.NOT_EXPECTED_TOKEN,
|
||||
@@ -682,10 +685,10 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
}
|
||||
|
||||
private boolean isValidQualifiedId(Token node) {
|
||||
if(node == null || node.kind == TokenKind.LITERAL_STRING) {
|
||||
if (node == null || node.kind == TokenKind.LITERAL_STRING) {
|
||||
return false;
|
||||
}
|
||||
if(node.kind == TokenKind.DOT || node.kind == TokenKind.IDENTIFIER) {
|
||||
if (node.kind == TokenKind.DOT || node.kind == TokenKind.IDENTIFIER) {
|
||||
return true;
|
||||
}
|
||||
String value = node.stringValue();
|
||||
@@ -708,9 +711,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
// TODO what is the end position for a method reference? the name or the last arg?
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
//constructor
|
||||
@@ -825,7 +826,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
// | GREATER_THAN_OR_EQUAL | INSTANCEOF | BETWEEN | MATCHES
|
||||
private Token maybeEatRelationalOperator() {
|
||||
Token t = peekToken();
|
||||
if (t==null) {
|
||||
if (t == null) {
|
||||
return null;
|
||||
}
|
||||
if (t.isNumericRelationalOperator()) {
|
||||
@@ -848,10 +849,10 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
|
||||
private Token eatToken(TokenKind expectedKind) {
|
||||
Token t = nextToken();
|
||||
if (t==null) {
|
||||
if (t == null) {
|
||||
raiseInternalException( this.expressionString.length(), SpelMessage.OOD);
|
||||
}
|
||||
if (t.kind!=expectedKind) {
|
||||
if (t.kind != expectedKind) {
|
||||
raiseInternalException(t.startpos,SpelMessage.NOT_EXPECTED_TOKEN, expectedKind.toString().toLowerCase(),t.getKind().toString().toLowerCase());
|
||||
}
|
||||
return t;
|
||||
@@ -866,7 +867,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
return false;
|
||||
}
|
||||
Token t = peekToken();
|
||||
if (t.kind==desiredTokenKind) {
|
||||
if (t.kind == desiredTokenKind) {
|
||||
if (consumeIfMatched) {
|
||||
this.tokenStreamPointer++;
|
||||
}
|
||||
@@ -876,7 +877,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
if (desiredTokenKind == TokenKind.IDENTIFIER) {
|
||||
// might be one of the textual forms of the operators (e.g. NE for != ) - in which case we can treat it as an identifier
|
||||
// The list is represented here: Tokenizer.alternativeOperatorNames and those ones are in order in the TokenKind enum
|
||||
if (t.kind.ordinal()>=TokenKind.DIV.ordinal() && t.kind.ordinal()<=TokenKind.NOT.ordinal() && t.data!=null) {
|
||||
if (t.kind.ordinal() >= TokenKind.DIV.ordinal() && t.kind.ordinal() <= TokenKind.NOT.ordinal() && t.data != null) {
|
||||
// if t.data were null, we'd know it wasn't the textual form, it was the symbol form
|
||||
return true;
|
||||
}
|
||||
@@ -889,7 +890,7 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
return false;
|
||||
}
|
||||
Token t = peekToken();
|
||||
return t.kind == possible1 || t.kind == possible2;
|
||||
return (t.kind == possible1 || t.kind == possible2);
|
||||
}
|
||||
|
||||
private boolean peekToken(TokenKind possible1,TokenKind possible2, TokenKind possible3) {
|
||||
@@ -965,14 +966,14 @@ class InternalSpelExpressionParser extends TemplateAwareExpressionParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compress the start and end of a token into a single int
|
||||
* Compress the start and end of a token into a single int.
|
||||
*/
|
||||
private int toPos(Token t) {
|
||||
return (t.startpos<<16)+t.endpos;
|
||||
return (t.startpos<<16) + t.endpos;
|
||||
}
|
||||
|
||||
private int toPos(int start,int end) {
|
||||
return (start<<16)+end;
|
||||
return (start<<16) + end;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return procedureName.toUpperCase();
|
||||
}
|
||||
else if(isStoresLowerCaseIdentifiers()) {
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return procedureName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
@@ -133,7 +133,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return catalogName.toUpperCase();
|
||||
}
|
||||
else if(isStoresLowerCaseIdentifiers()) {
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return catalogName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
@@ -149,7 +149,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return schemaName.toUpperCase();
|
||||
}
|
||||
else if(isStoresLowerCaseIdentifiers()) {
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return schemaName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
@@ -185,7 +185,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return parameterName.toUpperCase();
|
||||
}
|
||||
else if(isStoresLowerCaseIdentifiers()) {
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return parameterName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,34 +85,23 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Specify whether identifiers use upper case
|
||||
*/
|
||||
public void setStoresUpperCaseIdentifiers(boolean storesUpperCaseIdentifiers) {
|
||||
this.storesUpperCaseIdentifiers = storesUpperCaseIdentifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether identifiers use upper case
|
||||
*/
|
||||
public boolean isStoresUpperCaseIdentifiers() {
|
||||
return this.storesUpperCaseIdentifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether identifiers use lower case.
|
||||
*/
|
||||
public void setStoresLowerCaseIdentifiers(boolean storesLowerCaseIdentifiers) {
|
||||
this.storesLowerCaseIdentifiers = storesLowerCaseIdentifiers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether identifiers use lower case
|
||||
*/
|
||||
public boolean isStoresLowerCaseIdentifiers() {
|
||||
return this.storesLowerCaseIdentifiers;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isTableColumnMetaDataUsed() {
|
||||
return this.tableColumnMetaDataUsed;
|
||||
@@ -138,16 +127,10 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether a column name array is supported for generated keys
|
||||
*/
|
||||
public void setGetGeneratedKeysSupported(boolean getGeneratedKeysSupported) {
|
||||
this.getGeneratedKeysSupported = getGeneratedKeysSupported;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether a column name array is supported for generated keys
|
||||
*/
|
||||
public void setGeneratedKeysColumnNameArraySupported(boolean generatedKeysColumnNameArraySupported) {
|
||||
this.generatedKeysColumnNameArraySupported = generatedKeysColumnNameArraySupported;
|
||||
}
|
||||
@@ -179,8 +162,8 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
setGetGeneratedKeysSupported(false);
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.getGeneratedKeys' - " + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.getGeneratedKeys' - " + ex.getMessage());
|
||||
}
|
||||
try {
|
||||
String databaseProductName = databaseMetaData.getDatabaseProductName();
|
||||
@@ -198,26 +181,26 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductName' - " + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductName' - " + ex.getMessage());
|
||||
}
|
||||
try {
|
||||
this.databaseVersion = databaseMetaData.getDatabaseProductVersion();
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductVersion' - " + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.getDatabaseProductVersion' - " + ex.getMessage());
|
||||
}
|
||||
try {
|
||||
setStoresUpperCaseIdentifiers(databaseMetaData.storesUpperCaseIdentifiers());
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.storesUpperCaseIdentifiers' - " + ex.getMessage());
|
||||
}
|
||||
try {
|
||||
setStoresLowerCaseIdentifiers(databaseMetaData.storesLowerCaseIdentifiers());
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error retrieving 'DatabaseMetaData.storesLowerCaseIdentifiers' - " + ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -238,7 +221,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return tableName.toUpperCase();
|
||||
}
|
||||
else if(isStoresLowerCaseIdentifiers()) {
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return tableName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
@@ -254,7 +237,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return catalogName.toUpperCase();
|
||||
}
|
||||
else if(isStoresLowerCaseIdentifiers()) {
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return catalogName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
@@ -270,7 +253,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
else if (isStoresUpperCaseIdentifiers()) {
|
||||
return schemaName.toUpperCase();
|
||||
}
|
||||
else if(isStoresLowerCaseIdentifiers()) {
|
||||
else if (isStoresLowerCaseIdentifiers()) {
|
||||
return schemaName.toLowerCase();
|
||||
}
|
||||
else {
|
||||
@@ -325,22 +308,23 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
tmd.setSchemaName(tables.getString("TABLE_SCHEM"));
|
||||
tmd.setTableName(tables.getString("TABLE_NAME"));
|
||||
if (tmd.getSchemaName() == null) {
|
||||
tableMeta.put(userName != null ? userName.toUpperCase() : "", tmd);
|
||||
tableMeta.put(this.userName != null ? this.userName.toUpperCase() : "", tmd);
|
||||
}
|
||||
else {
|
||||
tableMeta.put(tmd.getSchemaName().toUpperCase(), tmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Error while accessing table meta data results" + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error while accessing table meta data results" + ex.getMessage());
|
||||
}
|
||||
finally {
|
||||
if (tables != null) {
|
||||
try {
|
||||
tables.close();
|
||||
} catch (SQLException e) {
|
||||
logger.warn("Error while closing table meta data results" + e.getMessage());
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error while closing table meta data results" + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -431,16 +415,16 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Error while retrieving metadata for table columns: " + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Error while retrieving metadata for table columns: " + ex.getMessage());
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
if (tableColumns != null)
|
||||
tableColumns.close();
|
||||
}
|
||||
catch (SQLException se) {
|
||||
logger.warn("Problem closing ResultSet for table column metadata " + se.getMessage());
|
||||
catch (SQLException ex) {
|
||||
logger.warn("Problem closing ResultSet for table column metadata " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,7 +442,6 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
|
||||
private String tableName;
|
||||
|
||||
|
||||
public void setCatalogName(String catalogName) {
|
||||
this.catalogName = catalogName;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public abstract class AbstractExceptionHandlerMethodResolver {
|
||||
*/
|
||||
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
|
||||
List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
|
||||
for(Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
|
||||
for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
|
||||
if (mappedException.isAssignableFrom(exceptionType)) {
|
||||
matches.add(mappedException);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,8 @@ public class SimpSessionScope implements Scope {
|
||||
if (value != null) {
|
||||
simpAttributes.removeAttribute(name);
|
||||
return value;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
|
||||
public void addSubscription(String destination, String subscriptionId) {
|
||||
Set<String> subs = this.subscriptions.get(destination);
|
||||
if (subs == null) {
|
||||
synchronized(this.monitor) {
|
||||
synchronized (this.monitor) {
|
||||
subs = this.subscriptions.get(destination);
|
||||
if (subs == null) {
|
||||
subs = new HashSet<String>(4);
|
||||
@@ -327,7 +327,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
|
||||
for (String destination : this.subscriptions.keySet()) {
|
||||
Set<String> subscriptionIds = this.subscriptions.get(destination);
|
||||
if (subscriptionIds.remove(subscriptionId)) {
|
||||
synchronized(this.monitor) {
|
||||
synchronized (this.monitor) {
|
||||
if (subscriptionIds.isEmpty()) {
|
||||
this.subscriptions.remove(destination);
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ public abstract class AbstractMessageBrokerConfiguration implements ApplicationC
|
||||
protected Validator simpValidator() {
|
||||
Validator validator = getValidator();
|
||||
if (validator == null) {
|
||||
if(this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) {
|
||||
if (this.applicationContext.containsBean(MVC_VALIDATOR_NAME)) {
|
||||
validator = this.applicationContext.getBean(MVC_VALIDATOR_NAME, Validator.class);
|
||||
}
|
||||
else if (ClassUtils.isPresent("javax.validation.Validator", getClass().getClassLoader())) {
|
||||
|
||||
@@ -192,7 +192,7 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
|
||||
if (this.systemHeartbeatReceiveInterval != null) {
|
||||
handler.setSystemHeartbeatReceiveInterval(this.systemHeartbeatReceiveInterval);
|
||||
}
|
||||
if(this.virtualHost != null) {
|
||||
if (this.virtualHost != null) {
|
||||
handler.setVirtualHost(this.virtualHost);
|
||||
}
|
||||
|
||||
|
||||
@@ -535,7 +535,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
|
||||
@Override
|
||||
public void setStatus(int status) {
|
||||
if(!this.isCommitted()) {
|
||||
if (!this.isCommitted()) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -543,7 +543,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
||||
@Override
|
||||
@Deprecated
|
||||
public void setStatus(int status, String errorMessage) {
|
||||
if(!this.isCommitted()) {
|
||||
if (!this.isCommitted()) {
|
||||
this.status = status;
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
*/
|
||||
protected abstract SmartContextLoader getAnnotationConfigLoader();
|
||||
|
||||
|
||||
// --- SmartContextLoader --------------------------------------------------
|
||||
|
||||
private static String name(SmartContextLoader loader) {
|
||||
@@ -94,6 +95,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
|
||||
private static ApplicationContext delegateLoading(SmartContextLoader loader, MergedContextConfiguration mergedConfig)
|
||||
throws Exception {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("Delegating to %s to load context from %s.", name(loader), mergedConfig));
|
||||
}
|
||||
@@ -103,7 +105,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
private boolean supports(SmartContextLoader loader, MergedContextConfiguration mergedConfig) {
|
||||
if (loader == getAnnotationConfigLoader()) {
|
||||
return ObjectUtils.isEmpty(mergedConfig.getLocations()) && !ObjectUtils.isEmpty(mergedConfig.getClasses());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return !ObjectUtils.isEmpty(mergedConfig.getLocations()) && ObjectUtils.isEmpty(mergedConfig.getClasses());
|
||||
}
|
||||
}
|
||||
@@ -111,12 +114,10 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
/**
|
||||
* Delegates to candidate {@code SmartContextLoaders} to process the supplied
|
||||
* {@link ContextConfigurationAttributes}.
|
||||
*
|
||||
* <p>Delegation is based on explicit knowledge of the implementations of the
|
||||
* default loaders for {@link #getXmlLoader() XML configuration files} and
|
||||
* {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the
|
||||
* delegation algorithm is as follows:
|
||||
*
|
||||
* <ul>
|
||||
* <li>If the resource locations or annotated classes in the supplied
|
||||
* {@code ContextConfigurationAttributes} are not empty, the appropriate
|
||||
@@ -131,7 +132,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* If the annotation-based loader detects default configuration
|
||||
* classes, an {@code info} message will be logged.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param configAttributes the context configuration attributes to process
|
||||
* @throws IllegalArgumentException if the supplied configuration attributes are
|
||||
* {@code null}, or if the supplied configuration attributes include both
|
||||
@@ -147,17 +147,19 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
|
||||
Assert.notNull(configAttributes, "configAttributes must not be null");
|
||||
Assert.isTrue(!(configAttributes.hasLocations() && configAttributes.hasClasses()), String.format(
|
||||
"Cannot process locations AND classes for context "
|
||||
+ "configuration %s; configure one or the other, but not both.", configAttributes));
|
||||
"Cannot process locations AND classes for context configuration %s; configure one or the other, but not both.",
|
||||
configAttributes));
|
||||
|
||||
// If the original locations or classes were not empty, there's no
|
||||
// need to bother with default detection checks; just let the
|
||||
// appropriate loader process the configuration.
|
||||
if (configAttributes.hasLocations()) {
|
||||
delegateProcessing(getXmlLoader(), configAttributes);
|
||||
} else if (configAttributes.hasClasses()) {
|
||||
}
|
||||
else if (configAttributes.hasClasses()) {
|
||||
delegateProcessing(getAnnotationConfigLoader(), configAttributes);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Else attempt to detect defaults...
|
||||
|
||||
// Let the XML loader process the configuration.
|
||||
@@ -198,15 +200,15 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
// throw an exception.
|
||||
if (!configAttributes.hasResources() && ObjectUtils.isEmpty(configAttributes.getInitializers())) {
|
||||
throw new IllegalStateException(String.format(
|
||||
"Neither %s nor %s was able to detect defaults, and no ApplicationContextInitializers "
|
||||
+ "were declared for context configuration %s", name(getXmlLoader()),
|
||||
"Neither %s nor %s was able to detect defaults, and no ApplicationContextInitializers " +
|
||||
"were declared for context configuration %s", name(getXmlLoader()),
|
||||
name(getAnnotationConfigLoader()), configAttributes));
|
||||
}
|
||||
|
||||
if (configAttributes.hasLocations() && configAttributes.hasClasses()) {
|
||||
String message = String.format(
|
||||
"Configuration error: both default locations AND default configuration classes "
|
||||
+ "were detected for context configuration %s; configure one or the other, but not both.",
|
||||
"Configuration error: both default locations AND default configuration classes " +
|
||||
"were detected for context configuration %s; configure one or the other, but not both.",
|
||||
configAttributes);
|
||||
logger.error(message);
|
||||
throw new IllegalStateException(message);
|
||||
@@ -217,12 +219,10 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
/**
|
||||
* Delegates to an appropriate candidate {@code SmartContextLoader} to load
|
||||
* an {@link ApplicationContext}.
|
||||
*
|
||||
* <p>Delegation is based on explicit knowledge of the implementations of the
|
||||
* default loaders for {@link #getXmlLoader() XML configuration files} and
|
||||
* {@link #getAnnotationConfigLoader() annotated classes}. Specifically, the
|
||||
* delegation algorithm is as follows:
|
||||
*
|
||||
* <ul>
|
||||
* <li>If the resource locations in the supplied {@code MergedContextConfiguration}
|
||||
* are not empty and the annotated classes are empty,
|
||||
@@ -231,7 +231,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
* are not empty and the resource locations are empty,
|
||||
* the annotation-based loader will load the {@code ApplicationContext}.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param mergedConfig the merged context configuration to use to load the application context
|
||||
* @throws IllegalArgumentException if the supplied merged configuration is {@code null}
|
||||
* @throws IllegalStateException if neither candidate loader is capable of loading an
|
||||
@@ -240,7 +239,6 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
@Override
|
||||
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
|
||||
Assert.notNull(mergedConfig, "mergedConfig must not be null");
|
||||
|
||||
List<SmartContextLoader> candidates = Arrays.asList(getXmlLoader(), getAnnotationConfigLoader());
|
||||
|
||||
for (SmartContextLoader loader : candidates) {
|
||||
@@ -262,6 +260,7 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
name(getAnnotationConfigLoader()), mergedConfig));
|
||||
}
|
||||
|
||||
|
||||
// --- ContextLoader -------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -272,8 +271,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
*/
|
||||
@Override
|
||||
public final String[] processLocations(Class<?> clazz, String... locations) {
|
||||
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. "
|
||||
+ "Call processContextConfiguration(ContextConfigurationAttributes) instead.");
|
||||
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " +
|
||||
"Call processContextConfiguration(ContextConfigurationAttributes) instead.");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -284,8 +283,8 @@ public abstract class AbstractDelegatingSmartContextLoader implements SmartConte
|
||||
*/
|
||||
@Override
|
||||
public final ApplicationContext loadContext(String... locations) throws Exception {
|
||||
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. "
|
||||
+ "Call loadContext(MergedContextConfiguration) instead.");
|
||||
throw new UnsupportedOperationException("DelegatingSmartContextLoaders do not support the ContextLoader SPI. " +
|
||||
"Call loadContext(MergedContextConfiguration) instead.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.SmartContextLoader;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -38,45 +39,12 @@ public abstract class AnnotationConfigContextLoaderUtils {
|
||||
private static final Log logger = LogFactory.getLog(AnnotationConfigContextLoaderUtils.class);
|
||||
|
||||
|
||||
private AnnotationConfigContextLoaderUtils() {
|
||||
/* no-op */
|
||||
}
|
||||
|
||||
private static boolean isStaticNonPrivateAndNonFinal(Class<?> clazz) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
int modifiers = clazz.getModifiers();
|
||||
return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the supplied {@link Class} meets the criteria for being
|
||||
* considered a <em>default configuration class</em> candidate.
|
||||
*
|
||||
* <p>Specifically, such candidates:
|
||||
*
|
||||
* <ul>
|
||||
* <li>must not be {@code null}</li>
|
||||
* <li>must not be {@code private}</li>
|
||||
* <li>must not be {@code final}</li>
|
||||
* <li>must be {@code static}</li>
|
||||
* <li>must be annotated with {@code @Configuration}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param clazz the class to check
|
||||
* @return {@code true} if the supplied class meets the candidate criteria
|
||||
*/
|
||||
private static boolean isDefaultConfigurationClassCandidate(Class<?> clazz) {
|
||||
return clazz != null && isStaticNonPrivateAndNonFinal(clazz) && clazz.isAnnotationPresent(Configuration.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect the default configuration classes for the supplied test class.
|
||||
*
|
||||
* <p>The returned class array will contain all static inner classes of
|
||||
* the supplied class that meet the requirements for {@code @Configuration}
|
||||
* class implementations as specified in the documentation for
|
||||
* {@link Configuration @Configuration}.
|
||||
*
|
||||
* <p>The implementation of this method adheres to the contract defined in the
|
||||
* {@link org.springframework.test.context.SmartContextLoader SmartContextLoader}
|
||||
* SPI. Specifically, this method uses introspection to detect default
|
||||
@@ -96,7 +64,8 @@ public abstract class AnnotationConfigContextLoaderUtils {
|
||||
for (Class<?> candidate : declaringClass.getDeclaredClasses()) {
|
||||
if (isDefaultConfigurationClassCandidate(candidate)) {
|
||||
configClasses.add(candidate);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format(
|
||||
"Ignoring class [%s]; it must be static, non-private, non-final, and annotated "
|
||||
@@ -117,4 +86,28 @@ public abstract class AnnotationConfigContextLoaderUtils {
|
||||
return configClasses.toArray(new Class<?>[configClasses.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the supplied {@link Class} meets the criteria for being
|
||||
* considered a <em>default configuration class</em> candidate.
|
||||
* <p>Specifically, such candidates:
|
||||
* <ul>
|
||||
* <li>must not be {@code null}</li>
|
||||
* <li>must not be {@code private}</li>
|
||||
* <li>must not be {@code final}</li>
|
||||
* <li>must be {@code static}</li>
|
||||
* <li>must be annotated with {@code @Configuration}</li>
|
||||
* </ul>
|
||||
* @param clazz the class to check
|
||||
* @return {@code true} if the supplied class meets the candidate criteria
|
||||
*/
|
||||
private static boolean isDefaultConfigurationClassCandidate(Class<?> clazz) {
|
||||
return (clazz != null && isStaticNonPrivateAndNonFinal(clazz) && clazz.isAnnotationPresent(Configuration.class));
|
||||
}
|
||||
|
||||
private static boolean isStaticNonPrivateAndNonFinal(Class<?> clazz) {
|
||||
Assert.notNull(clazz, "Class must not be null");
|
||||
int modifiers = clazz.getModifiers();
|
||||
return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>
|
||||
public final <T extends B> T addFilters(Filter... filters) {
|
||||
Assert.notNull(filters, "filters cannot be null");
|
||||
|
||||
for(Filter f : filters) {
|
||||
for (Filter f : filters) {
|
||||
Assert.notNull(f, "filters cannot contain null values");
|
||||
this.filters.add(f);
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public abstract class AbstractMockMvcBuilder<B extends AbstractMockMvcBuilder<B>
|
||||
Assert.notNull(filter, "filter cannot be null");
|
||||
Assert.notNull(urlPatterns, "urlPatterns cannot be null");
|
||||
|
||||
if(urlPatterns.length > 0) {
|
||||
if (urlPatterns.length > 0) {
|
||||
filter = new PatternMappingFilterProxy(filter, urlPatterns);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
@@ -10,12 +10,12 @@
|
||||
* 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.test.web.servlet.setup;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
@@ -61,29 +61,32 @@ final class PatternMappingFilterProxy implements Filter {
|
||||
public PatternMappingFilterProxy(Filter delegate, String... urlPatterns) {
|
||||
Assert.notNull(delegate, "A delegate Filter is required");
|
||||
this.delegate = delegate;
|
||||
for(String urlPattern : urlPatterns) {
|
||||
for (String urlPattern : urlPatterns) {
|
||||
addUrlPattern(urlPattern);
|
||||
}
|
||||
}
|
||||
|
||||
private void addUrlPattern(String urlPattern) {
|
||||
Assert.notNull(urlPattern, "Found null URL Pattern");
|
||||
if(urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) {
|
||||
if (urlPattern.startsWith(EXTENSION_MAPPING_PATTERN)) {
|
||||
this.endsWithMatches.add(urlPattern.substring(1, urlPattern.length()));
|
||||
} else if(urlPattern.equals(PATH_MAPPING_PATTERN)) {
|
||||
}
|
||||
else if (urlPattern.equals(PATH_MAPPING_PATTERN)) {
|
||||
this.startsWithMatches.add("");
|
||||
}
|
||||
else if (urlPattern.endsWith(PATH_MAPPING_PATTERN)) {
|
||||
this.startsWithMatches.add(urlPattern.substring(0, urlPattern.length() - 1));
|
||||
this.exactMatches.add(urlPattern.substring(0, urlPattern.length() - 2));
|
||||
} else {
|
||||
if("".equals(urlPattern)) {
|
||||
}
|
||||
else {
|
||||
if ("".equals(urlPattern)) {
|
||||
urlPattern = "/";
|
||||
}
|
||||
this.exactMatches.add(urlPattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
|
||||
throws IOException, ServletException {
|
||||
@@ -91,29 +94,30 @@ final class PatternMappingFilterProxy implements Filter {
|
||||
HttpServletRequest httpRequest = (HttpServletRequest) request;
|
||||
String requestPath = urlPathHelper.getPathWithinApplication(httpRequest);
|
||||
|
||||
if(matches(requestPath)) {
|
||||
if (matches(requestPath)) {
|
||||
this.delegate.doFilter(request, response, filterChain);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean matches(String requestPath) {
|
||||
for(String pattern : this.exactMatches) {
|
||||
if(pattern.equals(requestPath)) {
|
||||
for (String pattern : this.exactMatches) {
|
||||
if (pattern.equals(requestPath)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(!requestPath.startsWith("/")) {
|
||||
if (!requestPath.startsWith("/")) {
|
||||
return false;
|
||||
}
|
||||
for(String pattern : this.endsWithMatches) {
|
||||
if(requestPath.endsWith(pattern)) {
|
||||
for (String pattern : this.endsWithMatches) {
|
||||
if (requestPath.endsWith(pattern)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for(String pattern : this.startsWithMatches) {
|
||||
if(requestPath.startsWith(pattern)) {
|
||||
for (String pattern : this.startsWithMatches) {
|
||||
if (requestPath.startsWith(pattern)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ final class SimpleStreamingClientHttpRequest extends AbstractClientHttpRequest {
|
||||
@Override
|
||||
protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException {
|
||||
if (this.body == null) {
|
||||
if(this.outputStreaming) {
|
||||
if (this.outputStreaming) {
|
||||
int contentLength = (int) headers.getContentLength();
|
||||
if (contentLength >= 0) {
|
||||
this.connection.setFixedLengthStreamingMode(contentLength);
|
||||
|
||||
@@ -138,7 +138,7 @@ public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter<R
|
||||
}
|
||||
|
||||
public static MediaType getMediaType(Resource resource) {
|
||||
if(resource.getFilename() == null) {
|
||||
if (resource.getFilename() == null) {
|
||||
return null;
|
||||
}
|
||||
String mediaType = fileTypeMap.getContentType(resource.getFilename());
|
||||
|
||||
@@ -65,12 +65,8 @@ public abstract class AbstractWireFeedHttpMessageConverter<T extends WireFeed> e
|
||||
|
||||
WireFeedInput feedInput = new WireFeedInput();
|
||||
MediaType contentType = inputMessage.getHeaders().getContentType();
|
||||
Charset charset;
|
||||
if (contentType != null && contentType.getCharSet() != null) {
|
||||
charset = contentType.getCharSet();
|
||||
} else {
|
||||
charset = DEFAULT_CHARSET;
|
||||
}
|
||||
Charset charset =
|
||||
(contentType != null && contentType.getCharSet() != null? contentType.getCharSet() : DEFAULT_CHARSET);
|
||||
try {
|
||||
Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
|
||||
return (T) feedInput.build(reader);
|
||||
|
||||
@@ -201,7 +201,8 @@ public class ContentNegotiationManagerFactoryBean
|
||||
PathExtensionContentNegotiationStrategy strategy;
|
||||
if (this.servletContext != null) {
|
||||
strategy = new ServletPathExtensionContentNegotiationStrategy(this.servletContext, this.mediaTypes);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
strategy = new PathExtensionContentNegotiationStrategy(this.mediaTypes);
|
||||
}
|
||||
strategy.setIgnoreUnknownExtensions(this.ignoreUnknownPathExtensions);
|
||||
|
||||
@@ -116,7 +116,7 @@ public class WebRequestDataBinder extends WebDataBinder {
|
||||
public void bind(WebRequest request) {
|
||||
MutablePropertyValues mpvs = new MutablePropertyValues(request.getParameterMap());
|
||||
|
||||
if(isMultipartRequest(request) && (request instanceof NativeWebRequest)) {
|
||||
if (isMultipartRequest(request) && (request instanceof NativeWebRequest)) {
|
||||
MultipartRequest multipartRequest = ((NativeWebRequest) request).getNativeRequest(MultipartRequest.class);
|
||||
if (multipartRequest != null) {
|
||||
bindMultipart(multipartRequest.getMultiFileMap(), mpvs);
|
||||
|
||||
@@ -799,7 +799,8 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
public ResponseEntityResponseExtractor(Type responseType) {
|
||||
if (responseType != null && !Void.class.equals(responseType)) {
|
||||
this.delegate = new HttpMessageConverterExtractor<T>(responseType, getMessageConverters(), logger);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.delegate = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ServletContextAwareProcessor implements BeanPostProcessor {
|
||||
* has been registered.
|
||||
*/
|
||||
protected ServletContext getServletContext() {
|
||||
if(this.servletContext == null && getServletConfig() != null) {
|
||||
if (this.servletContext == null && getServletConfig() != null) {
|
||||
return getServletConfig().getServletContext();
|
||||
}
|
||||
return this.servletContext;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -19,7 +19,6 @@ package org.springframework.web.filter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
@@ -28,85 +27,91 @@ import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
/**
|
||||
* A generic composite servlet {@link Filter} that just delegates its behaviour to a chain (list) of user supplied
|
||||
* filters, achieving the functionality of a {@link FilterChain}, but conveniently using only {@link Filter} instances.
|
||||
* This is useful for filters that require dependency injection, and can therefore be set up in a Spring application
|
||||
* context. Typically this composite would be used in conjunction with {@link DelegatingFilterProxy}, so that it can be
|
||||
* declared in Spring but applied to a servlet context.
|
||||
* A generic composite servlet {@link Filter} that just delegates its behavior
|
||||
* to a chain (list) of user-supplied filters, achieving the functionality of a
|
||||
* {@link FilterChain}, but conveniently using only {@link Filter} instances.
|
||||
*
|
||||
* @since 3.1
|
||||
* <p>This is useful for filters that require dependency injection, and can
|
||||
* therefore be set up in a Spring application context. Typically, this
|
||||
* composite would be used in conjunction with {@link DelegatingFilterProxy},
|
||||
* so that it can be declared in Spring but applied to a servlet context.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
* @since 3.1
|
||||
*/
|
||||
public class CompositeFilter implements Filter {
|
||||
|
||||
private List<? extends Filter> filters = new ArrayList<Filter>();
|
||||
|
||||
|
||||
public void setFilters(List<? extends Filter> filters) {
|
||||
this.filters = new ArrayList<Filter>(filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.
|
||||
*
|
||||
* @see Filter#init(FilterConfig)
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
for (int i = filters.size(); i-- > 0;) {
|
||||
Filter filter = filters.get(i);
|
||||
filter.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all the filters, calling each one's init method in turn in the order supplied.
|
||||
*
|
||||
* @see Filter#init(FilterConfig)
|
||||
*/
|
||||
@Override
|
||||
public void init(FilterConfig config) throws ServletException {
|
||||
for (Filter filter : filters) {
|
||||
for (Filter filter : this.filters) {
|
||||
filter.init(config);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forms a temporary chain from the list of delegate filters supplied ({@link #setFilters(List)}) and executes them
|
||||
* in order. Each filter delegates to the next one in the list, achieving the normal behaviour of a
|
||||
* {@link FilterChain}, despite the fact that this is a {@link Filter}.
|
||||
*
|
||||
* Forms a temporary chain from the list of delegate filters supplied ({@link #setFilters})
|
||||
* and executes them in order. Each filter delegates to the next one in the list, achieving
|
||||
* the normal behavior of a {@link FilterChain}, despite the fact that this is a {@link Filter}.
|
||||
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
|
||||
*/
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
|
||||
ServletException {
|
||||
new VirtualFilterChain(chain, filters).doFilter(request, response);
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||
throws IOException, ServletException {
|
||||
|
||||
new VirtualFilterChain(chain, this.filters).doFilter(request, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up all the filters supplied, calling each one's destroy method in turn, but in reverse order.
|
||||
* @see Filter#init(FilterConfig)
|
||||
*/
|
||||
@Override
|
||||
public void destroy() {
|
||||
for (int i = this.filters.size(); i-- > 0;) {
|
||||
Filter filter = this.filters.get(i);
|
||||
filter.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class VirtualFilterChain implements FilterChain {
|
||||
|
||||
private final FilterChain originalChain;
|
||||
|
||||
private final List<? extends Filter> additionalFilters;
|
||||
|
||||
private int currentPosition = 0;
|
||||
|
||||
private VirtualFilterChain(FilterChain chain, List<? extends Filter> additionalFilters) {
|
||||
public VirtualFilterChain(FilterChain chain, List<? extends Filter> additionalFilters) {
|
||||
this.originalChain = chain;
|
||||
this.additionalFilters = additionalFilters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException,
|
||||
ServletException {
|
||||
if (currentPosition == additionalFilters.size()) {
|
||||
originalChain.doFilter(request, response);
|
||||
} else {
|
||||
currentPosition++;
|
||||
Filter nextFilter = additionalFilters.get(currentPosition - 1);
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response)
|
||||
throws IOException, ServletException {
|
||||
|
||||
if (this.currentPosition == this.additionalFilters.size()) {
|
||||
this.originalChain.doFilter(request, response);
|
||||
}
|
||||
else {
|
||||
this.currentPosition++;
|
||||
Filter nextFilter = this.additionalFilters.get(this.currentPosition - 1);
|
||||
nextFilter.doFilter(request, response, this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -143,23 +143,23 @@ public class ControllerAdviceBean implements Ordered {
|
||||
* @since 4.0
|
||||
*/
|
||||
public boolean isApplicableToBeanType(Class<?> beanType) {
|
||||
if(!hasSelectors()) {
|
||||
if (!hasSelectors()) {
|
||||
return true;
|
||||
}
|
||||
else if (beanType != null) {
|
||||
for (Class<?> clazz : this.assignableTypes) {
|
||||
if(ClassUtils.isAssignable(clazz, beanType)) {
|
||||
if (ClassUtils.isAssignable(clazz, beanType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
for (Class<? extends Annotation> annotationClass : this.annotations) {
|
||||
if(AnnotationUtils.findAnnotation(beanType, annotationClass) != null) {
|
||||
if (AnnotationUtils.findAnnotation(beanType, annotationClass) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
String packageName = beanType.getPackage().getName();
|
||||
for (Package basePackage : this.basePackages) {
|
||||
if(packageName.startsWith(basePackage.getName())) {
|
||||
if (packageName.startsWith(basePackage.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ public class ControllerAdviceBean implements Ordered {
|
||||
for (String pkgName : basePackageNames) {
|
||||
if (StringUtils.hasText(pkgName)) {
|
||||
Package pkg = Package.getPackage(pkgName);
|
||||
if(pkg != null) {
|
||||
if (pkg != null) {
|
||||
basePackages.add(pkg);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -148,7 +148,7 @@ public class ExceptionHandlerMethodResolver {
|
||||
*/
|
||||
private Method getMappedMethod(Class<? extends Exception> exceptionType) {
|
||||
List<Class<? extends Throwable>> matches = new ArrayList<Class<? extends Throwable>>();
|
||||
for(Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
|
||||
for (Class<? extends Throwable> mappedException : this.mappedMethods.keySet()) {
|
||||
if (mappedException.isAssignableFrom(exceptionType)) {
|
||||
matches.add(mappedException);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ public class RequestParamMethodArgumentResolver extends AbstractNamedValueMethod
|
||||
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
|
||||
arg = multipartRequest.getFiles(name);
|
||||
}
|
||||
else if(isMultipartFileArray(parameter)) {
|
||||
else if (isMultipartFileArray(parameter)) {
|
||||
assertIsMultipartRequest(servletRequest);
|
||||
Assert.notNull(multipartRequest, "Expected MultipartHttpServletRequest: is a MultipartResolver configured?");
|
||||
arg = multipartRequest.getFiles(name).toArray(new MultipartFile[0]);
|
||||
|
||||
@@ -396,7 +396,7 @@ final class HierarchicalUriComponents extends UriComponents {
|
||||
String path = getPath();
|
||||
if (StringUtils.hasLength(path) && path.charAt(0) != PATH_DELIMITER) {
|
||||
// Only prefix the path delimiter if something exists before it
|
||||
if(getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) {
|
||||
if (getScheme() != null || getUserInfo() != null || getHost() != null || getPort() != -1) {
|
||||
path = PATH_DELIMITER + path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
private void configurePathMatchingProperties(RootBeanDefinition handlerMappingDef,
|
||||
Element element, ParserContext parserContext) {
|
||||
Element pathMatchingElement = DomUtils.getChildElementByTagName(element, "path-matching");
|
||||
if(pathMatchingElement != null) {
|
||||
if (pathMatchingElement != null) {
|
||||
Object source = parserContext.extractSource(element);
|
||||
if (pathMatchingElement.hasAttribute("suffix-pattern")) {
|
||||
Boolean useSuffixPatternMatch = Boolean.valueOf(pathMatchingElement.getAttribute("suffix-pattern"));
|
||||
@@ -568,7 +568,7 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
|
||||
if (StringUtils.hasText("bean")) {
|
||||
reference = new RuntimeBeanReference(refElement.getAttribute("bean"),false);
|
||||
list.add(reference);
|
||||
}else if(StringUtils.hasText("parent")){
|
||||
}else if (StringUtils.hasText("parent")){
|
||||
reference = new RuntimeBeanReference(refElement.getAttribute("parent"),true);
|
||||
list.add(reference);
|
||||
}else{
|
||||
|
||||
@@ -63,8 +63,8 @@ abstract class MvcNamespaceUtils {
|
||||
* @return a RuntimeBeanReference to this {@link UrlPathHelper} instance
|
||||
*/
|
||||
public static RuntimeBeanReference registerUrlPathHelper(RuntimeBeanReference urlPathHelperRef, ParserContext parserContext, Object source) {
|
||||
if(urlPathHelperRef != null) {
|
||||
if(parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) {
|
||||
if (urlPathHelperRef != null) {
|
||||
if (parserContext.getRegistry().isAlias(URL_PATH_HELPER_BEAN_NAME)) {
|
||||
parserContext.getRegistry().removeAlias(URL_PATH_HELPER_BEAN_NAME);
|
||||
}
|
||||
parserContext.getRegistry().registerAlias(urlPathHelperRef.getBeanName(), URL_PATH_HELPER_BEAN_NAME);
|
||||
@@ -86,8 +86,8 @@ abstract class MvcNamespaceUtils {
|
||||
* @return a RuntimeBeanReference to this {@link PathMatcher} instance
|
||||
*/
|
||||
public static RuntimeBeanReference registerPathMatcher(RuntimeBeanReference pathMatcherRef, ParserContext parserContext, Object source) {
|
||||
if(pathMatcherRef != null) {
|
||||
if(parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
|
||||
if (pathMatcherRef != null) {
|
||||
if (parserContext.getRegistry().isAlias(PATH_MATCHER_BEAN_NAME)) {
|
||||
parserContext.getRegistry().removeAlias(PATH_MATCHER_BEAN_NAME);
|
||||
}
|
||||
parserContext.getRegistry().registerAlias(pathMatcherRef.getBeanName(), PATH_MATCHER_BEAN_NAME);
|
||||
|
||||
@@ -110,12 +110,12 @@ class ResourcesBeanDefinitionParser implements BeanDefinitionParser {
|
||||
}
|
||||
|
||||
ManagedList<? super Object> resourceResolvers = parseResourceResolvers(parserContext, element, source);
|
||||
if(!resourceResolvers.isEmpty()) {
|
||||
if (!resourceResolvers.isEmpty()) {
|
||||
resourceHandlerDef.getPropertyValues().add("resourceResolvers", resourceResolvers);
|
||||
}
|
||||
|
||||
ManagedList<? super Object> resourceTransformers = parseResourceTransformers(parserContext, element, source);
|
||||
if(!resourceTransformers.isEmpty()) {
|
||||
if (!resourceTransformers.isEmpty()) {
|
||||
resourceHandlerDef.getPropertyValues().add("resourceTransformers", resourceTransformers);
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ public class ViewResolversBeanDefinitionParser implements BeanDefinitionParser {
|
||||
List<Element> elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"});
|
||||
if (!elements.isEmpty()) {
|
||||
ManagedList<Object> list = new ManagedList<Object>();
|
||||
for(Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
|
||||
for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
|
||||
list.add(context.getDelegate().parsePropertySubElement(element, null));
|
||||
}
|
||||
values.add("defaultViews", list);
|
||||
|
||||
@@ -218,19 +218,19 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager());
|
||||
|
||||
PathMatchConfigurer configurer = getPathMatchConfigurer();
|
||||
if(configurer.isUseSuffixPatternMatch() != null) {
|
||||
if (configurer.isUseSuffixPatternMatch() != null) {
|
||||
handlerMapping.setUseSuffixPatternMatch(configurer.isUseSuffixPatternMatch());
|
||||
}
|
||||
if(configurer.isUseRegisteredSuffixPatternMatch() != null) {
|
||||
if (configurer.isUseRegisteredSuffixPatternMatch() != null) {
|
||||
handlerMapping.setUseRegisteredSuffixPatternMatch(configurer.isUseRegisteredSuffixPatternMatch());
|
||||
}
|
||||
if(configurer.isUseTrailingSlashMatch() != null) {
|
||||
if (configurer.isUseTrailingSlashMatch() != null) {
|
||||
handlerMapping.setUseTrailingSlashMatch(configurer.isUseTrailingSlashMatch());
|
||||
}
|
||||
if(configurer.getPathMatcher() != null) {
|
||||
if (configurer.getPathMatcher() != null) {
|
||||
handlerMapping.setPathMatcher(configurer.getPathMatcher());
|
||||
}
|
||||
if(configurer.getUrlPathHelper() != null) {
|
||||
if (configurer.getUrlPathHelper() != null) {
|
||||
handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper());
|
||||
}
|
||||
return handlerMapping;
|
||||
@@ -534,7 +534,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
*/
|
||||
@Bean
|
||||
public PathMatcher mvcPathMatcher() {
|
||||
if(getPathMatchConfigurer().getPathMatcher() != null) {
|
||||
if (getPathMatchConfigurer().getPathMatcher() != null) {
|
||||
return getPathMatchConfigurer().getPathMatcher();
|
||||
}
|
||||
else {
|
||||
@@ -551,7 +551,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
*/
|
||||
@Bean
|
||||
public UrlPathHelper mvcUrlPathHelper() {
|
||||
if(getPathMatchConfigurer().getUrlPathHelper() != null) {
|
||||
if (getPathMatchConfigurer().getUrlPathHelper() != null) {
|
||||
return getPathMatchConfigurer().getUrlPathHelper();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -103,7 +103,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
|
||||
for (String header : headers) {
|
||||
HeaderExpression expr = new HeaderExpression(header);
|
||||
if ("Accept".equalsIgnoreCase(expr.name)) {
|
||||
for( MediaType mediaType : MediaType.parseMediaTypes(expr.value)) {
|
||||
for ( MediaType mediaType : MediaType.parseMediaTypes(expr.value)) {
|
||||
result.add(new ProduceMediaTypeExpression(mediaType, expr.isNegated));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public final class RequestMethodsRequestCondition extends AbstractRequestConditi
|
||||
return this;
|
||||
}
|
||||
RequestMethod incomingRequestMethod = getRequestMethod(request);
|
||||
if(incomingRequestMethod != null) {
|
||||
if (incomingRequestMethod != null) {
|
||||
for (RequestMethod method : this.methods) {
|
||||
if (method.equals(incomingRequestMethod)) {
|
||||
return new RequestMethodsRequestCondition(method);
|
||||
|
||||
@@ -406,7 +406,7 @@ public class ExceptionHandlerExceptionResolver extends AbstractHandlerMethodExce
|
||||
}
|
||||
}
|
||||
for (Entry<ControllerAdviceBean, ExceptionHandlerMethodResolver> entry : this.exceptionHandlerAdviceCache.entrySet()) {
|
||||
if(entry.getKey().isApplicableToBeanType(handlerType)) {
|
||||
if (entry.getKey().isApplicableToBeanType(handlerType)) {
|
||||
ExceptionHandlerMethodResolver resolver = entry.getValue();
|
||||
Method method = resolver.resolveMethod(exception);
|
||||
if (method != null) {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.servlet.resource;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -69,6 +70,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
|
||||
|
||||
private final String fileExtension;
|
||||
|
||||
|
||||
/**
|
||||
* Create an AppCacheResourceTransformer that transforms files with extension ".manifest"
|
||||
*/
|
||||
@@ -90,6 +92,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
|
||||
this.sectionTransformers.put("CACHE:", new CacheSection());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException {
|
||||
resource = transformerChain.transform(request, resource);
|
||||
@@ -102,7 +105,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
|
||||
byte[] bytes = FileCopyUtils.copyToByteArray(resource.getInputStream());
|
||||
String content = new String(bytes, DEFAULT_CHARSET);
|
||||
|
||||
if(!content.startsWith(MANIFEST_HEADER)) {
|
||||
if (!content.startsWith(MANIFEST_HEADER)) {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("AppCache manifest does not start with 'CACHE MANIFEST', skipping: " + resource);
|
||||
}
|
||||
@@ -118,17 +121,14 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
|
||||
|
||||
Scanner scanner = new Scanner(content);
|
||||
SectionTransformer currentTransformer = this.sectionTransformers.get(MANIFEST_HEADER);
|
||||
while(scanner.hasNextLine()) {
|
||||
while (scanner.hasNextLine()) {
|
||||
String line = scanner.nextLine();
|
||||
|
||||
if(this.sectionTransformers.containsKey(line.trim())) {
|
||||
if (this.sectionTransformers.containsKey(line.trim())) {
|
||||
currentTransformer = this.sectionTransformers.get(line.trim());
|
||||
contentWriter.write(line + "\n");
|
||||
hashBuilder.appendString(line);
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
contentWriter.write(currentTransformer.transform(line, hashBuilder, resource, transformerChain) + "\n");
|
||||
}
|
||||
}
|
||||
@@ -147,23 +147,25 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
|
||||
|
||||
/**
|
||||
* Transforms a line in a section of the manifest
|
||||
*
|
||||
* The actual transformation depends on the chose transformation strategy
|
||||
* <p>The actual transformation depends on the chose transformation strategy
|
||||
* for the current manifest section (CACHE, NETWORK, FALLBACK, etc).
|
||||
*/
|
||||
String transform(String line, HashBuilder builder, Resource resource,
|
||||
ResourceTransformerChain transformerChain) throws IOException;
|
||||
}
|
||||
|
||||
|
||||
private static class NoOpSection implements SectionTransformer {
|
||||
|
||||
public String transform(String line, HashBuilder builder,
|
||||
Resource resource, ResourceTransformerChain transformerChain) throws IOException {
|
||||
public String transform(String line, HashBuilder builder, Resource resource, ResourceTransformerChain transformerChain)
|
||||
throws IOException {
|
||||
|
||||
builder.appendString(line);
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class CacheSection implements SectionTransformer {
|
||||
|
||||
private final String COMMENT_DIRECTIVE = "#";
|
||||
@@ -172,30 +174,26 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
|
||||
public String transform(String line, HashBuilder builder,
|
||||
Resource resource, ResourceTransformerChain transformerChain) throws IOException {
|
||||
|
||||
if(isLink(line) && !hasScheme(line)) {
|
||||
|
||||
if (isLink(line) && !hasScheme(line)) {
|
||||
Resource appCacheResource = transformerChain.getResolverChain().resolveResource(null, line, Arrays.asList(resource));
|
||||
String path = transformerChain.getResolverChain().resolveUrlPath(line, Arrays.asList(resource));
|
||||
|
||||
builder.appendResource(appCacheResource);
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Link modified: " + path + " (original: " + line + ")");
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
builder.appendString(line);
|
||||
return line;
|
||||
}
|
||||
|
||||
private boolean hasScheme(String link) {
|
||||
int schemeIndex = link.indexOf(":");
|
||||
return link.startsWith("//") || (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/"));
|
||||
return (link.startsWith("//") || (schemeIndex > 0 && !link.substring(0, schemeIndex).contains("/")));
|
||||
}
|
||||
|
||||
private boolean isLink(String line) {
|
||||
return StringUtils.hasText(line) && !line.startsWith(COMMENT_DIRECTIVE);
|
||||
return (StringUtils.hasText(line) && !line.startsWith(COMMENT_DIRECTIVE));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +202,7 @@ public class AppCacheManifestTransfomer implements ResourceTransformer {
|
||||
|
||||
private final ByteArrayOutputStream baos;
|
||||
|
||||
private HashBuilder(int initialSize) {
|
||||
public HashBuilder(int initialSize) {
|
||||
this.baos = new ByteArrayOutputStream(initialSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class CssLinkResourceTransformer implements ResourceTransformer {
|
||||
writer.write(content.substring(index, info.getStart()));
|
||||
String link = content.substring(info.getStart(), info.getEnd());
|
||||
String newLink = null;
|
||||
if(!hasScheme(link)) {
|
||||
if (!hasScheme(link)) {
|
||||
newLink = transformerChain.getResolverChain().resolveUrlPath(link, Arrays.asList(resource));
|
||||
}
|
||||
if (logger.isTraceEnabled()) {
|
||||
@@ -159,7 +159,8 @@ public class CssLinkResourceTransformer implements ResourceTransformer {
|
||||
index = extractLink(index, content, linkInfos);
|
||||
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
while (true);
|
||||
}
|
||||
|
||||
private int skipWhitespace(String content, int index) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class VersionResourceResolver extends AbstractResourceResolver {
|
||||
}
|
||||
|
||||
VersionStrategy versionStrategy = findStrategy(requestPath);
|
||||
if(versionStrategy == null) {
|
||||
if (versionStrategy == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class VersionResourceResolver extends AbstractResourceResolver {
|
||||
String baseUrl = chain.resolveUrlPath(resourceUrlPath, locations);
|
||||
if (StringUtils.hasText(baseUrl)) {
|
||||
VersionStrategy versionStrategy = findStrategy(resourceUrlPath);
|
||||
if(versionStrategy == null) {
|
||||
if (versionStrategy == null) {
|
||||
return null;
|
||||
}
|
||||
return versionStrategy.addVersionToUrl(baseUrl, locations, chain);
|
||||
@@ -129,12 +129,12 @@ public class VersionResourceResolver extends AbstractResourceResolver {
|
||||
protected VersionStrategy findStrategy(String requestPath) {
|
||||
String path = "/".concat(requestPath);
|
||||
List<String> matchingPatterns = new ArrayList<String>();
|
||||
for(String pattern : this.versionStrategyMap.keySet()) {
|
||||
if(this.pathMatcher.match(pattern, path)) {
|
||||
for (String pattern : this.versionStrategyMap.keySet()) {
|
||||
if (this.pathMatcher.match(pattern, path)) {
|
||||
matchingPatterns.add(pattern);
|
||||
}
|
||||
}
|
||||
if(!matchingPatterns.isEmpty()) {
|
||||
if (!matchingPatterns.isEmpty()) {
|
||||
Comparator<String> comparator = this.pathMatcher.getPatternComparator(path);
|
||||
Collections.sort(matchingPatterns, comparator);
|
||||
return this.versionStrategyMap.get(matchingPatterns.get(0));
|
||||
|
||||
@@ -228,7 +228,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||
if (this.code != null || this.text != null) {
|
||||
// We have a code or default text that we need to resolve.
|
||||
Object[] argumentsArray = resolveArguments(this.arguments);
|
||||
if(!this.nestedArguments.isEmpty()) {
|
||||
if (!this.nestedArguments.isEmpty()) {
|
||||
argumentsArray = appendArguments(argumentsArray,
|
||||
this.nestedArguments.toArray());
|
||||
}
|
||||
@@ -250,7 +250,7 @@ public class MessageTag extends HtmlEscapingAwareTag implements ArgumentAware {
|
||||
}
|
||||
|
||||
private Object[] appendArguments(Object[] sourceArguments, Object[] additionalArguments) {
|
||||
if(ObjectUtils.isEmpty(sourceArguments)) {
|
||||
if (ObjectUtils.isEmpty(sourceArguments)) {
|
||||
return additionalArguments;
|
||||
}
|
||||
Object[] arguments = new Object[sourceArguments.length + additionalArguments.length];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -137,7 +137,8 @@ public class OptionsTag extends AbstractHtmlElementTag {
|
||||
Object itemsObject = null;
|
||||
if (items != null) {
|
||||
itemsObject = (items instanceof String ? evaluate("items", items) : items);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Class<?> selectTagBoundType = selectTag.getBindStatus().getValueType();
|
||||
if (selectTagBoundType != null && selectTagBoundType.isEnum()) {
|
||||
itemsObject = selectTagBoundType.getEnumConstants();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,19 +35,20 @@ public class PasswordInputTag extends InputTag {
|
||||
|
||||
/**
|
||||
* Is the password value to be rendered?
|
||||
* @return {@code true} if the password value to be rendered.
|
||||
* @param showPassword {@code true} if the password value is to be rendered
|
||||
*/
|
||||
public void setShowPassword(boolean showPassword) {
|
||||
this.showPassword = showPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the password value to be rendered?
|
||||
* @return {@code true} if the password value to be rendered
|
||||
*/
|
||||
public boolean isShowPassword() {
|
||||
return this.showPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the password value to be rendered?
|
||||
* @param showPassword {@code true} if the password value is to be rendered.
|
||||
*/
|
||||
public void setShowPassword(boolean showPassword) {
|
||||
this.showPassword = showPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flags "type" as an illegal dynamic attribute.
|
||||
@@ -75,8 +76,10 @@ public class PasswordInputTag extends InputTag {
|
||||
protected void writeValue(TagWriter tagWriter) throws JspException {
|
||||
if (this.showPassword) {
|
||||
super.writeValue(tagWriter);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
tagWriter.writeAttribute("value", processFieldValue(getName(), "", getType()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ public class MappingJackson2JsonView extends AbstractView {
|
||||
Class<?> serializationView = (Class<?>) model.get(JsonView.class.getName());
|
||||
String jsonpParameterValue = getJsonpParameterValue(request);
|
||||
Object value = filterModel(model);
|
||||
if(serializationView != null || jsonpParameterValue != null) {
|
||||
if (serializationView != null || jsonpParameterValue != null) {
|
||||
MappingJacksonValue container = new MappingJacksonValue(value);
|
||||
container.setSerializationView(serializationView);
|
||||
container.setJsonpFunction(jsonpParameterValue);
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
* by user config.
|
||||
*#
|
||||
#macro( springBind $path )
|
||||
#if("$!springHtmlEscape" != "")
|
||||
#if ("$!springHtmlEscape" != "")
|
||||
#set( $status = $springMacroRequestContext.getBindStatus($path, $springHtmlEscape) )
|
||||
#else
|
||||
#set( $status = $springMacroRequestContext.getBindStatus($path) )
|
||||
@@ -171,7 +171,7 @@
|
||||
* from a list of options.
|
||||
*
|
||||
* The null check for $status.value leverages Velocity's 'quiet' notation rather
|
||||
* than the more common #if($status.value) since this method evaluates to the
|
||||
* than the more common #if ($status.value) since this method evaluates to the
|
||||
* boolean 'false' if the content of $status.value is the String "false" - not
|
||||
* what we want.
|
||||
*
|
||||
@@ -185,7 +185,7 @@
|
||||
<select id="${status.expression}" name="${status.expression}" ${attributes}>
|
||||
#foreach($option in $options.keySet())
|
||||
<option value="${option}"
|
||||
#if("$!status.value" == "$option") selected="selected" #end>
|
||||
#if ("$!status.value" == "$option") selected="selected" #end>
|
||||
${options.get($option)}</option>
|
||||
#end
|
||||
</select>
|
||||
@@ -208,7 +208,7 @@
|
||||
#foreach($option in $options.keySet())
|
||||
<option value="${option}"
|
||||
#foreach($item in $status.actualValue)
|
||||
#if($item == $option) selected="selected" #end
|
||||
#if ($item == $option) selected="selected" #end
|
||||
#end
|
||||
>${options.get($option)}</option>
|
||||
#end
|
||||
@@ -231,7 +231,7 @@
|
||||
#springBind($path)
|
||||
#foreach($option in $options.keySet())
|
||||
<input type="radio" name="${status.expression}" value="${option}"
|
||||
#if("$!status.value" == "$option") checked="checked" #end
|
||||
#if ("$!status.value" == "$option") checked="checked" #end
|
||||
${attributes}
|
||||
#springCloseTag()
|
||||
${options.get($option)} ${separator}
|
||||
@@ -255,7 +255,7 @@
|
||||
#foreach($option in $options.keySet())
|
||||
<input type="checkbox" name="${status.expression}" value="${option}"
|
||||
#foreach($item in $status.actualValue)
|
||||
#if($item == $option) checked="checked" #end
|
||||
#if ($item == $option) checked="checked" #end
|
||||
#end
|
||||
${attributes} #springCloseTag()
|
||||
${options.get($option)} ${separator}
|
||||
@@ -275,7 +275,7 @@
|
||||
#macro( springFormCheckbox $path $attributes )
|
||||
#springBind($path)
|
||||
<input type="hidden" name="_${status.expression}" value="on"/>
|
||||
<input type="checkbox" id="${status.expression}" name="${status.expression}"#if("$!{status.value}"=="true") checked="checked"#end ${attributes}/>
|
||||
<input type="checkbox" id="${status.expression}" name="${status.expression}"#if ("$!{status.value}"=="true") checked="checked"#end ${attributes}/>
|
||||
#end
|
||||
|
||||
#**
|
||||
@@ -293,10 +293,10 @@
|
||||
*#
|
||||
#macro( springShowErrors $separator $classOrStyle )
|
||||
#foreach($error in $status.errorMessages)
|
||||
#if($classOrStyle == "")
|
||||
#if ($classOrStyle == "")
|
||||
<b>${error}</b>
|
||||
#else
|
||||
#if($classOrStyle.indexOf(":") == -1)
|
||||
#if ($classOrStyle.indexOf(":") == -1)
|
||||
#set($attr="class")
|
||||
#else
|
||||
#set($attr="style")
|
||||
@@ -314,7 +314,7 @@
|
||||
* depending on the value of a 'springXhtmlCompliant' variable in the
|
||||
* template context.
|
||||
*#
|
||||
#macro( springCloseTag )#if($springXhtmlCompliant)/>#else>#end #end
|
||||
#macro( springCloseTag )#if ($springXhtmlCompliant)/>#else>#end #end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public class WebSocketExtension {
|
||||
}
|
||||
else {
|
||||
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>();
|
||||
for(String token : extensions.split(",")) {
|
||||
for (String token : extensions.split(",")) {
|
||||
result.add(parseExtension(token));
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -122,7 +122,7 @@ public class WebSocketHttpHeaders extends HttpHeaders {
|
||||
*/
|
||||
public void setSecWebSocketExtensions(List<WebSocketExtension> extensions) {
|
||||
List<String> result = new ArrayList<String>(extensions.size());
|
||||
for(WebSocketExtension extension : extensions) {
|
||||
for (WebSocketExtension extension : extensions) {
|
||||
result.add(extension.toString());
|
||||
}
|
||||
set(SEC_WEBSOCKET_EXTENSIONS, toCommaDelimitedString(result));
|
||||
|
||||
@@ -173,8 +173,8 @@ public class JettyWebSocketSession extends AbstractWebSocketSession<Session> {
|
||||
|
||||
List<ExtensionConfig> source = getNativeSession().getUpgradeResponse().getExtensions();
|
||||
this.extensions = new ArrayList<WebSocketExtension>(source.size());
|
||||
for(ExtensionConfig e : source) {
|
||||
this.extensions.add(new WebSocketExtension(e.getName(), e.getParameters()));
|
||||
for (ExtensionConfig ec : source) {
|
||||
this.extensions.add(new WebSocketExtension(ec.getName(), ec.getParameters()));
|
||||
}
|
||||
|
||||
if (this.user == null) {
|
||||
|
||||
@@ -184,11 +184,11 @@ public class StandardWebSocketSession extends AbstractWebSocketSession<Session>
|
||||
|
||||
List<Extension> source = getNativeSession().getNegotiatedExtensions();
|
||||
this.extensions = new ArrayList<WebSocketExtension>(source.size());
|
||||
for(Extension e : source) {
|
||||
this.extensions.add(new StandardToWebSocketExtensionAdapter(e));
|
||||
for (Extension ext : source) {
|
||||
this.extensions.add(new StandardToWebSocketExtensionAdapter(ext));
|
||||
}
|
||||
|
||||
if(this.user == null) {
|
||||
if (this.user == null) {
|
||||
this.user = session.getUserPrincipal();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
ManagedMap<String, Object> urlMap = new ManagedMap<String, Object>();
|
||||
urlMap.setSource(source);
|
||||
for(Element mappingElement : DomUtils.getChildElementsByTagName(element, "mapping")) {
|
||||
for (Element mappingElement : DomUtils.getChildElementsByTagName(element, "mapping")) {
|
||||
strategy.addMapping(mappingElement, urlMap, context);
|
||||
}
|
||||
handlerMappingDef.getPropertyValues().add("urlMap", urlMap);
|
||||
@@ -122,7 +122,7 @@ class HandlersBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
|
||||
cavs.addIndexedArgumentValue(0, handlerReference);
|
||||
if(this.handshakeHandlerReference != null) {
|
||||
if (this.handshakeHandlerReference != null) {
|
||||
cavs.addIndexedArgumentValue(1, this.handshakeHandlerReference);
|
||||
}
|
||||
RootBeanDefinition requestHandlerDef = new RootBeanDefinition(WebSocketHttpRequestHandler.class, cavs, null);
|
||||
|
||||
@@ -132,7 +132,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
|
||||
String pathAttribute = endpointElem.getAttribute("path");
|
||||
Assert.state(StringUtils.hasText(pathAttribute), "Invalid <stomp-endpoint> (no path mapping)");
|
||||
List<String> paths = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ","));
|
||||
for(String path : paths) {
|
||||
for (String path : paths) {
|
||||
path = path.trim();
|
||||
Assert.state(StringUtils.hasText(path), "Invalid <stomp-endpoint> path attribute: " + pathAttribute);
|
||||
if (DomUtils.getChildElementByTagName(endpointElem, "sockjs") != null) {
|
||||
@@ -374,7 +374,7 @@ class MessageBrokerBeanDefinitionParser implements BeanDefinitionParser {
|
||||
ConstructorArgumentValues cavs = new ConstructorArgumentValues();
|
||||
cavs.addIndexedArgumentValue(0, brokerChannel);
|
||||
RootBeanDefinition beanDef = new RootBeanDefinition(SimpMessagingTemplate.class,cavs, null);
|
||||
if(element.hasAttribute("user-destination-prefix")) {
|
||||
if (element.hasAttribute("user-destination-prefix")) {
|
||||
beanDef.getPropertyValues().add("userDestinationPrefix", element.getAttribute("user-destination-prefix"));
|
||||
}
|
||||
beanDef.getPropertyValues().add("messageConverter", messageConverter);
|
||||
|
||||
@@ -123,7 +123,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy {
|
||||
|
||||
private List<WebSocketExtension> getWebSocketExtensions() {
|
||||
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>();
|
||||
for(String name : this.factory.getExtensionFactory().getExtensionNames()) {
|
||||
for (String name : this.factory.getExtensionFactory().getExtensionNames()) {
|
||||
result.add(new WebSocketExtension(name));
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,7 +68,7 @@ public class HtmlFileTransportHandler extends AbstractHttpSendingTransportHandle
|
||||
" </script>"
|
||||
);
|
||||
|
||||
while(sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) {
|
||||
while (sb.length() < MINIMUM_PARTIAL_HTML_CONTENT_LENGTH) {
|
||||
sb.append(" ");
|
||||
}
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ public class StreamingSockJsSession extends AbstractHttpSockJsSession {
|
||||
this.byteCount = 0;
|
||||
break;
|
||||
}
|
||||
} while (!getMessageCache().isEmpty());
|
||||
}
|
||||
while (!getMessageCache().isEmpty());
|
||||
scheduleHeartbeat();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user