48d227d019330c3f52f3e8c1c4f28b9429b1a21e
[hc2vpp.git] /
1 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210;
2
3 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
4 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
5 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
6 import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
7 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
8 import org.opendaylight.controller.sal.binding.api.BindingAwareService;
9 import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
10 import org.opendaylight.yangtools.concepts.ListenerRegistration;
11 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
12 import org.opendaylight.yangtools.yang.binding.RpcService;
13 import org.osgi.framework.BundleContext;
14
15 public class NetconfBindingBrokerModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.AbstractNetconfBindingBrokerModule {
16     public NetconfBindingBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
17         super(identifier, dependencyResolver);
18     }
19
20     public NetconfBindingBrokerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.impl.rev141210.NetconfBindingBrokerModule oldModule, java.lang.AutoCloseable oldInstance) {
21         super(identifier, dependencyResolver, oldModule, oldInstance);
22     }
23
24     @Override
25     public void customValidation() {
26         // add custom validation form module attributes here.
27     }
28
29     @Override
30     public java.lang.AutoCloseable createInstance() {
31         return new FakeBindingAwareBroker(getNetconfBindingBrokerDependency());
32     }
33
34     private static class FakeBindingAwareBroker implements BindingAwareBroker, AutoCloseable {
35
36         private DataBroker netconfBindingBrokerDependency;
37
38         public FakeBindingAwareBroker(final DataBroker netconfBindingBrokerDependency) {
39
40             this.netconfBindingBrokerDependency = netconfBindingBrokerDependency;
41         }
42
43         @Deprecated
44         @Override
45         public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer,
46                                                 final BundleContext bundleContext) {
47             throw new UnsupportedOperationException("Unsupported");
48         }
49
50         @Override
51         public ConsumerContext registerConsumer(final BindingAwareConsumer bindingAwareConsumer) {
52             final ConsumerContext consumerContext = new ConsumerContext() {
53                 @Override
54                 public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
55                     return aClass.equals(DataBroker.class)
56                         ? (T) netconfBindingBrokerDependency
57                         : null;
58                 }
59
60                 @Override
61                 public <T extends RpcService> T getRpcService(final Class<T> aClass) {
62                     return null;
63                 }
64             };
65             bindingAwareConsumer.onSessionInitialized(consumerContext);
66             return consumerContext;
67         }
68
69         @Override
70         public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider,
71                                                 final BundleContext bundleContext) {
72             throw new UnsupportedOperationException("Unsupported");
73         }
74
75         @Override
76         public ProviderContext registerProvider(final BindingAwareProvider bindingAwareProvider) {
77             final ProviderContext context = new ProviderContext() {
78                 @Override
79                 public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
80                     final L l) {
81                     throw new UnsupportedOperationException("Unsupported");
82                 }
83
84                 @Override
85                 public <T extends RpcService> T getRpcService(final Class<T> aClass) {
86                     throw new UnsupportedOperationException("Unsupported");
87                 }
88
89                 @Override
90                 public <T extends RpcService> RpcRegistration<T> addRpcImplementation(final Class<T> aClass, final T t)
91                     throws IllegalStateException {
92                     throw new UnsupportedOperationException("Unsupported");
93                 }
94
95                 @Override
96                 public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(
97                     final Class<T> aClass, final T t) throws IllegalStateException {
98                     throw new UnsupportedOperationException("Unsupported");
99                 }
100
101                 @Override
102                 public <T extends BindingAwareService> T getSALService(final Class<T> aClass) {
103                     return aClass.equals(DataBroker.class)
104                         ? (T) netconfBindingBrokerDependency
105                         : null;                }
106             };
107             bindingAwareProvider.onSessionInitiated(context);
108             return context;
109         }
110
111         @Override
112         public void close() throws Exception {
113             netconfBindingBrokerDependency = null;
114         }
115     }
116 }
117