2 * Copyright (c) 2013 Cisco 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: nsos-threadpool yang module local name: netty-threadgroup-fixed
13 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
14 * Generated at: Fri Nov 08 08:31:45 CET 2013
16 * Do not modify this file unless it is present under src/main directory
18 package org.opendaylight.controller.config.yang.netty.threadgroup;
20 import com.google.common.reflect.AbstractInvocationHandler;
21 import com.google.common.reflect.Reflection;
22 import io.netty.channel.EventLoopGroup;
23 import java.lang.reflect.Method;
24 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
25 import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
26 import org.osgi.framework.BundleContext;
29 * @deprecated Replaced by blueprint wiring
32 public final class NettyThreadgroupModule extends org.opendaylight.controller.config.yang.netty.threadgroup.AbstractNettyThreadgroupModule
34 private BundleContext bundleContext;
36 public NettyThreadgroupModule(final org.opendaylight.controller.config.api.ModuleIdentifier name, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
37 super(name, dependencyResolver);
40 public NettyThreadgroupModule(final org.opendaylight.controller.config.api.ModuleIdentifier name, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final NettyThreadgroupModule oldModule, final java.lang.AutoCloseable oldInstance) {
41 super(name, dependencyResolver, oldModule, oldInstance);
45 public void validate(){
46 if(getThreadCount()!=null) {
47 JmxAttributeValidationException.checkCondition(getThreadCount() > 0, "value must be greater than 0",
48 threadCountJmxAttribute);
53 public AutoCloseable createInstance() {
54 // The service is provided via blueprint so wait for and return it here for backwards compatibility.
55 String typeFilter = String.format("(type=%s)", getIdentifier().getInstanceName());
56 final WaitingServiceTracker<EventLoopGroup> tracker = WaitingServiceTracker.create(
57 EventLoopGroup.class, bundleContext, typeFilter);
58 final EventLoopGroup group = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
60 return Reflection.newProxy(AutoCloseableEventLoopGroupInterface.class, new AbstractInvocationHandler() {
62 protected Object handleInvocation(final Object proxy, final Method method, final Object[] args) throws Throwable {
63 if (method.getName().equals("close")) {
67 return method.invoke(group, args);
73 public void setBundleContext(final BundleContext bundleContext) {
74 this.bundleContext = bundleContext;
77 private interface AutoCloseableEventLoopGroupInterface extends EventLoopGroup, AutoCloseable {