<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    gembin

    OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

    HBase, Hadoop, ZooKeeper, Cassandra

    Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

    There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

    About Me

     

    Ideas on Apache karaf shell

    i would like to share some ideas on Apache karaf shell.
    karaf shell is based on apache felix gogo.
    If you want to create a new command, you have to extends org.apache.karaf.shell.console.AbstractAction or XxxCommandSupport.
    public class CatAction extends AbstractAction {
    protected Object doExecute() throws Exception {
    //todo something here
    }
    }

    and then add to blueprint config, would be something like this:
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
        
    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
            
    <command name="shell/cat">
                
    <action class="org.apache.karaf.shell.commands.CatAction"/>
            
    </command>
            
        
    </command-bundle>
    </blueprint>
    it's somewhat a little bit verbose in my opinion.

    i would perfer something like this:
    @CommandProvider(scope = "shell", name = "ShellCommandProvider", description = "Unix Shell alike commands.")
    public class ShellCommandProvider {

    @Option(name 
    = "-n", aliases = {"--show-line-number"}, description = "The number the output lines, starting at 1.")
    private boolean displayLineNumbers;

    @Argument(name 
    = "paths or urls", description = "A list of file paths or urls to display separated by whitespaces (use - for STDIN)", required = true, multiValued = true)
    private List paths;

    @Command(scope
    ="my_scope", options = { "displayLineNumbers" },arguments={"paths"}, description = "Displays the content of a file or URL.")
    public void cat(CommandSession session) throws Exception {
    //todo something here
    }


    @Argument(name 
    = "paths or urls")
    private String arg1;
    @Command(options 
    = { "displayLineNumbers" },arguments={"arg1"})
    public void cat1() throws Exception {
     //todo something here
    }

    }

    1. The CommandProvider no need to extends some class or implements some interface, and  it groups a set of command.
    2. Each method can be a command by annotated with @Command, and opt or arg can be shared by different commands.
    3. The scope specified at @CommandProvider which is shared by all the commands within this provider. and also each command can override the scope.

    i.e. options = { "displayLineNumbers" }, it ref the opt by the field name. and also the same for arguments. the order indicate the index of the opt or arg.
    arguments = { "arg1","arg2" }: means the command will accept the args in order: arg1 arg2

    finally, add to blueprint config:
    <blueprint>
        
    <shell:command-provider class="org.apache.karaf.shell.commands.ShellCommandProvider">
           
    <shell:property name="bundleContext" ref="blueprintBundleContext"/>
             any standard blueprint elements here
        
    </shell:command-provider>
    </blueprint>

    thats it.
    any ideas are welcome.

    posted on 2011-05-11 11:37 gembin 閱讀(892) 評論(0)  編輯  收藏 所屬分類: OSGi

    導(dǎo)航

    統(tǒng)計

    常用鏈接

    留言簿(6)

    隨筆分類(440)

    隨筆檔案(378)

    文章檔案(6)

    新聞檔案(1)

    相冊

    收藏夾(9)

    Adobe

    Android

    AS3

    Blog-Links

    Build

    Design Pattern

    Eclipse

    Favorite Links

    Flickr

    Game Dev

    HBase

    Identity Management

    IT resources

    JEE

    Language

    OpenID

    OSGi

    SOA

    Version Control

    最新隨筆

    搜索

    積分與排名

    最新評論

    閱讀排行榜

    評論排行榜

    free counters
    主站蜘蛛池模板: 黄色视屏在线免费播放| 亚洲AV天天做在线观看| 亚洲色婷婷六月亚洲婷婷6月| 国产成人亚洲影院在线观看| 曰韩亚洲av人人夜夜澡人人爽| 亚洲AV综合色区无码另类小说 | 免费国产成人α片| free哆啪啪免费永久| 黄瓜视频高清在线看免费下载 | 国产一卡二卡3卡四卡免费| 全免费A级毛片免费看网站| 免费播放特黄特色毛片| 亚洲产国偷V产偷V自拍色戒| 亚洲女人初试黑人巨高清| 亚洲精品久久久久无码AV片软件| 日日狠狠久久偷偷色综合免费 | 一级**爱片免费视频| 无码精品人妻一区二区三区免费看 | 亚洲综合精品一二三区在线| 亚洲国产精品久久久久秋霞影院| 亚洲国产综合人成综合网站00| 亚洲a∨国产av综合av下载| 国产精品hd免费观看| 亚洲精品在线免费观看| 免费看小12萝裸体视频国产| 午夜影视日本亚洲欧洲精品一区 | 亚洲一区精品中文字幕| 亚洲精品GV天堂无码男同| 青青操免费在线观看| 国产福利在线免费| 国产成人精品日本亚洲专区61| 亚洲av无码不卡久久| 免费国产黄网站在线看| 毛片免费全部播放无码| 亚洲国产小视频精品久久久三级 | 一二三四免费观看在线视频中文版 | 老司机福利在线免费观看| 无码国产精品一区二区免费vr| 日韩吃奶摸下AA片免费观看| 国产午夜亚洲精品午夜鲁丝片| 亚洲电影唐人社一区二区|