|
|
@ -14,7 +14,7 @@
|
|
|
|
* limitations under the License.
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.developertools.remote.client;
|
|
|
|
package org.springframework.boot.devtools.remote.client;
|
|
|
|
|
|
|
|
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Arrays;
|
|
|
@ -33,20 +33,20 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
import org.springframework.boot.developertools.autoconfigure.DeveloperToolsProperties;
|
|
|
|
import org.springframework.boot.devtools.autoconfigure.DevToolsProperties;
|
|
|
|
import org.springframework.boot.developertools.autoconfigure.OptionalLiveReloadServer;
|
|
|
|
import org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer;
|
|
|
|
import org.springframework.boot.developertools.autoconfigure.RemoteDeveloperToolsProperties;
|
|
|
|
import org.springframework.boot.devtools.autoconfigure.RemoteDevToolsProperties;
|
|
|
|
import org.springframework.boot.developertools.classpath.ClassPathChangedEvent;
|
|
|
|
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
|
|
|
import org.springframework.boot.developertools.classpath.ClassPathFileSystemWatcher;
|
|
|
|
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
|
|
|
import org.springframework.boot.developertools.classpath.ClassPathRestartStrategy;
|
|
|
|
import org.springframework.boot.devtools.classpath.ClassPathRestartStrategy;
|
|
|
|
import org.springframework.boot.developertools.classpath.PatternClassPathRestartStrategy;
|
|
|
|
import org.springframework.boot.devtools.classpath.PatternClassPathRestartStrategy;
|
|
|
|
import org.springframework.boot.developertools.livereload.LiveReloadServer;
|
|
|
|
import org.springframework.boot.devtools.livereload.LiveReloadServer;
|
|
|
|
import org.springframework.boot.developertools.restart.DefaultRestartInitializer;
|
|
|
|
import org.springframework.boot.devtools.restart.DefaultRestartInitializer;
|
|
|
|
import org.springframework.boot.developertools.restart.RestartScope;
|
|
|
|
import org.springframework.boot.devtools.restart.RestartScope;
|
|
|
|
import org.springframework.boot.developertools.restart.Restarter;
|
|
|
|
import org.springframework.boot.devtools.restart.Restarter;
|
|
|
|
import org.springframework.boot.developertools.tunnel.client.HttpTunnelConnection;
|
|
|
|
import org.springframework.boot.devtools.tunnel.client.HttpTunnelConnection;
|
|
|
|
import org.springframework.boot.developertools.tunnel.client.TunnelClient;
|
|
|
|
import org.springframework.boot.devtools.tunnel.client.TunnelClient;
|
|
|
|
import org.springframework.boot.developertools.tunnel.client.TunnelConnection;
|
|
|
|
import org.springframework.boot.devtools.tunnel.client.TunnelConnection;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Conditional;
|
|
|
|
import org.springframework.context.annotation.Conditional;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
@ -63,16 +63,16 @@ import org.springframework.util.Assert;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author Phillip Webb
|
|
|
|
* @author Phillip Webb
|
|
|
|
* @since 1.3.0
|
|
|
|
* @since 1.3.0
|
|
|
|
* @see org.springframework.boot.developertools.RemoteSpringApplication
|
|
|
|
* @see org.springframework.boot.devtools.RemoteSpringApplication
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
|
@EnableConfigurationProperties(DeveloperToolsProperties.class)
|
|
|
|
@EnableConfigurationProperties(DevToolsProperties.class)
|
|
|
|
public class RemoteClientConfiguration {
|
|
|
|
public class RemoteClientConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(RemoteClientConfiguration.class);
|
|
|
|
private static final Log logger = LogFactory.getLog(RemoteClientConfiguration.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private DeveloperToolsProperties properties;
|
|
|
|
private DevToolsProperties properties;
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${remoteUrl}")
|
|
|
|
@Value("${remoteUrl}")
|
|
|
|
private String remoteUrl;
|
|
|
|
private String remoteUrl;
|
|
|
@ -91,18 +91,18 @@ public class RemoteClientConfiguration {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ClientHttpRequestInterceptor getSecurityInterceptor() {
|
|
|
|
private ClientHttpRequestInterceptor getSecurityInterceptor() {
|
|
|
|
RemoteDeveloperToolsProperties remoteProperties = this.properties.getRemote();
|
|
|
|
RemoteDevToolsProperties remoteProperties = this.properties.getRemote();
|
|
|
|
String secretHeaderName = remoteProperties.getSecretHeaderName();
|
|
|
|
String secretHeaderName = remoteProperties.getSecretHeaderName();
|
|
|
|
String secret = remoteProperties.getSecret();
|
|
|
|
String secret = remoteProperties.getSecret();
|
|
|
|
Assert.state(secret != null,
|
|
|
|
Assert.state(secret != null,
|
|
|
|
"The environment value 'spring.developertools.remote.secret' "
|
|
|
|
"The environment value 'spring.devtools.remote.secret' "
|
|
|
|
+ "is required to secure your connection.");
|
|
|
|
+ "is required to secure your connection.");
|
|
|
|
return new HttpHeaderInterceptor(secretHeaderName, secret);
|
|
|
|
return new HttpHeaderInterceptor(secretHeaderName, secret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
@PostConstruct
|
|
|
|
private void logWarnings() {
|
|
|
|
private void logWarnings() {
|
|
|
|
RemoteDeveloperToolsProperties remoteProperties = this.properties.getRemote();
|
|
|
|
RemoteDevToolsProperties remoteProperties = this.properties.getRemote();
|
|
|
|
if (!remoteProperties.getDebug().isEnabled()
|
|
|
|
if (!remoteProperties.getDebug().isEnabled()
|
|
|
|
&& !remoteProperties.getRestart().isEnabled()) {
|
|
|
|
&& !remoteProperties.getRestart().isEnabled()) {
|
|
|
|
logger.warn("Remote restart and debug are both disabled.");
|
|
|
|
logger.warn("Remote restart and debug are both disabled.");
|
|
|
@ -116,11 +116,11 @@ public class RemoteClientConfiguration {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* LiveReload configuration.
|
|
|
|
* LiveReload configuration.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ConditionalOnProperty(prefix = "spring.developertools.livereload", name = "enabled", matchIfMissing = true)
|
|
|
|
@ConditionalOnProperty(prefix = "spring.devtools.livereload", name = "enabled", matchIfMissing = true)
|
|
|
|
static class LiveReloadConfiguration {
|
|
|
|
static class LiveReloadConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private DeveloperToolsProperties properties;
|
|
|
|
private DevToolsProperties properties;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired(required = false)
|
|
|
|
@Autowired(required = false)
|
|
|
|
private LiveReloadServer liveReloadServer;
|
|
|
|
private LiveReloadServer liveReloadServer;
|
|
|
@ -162,11 +162,11 @@ public class RemoteClientConfiguration {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Client configuration for remote update and restarts.
|
|
|
|
* Client configuration for remote update and restarts.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ConditionalOnProperty(prefix = "spring.developertools.remote.restart", name = "enabled", matchIfMissing = true)
|
|
|
|
@ConditionalOnProperty(prefix = "spring.devtools.remote.restart", name = "enabled", matchIfMissing = true)
|
|
|
|
static class RemoteRestartClientConfiguration {
|
|
|
|
static class RemoteRestartClientConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private DeveloperToolsProperties properties;
|
|
|
|
private DevToolsProperties properties;
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${remoteUrl}")
|
|
|
|
@Value("${remoteUrl}")
|
|
|
|
private String remoteUrl;
|
|
|
|
private String remoteUrl;
|
|
|
@ -200,13 +200,13 @@ public class RemoteClientConfiguration {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Client configuration for remote debug HTTP tunneling.
|
|
|
|
* Client configuration for remote debug HTTP tunneling.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@ConditionalOnProperty(prefix = "spring.developertools.remote.debug", name = "enabled", matchIfMissing = true)
|
|
|
|
@ConditionalOnProperty(prefix = "spring.devtools.remote.debug", name = "enabled", matchIfMissing = true)
|
|
|
|
@ConditionalOnClass(Filter.class)
|
|
|
|
@ConditionalOnClass(Filter.class)
|
|
|
|
@Conditional(LocalDebugPortAvailableCondition.class)
|
|
|
|
@Conditional(LocalDebugPortAvailableCondition.class)
|
|
|
|
static class RemoteDebugTunnelClientConfiguration {
|
|
|
|
static class RemoteDebugTunnelClientConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private DeveloperToolsProperties properties;
|
|
|
|
private DevToolsProperties properties;
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${remoteUrl}")
|
|
|
|
@Value("${remoteUrl}")
|
|
|
|
private String remoteUrl;
|
|
|
|
private String remoteUrl;
|
|
|
@ -214,7 +214,7 @@ public class RemoteClientConfiguration {
|
|
|
|
@Bean
|
|
|
|
@Bean
|
|
|
|
public TunnelClient remoteDebugTunnelClient(
|
|
|
|
public TunnelClient remoteDebugTunnelClient(
|
|
|
|
ClientHttpRequestFactory requestFactory) {
|
|
|
|
ClientHttpRequestFactory requestFactory) {
|
|
|
|
RemoteDeveloperToolsProperties remoteProperties = this.properties.getRemote();
|
|
|
|
RemoteDevToolsProperties remoteProperties = this.properties.getRemote();
|
|
|
|
String url = this.remoteUrl + remoteProperties.getContextPath() + "/debug";
|
|
|
|
String url = this.remoteUrl + remoteProperties.getContextPath() + "/debug";
|
|
|
|
TunnelConnection connection = new HttpTunnelConnection(url, requestFactory);
|
|
|
|
TunnelConnection connection = new HttpTunnelConnection(url, requestFactory);
|
|
|
|
int localPort = remoteProperties.getDebug().getLocalPort();
|
|
|
|
int localPort = remoteProperties.getDebug().getLocalPort();
|