X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fnetty-event-executor-config%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fnetty%2Feventexecutor%2FGlobalEventExecutorModule.java;h=427cad5c74c3532092654d66683272962bb6cc20;hp=3707f016a271b41e746a71cd611fa706b84fd354;hb=7843fba86f5b123755eb53d19f7a001312897a72;hpb=66275014176d47619096a53d59a0894b93798bdc diff --git a/opendaylight/config/netty-event-executor-config/src/main/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModule.java b/opendaylight/config/netty-event-executor-config/src/main/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModule.java index 3707f016a2..427cad5c74 100644 --- a/opendaylight/config/netty-event-executor-config/src/main/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModule.java +++ b/opendaylight/config/netty-event-executor-config/src/main/java/org/opendaylight/controller/config/yang/netty/eventexecutor/GlobalEventExecutorModule.java @@ -1,3 +1,11 @@ +/* + * Copyright (c) 2013 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 @@ -9,105 +17,45 @@ */ package org.opendaylight.controller.config.yang.netty.eventexecutor; -import io.netty.util.concurrent.AbstractEventExecutor; import io.netty.util.concurrent.EventExecutor; -import io.netty.util.concurrent.EventExecutorGroup; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GlobalEventExecutor; - -import java.util.concurrent.TimeUnit; +import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker; +import org.opendaylight.controller.config.yang.netty.eventexecutor.AutoCloseableEventExecutor.CloseableEventExecutorMixin; +import org.osgi.framework.BundleContext; /** -* -*/ + * @deprecated Replaced by blueprint wiring + */ +@Deprecated public final class GlobalEventExecutorModule extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModule { + private BundleContext bundleContext; - public GlobalEventExecutorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + public GlobalEventExecutorModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); } - public GlobalEventExecutorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, - org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, - GlobalEventExecutorModule oldModule, java.lang.AutoCloseable oldInstance) { + public GlobalEventExecutorModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, + final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + final GlobalEventExecutorModule oldModule, final java.lang.AutoCloseable oldInstance) { super(identifier, dependencyResolver, oldModule, oldInstance); } @Override public void validate() { super.validate(); - // Add custom validation for module attributes here. } @Override - public java.lang.AutoCloseable createInstance() { - return new GlobalEventExecutorCloseable(GlobalEventExecutor.INSTANCE); + public AutoCloseable createInstance() { + // The service is provided via blueprint so wait for and return it here for backwards compatibility. + final WaitingServiceTracker tracker = WaitingServiceTracker.create( + EventExecutor.class, bundleContext, "(type=global-event-executor)"); + EventExecutor eventExecutor = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES); + return CloseableEventExecutorMixin.forwardingEventExecutor(eventExecutor, tracker); } - static final private class GlobalEventExecutorCloseable extends AbstractEventExecutor implements AutoCloseable { - - private EventExecutor executor; - - public GlobalEventExecutorCloseable(EventExecutor executor) { - this.executor = executor; - } - - @Override - public EventExecutorGroup parent() { - return this.executor.parent(); - } - - @Override - public boolean inEventLoop(Thread thread) { - return this.executor.inEventLoop(thread); - } - - @Override - public boolean isShuttingDown() { - return this.executor.isShuttingDown(); - } - - @Override - public Future shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { - return this.executor.shutdownGracefully(quietPeriod, timeout, unit); - } - - @Override - public Future terminationFuture() { - return this.executor.terminationFuture(); - } - - @Override - public boolean isShutdown() { - return this.executor.isShutdown(); - } - - @Override - public boolean isTerminated() { - return this.executor.isTerminated(); - } - - @Override - public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { - return this.executor.awaitTermination(timeout, unit); - } - - @Override - public void execute(Runnable command) { - this.executor.execute(command); - } - - @Override - public void close() throws Exception { - shutdownGracefully(); - } - - @SuppressWarnings("deprecation") - @Override - public void shutdown() { - this.executor.shutdown(); - } - + public void setBundleContext(final BundleContext bundleContext) { + this.bundleContext = bundleContext; } }