<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 閱讀(893) 評論(0)  編輯  收藏 所屬分類: OSGi

    導航

    統計

    常用鏈接

    留言簿(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
    主站蜘蛛池模板: 国产精品免费播放| 亚洲欧洲日韩综合| 日韩在线不卡免费视频一区| 亚洲国产成人久久| 亚洲A∨精品一区二区三区| a毛片免费在线观看| 亚洲国产夜色在线观看| 免费一级特黄特色大片在线观看| 处破痛哭A√18成年片免费| 人与动性xxxxx免费| 久久亚洲sm情趣捆绑调教| 国产成人免费片在线视频观看| 光棍天堂免费手机观看在线观看| 亚洲一区中文字幕在线电影网| 一级成人a毛片免费播放| 亚洲精品无码永久在线观看男男| 亚洲综合在线另类色区奇米| 中文字幕人成无码免费视频| 国产无遮挡色视频免费观看性色 | 久久综合久久综合亚洲| 午夜国产精品免费观看 | 7777久久亚洲中文字幕蜜桃| 免费国产成人高清视频网站| 2020因为爱你带字幕免费观看全集 | 日韩欧美一区二区三区免费观看| 国产精品玖玖美女张开腿让男人桶爽免费看| 亚洲精品午夜在线观看| 中文字幕第一页亚洲| 午夜神器成在线人成在线人免费| 国产精品免费高清在线观看| 免费一级特黄特色大片| 最新亚洲精品国偷自产在线| 亚洲小视频在线观看| 亚洲中文字幕无码久久2017| 国产一级一片免费播放| 色se01短视频永久免费| 四虎成人精品永久免费AV| 中文字幕成人免费高清在线视频 | 特级做A爰片毛片免费看无码| 精品亚洲成A人在线观看青青| 亚洲国产成人无码av在线播放|