Skip to content

Commit 1f6ab1a

Browse files
committed
Polishing
1 parent ce5869e commit 1f6ab1a

File tree

2 files changed

+35
-37
lines changed
  • spring-context/src/main/java/org/springframework/scheduling/annotation
  • spring-webmvc/src/main/java/org/springframework/web/servlet/function

2 files changed

+35
-37
lines changed

spring-context/src/main/java/org/springframework/scheduling/annotation/Scheduled.java

+21-21
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,27 @@
126126
*/
127127
String zone() default "";
128128

129+
/**
130+
* Execute the annotated method with a fixed period between invocations.
131+
* <p>The time unit is milliseconds by default but can be overridden via
132+
* {@link #timeUnit}.
133+
* @return the period
134+
*/
135+
long fixedRate() default -1;
136+
137+
/**
138+
* Execute the annotated method with a fixed period between invocations.
139+
* <p>The time unit is milliseconds by default but can be overridden via
140+
* {@link #timeUnit}.
141+
* <p>This attribute variant supports Spring-style "${...}" placeholders
142+
* as well as SpEL expressions.
143+
* @return the period as a String value &mdash; for example, a placeholder
144+
* or a {@link java.time.Duration#parse java.time.Duration} compliant value
145+
* @since 3.2.2
146+
* @see #fixedRate()
147+
*/
148+
String fixedRateString() default "";
149+
129150
/**
130151
* Execute the annotated method with a fixed period between the end of the
131152
* last invocation and the start of the next.
@@ -155,27 +176,6 @@
155176
*/
156177
String fixedDelayString() default "";
157178

158-
/**
159-
* Execute the annotated method with a fixed period between invocations.
160-
* <p>The time unit is milliseconds by default but can be overridden via
161-
* {@link #timeUnit}.
162-
* @return the period
163-
*/
164-
long fixedRate() default -1;
165-
166-
/**
167-
* Execute the annotated method with a fixed period between invocations.
168-
* <p>The time unit is milliseconds by default but can be overridden via
169-
* {@link #timeUnit}.
170-
* <p>This attribute variant supports Spring-style "${...}" placeholders
171-
* as well as SpEL expressions.
172-
* @return the period as a String value &mdash; for example, a placeholder
173-
* or a {@link java.time.Duration#parse java.time.Duration} compliant value
174-
* @since 3.2.2
175-
* @see #fixedRate()
176-
*/
177-
String fixedRateString() default "";
178-
179179
/**
180180
* Number of units of time to delay before the first execution of a
181181
* {@link #fixedRate} or {@link #fixedDelay} task.

spring-webmvc/src/main/java/org/springframework/web/servlet/function/RouterFunctions.java

+14-16
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public static RouterFunction<ServerResponse> resource(RequestPredicate predicate
160160
*/
161161
public static RouterFunction<ServerResponse> resource(RequestPredicate predicate, Resource resource,
162162
BiConsumer<Resource, HttpHeaders> headersConsumer) {
163+
163164
return resources(new PredicateResourceLookupFunction(predicate, resource), headersConsumer);
164165
}
165166

@@ -197,6 +198,7 @@ public static RouterFunction<ServerResponse> resources(String pattern, Resource
197198
*/
198199
public static RouterFunction<ServerResponse> resources(String pattern, Resource location,
199200
BiConsumer<Resource, HttpHeaders> headersConsumer) {
201+
200202
return resources(resourceLookupFunction(pattern, location), headersConsumer);
201203
}
202204

@@ -240,7 +242,9 @@ public static RouterFunction<ServerResponse> resources(Function<ServerRequest, O
240242
* @return a router function that routes to resources
241243
* @since 6.1
242244
*/
243-
public static RouterFunction<ServerResponse> resources(Function<ServerRequest, Optional<Resource>> lookupFunction, BiConsumer<Resource, HttpHeaders> headersConsumer) {
245+
public static RouterFunction<ServerResponse> resources(Function<ServerRequest, Optional<Resource>> lookupFunction,
246+
BiConsumer<Resource, HttpHeaders> headersConsumer) {
247+
244248
return new ResourcesRouterFunction(lookupFunction, headersConsumer);
245249
}
246250

@@ -250,12 +254,12 @@ public static RouterFunction<ServerResponse> resources(Function<ServerRequest, O
250254
* can be used to change the {@code PathPatternParser} properties from the defaults, for instance to change
251255
* {@linkplain PathPatternParser#setCaseSensitive(boolean) case sensitivity}.
252256
* @param routerFunction the router function to change the parser in
253-
* @param parser the parser to change to.
257+
* @param parser the parser to change to
254258
* @param <T> the type of response returned by the handler function
255259
* @return the change router function
256260
*/
257-
public static <T extends ServerResponse> RouterFunction<T> changeParser(RouterFunction<T> routerFunction,
258-
PathPatternParser parser) {
261+
public static <T extends ServerResponse> RouterFunction<T> changeParser(
262+
RouterFunction<T> routerFunction, PathPatternParser parser) {
259263

260264
Assert.notNull(routerFunction, "RouterFunction must not be null");
261265
Assert.notNull(parser, "Parser must not be null");
@@ -1151,7 +1155,6 @@ public Optional<HandlerFunction<T>> route(ServerRequest request) {
11511155
public void accept(Visitor visitor) {
11521156
visitor.route(this.predicate, this.handlerFunction);
11531157
}
1154-
11551158
}
11561159

11571160

@@ -1173,13 +1176,10 @@ public Optional<HandlerFunction<T>> route(ServerRequest serverRequest) {
11731176
return this.predicate.nest(serverRequest)
11741177
.map(nestedRequest -> {
11751178
if (logger.isTraceEnabled()) {
1176-
logger.trace(
1177-
String.format(
1178-
"Nested predicate \"%s\" matches against \"%s\"",
1179-
this.predicate, serverRequest));
1179+
logger.trace(String.format("Nested predicate \"%s\" matches against \"%s\"",
1180+
this.predicate, serverRequest));
11801181
}
1181-
Optional<HandlerFunction<T>> result =
1182-
this.routerFunction.route(nestedRequest);
1182+
Optional<HandlerFunction<T>> result = this.routerFunction.route(nestedRequest);
11831183
if (result.isPresent() && nestedRequest != serverRequest) {
11841184
serverRequest.attributes().clear();
11851185
serverRequest.attributes().putAll(nestedRequest.attributes());
@@ -1197,7 +1197,6 @@ public void accept(Visitor visitor) {
11971197
this.routerFunction.accept(visitor);
11981198
visitor.endNested(this.predicate);
11991199
}
1200-
12011200
}
12021201

12031202

@@ -1207,11 +1206,11 @@ private static class ResourcesRouterFunction extends AbstractRouterFunction<Serv
12071206

12081207
private final BiConsumer<Resource, HttpHeaders> headersConsumer;
12091208

1210-
12111209
public ResourcesRouterFunction(Function<ServerRequest, Optional<Resource>> lookupFunction,
12121210
BiConsumer<Resource, HttpHeaders> headersConsumer) {
1213-
Assert.notNull(lookupFunction, "Function must not be null");
1214-
Assert.notNull(headersConsumer, "HeadersConsumer must not be null");
1211+
1212+
Assert.notNull(lookupFunction, "Lookup function must not be null");
1213+
Assert.notNull(headersConsumer, "Headers consumer must not be null");
12151214
this.lookupFunction = lookupFunction;
12161215
this.headersConsumer = headersConsumer;
12171216
}
@@ -1279,5 +1278,4 @@ public RouterFunction<T> withAttributes(Consumer<Map<String, Object>> attributes
12791278
}
12801279
}
12811280

1282-
12831281
}

0 commit comments

Comments
 (0)