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: netty-event-executor yang module local name: netty-hashed-wheel-timer
13 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
14 * Generated at: Tue Nov 19 12:49:59 CET 2013
16 * Do not modify this file unless it is present under src/main directory
18 package org.opendaylight.controller.config.yang.netty.timer;
20 import com.google.common.reflect.AbstractInvocationHandler;
21 import com.google.common.reflect.Reflection;
22 import io.netty.util.Timer;
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 HashedWheelTimerModule extends
33 org.opendaylight.controller.config.yang.netty.timer.AbstractHashedWheelTimerModule {
34 private BundleContext bundleContext;
36 public HashedWheelTimerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
37 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
38 super(identifier, dependencyResolver);
41 public HashedWheelTimerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
42 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
43 HashedWheelTimerModule oldModule, java.lang.AutoCloseable oldInstance) {
44 super(identifier, dependencyResolver, oldModule, oldInstance);
48 public void validate() {
50 if (getTickDuration() != null) {
51 JmxAttributeValidationException.checkCondition(getTickDuration() > 0, "value must be greater than 0",
52 tickDurationJmxAttribute);
54 if (getTicksPerWheel() != null) {
55 JmxAttributeValidationException.checkCondition(getTicksPerWheel() > 0, "value must be greater than 0",
56 ticksPerWheelJmxAttribute);
61 public AutoCloseable createInstance() {
62 // The service is provided via blueprint so wait for and return it here for backwards compatibility.
63 final WaitingServiceTracker<Timer> tracker = WaitingServiceTracker.create(
64 Timer.class, bundleContext, "(type=global-timer)");
65 final Timer timer = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
67 return Reflection.newProxy(AutoCloseableTimerInterface.class, new AbstractInvocationHandler() {
69 protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
70 if (method.getName().equals("close")) {
74 return method.invoke(timer, args);
80 public void setBundleContext(BundleContext bundleContext) {
81 this.bundleContext = bundleContext;
84 private interface AutoCloseableTimerInterface extends Timer, AutoCloseable {