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
8 * Do not modify this file unless it is present under src/main directory
10 package org.opendaylight.controller.config.yang.config.toaster_consumer.impl;
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;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
26 public final class ToasterConsumerModule extends org.opendaylight.controller.config.yang.config.toaster_consumer.impl.AbstractToasterConsumerModule
28 private static final Logger log = LoggerFactory.getLogger(ToasterConsumerModule.class);
30 public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
31 super(identifier, dependencyResolver);
34 public ToasterConsumerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
35 ToasterConsumerModule oldModule, java.lang.AutoCloseable oldInstance) {
37 super(identifier, dependencyResolver, oldModule, oldInstance);
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
47 public java.lang.AutoCloseable createInstance() {
48 ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class);
50 final ToastConsumerImpl consumer = new ToastConsumerImpl(toasterService);
51 final Registration<NotificationListener<ToastDone>> notificationRegistration = getNotificationServiceDependency()
52 .registerNotificationListener(ToastDone.class, consumer);
54 final ToasterConsumerRuntimeRegistration runtimeRegistration = getRootRuntimeBeanRegistratorWrapper().register(consumer);
56 final class AutoCloseableToastConsumer implements AutoCloseable, ToastConsumer {
59 public void close() throws Exception {
60 runtimeRegistration.close();
61 notificationRegistration.close();
62 log.info("Toaster consumer (instance {}) torn down.", this);
66 public boolean createToast(Class<? extends ToastType> type, int doneness) {
67 return consumer.createToast(type, doneness);
71 AutoCloseable ret = new AutoCloseableToastConsumer();
72 log.info("Toaster consumer (instance {}) initialized.", ret);