SmartLifecycle default methods for auto-startup in default phase

Issue: SPR-17188
This commit is contained in:
Juergen Hoeller
2018-08-16 12:08:02 +02:00
parent 446a604ad0
commit 2ec8fa9cac
15 changed files with 97 additions and 144 deletions

View File

@@ -42,7 +42,7 @@ public abstract class ConnectionManagerSupport implements SmartLifecycle {
private boolean autoStartup = false;
private int phase = Integer.MAX_VALUE;
private int phase = DEFAULT_PHASE;
private volatile boolean running = false;

View File

@@ -254,16 +254,6 @@ public class SubProtocolWebSocketHandler
}
@Override
public boolean isAutoStartup() {
return true;
}
@Override
public int getPhase() {
return Integer.MAX_VALUE;
}
@Override
public final void start() {
Assert.isTrue(this.defaultProtocolHandler != null || !this.protocolHandlers.isEmpty(), "No handlers");

View File

@@ -79,7 +79,7 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
private boolean autoStartup = true;
private int phase = Integer.MAX_VALUE;
private int phase = DEFAULT_PHASE;
private volatile boolean running = false;
@@ -194,12 +194,6 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
}
}
@Override
public void stop(Runnable callback) {
stop();
callback.run();
}
@Override
public boolean isRunning() {
return this.running;
@@ -396,7 +390,10 @@ public class WebSocketStompClient extends StompClientSupport implements SmartLif
}
private void updateLastWriteTime() {
this.lastWriteTime = (this.lastWriteTime != -1 ? System.currentTimeMillis() : -1);
long lastWriteTime = this.lastWriteTime;
if (lastWriteTime != -1) {
this.lastWriteTime = System.currentTimeMillis();
}
}
@Override

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.
@@ -46,15 +46,6 @@ public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements
}
}
@Override
public boolean isAutoStartup() {
return true;
}
@Override
public int getPhase() {
return Integer.MAX_VALUE;
}
@Override
public void start() {
@@ -80,12 +71,6 @@ public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements
}
}
@Override
public void stop(Runnable callback) {
stop();
callback.run();
}
@Override
public boolean isRunning() {
return this.running;