Skip to content

Commit 3c549ef

Browse files
committed
Polishing
1 parent 8429c4b commit 3c549ef

File tree

6 files changed

+111
-111
lines changed

6 files changed

+111
-111
lines changed

spring-core/src/main/java/org/springframework/core/io/ClassPathResource.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -27,8 +27,8 @@
2727
import org.springframework.util.StringUtils;
2828

2929
/**
30-
* {@link Resource} implementation for class path resources.
31-
* Uses either a given ClassLoader or a given Class for loading resources.
30+
* {@link Resource} implementation for class path resources. Uses either a
31+
* given {@link ClassLoader} or a given {@link Class} for loading resources.
3232
*
3333
* <p>Supports resolution as {@code java.io.File} if the class path
3434
* resource resides in the file system, but not for resources in a JAR.
@@ -229,6 +229,7 @@ public String getDescription() {
229229
return builder.toString();
230230
}
231231

232+
232233
/**
233234
* This implementation compares the underlying class path locations.
234235
*/

spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -115,6 +115,26 @@ public InputStream getInputStream() throws IOException {
115115
return new FileInputStream(this.file);
116116
}
117117

118+
/**
119+
* This implementation checks whether the underlying file is marked as writable
120+
* (and corresponds to an actual file with content, not to a directory).
121+
* @see java.io.File#canWrite()
122+
* @see java.io.File#isDirectory()
123+
*/
124+
@Override
125+
public boolean isWritable() {
126+
return (this.file.canWrite() && !this.file.isDirectory());
127+
}
128+
129+
/**
130+
* This implementation opens a FileOutputStream for the underlying file.
131+
* @see java.io.FileOutputStream
132+
*/
133+
@Override
134+
public OutputStream getOutputStream() throws IOException {
135+
return new FileOutputStream(this.file);
136+
}
137+
118138
/**
119139
* This implementation returns a URL for the underlying file.
120140
* @see java.io.File#toURI()
@@ -180,29 +200,6 @@ public String getDescription() {
180200
}
181201

182202

183-
// implementation of WritableResource
184-
185-
/**
186-
* This implementation checks whether the underlying file is marked as writable
187-
* (and corresponds to an actual file with content, not to a directory).
188-
* @see java.io.File#canWrite()
189-
* @see java.io.File#isDirectory()
190-
*/
191-
@Override
192-
public boolean isWritable() {
193-
return (this.file.canWrite() && !this.file.isDirectory());
194-
}
195-
196-
/**
197-
* This implementation opens a FileOutputStream for the underlying file.
198-
* @see java.io.FileOutputStream
199-
*/
200-
@Override
201-
public OutputStream getOutputStream() throws IOException {
202-
return new FileOutputStream(this.file);
203-
}
204-
205-
206203
/**
207204
* This implementation compares the underlying File references.
208205
*/

spring-core/src/main/java/org/springframework/core/io/PathResource.java

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -37,6 +37,7 @@
3737
* Implements the extended {@link WritableResource} interface.
3838
*
3939
* @author Philippe Marschall
40+
* @author Juergen Hoeller
4041
* @since 4.0
4142
* @see java.nio.file.Path
4243
*/
@@ -130,6 +131,29 @@ public InputStream getInputStream() throws IOException {
130131
return Files.newInputStream(this.path);
131132
}
132133

134+
/**
135+
* This implementation checks whether the underlying file is marked as writable
136+
* (and corresponds to an actual file with content, not to a directory).
137+
* @see java.nio.file.Files#isWritable(Path)
138+
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
139+
*/
140+
@Override
141+
public boolean isWritable() {
142+
return (Files.isWritable(this.path) && !Files.isDirectory(this.path));
143+
}
144+
145+
/**
146+
* This implementation opens a OutputStream for the underlying file.
147+
* @see java.nio.file.spi.FileSystemProvider#newOutputStream(Path, OpenOption...)
148+
*/
149+
@Override
150+
public OutputStream getOutputStream() throws IOException {
151+
if (Files.isDirectory(this.path)) {
152+
throw new FileNotFoundException(getPath() + " (is a directory)");
153+
}
154+
return Files.newOutputStream(this.path);
155+
}
156+
133157
/**
134158
* This implementation returns a URL for the underlying file.
135159
* @see java.nio.file.Path#toUri()
@@ -178,8 +202,8 @@ public long contentLength() throws IOException {
178202
*/
179203
@Override
180204
public long lastModified() throws IOException {
181-
// we can not use the super class method since it uses conversion to a File and
182-
// only Paths on the default file system can be converted to a File
205+
// We can not use the superclass method since it uses conversion to a File and
206+
// only a Path on the default file system can be converted to a File...
183207
return Files.getLastModifiedTime(path).toMillis();
184208
}
185209

@@ -207,31 +231,6 @@ public String getDescription() {
207231
return "path [" + this.path.toAbsolutePath() + "]";
208232
}
209233

210-
// implementation of WritableResource
211-
212-
/**
213-
* This implementation checks whether the underlying file is marked as writable
214-
* (and corresponds to an actual file with content, not to a directory).
215-
* @see java.nio.file.Files#isWritable(Path)
216-
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
217-
*/
218-
@Override
219-
public boolean isWritable() {
220-
return Files.isWritable(this.path) && !Files.isDirectory(this.path);
221-
}
222-
223-
/**
224-
* This implementation opens a OutputStream for the underlying file.
225-
* @see java.nio.file.spi.FileSystemProvider#newOutputStream(Path, OpenOption...)
226-
*/
227-
@Override
228-
public OutputStream getOutputStream() throws IOException {
229-
if (Files.isDirectory(this.path)) {
230-
throw new FileNotFoundException(getPath() + " (is a directory)");
231-
}
232-
return Files.newOutputStream(this.path);
233-
}
234-
235234

236235
/**
237236
* This implementation compares the underlying Path references.

spring-jms/src/main/java/org/springframework/jms/annotation/JmsListener.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -25,21 +25,20 @@
2525
import org.springframework.messaging.handler.annotation.MessageMapping;
2626

2727
/**
28-
* Annotation that marks a method to be the target of a JMS message
29-
* listener on the specified {@link #destination}. The {@link #containerFactory}
30-
* identifies the {@link org.springframework.jms.config.JmsListenerContainerFactory
31-
* JmsListenerContainerFactory} to use to build the JMS listener container. If not
32-
* set, a <em>default</em> container factory is assumed to be available with a bean
33-
* name of {@code jmsListenerContainerFactory} unless an explicit default has been
34-
* provided through configuration.
28+
* Annotation that marks a method to be the target of a JMS message listener on the
29+
* specified {@link #destination}. The {@link #containerFactory} identifies the
30+
* {@link org.springframework.jms.config.JmsListenerContainerFactory} to use to build
31+
* the JMS listener container. If not set, a <em>default</em> container factory is
32+
* assumed to be available with a bean name of {@code jmsListenerContainerFactory}
33+
* unless an explicit default has been provided through configuration.
3534
*
36-
* <p>Processing of {@code @JmsListener} annotations is performed by
37-
* registering a {@link JmsListenerAnnotationBeanPostProcessor}. This can be
38-
* done manually or, more conveniently, through the {@code <jms:annotation-driven/>}
39-
* element or {@link EnableJms @EnableJms} annotation.
35+
* <p>Processing of {@code @JmsListener} annotations is performed by registering a
36+
* {@link JmsListenerAnnotationBeanPostProcessor}. This can be done manually or,
37+
* more conveniently, through the {@code <jms:annotation-driven/>} element or
38+
* {@link EnableJms @EnableJms} annotation.
4039
*
41-
* <p>Annotated methods are allowed to have flexible signatures similar to what
42-
* {@link MessageMapping} provides:
40+
* <p>Annotated JMS listener methods are allowed to have flexible signatures similar
41+
* to what {@link MessageMapping} provides:
4342
* <ul>
4443
* <li>{@link javax.jms.Session} to get access to the JMS session</li>
4544
* <li>{@link javax.jms.Message} or one of its subclasses to get access to the raw JMS message</li>
@@ -48,15 +47,15 @@
4847
* arguments, including support for validation</li>
4948
* <li>{@link org.springframework.messaging.handler.annotation.Header @Header}-annotated method
5049
* arguments to extract specific header values, including standard JMS headers defined by
51-
* {@link org.springframework.jms.support.JmsHeaders JmsHeaders}</li>
50+
* {@link org.springframework.jms.support.JmsHeaders}</li>
5251
* <li>{@link org.springframework.messaging.handler.annotation.Headers @Headers}-annotated
53-
* method argument that must also be assignable to {@link java.util.Map} for obtaining access to all
54-
* headers</li>
55-
* <li>{@link org.springframework.messaging.MessageHeaders MessageHeaders} arguments for
56-
* obtaining access to all headers</li>
57-
* <li>{@link org.springframework.messaging.support.MessageHeaderAccessor MessageHeaderAccessor}
58-
* or {@link org.springframework.jms.support.JmsMessageHeaderAccessor JmsMessageHeaderAccessor}
59-
* for convenient access to all method arguments</li>
52+
* method argument that must also be assignable to {@link java.util.Map} for obtaining
53+
* access to all headers</li>
54+
* <li>{@link org.springframework.messaging.MessageHeaders} arguments for obtaining
55+
* access to all headers</li>
56+
* <li>{@link org.springframework.messaging.support.MessageHeaderAccessor} or
57+
* {@link org.springframework.jms.support.JmsMessageHeaderAccessor} for convenient
58+
* access to all method arguments</li>
6059
* </ul>
6160
*
6261
* <p>Annotated methods may have a non-{@code void} return type. When they do,
@@ -73,8 +72,8 @@
7372
*/
7473
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
7574
@Retention(RetentionPolicy.RUNTIME)
76-
@MessageMapping
7775
@Documented
76+
@MessageMapping
7877
public @interface JmsListener {
7978

8079
/**
@@ -85,16 +84,15 @@
8584
String id() default "";
8685

8786
/**
88-
* The bean name of the {@link org.springframework.jms.config.JmsListenerContainerFactory JmsListenerContainerFactory}
87+
* The bean name of the {@link org.springframework.jms.config.JmsListenerContainerFactory}
8988
* to use to create the message listener container responsible for serving this endpoint.
9089
* <p>If not specified, the default container factory is used, if any.
9190
*/
9291
String containerFactory() default "";
9392

9493
/**
9594
* The destination name for this listener, resolved through the container-wide
96-
* {@link org.springframework.jms.support.destination.DestinationResolver DestinationResolver}
97-
* strategy.
95+
* {@link org.springframework.jms.support.destination.DestinationResolver} strategy.
9896
*/
9997
String destination();
10098

spring-jms/src/main/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessor.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 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.
@@ -54,19 +54,19 @@
5454
/**
5555
* Bean post-processor that registers methods annotated with {@link JmsListener}
5656
* to be invoked by a JMS message listener container created under the cover
57-
* by a {@link org.springframework.jms.config.JmsListenerContainerFactory} according
58-
* to the parameters of the annotation.
57+
* by a {@link org.springframework.jms.config.JmsListenerContainerFactory}
58+
* according to the attributes of the annotation.
5959
*
6060
* <p>Annotated methods can use flexible arguments as defined by {@link JmsListener}.
6161
*
6262
* <p>This post-processor is automatically registered by Spring's
6363
* {@code <jms:annotation-driven>} XML element, and also by the {@link EnableJms}
6464
* annotation.
6565
*
66-
* <p>Auto-detect any {@link JmsListenerConfigurer} instances in the container,
66+
* <p>Autodetects any {@link JmsListenerConfigurer} instances in the container,
6767
* allowing for customization of the registry to be used, the default container
68-
* factory or for fine-grained control over endpoints registration. See
69-
* {@link EnableJms} Javadoc for complete usage details.
68+
* factory or for fine-grained control over endpoints registration. See the
69+
* {@link EnableJms} javadocs for complete usage details.
7070
*
7171
* @author Stephane Nicoll
7272
* @author Juergen Hoeller
@@ -208,8 +208,8 @@ public void doWith(Method method) throws IllegalArgumentException, IllegalAccess
208208
});
209209
if (annotatedMethods.isEmpty()) {
210210
this.nonAnnotatedClasses.add(bean.getClass());
211-
if (logger.isDebugEnabled()) {
212-
logger.debug("No @JmsListener annotations found on bean class: " + bean.getClass());
211+
if (logger.isTraceEnabled()) {
212+
logger.trace("No @JmsListener annotations found on bean class: " + bean.getClass());
213213
}
214214
}
215215
else {
@@ -281,7 +281,7 @@ private String getEndpointId(JmsListener jmsListener) {
281281
return resolve(jmsListener.id());
282282
}
283283
else {
284-
return "org.springframework.jms.JmsListenerEndpointContainer#" + counter.getAndIncrement();
284+
return "org.springframework.jms.JmsListenerEndpointContainer#" + this.counter.getAndIncrement();
285285
}
286286
}
287287

spring-messaging/src/main/java/org/springframework/messaging/MessageHeaders.java

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public Object getErrorChannel() {
165165
return get(ERROR_CHANNEL);
166166
}
167167

168+
168169
@SuppressWarnings("unchecked")
169170
public <T> T get(Object key, Class<T> type) {
170171
Object value = this.headers.get(key);
@@ -179,23 +180,6 @@ public <T> T get(Object key, Class<T> type) {
179180
}
180181

181182

182-
@Override
183-
public boolean equals(Object other) {
184-
return (this == other ||
185-
(other instanceof MessageHeaders && this.headers.equals(((MessageHeaders) other).headers)));
186-
}
187-
188-
@Override
189-
public int hashCode() {
190-
return this.headers.hashCode();
191-
}
192-
193-
@Override
194-
public String toString() {
195-
return this.headers.toString();
196-
}
197-
198-
199183
// Delegating Map implementation
200184

201185
public boolean containsKey(Object key) {
@@ -275,11 +259,13 @@ private void writeObject(ObjectOutputStream out) throws IOException {
275259
keysToRemove.add(entry.getKey());
276260
}
277261
}
278-
for (String key : keysToRemove) {
279-
if (logger.isInfoEnabled()) {
280-
logger.info("Removing non-serializable header: " + key);
262+
if (!keysToRemove.isEmpty()) {
263+
if (logger.isDebugEnabled()) {
264+
logger.debug("Removing non-serializable message headers: " + keysToRemove);
265+
}
266+
for (String key : keysToRemove) {
267+
this.headers.remove(key);
281268
}
282-
this.headers.remove(key);
283269
}
284270
out.defaultWriteObject();
285271
}
@@ -288,4 +274,23 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
288274
in.defaultReadObject();
289275
}
290276

277+
278+
// equals, hashCode, toString
279+
280+
@Override
281+
public boolean equals(Object other) {
282+
return (this == other ||
283+
(other instanceof MessageHeaders && this.headers.equals(((MessageHeaders) other).headers)));
284+
}
285+
286+
@Override
287+
public int hashCode() {
288+
return this.headers.hashCode();
289+
}
290+
291+
@Override
292+
public String toString() {
293+
return this.headers.toString();
294+
}
295+
291296
}

0 commit comments

Comments
 (0)