X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fmd%2Fsal%2Fbinding%2Fimpl%2FBindingBrokerImplModule.java;h=f74faa3d223c2cdc19691e3535882ec2709a0cbc;hp=bce1f61cf5a20bfa936c0adac55f5c159533eed3;hb=0dcdc14a4ff38b39fed0d07658941a09a4c043fd;hpb=2202c2e0c5e65783b02254a7cfc2b1fb6d84afe9 diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java index bce1f61cf5..f74faa3d22 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/binding/impl/BindingBrokerImplModule.java @@ -1,52 +1,114 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ /** -* Generated file + * Generated file -* Generated from: yang module name: opendaylight-sal-binding-broker-impl yang module local name: binding-broker-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Wed Nov 20 17:33:01 CET 2013 -* -* Do not modify this file unless it is present under src/main directory -*/ + * Generated from: yang module name: opendaylight-sal-binding-broker-impl yang module local name: binding-broker-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 20 17:33:01 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ package org.opendaylight.controller.config.yang.md.sal.binding.impl; -import org.opendaylight.controller.sal.binding.impl.BindingAwareBrokerImpl; -import org.osgi.framework.BundleContext; +import org.opendaylight.controller.md.sal.binding.api.MountPointService; +import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry; +import org.opendaylight.controller.md.sal.binding.compat.HydrogenMountProvisionServiceAdapter; +import org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter; +import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter; +import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter; +import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.controller.sal.binding.api.mount.MountProviderService; +import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker; +import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; /** * */ -public final class BindingBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule { - - private BundleContext bundleContext; +public final class BindingBrokerImplModule extends + org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule { - public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } - public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) { + public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + final BindingBrokerImplModule oldModule, final java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } @Override - public void validate(){ + public void validate() { super.validate(); - // Add custom validation for module attributes here. } @Override - public java.lang.AutoCloseable createInstance() { - BindingAwareBrokerImpl broker = new BindingAwareBrokerImpl(getBundleContext()); - broker.setDataBroker(getDataBrokerDependency()); - broker.setNotifyBroker(getNotificationServiceDependency()); + public RootBindingAwareBroker createInstance() { + final Broker domBroker = getDomAsyncBrokerDependency(); + final BindingToNormalizedNodeCodec codec = getBindingMappingServiceDependency(); + final ProviderSession session = domBroker.registerProvider(new DummyDOMProvider()); + + final MountPointService mount = createMountPointAdapter(codec,session); + final BindingDOMRpcServiceAdapter rpcConsumer = createRpcConsumer(codec,session); + final BindingDOMRpcProviderServiceAdapter rpcProvider = createRpcProvider(codec,session); + final RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName()); + final RpcProviderRegistry heliumRpcBroker = new HeliumRpcProviderRegistry(rpcConsumer, rpcProvider); + final MountProviderService legacyMount = createLegacyMountPointService(mount); + + broker.setLegacyDataBroker(getDataBrokerDependency()); + broker.setNotificationBroker(getNotificationServiceDependency()); + broker.setRpcBroker(heliumRpcBroker); + broker.setDataBroker(getRootDataBrokerDependency()); + broker.setMountService(mount); + broker.setLegacyMountManager(legacyMount); broker.start(); return broker; } - public BundleContext getBundleContext() { - return bundleContext; + + @SuppressWarnings("deprecation") + private MountProviderService createLegacyMountPointService(final MountPointService service) { + if(service != null) { + return new HydrogenMountProvisionServiceAdapter(service); + } + return null; } - public void setBundleContext(BundleContext bundleContext) { - this.bundleContext = bundleContext; + private BindingDOMRpcProviderServiceAdapter createRpcProvider(final BindingToNormalizedNodeCodec codec, + final ProviderSession session) { + final DOMRpcProviderService domService = session.getService(DOMRpcProviderService.class); + if(domService != null) { + return new BindingDOMRpcProviderServiceAdapter(domService, codec); + } + return null; } + + private BindingDOMRpcServiceAdapter createRpcConsumer(final BindingToNormalizedNodeCodec codec, final ProviderSession session) { + final DOMRpcService domService = session.getService(DOMRpcService.class); + if(domService != null) { + return new BindingDOMRpcServiceAdapter(domService, codec); + } + return null; + } + + private MountPointService createMountPointAdapter(final BindingToNormalizedNodeCodec codec, final ProviderSession session) { + final DOMMountPointService domService = session.getService(DOMMountPointService.class); + if(domService != null) { + return new BindingDOMMountPointServiceAdapter(domService, codec); + } + return null; + } + }