Merge "BUG-1105: Implement subtree filtering in netconf"
[controller.git] / opendaylight / md-sal / samples / toaster-consumer / src / main / java / org / opendaylight / controller / config / yang / config / kitchen_service / impl / KitchenServiceModule.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.kitchen_service.impl;
11
12 import org.opendaylight.controller.sample.kitchen.api.EggsType;
13 import org.opendaylight.controller.sample.kitchen.api.KitchenService;
14 import org.opendaylight.controller.sample.kitchen.impl.KitchenServiceImpl;
15 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType;
16 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
17 import org.opendaylight.yangtools.concepts.Registration;
18 import org.opendaylight.yangtools.yang.binding.NotificationListener;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 /**
23  *
24  */
25 public final class KitchenServiceModule extends AbstractKitchenServiceModule {
26     private static final Logger log = LoggerFactory.getLogger(KitchenServiceModule.class);
27
28     public KitchenServiceModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
29         super(identifier, dependencyResolver);
30     }
31
32     public KitchenServiceModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
33             final KitchenServiceModule oldModule, final java.lang.AutoCloseable oldInstance) {
34
35         super(identifier, dependencyResolver, oldModule, oldInstance);
36     }
37
38     @Override
39     protected void customValidation(){
40         // No need to validate dependencies, since all dependencies have mandatory true flag in yang
41         // config-subsystem will perform the validation
42     }
43
44     @Override
45     public java.lang.AutoCloseable createInstance() {
46         ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class);
47
48         final KitchenServiceImpl kitchenService = new KitchenServiceImpl(toasterService);
49
50         final Registration<NotificationListener> toasterListenerReg =
51                 getNotificationServiceDependency().registerNotificationListener( kitchenService );
52
53         final KitchenServiceRuntimeRegistration runtimeReg =
54                 getRootRuntimeBeanRegistratorWrapper().register( kitchenService );
55
56         final class AutoCloseableKitchenService implements KitchenService, AutoCloseable {
57
58             @Override
59             public void close() throws Exception {
60                 toasterListenerReg.close();
61                 runtimeReg.close();
62                 log.info("Toaster consumer (instance {}) torn down.", this);
63             }
64
65             @Override
66             public boolean makeBreakfast( final EggsType eggs, final Class<? extends ToastType> toast, final int toastDoneness ) {
67                 return kitchenService.makeBreakfast( eggs, toast, toastDoneness );
68             }
69         }
70
71         AutoCloseable ret = new AutoCloseableKitchenService();
72         log.info("KitchenService (instance {}) initialized.", ret );
73         return ret;
74     }
75 }