diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java b/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java index f9869a5f9b1..7d9b2ad2dc8 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AdviceEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2020 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. @@ -30,13 +30,14 @@ public class AdviceEntry implements ParseState.Entry { /** - * Creates a new instance of the {@link AdviceEntry} class. - * @param kind the kind of advice represented by this entry (before, after, around, etc.) + * Create a new {@code AdviceEntry} instance. + * @param kind the kind of advice represented by this entry (before, after, around) */ public AdviceEntry(String kind) { this.kind = kind; } + @Override public String toString() { return "Advice (" + this.kind + ")"; diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java b/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java index 1f7ba059620..1a8b45c4823 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AdvisorEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2020 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. @@ -30,13 +30,14 @@ public class AdvisorEntry implements ParseState.Entry { /** - * Creates a new instance of the {@link AdvisorEntry} class. + * Create a new {@code AdvisorEntry} instance. * @param name the bean name of the advisor */ public AdvisorEntry(String name) { this.name = name; } + @Override public String toString() { return "Advisor '" + this.name + "'"; diff --git a/spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java b/spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java index 13633bc2a27..2d4360048cf 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/AspectEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2020 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. @@ -34,7 +34,7 @@ public class AspectEntry implements ParseState.Entry { /** - * Create a new AspectEntry. + * Create a new {@code AspectEntry} instance. * @param id the id of the aspect element * @param ref the bean name referenced by this aspect element */ @@ -43,6 +43,7 @@ public class AspectEntry implements ParseState.Entry { this.ref = ref; } + @Override public String toString() { return "Aspect: " + (StringUtils.hasLength(this.id) ? "id='" + this.id + "'" : "ref='" + this.ref + "'"); diff --git a/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java b/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java index 950f8da387e..e6066c513ee 100644 --- a/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java +++ b/spring-aop/src/main/java/org/springframework/aop/config/PointcutEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2020 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,14 +28,16 @@ public class PointcutEntry implements ParseState.Entry { private final String name; + /** - * Creates a new instance of the {@link PointcutEntry} class. + * Create a new {@code PointcutEntry} instance. * @param name the bean name of the pointcut */ public PointcutEntry(String name) { this.name = name; } + @Override public String toString() { return "Pointcut '" + this.name + "'"; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanEntry.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanEntry.java index 207650a27ba..ccba6d76e68 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanEntry.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/BeanEntry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2020 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. @@ -24,11 +24,11 @@ package org.springframework.beans.factory.parsing; */ public class BeanEntry implements ParseState.Entry { - private String beanDefinitionName; + private final String beanDefinitionName; /** - * Creates a new instance of {@link BeanEntry} class. + * Create a new {@code BeanEntry} instance. * @param beanDefinitionName the name of the associated bean definition */ public BeanEntry(String beanDefinitionName) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java index 3b7c3062f20..3f21ee43bce 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/ParseState.java @@ -20,23 +20,17 @@ import java.util.Stack; /** * Simple {@link Stack}-based structure for tracking the logical position during - * a parsing process. {@link Entry entries} are added to the stack at - * each point during the parse phase in a reader-specific manner. + * a parsing process. {@link Entry entries} are added to the stack at each point + * during the parse phase in a reader-specific manner. * *
Calling {@link #toString()} will render a tree-style view of the current logical
- * position in the parse phase. This representation is intended for use in
- * error messages.
+ * position in the parse phase. This representation is intended for use in error messages.
*
* @author Rob Harrop
* @since 2.0
*/
public final class ParseState {
- /**
- * Tab character used when rendering the tree-style representation.
- */
- private static final char TAB = '\t';
-
/**
* Internal {@link Stack} storage.
*/
@@ -51,7 +45,7 @@ public final class ParseState {
}
/**
- * Create a new {@code ParseState} whose {@link Stack} is a {@link Object#clone clone}
+ * Create a new {@code ParseState} whose {@link Stack} is a clone
* of that of the passed in {@code ParseState}.
*/
@SuppressWarnings("unchecked")
@@ -79,7 +73,7 @@ public final class ParseState {
* {@code null} if the {@link Stack} is empty.
*/
public Entry peek() {
- return this.state.empty() ? null : this.state.peek();
+ return (this.state.empty() ? null : this.state.peek());
}
/**
@@ -96,16 +90,18 @@ public final class ParseState {
*/
@Override
public String toString() {
- StringBuilder sb = new StringBuilder();
- for (int x = 0; x < this.state.size(); x++) {
- if (x > 0) {
+ StringBuilder sb = new StringBuilder(64);
+ int i = 0;
+ for (ParseState.Entry entry : this.state) {
+ if (i > 0) {
sb.append('\n');
- for (int y = 0; y < x; y++) {
- sb.append(TAB);
+ for (int j = 0; j < i; j++) {
+ sb.append('\t');
}
sb.append("-> ");
}
- sb.append(this.state.get(x));
+ sb.append(entry);
+ i++;
}
return sb.toString();
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java
index 983e72101b8..c20235a09b7 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/PropertyEntry.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2020 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.
@@ -30,14 +30,12 @@ public class PropertyEntry implements ParseState.Entry {
/**
- * Creates a new instance of the {@link PropertyEntry} class.
+ * Create a new {@code PropertyEntry} instance.
* @param name the name of the JavaBean property represented by this instance
- * @throws IllegalArgumentException if the supplied {@code name} is {@code null}
- * or consists wholly of whitespace
*/
public PropertyEntry(String name) {
if (!StringUtils.hasText(name)) {
- throw new IllegalArgumentException("Invalid property name '" + name + "'.");
+ throw new IllegalArgumentException("Invalid property name '" + name + "'");
}
this.name = name;
}
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java
index 8fc3207e80e..45283e5838c 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/parsing/QualifierEntry.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2012 the original author or authors.
+ * Copyright 2002-2020 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.
@@ -26,16 +26,21 @@ import org.springframework.util.StringUtils;
*/
public class QualifierEntry implements ParseState.Entry {
- private String typeName;
+ private final String typeName;
+ /**
+ * Create a new {@code QualifierEntry} instance.
+ * @param typeName the name of the qualifier type
+ */
public QualifierEntry(String typeName) {
if (!StringUtils.hasText(typeName)) {
- throw new IllegalArgumentException("Invalid qualifier type '" + typeName + "'.");
+ throw new IllegalArgumentException("Invalid qualifier type '" + typeName + "'");
}
this.typeName = typeName;
}
+
@Override
public String toString() {
return "Qualifier '" + this.typeName + "'";
diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java
index b38eb782c2a..9c4c3a8ab47 100644
--- a/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java
+++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/ReplaceOverride.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2019 the original author or authors.
+ * Copyright 2002-2020 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.
@@ -38,7 +38,7 @@ public class ReplaceOverride extends MethodOverride {
private final String methodReplacerBeanName;
- private List Adds a new buffer that can store at least {@code minCapacity} bytes.
*/
private void addBuffer(int minCapacity) {
diff --git a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java
index d00bb4b64db..0738ecfae1c 100644
--- a/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java
+++ b/spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2018 the original author or authors.
+ * Copyright 2002-2020 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.
@@ -64,10 +64,10 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
- if (!"".equals(containerClass)) {
- return null; // Not supported
+ if (StringUtils.hasLength(containerClass)) {
+ return null; // not supported
}
- else if ("".equals(containerType) || containerType.startsWith("default")) {
+ else if (!StringUtils.hasLength(containerType) || containerType.startsWith("default")) {
factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJmsListenerContainerFactory");
}
else if (containerType.startsWith("simple")) {
@@ -91,10 +91,10 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
- if (!"".equals(containerClass)) {
+ if (StringUtils.hasLength(containerClass)) {
containerDef.setBeanClassName(containerClass);
}
- else if ("".equals(containerType) || containerType.startsWith("default")) {
+ else if (!StringUtils.hasLength(containerType) || containerType.startsWith("default")) {
containerDef.setBeanClassName("org.springframework.jms.listener.DefaultMessageListenerContainer");
}
else if (containerType.startsWith("simple")) {
diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java
index 27c8551f0b8..c51365ec81a 100644
--- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java
+++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/MutablePersistenceUnitInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2015 the original author or authors.
+ * Copyright 2002-2020 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.
@@ -55,7 +55,7 @@ public class MutablePersistenceUnitInfo implements SmartPersistenceUnitInfo {
private final List Implementation details:
- *
* Implementation details:
- *
* Note: this method does not provide a means to set active bean definition
* profiles for the loaded context. See {@link #loadContext(MergedContextConfiguration)}
* and {@link AbstractContextLoader#prepareContext(ConfigurableApplicationContext, MergedContextConfiguration)}
* for an alternative.
- *
* @return a new application context
* @see org.springframework.test.context.ContextLoader#loadContext
* @see GenericApplicationContext
@@ -182,26 +178,28 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
public final ConfigurableApplicationContext loadContext(String... locations) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Loading ApplicationContext for locations [%s].",
- StringUtils.arrayToCommaDelimitedString(locations)));
+ StringUtils.arrayToCommaDelimitedString(locations)));
}
+
GenericApplicationContext context = new GenericApplicationContext();
+
prepareContext(context);
customizeBeanFactory(context.getDefaultListableBeanFactory());
createBeanDefinitionReader(context).loadBeanDefinitions(locations);
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
customizeContext(context);
+
context.refresh();
context.registerShutdownHook();
+
return context;
}
/**
* Prepare the {@link GenericApplicationContext} created by this {@code ContextLoader}.
* Called before bean definitions are read.
- *
* The default implementation is empty. Can be overridden in subclasses to
* customize {@code GenericApplicationContext}'s standard settings.
- *
* @param context the context that should be prepared
* @see #loadContext(MergedContextConfiguration)
* @see #loadContext(String...)
@@ -217,10 +215,8 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
/**
* Customize the internal bean factory of the ApplicationContext created by
* this {@code ContextLoader}.
- *
* The default implementation is empty but can be overridden in subclasses
* to customize {@code DefaultListableBeanFactory}'s standard settings.
- *
* @param beanFactory the bean factory created by this {@code ContextLoader}
* @see #loadContext(MergedContextConfiguration)
* @see #loadContext(String...)
@@ -236,18 +232,15 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
/**
* Load bean definitions into the supplied {@link GenericApplicationContext context}
* from the locations or classes in the supplied {@code MergedContextConfiguration}.
- *
* The default implementation delegates to the {@link BeanDefinitionReader}
* returned by {@link #createBeanDefinitionReader(GenericApplicationContext)} to
* {@link BeanDefinitionReader#loadBeanDefinitions(String) load} the
* bean definitions.
- *
* Subclasses must provide an appropriate implementation of
* {@link #createBeanDefinitionReader(GenericApplicationContext)}. Alternatively subclasses
* may provide a no-op implementation of {@code createBeanDefinitionReader()}
* and override this method to provide a custom strategy for loading or
* registering bean definitions.
- *
* @param context the context into which the bean definitions should be loaded
* @param mergedConfig the merged context configuration
* @see #loadContext(MergedContextConfiguration)
@@ -260,7 +253,6 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
/**
* Factory method for creating a new {@link BeanDefinitionReader} for loading
* bean definitions into the supplied {@link GenericApplicationContext context}.
- *
* @param context the context for which the {@code BeanDefinitionReader}
* should be created
* @return a {@code BeanDefinitionReader} for the supplied context
@@ -275,10 +267,8 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
* Customize the {@link GenericApplicationContext} created by this
* {@code ContextLoader} after bean definitions have been
* loaded into the context but before the context is refreshed.
- *
* The default implementation is empty but can be overridden in subclasses
* to customize the application context.
- *
* @param context the newly created application context
* @see #loadContext(MergedContextConfiguration)
* @see #loadContext(String...)
diff --git a/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java b/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java
index 25bd84779e7..23feb00fcc7 100644
--- a/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java
+++ b/spring-tx/src/main/java/org/springframework/transaction/config/TxAdviceBeanDefinitionParser.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2020 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.
@@ -96,7 +96,7 @@ class TxAdviceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
private RootBeanDefinition parseAttributeSource(Element attrEle, ParserContext parserContext) {
List
*
- *
* @return a new application context
* @see org.springframework.test.context.SmartContextLoader#loadContext(MergedContextConfiguration)
* @see GenericApplicationContext
@@ -107,7 +104,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug(String.format("Loading ApplicationContext for merged context configuration [%s].",
- mergedConfig));
+ mergedConfig));
}
validateMergedContextConfiguration(mergedConfig);
@@ -118,6 +115,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
if (parent != null) {
context.setParent(parent);
}
+
prepareContext(context);
prepareContext(context, mergedConfig);
customizeBeanFactory(context.getDefaultListableBeanFactory());
@@ -125,8 +123,10 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
AnnotationConfigUtils.registerAnnotationConfigProcessors(context);
customizeContext(context);
customizeContext(context, mergedConfig);
+
context.refresh();
context.registerShutdownHook();
+
return context;
}
@@ -146,9 +146,7 @@ public abstract class AbstractGenericContextLoader extends AbstractContextLoader
/**
* Load a Spring ApplicationContext from the supplied {@code locations}.
- *
*
*
- *
*