f9a64ab071d8bd04eb8183b646a39e4d079be14d
[controller.git] / opendaylight / md-sal / sal-binding-config / 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.impl.BindingDOMMountPointServiceAdapter;
22 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcProviderServiceAdapter;
23 import org.opendaylight.controller.md.sal.binding.impl.BindingDOMRpcServiceAdapter;
24 import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
25 import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
26 import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
27 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
28 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
29 import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
30 import org.opendaylight.controller.sal.core.api.Broker;
31 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
32
33 /**
34  * Deprecated.
35  *
36  * @deprecated Replaced by blueprint wiring
37  */
38 @Deprecated
39 public final class BindingBrokerImplModule extends
40         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {
41
42     public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
43             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
44         super(identifier, dependencyResolver);
45     }
46
47     public BindingBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
48             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
49             final BindingBrokerImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
50         super(identifier, dependencyResolver, oldModule, oldInstance);
51     }
52
53     @Override
54     public void validate() {
55         super.validate();
56     }
57
58     @Override
59     public RootBindingAwareBroker createInstance() {
60         final Broker domBroker = getDomAsyncBrokerDependency();
61         final BindingToNormalizedNodeCodec codec = getBindingMappingServiceDependency();
62         final ProviderSession session = domBroker.registerProvider(new DummyDOMProvider());
63
64         final MountPointService mount = createMountPointAdapter(codec,session);
65         final BindingDOMRpcServiceAdapter rpcConsumer = createRpcConsumer(codec,session);
66         final BindingDOMRpcProviderServiceAdapter rpcProvider = createRpcProvider(codec,session);
67         final RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName());
68         final RpcProviderRegistry heliumRpcBroker = new HeliumRpcProviderRegistry(rpcConsumer, rpcProvider);
69
70         broker.setNotificationBroker(getNotificationServiceDependency());
71         if (getNotificationPublishServiceDependency() != null) {
72             broker.setNotificationPublishService(getNotificationPublishServiceDependency());
73         }
74         broker.setRpcBroker(heliumRpcBroker);
75         broker.setDataBroker(getRootDataBrokerDependency());
76         broker.setMountService(mount);
77         broker.start();
78         return broker;
79     }
80
81     private BindingDOMRpcProviderServiceAdapter createRpcProvider(final BindingToNormalizedNodeCodec codec,
82             final ProviderSession session) {
83         final DOMRpcProviderService domService = session.getService(DOMRpcProviderService.class);
84         if (domService != null) {
85             return new BindingDOMRpcProviderServiceAdapter(domService, codec);
86         }
87         return null;
88     }
89
90     private BindingDOMRpcServiceAdapter createRpcConsumer(final BindingToNormalizedNodeCodec codec,
91             final ProviderSession session) {
92         final DOMRpcService domService = session.getService(DOMRpcService.class);
93         if (domService != null) {
94             return new BindingDOMRpcServiceAdapter(domService, codec);
95         }
96         return null;
97     }
98
99     private MountPointService createMountPointAdapter(final BindingToNormalizedNodeCodec codec,
100             final ProviderSession session) {
101         final DOMMountPointService domService = session.getService(DOMMountPointService.class);
102         if (domService != null) {
103             return new BindingDOMMountPointServiceAdapter(domService, codec);
104         }
105         return null;
106     }
107
108 }

©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.