REST API to fetch Node Property
[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 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 /**
24 *
25 */
26 public final class ToasterConsumerModule extends org.opendaylight.controller.config.yang.config.toaster_consumer.impl.AbstractToasterConsumerModule
27  {
28     private static final Logger log = LoggerFactory.getLogger(ToasterConsumerModule.class);
29
30     public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
31         super(identifier, dependencyResolver);
32     }
33
34     public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
35             ToasterConsumerModule oldModule, java.lang.AutoCloseable oldInstance) {
36
37         super(identifier, dependencyResolver, oldModule, oldInstance);
38     }
39
40     @Override
41     protected void customValidation(){
42         // No need to validate dependencies, since all dependencies have mandatory true flag in yang
43         // config-subsystem will perform the validation
44     }
45
46     @Override
47     public java.lang.AutoCloseable createInstance() {
48         ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class);
49
50         final ToastConsumerImpl consumer = new ToastConsumerImpl(toasterService);
51         final Registration<NotificationListener<ToastDone>> notificationRegistration = getNotificationServiceDependency()
52                 .registerNotificationListener(ToastDone.class, consumer);
53
54         final ToasterConsumerRuntimeRegistration runtimeRegistration = getRootRuntimeBeanRegistratorWrapper().register(consumer);
55
56         final class AutoCloseableToastConsumer implements AutoCloseable, ToastConsumer {
57
58             @Override
59             public void close() throws Exception {
60                 runtimeRegistration.close();
61                 notificationRegistration.close();
62                 log.info("Toaster consumer (instance {}) torn down.", this);
63             }
64
65             @Override
66             public boolean createToast(Class<? extends ToastType> type, int doneness) {
67                 return consumer.createToast(type, doneness);
68             }
69         }
70
71         AutoCloseable ret = new AutoCloseableToastConsumer();
72         log.info("Toaster consumer (instance {}) initialized.", ret);
73         return ret;
74     }
75 }