diff --git a/samples/helloworld/.gitignore b/samples/helloworld/.gitignore index 9a33f906..9a55f4ea 100644 --- a/samples/helloworld/.gitignore +++ b/samples/helloworld/.gitignore @@ -3,4 +3,6 @@ .settings/ target/ /log.roo +*.log + diff --git a/samples/helloworld/spring-shell.log b/samples/helloworld/spring-shell.log deleted file mode 100644 index 4d5cc012..00000000 --- a/samples/helloworld/spring-shell.log +++ /dev/null @@ -1,5 +0,0 @@ -// Spring Roo UNKNOWN VERSION log opened at 2012-04-11 18:02:23 -date -system properties -quit -// Spring Roo UNKNOWN VERSION log closed at 2012-04-11 18:02:32 diff --git a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/HelloWorldPlugin.java b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/HelloWorldPlugin.java deleted file mode 100644 index ae8fbaee..00000000 --- a/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/HelloWorldPlugin.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.springframework.shell.samples.helloworld; - -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -@Configuration -@ComponentScan({"org.springframework.shell.samples.helloworld.commands"}) -public class HelloWorldPlugin { - - - -} 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/MyHistoryFileProvider.java new file mode 100644 index 00000000..9450ccf3 --- /dev/null +++ b/samples/helloworld/src/main/java/org/springframework/shell/samples/helloworld/commands/MyHistoryFileProvider.java @@ -0,0 +1,38 @@ +/* + * Copyright 2011-2012 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.shell.samples.helloworld.commands; + +import org.springframework.shell.plugin.HistoryFileProvider; +import org.springframework.stereotype.Component; + +/** + * + * @author Jarred Li + * + */ +@Component +public class MyHistoryFileProvider implements HistoryFileProvider { + + public int getOrder() { + return 1; + } + + public String getHistoryFileName() { + return "my.log"; + } + +} diff --git a/src/main/java/org/springframework/shell/Bootstrap.java b/src/main/java/org/springframework/shell/Bootstrap.java index aae22b03..2b5febdb 100644 --- a/src/main/java/org/springframework/shell/Bootstrap.java +++ b/src/main/java/org/springframework/shell/Bootstrap.java @@ -67,7 +67,7 @@ public class Bootstrap { //shell = new JLineShellComponent(); shell = ctx.getBean("shell", JLineShellComponent.class); - + shell.setApplicationContext(ctx); Map commands = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx,CommandMarker.class); @@ -129,6 +129,7 @@ public class Bootstrap { ctx = initPluginApplicationContext(annctx); ctx.refresh(); + } diff --git a/src/main/java/org/springframework/shell/JLineShell.java b/src/main/java/org/springframework/shell/JLineShell.java index 4be662d7..2cb0fc0f 100644 --- a/src/main/java/org/springframework/shell/JLineShell.java +++ b/src/main/java/org/springframework/shell/JLineShell.java @@ -10,6 +10,7 @@ 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; @@ -59,8 +60,7 @@ import org.springframework.shell.plugin.HistoryFileProvider; * @author Jarred Li * @since 1.0 */ -public abstract class JLineShell extends AbstractShell implements CommandMarker, Shell, Runnable, - ApplicationContextAware { +public abstract class JLineShell extends AbstractShell implements CommandMarker, Shell, Runnable { // Constants private static final String ANSI_CONSOLE_CLASSNAME = "org.fusesource.jansi.AnsiConsole"; @@ -469,6 +469,7 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, Map historyFileProviders = BeanFactoryUtils.beansOfTypeIncludingAncestors( this.applicatonContext, HistoryFileProvider.class); int order = Integer.MIN_VALUE; + System.out.println("history file provider count:" + Arrays.toString(historyFileProviders.keySet().toArray())); for(HistoryFileProvider p : historyFileProviders.values()){ if(p.getOrder() > order){ order = p.getOrder();