add history file name example

This commit is contained in:
Jarred Li
2012-04-11 06:03:03 -07:00
parent e6e201e390
commit 956d72ee28
6 changed files with 45 additions and 20 deletions

View File

@@ -3,4 +3,6 @@
.settings/
target/
/log.roo
*.log

View File

@@ -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 File

@@ -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 File

@@ -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 File

@@ -67,7 +67,7 @@ public class Bootstrap {
//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 @@ public class Bootstrap {
ctx = initPluginApplicationContext(annctx);
ctx.refresh();
}

View File

@@ -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<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();