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;
21 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
22 import org.opendaylight.controller.sample.kitchen.api.EggsType;
23 import org.opendaylight.controller.sample.kitchen.api.KitchenService;
24 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType;
25 import org.opendaylight.yangtools.yang.common.RpcResult;
26 import org.osgi.framework.BundleContext;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
33 public final class KitchenServiceModule extends AbstractKitchenServiceModule {
34 private static final Logger log = LoggerFactory.getLogger(KitchenServiceModule.class);
36 private BundleContext bundleContext;
38 public KitchenServiceModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
39 super(identifier, dependencyResolver);
42 public KitchenServiceModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
43 final KitchenServiceModule oldModule, final java.lang.AutoCloseable oldInstance) {
45 super(identifier, dependencyResolver, oldModule, oldInstance);
49 protected void customValidation(){
50 // No need to validate dependencies, since all dependencies have mandatory true flag in yang
51 // config-subsystem will perform the validation
55 public AutoCloseable createInstance() {
56 // The KitchenServiceImpl instance is created and advertised with the OSGi registry via blueprint
57 // so obtain it here so we can return it to the config system. It's possible the blueprint container
58 // hasn't been created yet so we busy wait 5 min for the service.
59 final WaitingServiceTracker<KitchenService> tracker = WaitingServiceTracker.create(
60 KitchenService.class, bundleContext);
61 final KitchenService kitchenService = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
63 final class AutoCloseableKitchenService implements KitchenService, AutoCloseable {
66 // We need to close the ServiceTracker however we don't want to close the actual
67 // KitchenService instance because its life-cycle is controlled via blueprint.
69 log.info("KitchenService (instance {}) closed.", kitchenService);
73 public Future<RpcResult<Void>> makeBreakfast(final EggsType eggs, final Class<? extends ToastType> toast,
74 final int toastDoneness) {
75 return kitchenService.makeBreakfast(eggs, toast, toastDoneness);
79 return new AutoCloseableKitchenService();
82 public void setBundleContext(BundleContext bundleContext) {
83 this.bundleContext = bundleContext;