X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-config%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyang%2Fgen%2Fv1%2Furn%2Fopendaylight%2Fparams%2Fxml%2Fns%2Fyang%2Fmd%2Fsal%2Fconfig%2Fimpl%2Fcluster%2Fsingleton%2Fservice%2Frev160718%2FClusterSingletonServiceProviderModule.java;fp=opendaylight%2Fmd-sal%2Fsal-dom-config%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyang%2Fgen%2Fv1%2Furn%2Fopendaylight%2Fparams%2Fxml%2Fns%2Fyang%2Fmd%2Fsal%2Fconfig%2Fimpl%2Fcluster%2Fsingleton%2Fservice%2Frev160718%2FClusterSingletonServiceProviderModule.java;h=daeb0a59a4c5e2c7854ebe752cd19a3b8803d954;hp=0000000000000000000000000000000000000000;hb=0684451f34cc0cbdc677a345e1e04b21cbacac20;hpb=59918fc863252de0e51e5167f0cb57f697b76c13 diff --git a/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/md/sal/config/impl/cluster/singleton/service/rev160718/ClusterSingletonServiceProviderModule.java b/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/md/sal/config/impl/cluster/singleton/service/rev160718/ClusterSingletonServiceProviderModule.java new file mode 100644 index 0000000000..daeb0a59a4 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-config/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/md/sal/config/impl/cluster/singleton/service/rev160718/ClusterSingletonServiceProviderModule.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2016 Brocade Communications 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 + */ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.md.sal.config.impl.cluster.singleton.service.rev160718; + +import com.google.common.reflect.AbstractInvocationHandler; +import com.google.common.reflect.Reflection; +import java.lang.reflect.Method; +import org.opendaylight.controller.config.api.DependencyResolver; +import org.opendaylight.controller.config.api.ModuleIdentifier; +import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker; +import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; +import org.osgi.framework.BundleContext; + +/** + * @deprecated Replaced by blueprint wiring but remains for backwards compatibility until downstream users + * of the provided config system service are converted to blueprint. + */ +@Deprecated +public class ClusterSingletonServiceProviderModule extends AbstractClusterSingletonServiceProviderModule { + private BundleContext bundleContext; + + public ClusterSingletonServiceProviderModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public ClusterSingletonServiceProviderModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver, + final ClusterSingletonServiceProviderModule oldModule, final java.lang.AutoCloseable oldInstance) { + super(identifier, dependencyResolver, oldModule, oldInstance); + } + + + @Override + public AutoCloseable createInstance() { + final WaitingServiceTracker tracker = WaitingServiceTracker + .create(ClusterSingletonServiceProvider.class, bundleContext); + final ClusterSingletonServiceProvider service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES); + + // Create a proxy to override close to close the ServiceTracker. The actual DOMClusterSingletonServiceProvider + // instance will be closed via blueprint. + return Reflection.newProxy(AutoCloseableDOMClusterSingletonServiceProvider.class, + new AbstractInvocationHandler() { + @Override + protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) + throws Throwable { + if (method.getName().equals("close")) { + tracker.close(); + return null; + } else { + return method.invoke(service, args); + } + } + }); + } + + void setBundleContext(final BundleContext bundleContext) { + this.bundleContext = bundleContext; + } + + private static interface AutoCloseableDOMClusterSingletonServiceProvider + extends ClusterSingletonServiceProvider, AutoCloseable { + } +} \ No newline at end of file