diff --git a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/MyHistoryFileProvider.java b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/MyHistoryFileNameProvider.java similarity index 86% rename from samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/MyHistoryFileProvider.java rename to samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/MyHistoryFileNameProvider.java index 9450ccf3..d537dd74 100644 --- a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/MyHistoryFileProvider.java +++ b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/MyHistoryFileNameProvider.java @@ -16,7 +16,7 @@ package org.springframework.shell.samples.helloworld.commands; -import org.springframework.shell.plugin.HistoryFileProvider; +import org.springframework.shell.plugin.HistoryFileNameProvider; import org.springframework.stereotype.Component; /** @@ -25,7 +25,7 @@ import org.springframework.stereotype.Component; * */ @Component -public class MyHistoryFileProvider implements HistoryFileProvider { +public class MyHistoryFileNameProvider implements HistoryFileNameProvider { public int getOrder() { return 1; diff --git a/samples/helloworld/src/main/resources/spring-shell-beans.xml b/samples/helloworld/src/main/resources/META-INF/spring/spring-shell-plugin.xml similarity index 100% rename from samples/helloworld/src/main/resources/spring-shell-beans.xml rename to samples/helloworld/src/main/resources/META-INF/spring/spring-shell-plugin.xml diff --git a/src/main/java/org/springframework/roo/shell/AbstractShell.java b/src/main/java/org/springframework/roo/shell/AbstractShell.java index 91a52afb..8af845e2 100644 --- a/src/main/java/org/springframework/roo/shell/AbstractShell.java +++ b/src/main/java/org/springframework/roo/shell/AbstractShell.java @@ -332,7 +332,7 @@ public abstract class AbstractShell extends AbstractShellStatusPublisher impleme return DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()); } - @CliCommand(value = { "flash test" }, help = "Tests message flashing") + //@CliCommand(value = { "flash test" }, help = "Tests message flashing") public void flashCustom() throws Exception { flash(Level.FINE, "Hello world", "a"); Thread.sleep(150); @@ -357,7 +357,7 @@ public abstract class AbstractShell extends AbstractShellStatusPublisher impleme flash(Level.FINE, "", "b"); } - @CliCommand(value = { "version" }, help = "Displays shell version") + //@CliCommand(value = { "version" }, help = "Displays shell version") public String version(@CliOption(key = "", help = "Special version flags") final String extra) { StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/org/springframework/shell/Bootstrap.java b/src/main/java/org/springframework/shell/Bootstrap.java index fa8bbb22..73461f22 100644 --- a/src/main/java/org/springframework/shell/Bootstrap.java +++ b/src/main/java/org/springframework/shell/Bootstrap.java @@ -148,7 +148,7 @@ public class Bootstrap { * @return new ApplicationContext in the plugin with core spring shell's context as parent */ private ConfigurableApplicationContext initPluginApplicationContext(AnnotationConfigApplicationContext annctx) { - ClassPathXmlApplicationContext subContext = new ClassPathXmlApplicationContext("spring-shell-beans.xml"); + ClassPathXmlApplicationContext subContext = new ClassPathXmlApplicationContext("classpath*:/META-INF/spring/spring-shell-plugin.xml"); subContext.setParent(annctx); return subContext; } @@ -189,7 +189,6 @@ public class Bootstrap { exitShellRequest = ExitShellRequest.NORMAL_EXIT; } } else { - //shell.promptLoop(); exitShellRequest = shell.getExitShellRequest(); if (exitShellRequest == null) { // shouldn't really happen, but we'll fallback to this anyway diff --git a/src/main/java/org/springframework/shell/JLineShell.java b/src/main/java/org/springframework/shell/JLineShell.java index c66a00b7..49492333 100644 --- a/src/main/java/org/springframework/shell/JLineShell.java +++ b/src/main/java/org/springframework/shell/JLineShell.java @@ -10,7 +10,6 @@ import java.io.PrintStream; import java.io.PrintWriter; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -42,7 +41,7 @@ import org.springframework.roo.support.util.IOUtils; import org.springframework.roo.support.util.OsUtils; import org.springframework.roo.support.util.StringUtils; import org.springframework.shell.plugin.BannerProvider; -import org.springframework.shell.plugin.HistoryFileProvider; +import org.springframework.shell.plugin.HistoryFileNameProvider; import org.springframework.shell.plugin.PromptProvider; @@ -59,7 +58,8 @@ import org.springframework.shell.plugin.PromptProvider; * @author Jarred Li * @since 1.0 */ -public abstract class JLineShell extends AbstractShell implements CommandMarker, Shell, Runnable { +public abstract class JLineShell extends AbstractShell + implements CommandMarker, Shell, Runnable { // Constants private static final String ANSI_CONSOLE_CLASSNAME = "org.fusesource.jansi.AnsiConsole"; @@ -528,6 +528,7 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, this.applicatonContext = applicationContext; } + /** * get history file name from provider. The provider has highest order * org.springframework.core.Ordered.getOder will win. @@ -536,15 +537,14 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, */ private String getHistoryFileName() { String historyFileName = null; - Map historyFileProviders = getBeansInFactory(HistoryFileProvider.class); + Map historyFileProviders = getBeansInFactory(HistoryFileNameProvider.class); int order = Integer.MIN_VALUE; - for(HistoryFileProvider p : historyFileProviders.values()){ + for(HistoryFileNameProvider p : historyFileProviders.values()){ if(p.getOrder() > order){ order = p.getOrder(); historyFileName = p.getHistoryFileName(); } } - historyFileName = (historyFileName == null)?Constant.HISTORY_FILE_NAME:historyFileName; return historyFileName; } @@ -564,7 +564,6 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, promptText = p.getPromptText(); } } - promptText = (promptText == null)?Constant.COMMAND_LINE_PROMPT:promptText; return promptText; } @@ -585,8 +584,6 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, bannerText[1] = p.getWelcomMessage(); } } - bannerText[0] = (bannerText[0] == null)?Constant.COMMAND_LINE_PROMPT:bannerText[0]; - bannerText[1] = (bannerText[1] == null)?Constant.WELCOME_MESSAGE:bannerText[1]; return bannerText; } diff --git a/src/main/java/org/springframework/shell/JLineShellComponent.java b/src/main/java/org/springframework/shell/JLineShellComponent.java index 880f3a08..8b0d1394 100644 --- a/src/main/java/org/springframework/shell/JLineShellComponent.java +++ b/src/main/java/org/springframework/shell/JLineShellComponent.java @@ -1,13 +1,9 @@ package org.springframework.shell; -import static org.springframework.roo.support.util.StringUtils.LINE_SEPARATOR; - import java.net.URL; import java.util.Collection; import org.springframework.context.Lifecycle; -import org.springframework.roo.shell.CliCommand; -import org.springframework.roo.shell.CliOption; import org.springframework.roo.shell.ExecutionStrategy; import org.springframework.roo.shell.Parser; import org.springframework.roo.shell.SimpleParser; diff --git a/src/main/java/org/springframework/shell/commands/HintCommands.java b/src/main/java/org/springframework/shell/commands/HintCommands.java index 1d5dea07..ef33deb4 100644 --- a/src/main/java/org/springframework/shell/commands/HintCommands.java +++ b/src/main/java/org/springframework/shell/commands/HintCommands.java @@ -12,7 +12,8 @@ public class HintCommands implements CommandMarker { // Fields @Autowired private HintOperations hintOperations; - @CliCommand(value = "hint", help = "Provides step-by-step hints and context-sensitive guidance") + //TODO: figure out how to provide hint + //@CliCommand(value = "hint", help = "Provides step-by-step hints and context-sensitive guidance") public String hint( @CliOption(key = { "topic", "" }, mandatory = false, unspecifiedDefaultValue = "", optionContext = "disable-string-converter,topics", help = "The topic for which advice should be provided") final String topic) { diff --git a/src/main/java/org/springframework/shell/plugin/HistoryFileProvider.java b/src/main/java/org/springframework/shell/plugin/HistoryFileNameProvider.java similarity index 94% rename from src/main/java/org/springframework/shell/plugin/HistoryFileProvider.java rename to src/main/java/org/springframework/shell/plugin/HistoryFileNameProvider.java index b4489581..1454eb1c 100644 --- a/src/main/java/org/springframework/shell/plugin/HistoryFileProvider.java +++ b/src/main/java/org/springframework/shell/plugin/HistoryFileNameProvider.java @@ -25,7 +25,7 @@ import org.springframework.core.Ordered; * @since 1.0 * */ -public interface HistoryFileProvider extends Ordered{ +public interface HistoryFileNameProvider extends Ordered{ /** * get history file name diff --git a/src/main/java/org/springframework/shell/plugin/support/DefaultBannerProvider.java b/src/main/java/org/springframework/shell/plugin/support/DefaultBannerProvider.java index f56ff649..62d9b1f2 100644 --- a/src/main/java/org/springframework/shell/plugin/support/DefaultBannerProvider.java +++ b/src/main/java/org/springframework/shell/plugin/support/DefaultBannerProvider.java @@ -43,7 +43,7 @@ public class DefaultBannerProvider implements BannerProvider, CommandMarker { /* (non-Javadoc) * @see org.springframework.shell.plugin.BannerProvider#getBanner() */ - @CliCommand(value = { "shell-version" }, help = "Displays shell version") + //@CliCommand(value = { "shell-version" }, help = "Displays shell version") public String getBanner() { StringBuilder sb = new StringBuilder(); sb.append(" _____ _ ").append(LINE_SEPARATOR); diff --git a/src/main/java/org/springframework/shell/plugin/support/DefaultHistoryFileProvider.java b/src/main/java/org/springframework/shell/plugin/support/DefaultHistoryFileNameProvider.java similarity index 89% rename from src/main/java/org/springframework/shell/plugin/support/DefaultHistoryFileProvider.java rename to src/main/java/org/springframework/shell/plugin/support/DefaultHistoryFileNameProvider.java index 08d1112e..8d56aeb1 100644 --- a/src/main/java/org/springframework/shell/plugin/support/DefaultHistoryFileProvider.java +++ b/src/main/java/org/springframework/shell/plugin/support/DefaultHistoryFileNameProvider.java @@ -16,7 +16,7 @@ package org.springframework.shell.plugin.support; import org.springframework.shell.Constant; -import org.springframework.shell.plugin.HistoryFileProvider; +import org.springframework.shell.plugin.HistoryFileNameProvider; import org.springframework.stereotype.Component; /** @@ -26,7 +26,7 @@ import org.springframework.stereotype.Component; * */ @Component -public class DefaultHistoryFileProvider implements HistoryFileProvider{ +public class DefaultHistoryFileNameProvider implements HistoryFileNameProvider{ /* (non-Javadoc) * @see org.springframework.core.Ordered#getOrder() diff --git a/src/test/java/org/springframework/shell/plugin/support/DefaultHistoryFileProviderTest.java b/src/test/java/org/springframework/shell/plugin/support/DefaultHistoryFileProviderTest.java index 057a3aaf..a6ba66c7 100644 --- a/src/test/java/org/springframework/shell/plugin/support/DefaultHistoryFileProviderTest.java +++ b/src/test/java/org/springframework/shell/plugin/support/DefaultHistoryFileProviderTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.*; import org.junit.Assert; import org.junit.Test; import org.springframework.shell.Constant; -import org.springframework.shell.plugin.HistoryFileProvider; +import org.springframework.shell.plugin.HistoryFileNameProvider; /** * @author Jarred Li @@ -28,10 +28,10 @@ import org.springframework.shell.plugin.HistoryFileProvider; */ public class DefaultHistoryFileProviderTest { - private HistoryFileProvider historyFile = new DefaultHistoryFileProvider(); + private HistoryFileNameProvider historyFile = new DefaultHistoryFileNameProvider(); /** - * Test method for {@link org.springframework.shell.plugin.support.DefaultHistoryFileProvider#getOrder()}. + * Test method for {@link org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider#getOrder()}. */ @Test public void testGetOrder() { @@ -39,7 +39,7 @@ public class DefaultHistoryFileProviderTest { } /** - * Test method for {@link org.springframework.shell.plugin.support.DefaultHistoryFileProvider#getHistoryFileName()}. + * Test method for {@link org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider#getHistoryFileName()}. */ @Test public void testGetHistoryFileName() {