d9bb36eb8ec6d1ca97032e3328cbb72a9879f1bf
[controller.git] / opendaylight / md-sal / samples / toaster-provider / src / main / java / org / opendaylight / controller / config / yang / config / toaster_provider / impl / ToasterProviderModule.java
1 /**
2 * Generated file
3
4 * Generated from: yang module name: toaster-provider-impl  yang module local name: toaster-provider-impl
5 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6 * Generated at: Wed Feb 05 11:05:32 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_provider.impl;
11
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
13 import org.opendaylight.controller.sample.toaster.provider.OpendaylightToaster;
14 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster;
15 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterData;
16 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 /**
21 *
22 */
23 public final class ToasterProviderModule extends org.opendaylight.controller.config.yang.config.toaster_provider.impl.AbstractToasterProviderModule
24  {
25     private static final Logger log = LoggerFactory.getLogger(ToasterProviderModule.class);
26
27     public ToasterProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
28         super(identifier, dependencyResolver);
29     }
30
31     public ToasterProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
32             ToasterProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
33
34         super(identifier, dependencyResolver, oldModule, oldInstance);
35     }
36
37     @Override
38     protected void customValidation() {
39         // No need to validate dependencies, since all dependencies have mandatory true flag in yang
40         // config-subsystem will perform the validation for dependencies
41     }
42
43     @Override
44     public java.lang.AutoCloseable createInstance() {
45         final OpendaylightToaster opendaylightToaster = new OpendaylightToaster();
46
47         // Register to md-sal
48         opendaylightToaster.setNotificationProvider(getNotificationServiceDependency());
49         opendaylightToaster.setDataProvider(getDataBrokerDependency());
50         final BindingAwareBroker.RpcRegistration<ToasterService> rpcRegistration = getRpcRegistryDependency()
51                 .addRpcImplementation(ToasterService.class, opendaylightToaster);
52
53         // Register runtimeBean for toaster statistics via JMX
54         final ToasterProviderRuntimeRegistration runtimeReg = getRootRuntimeBeanRegistratorWrapper().register(
55                 opendaylightToaster);
56
57         // Wrap toaster as AutoCloseable and close registrations to md-sal at
58         // close()
59         final class AutoCloseableToaster implements AutoCloseable, ToasterData {
60
61             @Override
62             public void close() throws Exception {
63                 rpcRegistration.close();
64                 runtimeReg.close();
65                 opendaylightToaster.close();
66                 log.info("Toaster provider (instance {}) torn down.", this);
67             }
68
69             @Override
70             public Toaster getToaster() {
71                 return opendaylightToaster.getToaster();
72             }
73         }
74
75         AutoCloseable ret = new AutoCloseableToaster();
76         log.info("Toaster provider (instance {}) initialized.", ret);
77         return ret;
78     }
79 }

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