2 * Copyright (c) 2014, 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 * Generated from: yang module name: toaster-consumer-impl yang module local name: toaster-consumer-impl
13 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
14 * Generated at: Wed Feb 05 11:31:30 CET 2014
16 * Do not modify this file unless it is present under src/main directory
18 package org.opendaylight.controller.config.yang.config.kitchen_service.impl;
20 import java.util.concurrent.Future;
22 import org.opendaylight.controller.sample.kitchen.api.EggsType;
23 import org.opendaylight.controller.sample.kitchen.api.KitchenService;
24 import org.opendaylight.controller.sample.kitchen.impl.KitchenServiceImpl;
25 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType;
26 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
27 import org.opendaylight.yangtools.concepts.ListenerRegistration;
28 import org.opendaylight.yangtools.yang.binding.NotificationListener;
29 import org.opendaylight.yangtools.yang.common.RpcResult;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
36 public final class KitchenServiceModule extends AbstractKitchenServiceModule {
37 private static final Logger log = LoggerFactory.getLogger(KitchenServiceModule.class);
39 public KitchenServiceModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
40 super(identifier, dependencyResolver);
43 public KitchenServiceModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
44 final KitchenServiceModule oldModule, final java.lang.AutoCloseable oldInstance) {
46 super(identifier, dependencyResolver, oldModule, oldInstance);
50 protected void customValidation(){
51 // No need to validate dependencies, since all dependencies have mandatory true flag in yang
52 // config-subsystem will perform the validation
56 public java.lang.AutoCloseable createInstance() {
57 ToasterService toasterService = getRpcRegistryDependency().getRpcService(ToasterService.class);
59 final KitchenServiceImpl kitchenService = new KitchenServiceImpl(toasterService);
61 final ListenerRegistration<NotificationListener> toasterListenerReg =
62 getNotificationServiceDependency().registerNotificationListener( kitchenService );
64 final KitchenServiceRuntimeRegistration runtimeReg =
65 getRootRuntimeBeanRegistratorWrapper().register( kitchenService );
67 final class AutoCloseableKitchenService implements KitchenService, AutoCloseable {
70 public void close() throws Exception {
71 toasterListenerReg.close();
73 log.info("Toaster consumer (instance {}) torn down.", this);
77 public Future<RpcResult<Void>> makeBreakfast( final EggsType eggs,
78 final Class<? extends ToastType> toast,
79 final int toastDoneness ) {
80 return kitchenService.makeBreakfast( eggs, toast, toastDoneness );
84 AutoCloseable ret = new AutoCloseableKitchenService();
85 log.info("KitchenService (instance {}) initialized.", ret );