Add more beans to AbstractShellComponent

- Add more common stuff like ResourceLoader, TemplateExecutor,
  ThemeResolver.
- Make class abstract.
- Expose more with sub-classes.
This commit is contained in:
Janne Valkealahti
2022-02-18 13:07:08 +00:00
parent 544e4aee1d
commit 5ff98290e9
4 changed files with 49 additions and 39 deletions

View File

@@ -17,7 +17,6 @@ package org.springframework.shell.standard.commands;
import java.util.stream.Collectors;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.ResourceLoader;
import org.springframework.shell.standard.AbstractShellComponent;
import org.springframework.shell.standard.ShellComponent;
@@ -30,7 +29,7 @@ import org.springframework.shell.standard.completion.BashCompletions;
* @author Janne Valkealahti
*/
@ShellComponent
public class Completion extends AbstractShellComponent implements ResourceLoaderAware {
public class Completion extends AbstractShellComponent {
/**
* Marker interface used in auto-config.

View File

@@ -27,7 +27,6 @@ import org.jline.utils.AttributedString;
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.info.GitProperties;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.shell.standard.AbstractShellComponent;
@@ -43,7 +42,7 @@ import org.springframework.util.StringUtils;
* @author Janne Valkealahti
*/
@ShellComponent
public class Version extends AbstractShellComponent implements ResourceLoaderAware {
public class Version extends AbstractShellComponent {
/**
* Marker interface used in auto-config.
@@ -70,11 +69,6 @@ public class Version extends AbstractShellComponent implements ResourceLoaderAwa
this.templateExecutor = templateExecutor;
}
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
@ShellMethod(key = "version", value = "Show version info")
public AttributedString version() {
String templateResource = resourceAsString(resourceLoader.getResource(template));