Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import java.util.Set;

/**
* Utility to deduce if Devtools should be enabled in the current context.
* Utility to deduce if DevTools should be enabled in the current context.
*
* @author Madhura Bhave
* @since 2.2.0
*/
public final class DevtoolsEnablementDeducer {
public final class DevToolsEnablementDeducer {

private static final Set<String> SKIPPED_STACK_ELEMENTS;

Expand All @@ -38,7 +39,7 @@ public final class DevtoolsEnablementDeducer {
SKIPPED_STACK_ELEMENTS = Collections.unmodifiableSet(skipped);
}

private DevtoolsEnablementDeducer() {
private DevToolsEnablementDeducer() {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* @since 1.3.3
*/
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
@Conditional({ OnEnabledDevtoolsCondition.class, DevToolsDataSourceCondition.class })
@Conditional({ OnEnabledDevToolsCondition.class, DevToolsDataSourceCondition.class })
@Configuration(proxyBeanMethods = false)
public class DevToolsDataSourceAutoConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,23 @@
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
import org.springframework.boot.devtools.DevToolsEnablementDeducer;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
* A condition that checks if DevTools should be enabled.
*
* @author Madhura Bhave
* @since 2.2.0
*/
public class OnEnabledDevtoolsCondition extends SpringBootCondition {
public class OnEnabledDevToolsCondition extends SpringBootCondition {

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
AnnotatedTypeMetadata metadata) {
ConditionMessage.Builder message = ConditionMessage.forCondition("Devtools");
boolean shouldEnable = DevtoolsEnablementDeducer
boolean shouldEnable = DevToolsEnablementDeducer
.shouldEnable(Thread.currentThread());
if (!shouldEnable) {
return ConditionOutcome.noMatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* @since 1.3.0
*/
@Configuration(proxyBeanMethods = false)
@Conditional(OnEnabledDevtoolsCondition.class)
@Conditional(OnEnabledDevToolsCondition.class)
@ConditionalOnProperty(prefix = "spring.devtools.remote", name = "secret")
@ConditionalOnClass({ Filter.class, ServerHttpRequest.class })
@EnableConfigurationProperties({ ServerProperties.class, DevToolsProperties.class })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Properties;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
import org.springframework.boot.devtools.DevToolsEnablementDeducer;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.PropertiesPropertySource;
Expand All @@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
if (DevtoolsEnablementDeducer.shouldEnable(Thread.currentThread())) {
if (DevToolsEnablementDeducer.shouldEnable(Thread.currentThread())) {
File home = getHomeFolder();
File propertyFile = (home != null) ? new File(home, FILE_NAME) : null;
if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
import org.springframework.boot.devtools.DevToolsEnablementDeducer;
import org.springframework.boot.devtools.logger.DevToolsLogFactory;
import org.springframework.boot.devtools.restart.Restarter;
import org.springframework.boot.env.EnvironmentPostProcessor;
Expand Down Expand Up @@ -80,7 +80,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
if (DevtoolsEnablementDeducer.shouldEnable(Thread.currentThread())
if (DevToolsEnablementDeducer.shouldEnable(Thread.currentThread())
&& isLocalApplication(environment)) {
if (canAddProperties(environment)) {
logger.info("Devtools property defaults active! Set '" + ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.net.URL;

import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
import org.springframework.boot.devtools.DevToolsEnablementDeducer;

/**
* Default {@link RestartInitializer} that only enable initial restart when running a
Expand All @@ -36,7 +36,7 @@ public URL[] getInitialUrls(Thread thread) {
if (!isMain(thread)) {
return null;
}
if (!DevtoolsEnablementDeducer.shouldEnable(thread)) {
if (!DevToolsEnablementDeducer.shouldEnable(thread)) {
return null;
}
return getUrls(thread);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
import static org.assertj.core.api.Assertions.assertThat;

/**
* Tests for {@link OnEnabledDevtoolsCondition}.
* Tests for {@link OnEnabledDevToolsCondition}.
*
* @author Madhura Bhave
*/
public class OnEnabledDevtoolsConditionTests {
public class OnEnabledDevToolsConditionTests {

private AnnotationConfigApplicationContext context;

Expand All @@ -44,8 +44,8 @@ public void setup() {
@Test
public void outcomeWhenDevtoolsShouldBeEnabledIsTrueShouldMatch() throws Exception {
Thread thread = new Thread(() -> {
OnEnabledDevtoolsConditionTests.this.context.refresh();
assertThat(OnEnabledDevtoolsConditionTests.this.context.containsBean("test"))
OnEnabledDevToolsConditionTests.this.context.refresh();
assertThat(OnEnabledDevToolsConditionTests.this.context.containsBean("test"))
.isTrue();
});
thread.start();
Expand All @@ -54,16 +54,16 @@ public void outcomeWhenDevtoolsShouldBeEnabledIsTrueShouldMatch() throws Excepti

@Test
public void outcomeWhenDevtoolsShouldBeEnabledIsFalseShouldNotMatch() {
OnEnabledDevtoolsConditionTests.this.context.refresh();
assertThat(OnEnabledDevtoolsConditionTests.this.context.containsBean("test"))
OnEnabledDevToolsConditionTests.this.context.refresh();
assertThat(OnEnabledDevToolsConditionTests.this.context.containsBean("test"))
.isFalse();
}

@Configuration(proxyBeanMethods = false)
static class TestConfiguration {

@Bean
@Conditional(OnEnabledDevtoolsCondition.class)
@Conditional(OnEnabledDevToolsCondition.class)
public String test() {
return "hello";
}
Expand Down