Skip to content

Commit f691618

Browse files
committed
Polishing
1 parent fde0713 commit f691618

File tree

30 files changed

+151
-163
lines changed

30 files changed

+151
-163
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/NoSuchBeanDefinitionException.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,21 +20,23 @@
2020
import org.springframework.util.StringUtils;
2121

2222
/**
23-
* Exception thrown when a {@code BeanFactory} is asked for a bean instance
24-
* for which it cannot find a definition.
23+
* Exception thrown when a {@code BeanFactory} is asked for a bean instance for which it
24+
* cannot find a definition. This may point to a non-existing bean, a non-unique bean,
25+
* or a manually registered singleton instance without an associated bean definition.
2526
*
2627
* @author Rod Johnson
2728
* @author Juergen Hoeller
2829
* @see BeanFactory#getBean(String)
2930
* @see BeanFactory#getBean(Class)
31+
* @see NoUniqueBeanDefinitionException
3032
*/
3133
@SuppressWarnings("serial")
3234
public class NoSuchBeanDefinitionException extends BeansException {
3335

34-
/** Name of the missing bean. */
36+
/** Name of the missing bean */
3537
private String beanName;
3638

37-
/** Required type of the missing bean. */
39+
/** Required type of the missing bean */
3840
private Class<?> beanType;
3941

4042

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
140140
/** Map of bean definition objects, keyed by bean name */
141141
private final Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<String, BeanDefinition>(64);
142142

143-
/** Map of singleton and non-singleton bean names keyed by dependency type */
143+
/** Map of singleton and non-singleton bean names, keyed by dependency type */
144144
private final Map<Class<?>, String[]> allBeanNamesByType = new ConcurrentHashMap<Class<?>, String[]>(64);
145145

146-
/** Map of singleton-only bean names keyed by dependency type */
146+
/** Map of singleton-only bean names, keyed by dependency type */
147147
private final Map<Class<?>, String[]> singletonBeanNamesByType = new ConcurrentHashMap<Class<?>, String[]>(64);
148148

149149
/** List of bean definition names, in registration order */
150-
private final List<String> beanDefinitionNames = new ArrayList<String>();
150+
private final List<String> beanDefinitionNames = new ArrayList<String>(64);
151151

152152
/** Whether bean definition metadata may be cached for all beans */
153153
private boolean configurationFrozen = false;

spring-jms/src/main/java/org/springframework/jms/connection/DelegatingConnectionFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -76,7 +76,7 @@ public ConnectionFactory getTargetConnectionFactory() {
7676
/**
7777
* Indicate whether Connections obtained from the target factory are supposed
7878
* to be stopped before closed ("true") or simply closed ("false").
79-
* The latter may be necessary for some connection pools that simply return
79+
* An extra stop call may be necessary for some connection pools that simply return
8080
* released connections to the pool, not stopping them while they sit in the pool.
8181
* <p>Default is "false", simply closing Connections.
8282
* @see ConnectionFactoryUtils#releaseConnection

spring-jms/src/main/java/org/springframework/jms/connection/SingleConnectionFactory.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@
7373
* @see org.springframework.jms.listener.SimpleMessageListenerContainer
7474
* @see org.springframework.jms.listener.DefaultMessageListenerContainer#setCacheLevel
7575
*/
76-
public class SingleConnectionFactory
77-
implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory, ExceptionListener,
78-
InitializingBean, DisposableBean {
76+
public class SingleConnectionFactory implements ConnectionFactory, QueueConnectionFactory,
77+
TopicConnectionFactory, ExceptionListener, InitializingBean, DisposableBean {
7978

8079
protected final Log logger = LogFactory.getLog(getClass());
8180

@@ -171,7 +170,7 @@ protected String getClientId() {
171170

172171
/**
173172
* Specify an JMS ExceptionListener implementation that should be
174-
* registered with with the single Connection created by this factory.
173+
* registered with the single Connection created by this factory.
175174
* @see #setReconnectOnException
176175
*/
177176
public void setExceptionListener(ExceptionListener exceptionListener) {
@@ -180,7 +179,7 @@ public void setExceptionListener(ExceptionListener exceptionListener) {
180179

181180
/**
182181
* Return the JMS ExceptionListener implementation that should be registered
183-
* with with the single Connection created by this factory, if any.
182+
* with the single Connection created by this factory, if any.
184183
*/
185184
protected ExceptionListener getExceptionListener() {
186185
return this.exceptionListener;
@@ -315,6 +314,7 @@ public void onException(JMSException ex) {
315314
* The provider of this ConnectionFactory needs to care for proper shutdown.
316315
* <p>As this bean implements DisposableBean, a bean factory will
317316
* automatically invoke this on destruction of its cached singletons.
317+
* @see #resetConnection()
318318
*/
319319
@Override
320320
public void destroy() {
@@ -323,6 +323,7 @@ public void destroy() {
323323

324324
/**
325325
* Reset the underlying shared Connection, to be reinitialized on next access.
326+
* @see #closeConnection
326327
*/
327328
public void resetConnection() {
328329
synchronized (this.connectionMonitor) {

spring-messaging/src/main/java/org/springframework/messaging/handler/DestinationPatternsMessageCondition.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,8 +38,7 @@
3838
* @author Rossen Stoyanchev
3939
* @since 4.0
4040
*/
41-
public final class DestinationPatternsMessageCondition
42-
extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
41+
public class DestinationPatternsMessageCondition extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
4342

4443
public static final String LOOKUP_DESTINATION_HEADER = "lookupDestination";
4544

@@ -59,22 +58,22 @@ public DestinationPatternsMessageCondition(String... patterns) {
5958
}
6059

6160
/**
62-
* Additional constructor with flags for using suffix pattern (.*) and
63-
* trailing slash matches.
61+
* Additional constructor with flags for using suffix pattern (.*) and trailing slash matches.
6462
* @param patterns the URL patterns to use; if 0, the condition will match to every request.
65-
* @param pathMatcher for path matching with patterns
63+
* @param pathMatcher the PathMatcher to use
6664
*/
67-
public DestinationPatternsMessageCondition(String[] patterns,PathMatcher pathMatcher) {
65+
public DestinationPatternsMessageCondition(String[] patterns, PathMatcher pathMatcher) {
6866
this(asList(patterns), pathMatcher);
6967
}
7068

7169
private DestinationPatternsMessageCondition(Collection<String> patterns, PathMatcher pathMatcher) {
7270
this.patterns = Collections.unmodifiableSet(prependLeadingSlash(patterns));
73-
this.pathMatcher = (pathMatcher != null) ? pathMatcher : new AntPathMatcher();
71+
this.pathMatcher = (pathMatcher != null ? pathMatcher : new AntPathMatcher());
7472
}
7573

74+
7675
private static List<String> asList(String... patterns) {
77-
return patterns != null ? Arrays.asList(patterns) : Collections.<String>emptyList();
76+
return (patterns != null ? Arrays.asList(patterns) : Collections.<String>emptyList());
7877
}
7978

8079
private static Set<String> prependLeadingSlash(Collection<String> patterns) {
@@ -91,6 +90,7 @@ private static Set<String> prependLeadingSlash(Collection<String> patterns) {
9190
return result;
9291
}
9392

93+
9494
public Set<String> getPatterns() {
9595
return this.patterns;
9696
}
@@ -105,14 +105,15 @@ protected String getToStringInfix() {
105105
return " || ";
106106
}
107107

108+
108109
/**
109110
* Returns a new instance with URL patterns from the current instance ("this") and
110111
* the "other" instance as follows:
111112
* <ul>
112-
* <li>If there are patterns in both instances, combine the patterns in "this" with
113-
* the patterns in "other" using {@link org.springframework.util.PathMatcher#combine(String, String)}.
114-
* <li>If only one instance has patterns, use them.
115-
* <li>If neither instance has patterns, use an empty String (i.e. "").
113+
* <li>If there are patterns in both instances, combine the patterns in "this" with
114+
* the patterns in "other" using {@link org.springframework.util.PathMatcher#combine(String, String)}.
115+
* <li>If only one instance has patterns, use them.
116+
* <li>If neither instance has patterns, use an empty String (i.e. "").
116117
* </ul>
117118
*/
118119
@Override

spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public LocalSessionFactoryBuilder addAnnotatedClasses(Class<?>... annotatedClass
241241
* @see #scanPackages
242242
*/
243243
public LocalSessionFactoryBuilder addPackages(String... annotatedPackages) {
244-
for (String annotatedPackage :annotatedPackages) {
244+
for (String annotatedPackage : annotatedPackages) {
245245
addPackage(annotatedPackage);
246246
}
247247
return this;

spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/SpringFlushSynchronization.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@
2828
* @author Juergen Hoeller
2929
* @since 3.1
3030
*/
31-
class SpringFlushSynchronization extends TransactionSynchronizationAdapter {
31+
public class SpringFlushSynchronization extends TransactionSynchronizationAdapter {
3232

3333
private final Session session;
3434

spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/SpringSessionSynchronization.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-orm-hibernate4/src/test/java/org/springframework/orm/hibernate4/HibernateTransactionManagerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
* @author Juergen Hoeller
7171
* @since 3.2
7272
*/
73-
@SuppressWarnings({ "rawtypes", "unchecked" })
73+
@SuppressWarnings({"rawtypes", "unchecked"})
7474
public class HibernateTransactionManagerTests {
7575

7676
@After

spring-orm/src/main/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBean.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,15 +55,15 @@
5555
import org.springframework.util.CollectionUtils;
5656

5757
/**
58-
* Abstract {@link org.springframework.beans.factory.FactoryBean} that
59-
* creates a local JPA {@link javax.persistence.EntityManagerFactory}
60-
* instance within a Spring application context.
58+
* Abstract {@link org.springframework.beans.factory.FactoryBean} that creates
59+
* a local JPA {@link javax.persistence.EntityManagerFactory} instance within
60+
* a Spring application context.
6161
*
62-
* <p>Encapsulates the common functionality between the different JPA
63-
* bootstrap contracts (standalone as well as container).
62+
* <p>Encapsulates the common functionality between the different JPA bootstrap
63+
* contracts (standalone as well as container).
6464
*
65-
* <p>Implements support for standard JPA configuration as well as
66-
* Spring's {@link JpaVendorAdapter} abstraction, and controls the
65+
* <p>Implements support for standard JPA configuration conventions as well as
66+
* Spring's customizable {@link JpaVendorAdapter} mechanism, and controls the
6767
* EntityManagerFactory's lifecycle.
6868
*
6969
* <p>This class also implements the

spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryAccessor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,8 +33,8 @@
3333
import org.springframework.util.CollectionUtils;
3434

3535
/**
36-
* Base class for any class that needs to access an EntityManagerFactory,
37-
* usually in order to obtain an EntityManager. Defines common properties.
36+
* Base class for any class that needs to access a JPA {@link EntityManagerFactory},
37+
* usually in order to obtain a JPA {@link EntityManager}. Defines common properties.
3838
*
3939
* @author Juergen Hoeller
4040
* @since 2.0

spring-orm/src/main/java/org/springframework/orm/jpa/EntityManagerFactoryUtils.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -80,6 +80,7 @@ public abstract class EntityManagerFactoryUtils {
8080

8181
private static final Log logger = LogFactory.getLog(EntityManagerFactoryUtils.class);
8282

83+
8384
private static Method createEntityManagerWithSynchronizationTypeMethod;
8485

8586
private static Object synchronizationTypeUnsynchronized;
@@ -144,9 +145,8 @@ public static EntityManagerFactory findEntityManagerFactory(
144145
}
145146

146147
/**
147-
* Obtain a JPA EntityManager from the given factory. Is aware of a
148-
* corresponding EntityManager bound to the current thread,
149-
* for example when using JpaTransactionManager.
148+
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
149+
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
150150
* <p>Note: Will return {@code null} if no thread-bound EntityManager found!
151151
* @param emf EntityManagerFactory to create the EntityManager with
152152
* @return the EntityManager, or {@code null} if none found
@@ -160,9 +160,8 @@ public static EntityManager getTransactionalEntityManager(EntityManagerFactory e
160160
}
161161

162162
/**
163-
* Obtain a JPA EntityManager from the given factory. Is aware of a
164-
* corresponding EntityManager bound to the current thread,
165-
* for example when using JpaTransactionManager.
163+
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
164+
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
166165
* <p>Note: Will return {@code null} if no thread-bound EntityManager found!
167166
* @param emf EntityManagerFactory to create the EntityManager with
168167
* @param properties the properties to be passed into the {@code createEntityManager}
@@ -182,9 +181,8 @@ public static EntityManager getTransactionalEntityManager(EntityManagerFactory e
182181
}
183182

184183
/**
185-
* Obtain a JPA EntityManager from the given factory. Is aware of a
186-
* corresponding EntityManager bound to the current thread,
187-
* for example when using JpaTransactionManager.
184+
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
185+
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
188186
* <p>Same as {@code getEntityManager}, but throwing the original PersistenceException.
189187
* @param emf EntityManagerFactory to create the EntityManager with
190188
* @param properties the properties to be passed into the {@code createEntityManager}
@@ -201,9 +199,8 @@ public static EntityManager doGetTransactionalEntityManager(EntityManagerFactory
201199
}
202200

203201
/**
204-
* Obtain a JPA EntityManager from the given factory. Is aware of a
205-
* corresponding EntityManager bound to the current thread,
206-
* for example when using JpaTransactionManager.
202+
* Obtain a JPA EntityManager from the given factory. Is aware of a corresponding
203+
* EntityManager bound to the current thread, e.g. when using JpaTransactionManager.
207204
* <p>Same as {@code getEntityManager}, but throwing the original PersistenceException.
208205
* @param emf EntityManagerFactory to create the EntityManager with
209206
* @param properties the properties to be passed into the {@code createEntityManager}
@@ -285,8 +282,8 @@ else if (!TransactionSynchronizationManager.isSynchronizationActive()) {
285282
em = (!CollectionUtils.isEmpty(properties) ? emf.createEntityManager(properties) : emf.createEntityManager());
286283
}
287284

288-
// Use same EntityManager for further JPA actions within the transaction.
289-
// Thread object will get removed by synchronization at transaction completion.
285+
// Use same EntityManager for further JPA operations within the transaction.
286+
// Thread-bound object will get removed by synchronization at transaction completion.
290287
logger.debug("Registering transaction synchronization for JPA EntityManager");
291288
emHolder = new EntityManagerHolder(em);
292289
if (synchronizedWithTransaction) {
@@ -296,7 +293,7 @@ else if (!TransactionSynchronizationManager.isSynchronizationActive()) {
296293
emHolder.setSynchronizedWithTransaction(true);
297294
}
298295
else {
299-
// unsynchronized - just scope it for the transaction, as demanded by the JPA 2.1 spec
296+
// Unsynchronized - just scope it for the transaction, as demanded by the JPA 2.1 spec...
300297
TransactionSynchronizationManager.registerSynchronization(
301298
new TransactionScopedEntityManagerSynchronization(emHolder, emf));
302299
}

spring-orm/src/main/java/org/springframework/orm/jpa/ExtendedEntityManagerCreator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public static EntityManager createApplicationManagedEntityManager(
9595
* transactions (according to the JPA 2.1 SynchronizationType rules)
9696
* @return an application-managed EntityManager that can join transactions
9797
* but does not participate in them automatically
98+
* @since 4.0
9899
*/
99100
public static EntityManager createApplicationManagedEntityManager(
100101
EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo, boolean synchronizedWithTransaction) {
@@ -156,6 +157,7 @@ public static EntityManager createContainerManagedEntityManager(EntityManagerFac
156157
* @return a container-managed EntityManager that expects container-driven lifecycle
157158
* management but may opt out of automatic transaction synchronization
158159
* @see javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)
160+
* @since 4.0
159161
*/
160162
public static EntityManager createContainerManagedEntityManager(
161163
EntityManagerFactory emf, Map<?, ?> properties, boolean synchronizedWithTransaction) {

0 commit comments

Comments
 (0)