• JXSE 2.5 : What's Cool #2 METAINF/services


    http://weblogs.java.net/blog/bondolo/archive/2007/09/jxse_25_whats_c_2.html

    ——————————————————————————————————————————————————————————————

    JXSE 2.5 : What's Cool #2 -- META-INF/services

    Posted by bondolo on September 12, 2007 at 5:33 PM EDT
    JXSE (JXTA for Java SE/EE 5.0) 2.5 contains quite a number of exciting changes for JXTA application developers. This little series will look at a few of the important changes in the upcoming release.

    One thing that's cool about working on an open source project is that every so often a community member you've never heard of will speak up and make a brilliant suggestion that even after years of devoted work on the project everyone else somehow missed. Exactly this happened last fall a few weeks before JXSE 2.4.1 went final and unfortunately too late for it to be included in JXSE 2.4.1 but it is now available in JXSE 2.5. The old jxta.org bugzilla was not preserved when we transfered the JXSE project to Java.net, so I have lost track of the name of the user who suggested the feature. If you're willing to step forward and identify yourself I'd be very happy to acknowledge your contribution.

    The cool feature which is the subject of this blog is the JAR Service Provider, otherwise known as the META-INF/services system. The META-INF/services system allows for the dynamic registration of instance classes for a particular interface. We are now using it for several of the JXSE class factories and the JXSE Class Loader.

    To register classes you list the class names implementing an interface in a file named for the interface in the META-INF/services folder of your JAR file. For example, to register new Advertisement types you include a file "net.jxta.document.Advertisement" in the META-INF/services folder of your JAR containing the full names of your Advertisement classes. During startup the JXSE AdvertisementFactory will read class names from that file and register classes. The process is repeated for each net.jxta.document.Advertisement file in all of the other JARs.

    Use of the META-INF/services system makes it much, much easier to extend JXSE by adding your own components. Adding support for your advertisement type to JXSE now requires only including the class names in the net.jxta.document.Advertisement file of your JAR file. You can also register StructuredDocument types, ID formats, WireMessageFormats and JXTA Services and Modules. We have converted JXSE to use the META-INF/services system for all of the core modules.

     
  • 相关阅读:
    全国哀悼日 灰色CSS滤镜 PENGHAO
    Jmail发信函数 PENGHAO
    XHTML 1.0 参考 PENGHAO
    今天搬家。。 PENGHAO
    JS代码Checkbox控制输入框 PENGHAO
    CSS hack:区分IE6,IE7,firefox PENGHAO
    获取表中新记录(下一条记录)的主键值的存储过程 PENGHAO
    五种提高 SQL 性能的方法 PENGHAO
    [收藏 ]针对IE网页浏览器不同版本解释的CSS或javascript PENGHAO
    小本创业者的致胜法宝! PENGHAO
  • 原文地址:https://www.cnblogs.com/cuizhf/p/2222236.html
Copyright © 2020-2023  润新知