Polishing

This commit is contained in:
Juergen Hoeller
2018-08-07 21:23:43 +02:00
parent 89cadfa8d9
commit 5515112f87
6 changed files with 32 additions and 38 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2018 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.
@@ -31,11 +31,10 @@ import org.springframework.util.Assert;
/**
* Utility class for handling registration of AOP auto-proxy creators.
*
* <p>Only a single auto-proxy creator can be registered yet multiple concrete
* implementations are available. Therefore this class wraps a simple escalation
* protocol, allowing classes to request a particular auto-proxy creator and know
* that class, {@code or a subclass thereof}, will eventually be resident
* in the application context.
* <p>Only a single auto-proxy creator should be registered yet multiple concrete
* implementations are available. This class provides a simple escalation protocol,
* allowing a caller to request a particular auto-proxy creator and know that creator,
* <i>or a more capable variant thereof</i>, will be registered as a post-processor.
*
* @author Rob Harrop
* @author Juergen Hoeller
@@ -54,12 +53,10 @@ public abstract class AopConfigUtils {
/**
* Stores the auto proxy creator classes in escalation order.
*/
private static final List<Class<?>> APC_PRIORITY_LIST = new ArrayList<Class<?>>();
private static final List<Class<?>> APC_PRIORITY_LIST = new ArrayList<Class<?>>(3);
/**
* Setup the escalation list.
*/
static {
// Set up the escalation list...
APC_PRIORITY_LIST.add(InfrastructureAdvisorAutoProxyCreator.class);
APC_PRIORITY_LIST.add(AspectJAwareAdvisorAutoProxyCreator.class);
APC_PRIORITY_LIST.add(AnnotationAwareAspectJAutoProxyCreator.class);
@@ -107,6 +104,7 @@ public abstract class AopConfigUtils {
private static BeanDefinition registerOrEscalateApcAsRequired(Class<?> cls, BeanDefinitionRegistry registry, Object source) {
Assert.notNull(registry, "BeanDefinitionRegistry must not be null");
if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
@@ -118,6 +116,7 @@ public abstract class AopConfigUtils {
}
return null;
}
RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
beanDefinition.setSource(source);
beanDefinition.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@@ -27,11 +27,11 @@ import org.springframework.beans.factory.xml.ParserContext;
* Utility class for handling registration of auto-proxy creators used internally
* by the '{@code aop}' namespace tags.
*
* <p>Only a single auto-proxy creator can be registered and multiple tags may wish
* to register different concrete implementations. As such this class delegates to
* {@link AopConfigUtils} which wraps a simple escalation protocol. Therefore classes
* may request a particular auto-proxy creator and know that class, <i>or a subclass
* thereof</i>, will eventually be resident in the application context.
* <p>Only a single auto-proxy creator should be registered and multiple configuration
* elements may wish to register different concrete implementations. As such this class
* delegates to {@link AopConfigUtils} which provides a simple escalation protocol.
* Callers may request a particular auto-proxy creator and know that creator,
* <i>or a more capable variant thereof</i>, will be registered as a post-processor.
*
* @author Rob Harrop
* @author Juergen Hoeller
@@ -94,9 +94,8 @@ public abstract class AopNamespaceUtils {
private static void registerComponentIfNecessary(BeanDefinition beanDefinition, ParserContext parserContext) {
if (beanDefinition != null) {
BeanComponentDefinition componentDefinition =
new BeanComponentDefinition(beanDefinition, AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
parserContext.registerComponent(componentDefinition);
parserContext.registerComponent(
new BeanComponentDefinition(beanDefinition, AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME));
}
}

View File

@@ -144,12 +144,7 @@ public class AnnotationUtilsTests {
assertNull(getAnnotation(bridgeMethod, Order.class));
assertNotNull(findAnnotation(bridgeMethod, Order.class));
// As of OpenJDK 8 b99, invoking getAnnotation() on a bridge method actually finds
// an annotation on its 'bridged' method. This differs from the previous behavior
// of JDK 5 through 7 and from the current behavior of the Eclipse compiler;
// however, we need to ensure that the tests pass in the Gradle build. So we
// comment out the following assertion.
// assertNull(bridgeMethod.getAnnotation(Transactional.class));
assertNotNull(bridgeMethod.getAnnotation(Transactional.class));
assertNotNull(getAnnotation(bridgeMethod, Transactional.class));
assertNotNull(findAnnotation(bridgeMethod, Transactional.class));
}
@@ -285,7 +280,7 @@ public class AnnotationUtilsTests {
}
@Test
public void findAnnotationDeclaringClassForAllScenarios() throws Exception {
public void findAnnotationDeclaringClassForAllScenarios() {
// no class-level annotation
assertNull(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedInterface.class));
assertNull(findAnnotationDeclaringClass(Transactional.class, NonAnnotatedClass.class));
@@ -394,7 +389,7 @@ public class AnnotationUtilsTests {
}
@Test
public void isAnnotationInheritedForAllScenarios() throws Exception {
public void isAnnotationInheritedForAllScenarios() {
// no class-level annotation
assertFalse(isAnnotationInherited(Transactional.class, NonAnnotatedInterface.class));
assertFalse(isAnnotationInherited(Transactional.class, NonAnnotatedClass.class));
@@ -503,7 +498,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getDefaultValueFromNonPublicAnnotation() throws Exception {
public void getDefaultValueFromNonPublicAnnotation() {
Annotation[] declaredAnnotations = NonPublicAnnotatedClass.class.getDeclaredAnnotations();
assertEquals(1, declaredAnnotations.length);
Annotation annotation = declaredAnnotations[0];
@@ -514,7 +509,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getDefaultValueFromAnnotationType() throws Exception {
public void getDefaultValueFromAnnotationType() {
assertEquals(Ordered.LOWEST_PRECEDENCE, getDefaultValue(Order.class, VALUE));
assertEquals(Ordered.LOWEST_PRECEDENCE, getDefaultValue(Order.class));
}
@@ -546,7 +541,7 @@ public class AnnotationUtilsTests {
}
@Test
public void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() throws Exception {
public void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() {
final List<String> expectedLocations = asList("A", "B");
Set<ContextConfig> annotations = getRepeatableAnnotations(ConfigHierarchyTestCase.class, ContextConfig.class, null);

View File

@@ -63,10 +63,10 @@ public class HessianServiceExporter extends HessianExporter implements HttpReque
response.setContentType(CONTENT_TYPE_HESSIAN);
try {
invoke(request.getInputStream(), response.getOutputStream());
invoke(request.getInputStream(), response.getOutputStream());
}
catch (Throwable ex) {
throw new NestedServletException("Hessian skeleton invocation failed", ex);
throw new NestedServletException("Hessian skeleton invocation failed", ex);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 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.
@@ -157,11 +157,12 @@ public class SimpleHttpServerJaxWsServiceExporter extends AbstractJaxWsServiceEx
if (this.server == null) {
InetSocketAddress address = (this.hostname != null ?
new InetSocketAddress(this.hostname, this.port) : new InetSocketAddress(this.port));
this.server = HttpServer.create(address, this.backlog);
if (this.logger.isInfoEnabled()) {
this.logger.info("Starting HttpServer at address " + address);
HttpServer server = HttpServer.create(address, this.backlog);
if (logger.isInfoEnabled()) {
logger.info("Starting HttpServer at address " + address);
}
this.server.start();
server.start();
this.server = server;
this.localServer = true;
}
super.afterPropertiesSet();

View File

@@ -156,7 +156,7 @@ public class ConcurrentWebSocketSessionDecorator extends WebSocketSessionDecorat
}
finally {
this.sendStartTime = 0;
flushLock.unlock();
this.flushLock.unlock();
}
return true;
}