refactor plugin, add Order annoaton support
This commit is contained in:
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
package org.springframework.shell.samples.helloworld.commands;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.roo.shell.CliCommand;
|
||||
import org.springframework.roo.shell.CommandMarker;
|
||||
import org.springframework.roo.support.util.StringUtils;
|
||||
import org.springframework.shell.plugin.BannerProvider;
|
||||
import org.springframework.shell.plugin.support.DefaultBannerProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -26,14 +28,9 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class MyBannerProvider implements BannerProvider, CommandMarker {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.core.Ordered#getOrder()
|
||||
*/
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class MyBannerProvider extends DefaultBannerProvider
|
||||
implements CommandMarker {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.shell.plugin.BannerProvider#getBanner()
|
||||
@@ -66,5 +63,11 @@ public class MyBannerProvider implements BannerProvider, CommandMarker {
|
||||
public String getWelcomMessage() {
|
||||
return "Welcome to vHelper CLI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "my banner provider";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
|
||||
package org.springframework.shell.samples.helloworld.commands;
|
||||
|
||||
import org.springframework.shell.plugin.HistoryFileNameProvider;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.shell.plugin.support.DefaultHistoryFileNameProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -25,14 +27,16 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class MyHistoryFileNameProvider implements HistoryFileNameProvider {
|
||||
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class MyHistoryFileNameProvider extends DefaultHistoryFileNameProvider{
|
||||
|
||||
public String getHistoryFileName() {
|
||||
return "my.log";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "my banner provider";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
*/
|
||||
package org.springframework.shell.samples.helloworld.commands;
|
||||
|
||||
import org.springframework.shell.plugin.PromptProvider;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.shell.plugin.support.DefaultPromptProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -23,14 +25,8 @@ import org.springframework.stereotype.Component;
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
public class MyPromptProvider implements PromptProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.core.Ordered#getOrder()
|
||||
*/
|
||||
public int getOrder() {
|
||||
return 1;
|
||||
}
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
public class MyPromptProvider extends DefaultPromptProvider {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.shell.plugin.PromptProvider#getPromptText()
|
||||
@@ -38,5 +34,10 @@ public class MyPromptProvider implements PromptProvider {
|
||||
public String getPromptText() {
|
||||
return "vHelper>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "my banner provider";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user