X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsamples%2Ftoaster-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fconfig%2Ftoaster_provider%2Fimpl%2FToasterProviderModule.java;h=47c5692564c056c509d63a045d5c7dc1781cbbd0;hb=44b5dbe52783a3a558b3eae619b01baf613f82e0;hp=388c78eaaf6365c77241c17cae04848680882624;hpb=cbe83ca3074fa0182d4f079f528bb710a997ced7;p=controller.git diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java index 388c78eaaf..47c5692564 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/config/yang/config/toaster_provider/impl/ToasterProviderModule.java @@ -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 @@ -10,13 +18,9 @@ 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 dataChangeListenerRegistration = dataBrokerService - .registerDataChangeListener(LogicalDatastoreType.CONFIGURATION, OpendaylightToaster.TOASTER_IID, - opendaylightToaster, DataChangeScope.SUBTREE); - final BindingAwareBroker.RpcRegistration 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();