Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jul 19, 2017
1 parent 12978b8 commit c752ba5
Show file tree
Hide file tree
Showing 28 changed files with 226 additions and 231 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -22,7 +22,6 @@
import org.springframework.aop.PointcutAdvisor;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;

/**
* AspectJPointcutAdvisor that adapts an {@link AbstractAspectJAdvice}
Expand Down Expand Up @@ -51,11 +50,11 @@ public AspectJPointcutAdvisor(AbstractAspectJAdvice advice) {
this.pointcut = advice.buildSafePointcut();
}


public void setOrder(int order) {
this.order = order;
}


@Override
public boolean isPerInstance() {
return true;
Expand Down Expand Up @@ -91,12 +90,12 @@ public boolean equals(Object other) {
return false;
}
AspectJPointcutAdvisor otherAdvisor = (AspectJPointcutAdvisor) other;
return (ObjectUtils.nullSafeEquals(this.advice, otherAdvisor.advice));
return this.advice.equals(otherAdvisor.advice);
}

@Override
public int hashCode() {
return AspectJPointcutAdvisor.class.hashCode();
return AspectJPointcutAdvisor.class.hashCode() * 29 + this.advice.hashCode();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,8 +21,8 @@
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.core.Ordered;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

/**
* Implementation of {@link AspectInstanceFactory} that locates the aspect from the
Expand Down Expand Up @@ -50,9 +50,7 @@ public void setAspectBeanName(String aspectBeanName) {
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
if (!StringUtils.hasText(this.aspectBeanName)) {
throw new IllegalArgumentException("'aspectBeanName' is required");
}
Assert.notNull(this.aspectBeanName, "'aspectBeanName' is required");
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -89,7 +89,7 @@ public static BeanDefinitionHolder createScopedProxy(BeanDefinitionHolder defini
}

/**
* Generates the bean name that is used within the scoped proxy to reference the target bean.
* Generate the bean name that is used within the scoped proxy to reference the target bean.
* @param originalBeanName the original name of bean
* @return the generated bean to be used to reference the target bean
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -76,8 +76,7 @@ private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefini
List<BeanDefinition> innerBeans = new ArrayList<BeanDefinition>();
List<BeanReference> references = new ArrayList<BeanReference>();
PropertyValues propertyValues = beanDefinition.getPropertyValues();
for (int i = 0; i < propertyValues.getPropertyValues().length; i++) {
PropertyValue propertyValue = propertyValues.getPropertyValues()[i];
for (PropertyValue propertyValue : propertyValues.getPropertyValues()) {
Object value = propertyValue.getValue();
if (value instanceof BeanDefinitionHolder) {
innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,15 +54,15 @@ public void setCacheManager(CacheManager cacheManager) {
}

/**
* Return the {@link CacheManager} that this instance use.
* Return the {@link CacheManager} that this instance uses.
*/
public CacheManager getCacheManager() {
return this.cacheManager;
}

@Override
public void afterPropertiesSet() {
Assert.notNull(this.cacheManager, "CacheManager must not be null");
Assert.notNull(this.cacheManager, "CacheManager is required");
}


Expand All @@ -75,7 +75,7 @@ public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext
else {
Collection<Cache> result = new ArrayList<Cache>();
for (String cacheName : cacheNames) {
Cache cache = this.cacheManager.getCache(cacheName);
Cache cache = getCacheManager().getCache(cacheName);
if (cache == null) {
throw new IllegalArgumentException("Cannot find cache named '" +
cacheName + "' for " + context.getOperation());
Expand All @@ -91,7 +91,7 @@ public Collection<? extends Cache> resolveCaches(CacheOperationInvocationContext
* <p>It is acceptable to return {@code null} to indicate that no cache could
* be resolved for this invocation.
* @param context the context of the particular invocation
* @return the cache name(s) to resolve or {@code null} if no cache should be resolved
* @return the cache name(s) to resolve, or {@code null} if no cache should be resolved
*/
protected abstract Collection<String> getCacheNames(CacheOperationInvocationContext<?> context);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,6 @@

package org.springframework.cache.interceptor;


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand All @@ -34,13 +33,15 @@ public class NamedCacheResolver extends AbstractCacheResolver {

private Collection<String> cacheNames;


public NamedCacheResolver() {
}

public NamedCacheResolver(CacheManager cacheManager, String... cacheNames) {
super(cacheManager);
this.cacheNames = new ArrayList<String>(Arrays.asList(cacheNames));
}

public NamedCacheResolver() {
}

/**
* Set the cache name(s) that this resolver should use.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
package org.springframework.cache.support;

import java.util.Collection;
import java.util.Collections;

import org.springframework.cache.Cache;

Expand All @@ -29,7 +30,7 @@
*/
public class SimpleCacheManager extends AbstractCacheManager {

private Collection<? extends Cache> caches;
private Collection<? extends Cache> caches = Collections.emptySet();


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,7 +51,9 @@ public TypeMismatchNamingException(String jndiName, Class<?> requiredType, Class
/**
* Construct a new TypeMismatchNamingException.
* @param explanation the explanation text
* @deprecated as of Spring Framework 4.3.10
*/
@Deprecated
public TypeMismatchNamingException(String explanation) {
super(explanation);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -49,8 +49,8 @@ public class ScopedProxyTests {
private static final ClassPathResource OVERRIDE_CONTEXT = new ClassPathResource(CLASSNAME + "-override.xml", CLASS);
private static final ClassPathResource TESTBEAN_CONTEXT = new ClassPathResource(CLASSNAME + "-testbean.xml", CLASS);

/* SPR-2108 */
@Test

@Test // SPR-2108
public void testProxyAssignable() throws Exception {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(MAP_CONTEXT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">

<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean" scope="request">
<aop:scoped-proxy proxy-target-class="false"/>
<property name="age" value="99"/>
</bean>
<aop:scoped-proxy proxy-target-class="false"/>
<property name="age" value="99"/>
</bean>

<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="properties">
<map>
<entry key="testBean.sex" value="male"/>
</map>
</property>
</bean>
<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="properties">
<map>
<entry key="testBean.sex" value="male"/>
</map>
</property>
</bean>

</beans>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,8 +51,7 @@ public class PathResource extends AbstractResource implements WritableResource {
* Create a new PathResource from a Path handle.
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
* the given root:
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* @param path a Path handle
*/
public PathResource(Path path) {
Expand All @@ -64,8 +63,7 @@ public PathResource(Path path) {
* Create a new PathResource from a Path handle.
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
* the given root:
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* @param path a path
* @see java.nio.file.Paths#get(String, String...)
*/
Expand All @@ -78,8 +76,7 @@ public PathResource(String path) {
* Create a new PathResource from a Path handle.
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
* the given root:
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
* @see java.nio.file.Paths#get(URI)
* @param uri a path URI
*/
Expand Down Expand Up @@ -184,7 +181,7 @@ public File getFile() throws IOException {
catch (UnsupportedOperationException ex) {
// Only paths on the default file system can be converted to a File:
// Do exception translation for cases where conversion is not possible.
throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path");
throw new FileNotFoundException(this.path + " cannot be resolved to absolute file path");
}
}

Expand All @@ -204,11 +201,11 @@ public long contentLength() throws IOException {
public long lastModified() throws IOException {
// We can not use the superclass method since it uses conversion to a File and
// only a Path on the default file system can be converted to a File...
return Files.getLastModifiedTime(path).toMillis();
return Files.getLastModifiedTime(this.path).toMillis();
}

/**
* This implementation creates a FileResource, applying the given path
* This implementation creates a PathResource, applying the given path
* relative to the path of the underlying file of this resource descriptor.
* @see java.nio.file.Path#resolve(String)
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -52,31 +52,32 @@ class StaxResult extends SAXResult {


/**
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
* @param streamWriter the {@code XMLStreamWriter} to write to
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLEventWriter}.
* @param eventWriter the {@code XMLEventWriter} to write to
*/
public StaxResult(XMLStreamWriter streamWriter) {
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
public StaxResult(XMLEventWriter eventWriter) {
StaxEventHandler handler = new StaxEventHandler(eventWriter);
super.setHandler(handler);
super.setLexicalHandler(handler);
this.streamWriter = streamWriter;
this.eventWriter = eventWriter;
}

/**
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLEventWriter}.
* @param eventWriter the {@code XMLEventWriter} to write to
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
* @param streamWriter the {@code XMLStreamWriter} to write to
*/
public StaxResult(XMLEventWriter eventWriter) {
StaxEventHandler handler = new StaxEventHandler(eventWriter);
public StaxResult(XMLStreamWriter streamWriter) {
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
super.setHandler(handler);
super.setLexicalHandler(handler);
this.eventWriter = eventWriter;
this.streamWriter = streamWriter;
}


/**
* Return the {@code XMLEventWriter} used by this {@code StaxResult}. If this {@code StaxResult}
* was created with an {@code XMLStreamWriter}, the result will be {@code null}.
* Return the {@code XMLEventWriter} used by this {@code StaxResult}.
* <p>If this {@code StaxResult} was created with an {@code XMLStreamWriter},
* the result will be {@code null}.
* @return the StAX event writer used by this result
* @see #StaxResult(javax.xml.stream.XMLEventWriter)
*/
Expand All @@ -85,8 +86,9 @@ public XMLEventWriter getXMLEventWriter() {
}

/**
* Return the {@code XMLStreamWriter} used by this {@code StaxResult}. If this {@code StaxResult}
* was created with an {@code XMLEventConsumer}, the result will be {@code null}.
* Return the {@code XMLStreamWriter} used by this {@code StaxResult}.
* <p>If this {@code StaxResult} was created with an {@code XMLEventConsumer},
* the result will be {@code null}.
* @return the StAX stream writer used by this result
* @see #StaxResult(javax.xml.stream.XMLStreamWriter)
*/
Expand Down

0 comments on commit c752ba5

Please sign in to comment.