diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java index 640c3fb2..c2931481 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/SpringShellSample.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2021 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. @@ -21,7 +21,6 @@ import org.jline.utils.AttributedStyle; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.shell.jline.PromptProvider; @@ -36,7 +35,7 @@ import org.springframework.shell.jline.PromptProvider; public class SpringShellSample { public static void main(String[] args) throws Exception { - ConfigurableApplicationContext context = SpringApplication.run(SpringShellSample.class, args); + SpringApplication.run(SpringShellSample.class, args); } @Bean diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java index 9128d471..0d3cc367 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/noautoconf/NoAutoConf.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2021 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. @@ -17,7 +17,6 @@ package org.springframework.shell.samples.noautoconf; import org.springframework.boot.SpringApplication; -import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; import org.springframework.shell.SpringShellAutoConfiguration; @@ -58,7 +57,7 @@ import org.springframework.shell.standard.commands.StandardCommandsAutoConfigura public class NoAutoConf { public static void main(String[] args) { - ConfigurableApplicationContext context = SpringApplication.run(NoAutoConf.class, args); + SpringApplication.run(NoAutoConf.class, args); } } diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/ConversionExample.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/ConversionExample.java index 51c32c16..86dbe2c5 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/ConversionExample.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/ConversionExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2021 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. @@ -37,6 +37,10 @@ class DomainObject { DomainObject(String value) { this.value = value; } + + public String getValue() { + return value; + } } @Component diff --git a/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/DynamicCommands.java b/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/DynamicCommands.java index b483b9a0..494210d6 100644 --- a/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/DynamicCommands.java +++ b/spring-shell-samples/src/main/java/org/springframework/shell/samples/standard/DynamicCommands.java @@ -1,5 +1,5 @@ /* - * Copyright 2017 the original author or authors. + * Copyright 2017-2021 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. @@ -31,15 +31,12 @@ public class DynamicCommands { private boolean connected; - private boolean authenticated; - public Availability authenticateAvailability() { return connected ? Availability.available() : Availability.unavailable("you are not connected"); } @ShellMethod(value = "Authenticate with the system", group = "Dynamic Commands") public void authenticate(String credentials) { - authenticated = "sesame".equals(credentials); } @ShellMethod(value = "Connect to the system", group = "Dynamic Commands") @@ -57,8 +54,4 @@ public class DynamicCommands { public String blowUp() { return "Boom!"; } - - private Availability dangerousAvailability() { - return connected && authenticated ? Availability.available() : Availability.unavailable("you failed to authenticate. Try 'sesame'."); - } } diff --git a/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java b/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java index 3f567b41..b50acab4 100644 --- a/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java +++ b/spring-shell-standard/src/main/java/org/springframework/shell/standard/StandardParameterResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2017 the original author or authors. + * Copyright 2015-2021 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. @@ -16,8 +16,6 @@ package org.springframework.shell.standard; -import static org.springframework.shell.Utils.unCamelify; - import java.lang.reflect.Array; import java.lang.reflect.Executable; import java.lang.reflect.Method; @@ -37,6 +35,12 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; +import javax.validation.metadata.MethodDescriptor; +import javax.validation.metadata.ParameterDescriptor; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.MethodParameter; import org.springframework.core.convert.ConversionService; @@ -54,9 +58,7 @@ import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; import org.springframework.util.ObjectUtils; -import javax.validation.*; -import javax.validation.metadata.MethodDescriptor; -import javax.validation.metadata.ParameterDescriptor; +import static org.springframework.shell.Utils.unCamelify; /** * Default ParameterResolver implementation that supports the following features: @@ -129,8 +131,6 @@ public class StandardParameterResolver implements ParameterResolver { @Override public ValueResult resolve(MethodParameter methodParameter, List wordsBuffer) { - String prefix = prefixForMethod(methodParameter.getMethod()); - List words = wordsBuffer.stream().filter(w -> !w.isEmpty()).collect(Collectors.toList()); CacheKey cacheKey = new CacheKey(methodParameter.getMethod(), wordsBuffer); @@ -526,14 +526,10 @@ public class StandardParameterResolver implements ParameterResolver { private static class ParameterRawValue { - private CompletionContext context; - private Integer from; private Integer to; - private Integer keyIndex; - /** * The raw String value that got bound to a parameter. */