c006a34da7328add85de51d5e2f94a6377478697
[controller.git] / opendaylight / md-sal / samples / toaster-consumer / src / main / java / org / opendaylight / controller / config / yang / config / toaster_consumer / impl / ToasterConsumerModule.java
1 /**
2 * Generated file
3
4 * Generated from: yang module name: toaster-consumer-impl  yang module local name: toaster-consumer-impl
5 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6 * Generated at: Wed Feb 05 11:31:30 CET 2014
7 *
8 * Do not modify this file unless it is present under src/main directory
9 */
10 package org.opendaylight.controller.config.yang.config.toaster_consumer.impl;
11
12 import org.opendaylight.controller.sal.binding.api.NotificationListener;
13 import org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer;
14 import org.opendaylight.controller.sample.toaster.provider.impl.ToastConsumerImpl;
15 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastDone;
16 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType;
17 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
18 import org.opendaylight.yangtools.concepts.Registration;
19
20 /**
21 *
22 */
23 public final class ToasterConsumerModule extends org.opendaylight.controller.config.yang.config.toaster_consumer.impl.AbstractToasterConsumerModule
24  {
25
26     public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
27         super(identifier, dependencyResolver);
28     }
29
30     public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
31             ToasterConsumerModule oldModule, java.lang.AutoCloseable oldInstance) {
32
33         super(identifier, dependencyResolver, oldModule, oldInstance);
34     }
35
36     @Override
37     protected void customValidation(){
38         // No need to validate dependencies, since all dependencies have mandatory true flag in yang
39         // config-subsystem will perform the validation
40     }
41
42     @Override
43     public java.lang.AutoCloseable createInstance() {
44         ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class);
45
46         final ToastConsumerImpl consumer = new ToastConsumerImpl(toasterService);
47         final Registration<NotificationListener<ToastDone>> notificationRegistration = getNotificationServiceDependency()
48                 .registerNotificationListener(ToastDone.class, consumer);
49
50         final ToasterConsumerRuntimeRegistration runtimeRegistration = getRootRuntimeBeanRegistratorWrapper().register(consumer);
51
52         final class AutoCloseableToastConsumer implements AutoCloseable, ToastConsumer {
53
54             @Override
55             public void close() throws Exception {
56                 runtimeRegistration.close();
57                 notificationRegistration.close();
58             }
59
60             @Override
61             public boolean createToast(Class<? extends ToastType> type, int doneness) {
62                 return consumer.createToast(type, doneness);
63             }
64         }
65
66         return new AutoCloseableToastConsumer();
67     }
68 }