bfafc1f9b722e2100b4e327a3050e25b5188914c
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / connect / dom / BindingDomConnectorDeployer.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.controller.sal.binding.impl.connect.dom;
9
10 import static com.google.common.base.Preconditions.checkNotNull;
11
12 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
13 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
14 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
15 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
16 import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;
17 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
18 import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
19 import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
20
21 public class BindingDomConnectorDeployer {
22
23     private static BindingIndependentMappingService mappingService;
24
25     public static BindingIndependentConnector tryToDeployConnector(RootBindingAwareBroker baBroker,
26             ProviderSession domSession) {
27         checkNotNull(baBroker);
28         checkNotNull(domSession);
29         BindingIndependentConnector connector = createConnector(mappingService);
30         return connector;
31     }
32
33     public static BindingIndependentConnector createConnector(BindingIndependentMappingService mappingService) {
34         BindingIndependentConnector connector = new BindingIndependentConnector();
35         connector.setMappingService(mappingService);
36         return connector;
37     }
38
39     public static BindingIndependentConnector createConnector(BindingIndependentConnector source) {
40         BindingIndependentConnector connector = new BindingIndependentConnector();
41         connector.setMappingService(source.getMappingService());
42         return connector;
43     }
44
45     public static void startDataForwarding(BindingIndependentConnector connector, DataProviderService baService,
46             ProviderSession domContext) {
47         startDataForwarding(connector, baService,
48                 domContext.getService(org.opendaylight.controller.sal.core.api.data.DataProviderService.class));
49     }
50
51     public static void startRpcForwarding(BindingIndependentConnector connector,
52             RpcProviderRegistry rpcProviderRegistry, ProviderSession domProviderContext) {
53         startRpcForwarding(connector, rpcProviderRegistry, domProviderContext.getService(RpcProvisionRegistry.class));
54
55     }
56
57     public static void startNotificationForwarding(BindingIndependentConnector connector, NotificationProviderService provider,ProviderSession domProviderContext) {
58         startNotificationForwarding(connector, provider, domProviderContext.getService(NotificationPublishService.class));
59     }
60
61     public static void startRpcForwarding(BindingIndependentConnector connector, RpcProviderRegistry baService,
62             RpcProvisionRegistry domService) {
63         if (connector.isRpcForwarding()) {
64             return;
65         }
66
67         connector.setDomRpcRegistry(domService);
68         connector.setBindingRpcRegistry(baService);
69         connector.startRpcForwarding();
70     }
71
72     public static void startDataForwarding(BindingIndependentConnector connector, DataProviderService baService,
73             org.opendaylight.controller.sal.core.api.data.DataProviderService domService) {
74         if (connector.isDataForwarding()) {
75             return;
76         }
77
78         connector.setBindingDataService(baService);
79         connector.setDomDataService(domService);
80         connector.startDataForwarding();
81     }
82
83     public static void startNotificationForwarding(BindingIndependentConnector connector,
84             NotificationProviderService baService, NotificationPublishService domService) {
85         if(connector.isNotificationForwarding()) {
86             return;
87         }
88         connector.setBindingNotificationService(baService);
89         connector.setDomNotificationService(domService);
90         connector.startNotificationForwarding();
91     }
92
93     //
94     // public static BindingIndependentMappingService getGlobalMappingService()
95     // {
96     // return mappingService;
97     // }
98     //
99     // protected static BindingIndependentMappingService
100     // setGlobalMappingService(BindingIndependentMappingService service) {
101     // mappingService= service;
102     // return mappingService;
103     // }
104     //
105     // public static BindingIndependentConnector
106     // tryToDeployConnector(MountProviderInstance baMount,MountProvisionInstance
107     // domMount) {
108     //
109     //
110     // return null;
111     // }
112
113 }

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