/* * 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 * Generated from: yang module name: netty-event-executor yang module local name: netty-global-event-executor * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator * Generated at: Tue Nov 12 10:44:21 CET 2013 * * Do not modify this file unless it is present under src/main directory */ package org.opendaylight.controller.config.yang.netty.eventexecutor; import com.google.common.reflect.AbstractInvocationHandler; import com.google.common.reflect.Reflection; import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.GlobalEventExecutor; import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; public final class GlobalEventExecutorModule extends org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModule { public GlobalEventExecutorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, 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) { super(identifier, dependencyResolver, oldModule, oldInstance); } @Override public void validate() { super.validate(); } @Override public java.lang.AutoCloseable createInstance() { final CloseableGlobalEventExecutorMixin closeableGlobalEventExecutorMixin = new CloseableGlobalEventExecutorMixin(GlobalEventExecutor.INSTANCE); return Reflection.newProxy(AutoCloseableEventExecutor.class, new AbstractInvocationHandler() { @Override protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("close")) { closeableGlobalEventExecutorMixin.close(); return null; } else { return method.invoke(GlobalEventExecutor.INSTANCE, args); } } }); } public static interface AutoCloseableEventExecutor extends EventExecutor, AutoCloseable { } public static class CloseableGlobalEventExecutorMixin implements AutoCloseable { private final GlobalEventExecutor eventExecutor; public CloseableGlobalEventExecutorMixin(GlobalEventExecutor eventExecutor) { this.eventExecutor = eventExecutor; } @Override public void close() { eventExecutor.shutdownGracefully(0, 1, TimeUnit.SECONDS); } } }