Skip to content
Browse files

add history file name example

  • Loading branch information...
1 parent e6e201e commit 956d72ee2842e6a46ffe484f65c87cb8c789b205 @leejianwei leejianwei committed
View
2 samples/helloworld/.gitignore
@@ -3,4 +3,6 @@
.settings/
target/
/log.roo
+*.log
+
View
5 samples/helloworld/spring-shell.log
@@ -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
View
12 ...lloworld/src/main/java/org/springframework/shell/samples/helloworld/HelloWorldPlugin.java
@@ -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 {
-
-
-
-}
View
38 ...ain/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";
+ }
+
+}
View
3 src/main/java/org/springframework/shell/Bootstrap.java
@@ -67,7 +67,7 @@ public Bootstrap(String applicationContextLocation) throws IOException {
//shell = new JLineShellComponent();
shell = ctx.getBean("shell", JLineShellComponent.class);
-
+ shell.setApplicationContext(ctx);
Map<String, CommandMarker> commands = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx,CommandMarker.class);
@@ -129,6 +129,7 @@ private void createApplicationContext(String applicationContextLocation) {
ctx = initPluginApplicationContext(annctx);
ctx.refresh();
+
}
View
5 src/main/java/org/springframework/shell/JLineShell.java
@@ -10,6 +10,7 @@
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 @@
* @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 @@ private String getHistoryFileName() {
Map<String, HistoryFileProvider> 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();

2 comments on commit 956d72e

@markpollack
Spring member

Should remove use of System.out.println. Switch to logging

Please sign in to comment.
Something went wrong with that request. Please try again.