Consistent bracket alignment
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user