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;
31 public final class NettyThreadgroupModule extends org.opendaylight.controller.config.yang.netty.threadgroup.AbstractNettyThreadgroupModule
33 private BundleContext bundleContext;
35 public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
36 super(name, dependencyResolver);
39 public NettyThreadgroupModule(org.opendaylight.controller.config.api.ModuleIdentifier name, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NettyThreadgroupModule oldModule, java.lang.AutoCloseable oldInstance) {
40 super(name, dependencyResolver, oldModule, oldInstance);
44 public void validate(){
45 if(getThreadCount()!=null) {
46 JmxAttributeValidationException.checkCondition(getThreadCount() > 0, "value must be greater than 0",
47 threadCountJmxAttribute);
52 public AutoCloseable createInstance() {
53 // The service is provided via blueprint so wait for and return it here for backwards compatibility.
54 String typeFilter = String.format("(type=%s)", getIdentifier().getInstanceName());
55 final WaitingServiceTracker<EventLoopGroup> tracker = WaitingServiceTracker.create(
56 EventLoopGroup.class, bundleContext, typeFilter);
57 final EventLoopGroup group = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
59 return Reflection.newProxy(AutoCloseableEventLoopGroupInterface.class, new AbstractInvocationHandler() {
61 protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
62 if (method.getName().equals("close")) {
66 return method.invoke(group, args);
72 public void setBundleContext(BundleContext bundleContext) {
73 this.bundleContext = bundleContext;
76 private static interface AutoCloseableEventLoopGroupInterface extends EventLoopGroup, AutoCloseable {