Add blueprint wiring to the toaster sample
[controller.git] / opendaylight / md-sal / samples / toaster-provider / src / main / java / org / opendaylight / controller / config / yang / config / toaster_provider / impl / ToasterProviderModule.java
index 388c78eaaf6365c77241c17cae04848680882624..47c5692564c056c509d63a045d5c7dc1781cbbd0 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 /**
 * Generated file
 
 package org.opendaylight.controller.config.yang.config.toaster_provider.impl;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sample.toaster.provider.OpendaylightToaster;
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -56,10 +60,6 @@ public final class ToasterProviderModule extends
         DataBroker dataBrokerService = getDataBrokerDependency();
         opendaylightToaster.setDataProvider(dataBrokerService);
 
-        final ListenerRegistration<DataChangeListener> dataChangeListenerRegistration = dataBrokerService
-                .registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, OpendaylightToaster.TOASTER_IID,
-                        opendaylightToaster, DataChangeScope.SUBTREE);
-
         final BindingAwareBroker.RpcRegistration<ToasterService> rpcRegistration = getRpcRegistryDependency()
                 .addRpcImplementation(ToasterService.class, opendaylightToaster);
 
@@ -73,12 +73,19 @@ public final class ToasterProviderModule extends
 
             @Override
             public void close() throws Exception {
-                dataChangeListenerRegistration.close();
                 rpcRegistration.close();
                 runtimeReg.close();
-                opendaylightToaster.close();
+                closeQuietly(opendaylightToaster);
                 log.info("Toaster provider (instance {}) torn down.", this);
             }
+
+            private void closeQuietly(final AutoCloseable resource) {
+                try {
+                    resource.close();
+                } catch (final Exception e) {
+                    log.debug("Ignoring exception while closing {}", resource, e);
+                }
+            }
         }
 
         AutoCloseable ret = new AutoCloseableToaster();