Bug 2364: Migrated Binding MD-SAL to not use composites nodes
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / BindingBrokerImplModule.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 /**
9  * Generated file
10
11  * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl
12  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
13  * Generated at: Wed Nov 20 17:33:01 CET 2013
14  *
15  * Do not modify this file unless it is present under src/main directory
16  */
17 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
18
19 import org.opendaylight.controller.md.sal.binding.api.MountPointService;
20 import org.opendaylight.controller.md.sal.binding.compat.HeliumRpcProviderRegistry;
21 import org.opendaylight.controller.md.sal.binding.compat.HydrogenMountProvisionServiceAdapter;
22 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMMountPointServiceAdapter;
23 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
24 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter;
25 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
26 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
27 import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
28 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
29 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
30 import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
31 import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
32 import org.opendaylight.controller.sal.core.api.Broker;
33 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
34
35 /**
36 *
37 */
38 public final class BindingBrokerImplModule extends
39         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {
40
41     public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
42             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
43         super(identifier, dependencyResolver);
44     }
45
46     public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
47             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
48             final BindingBrokerImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
49         super(identifier, dependencyResolver, oldModule, oldInstance);
50     }
51
52     @Override
53     public void validate() {
54         super.validate();
55     }
56
57     @Override
58     public RootBindingAwareBroker createInstance() {
59         final Broker domBroker = getDomAsyncBrokerDependency();
60         final BindingToNormalizedNodeCodec codec = getBindingMappingServiceDependency();
61         final ProviderSession session = domBroker.registerProvider(new DummyDOMProvider());
62
63         final MountPointService mount = createMountPointAdapter(codec,session);
64         final BindingDOMRpcServiceAdapter rpcConsumer = createRpcConsumer(codec,session);
65         final BindingDOMRpcProviderServiceAdapter rpcProvider = createRpcProvider(codec,session);
66         final RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName());
67         final RpcProviderRegistry heliumRpcBroker = new HeliumRpcProviderRegistry(rpcConsumer, rpcProvider);
68         final MountProviderService legacyMount = createLegacyMountPointService(mount);
69
70         broker.setLegacyDataBroker(getDataBrokerDependency());
71         broker.setNotificationBroker(getNotificationServiceDependency());
72         broker.setRpcBroker(heliumRpcBroker);
73         broker.setDataBroker(getRootDataBrokerDependency());
74         broker.setMountService(mount);
75         broker.setLegacyMountManager(legacyMount);
76         broker.start();
77         return broker;
78     }
79
80
81     @SuppressWarnings("deprecation")
82     private MountProviderService createLegacyMountPointService(final MountPointService service) {
83         if(service != null) {
84             return new HydrogenMountProvisionServiceAdapter(service);
85         }
86         return null;
87     }
88
89     private BindingDOMRpcProviderServiceAdapter createRpcProvider(final BindingToNormalizedNodeCodec codec,
90             final ProviderSession session) {
91         final DOMRpcProviderService domService = session.getService(DOMRpcProviderService.class);
92         if(domService != null) {
93             return new BindingDOMRpcProviderServiceAdapter(domService, codec);
94         }
95         return null;
96     }
97
98     private BindingDOMRpcServiceAdapter createRpcConsumer(final BindingToNormalizedNodeCodec codec, final ProviderSession session) {
99         final DOMRpcService domService = session.getService(DOMRpcService.class);
100         if(domService != null) {
101             return new BindingDOMRpcServiceAdapter(domService, codec);
102         }
103         return null;
104     }
105
106     private MountPointService createMountPointAdapter(final BindingToNormalizedNodeCodec codec, final ProviderSession session) {
107         final DOMMountPointService domService = session.getService(DOMMountPointService.class);
108         if(domService != null) {
109             return new BindingDOMMountPointServiceAdapter(domService, codec);
110         }
111         return null;
112     }
113
114 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.