OSGI配置子系统的方式——feature配置子系统

    ---------------------------
    1、在\features\src\main\features\features.xml中配置feature。
    <feature name='odl-blog-example' version='${project.version}' description="Sd-Otn :: Noth-">
        <feature version='${project.version}'>odl-blog-fcmanager</feature>
        <bundle>mvn:com.csdn.blog/example-api/${blog.version}</bundle>
        <bundle>mvn:com.csdn.blog/example-impl/${blog.version}</bundle>
        <configfile finalname="${configfile.directory}/54-example.xml">
            mvn:com.csdn.blog/example-config/${blog.version}/xml/config
        </configfile>
    </feature>
    -------------------------------------------
    2、example\impl\src\main\yang创建module,并将第3步的所依赖的服务注册到yang生成的实例中,如果是纯osgi框架则需要从BundleContext中获取依赖的服务。BundleContext可以获取整个osgi所有的服务。
    module csdnblogmoudle-impl {
    yang-version 1;
    namespace "urn:opendaylight:params:xml:ns:yang:blog:csdnblogmoudle:impl";
    prefix "csdnblogmoudleimpl";
    import config { prefix config; revision-date 2017-9-25; }
    import otherservice1-api { prefix cim; revision-date 2017-9-25; }
    import otherservice2-api { prefix route; revision-date 2017-9-25 }
    import otherservice3-api { prefix traffic; revision-date 2017-9-25; }
    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2017-9-25; }
    organization "CSDN";


    description
        "Module definition for CSDN.";


    revision "2017-9-25" {
        description "Initial revision.";
    }


    identity csdnblogmoudle-impl {
        base config:module-type;
        config:java-name-prefix Csdnblogmoudleimpl;
    }


    augment "/config:modules/config:module/config:configuration" {
        case csdnblogmoudle-impl {
            when "/config:modules/config:module/config:type = 'csdnblogmoudle-impl'";
            container rpc-registry {
                uses config:service-ref {
                    refine type {
                        mandatory true;
                        config:required-identity mdsal:binding-rpc-registry;
                    }
                }
            }
            container data-broker {
                uses config:service-ref {
                    refine type {
                        mandatory true;
                        config:required-identity mdsal:binding-async-data-broker;
                    }
                }
            }
            container notification-service {
                uses config:service-ref {
                    refine type {
                        mandatory true;
                        config:required-identity mdsal:binding-notification-service;
                    }
                }
            }
            container otherservice-name1 {
                uses config:service-ref {
                    refine type {
                        mandatory true;
                        config:required-identity otherservice1:otherservice1-service;
                    }
                }
            }
        }
    }
}




    -------------------------------
    3、在example\config\src\main\resources\initial创建54-example.xml,并将本bundle的服务注册到osgi中。
<?xml version="1.0" encoding="UTF-8"?>
<snapshot>
    <required-capabilities>
        <capability>
            urn:opendaylight:params:xml:ns:yang:blog:otherservice1:api?module=otherservice1-api&amp;revision=2016-01-13
        </capability>
    </required-capabilities>
    <configuration>
        <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
            <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
                <module>
                    <type xmlns:northadapteripplusoimpl="urn:opendaylight:params:xml:ns:yang:blog:csdnblogmoudle:impl">
                        csdnblogmoudleimpl:csdnblogmoudle-impl
                    </type>
                    <name>csdnblogmoudleimpl-service-impl</name>
                    <rpc-registry>
                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
                        <name>binding-rpc-broker</name>
                    </rpc-registry>
                    <data-broker>
                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
                            binding:binding-async-data-broker
                        </type>
                        <name>binding-data-broker</name>
                    </data-broker>
                    <notification-service>
                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
                            binding:binding-notification-service
                        </type>
                        <name>binding-notification-broker</name>
                    </notification-service>
                    <otherservicemanager>
                        <type xmlns:tramapi="urn:opendaylight:params:xml:ns:yang:blog:other:service:api">
                            tramapi:other-service
                        </type>
                        <name>other-service</name>
                    </otherservicemanager>
                </module>
            </modules>
        </data>
    </configuration>
</snapshot>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山隐的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值