Exception for URI /restconf/operations/module_name:rpc ended with slash
[controller.git] / opendaylight / config / netty-event-executor-config / src / main / java / org / opendaylight / controller / config / yang / netty / eventexecutor / GlobalEventExecutorModule.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 /**
10  * Generated file
11
12  * Generated from: yang module name: netty-event-executor  yang module local name: netty-global-event-executor
13  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
14  * Generated at: Tue Nov 12 10:44:21 CET 2013
15  *
16  * Do not modify this file unless it is present under src/main directory
17  */
18 package org.opendaylight.controller.config.yang.netty.eventexecutor;
19
20 import com.google.common.reflect.AbstractInvocationHandler;
21 import com.google.common.reflect.Reflection;
22 import io.netty.util.concurrent.EventExecutor;
23 import io.netty.util.concurrent.GlobalEventExecutor;
24
25 import java.lang.reflect.Method;
26 import java.util.concurrent.TimeUnit;
27
28 public final class GlobalEventExecutorModule extends
29         org.opendaylight.controller.config.yang.netty.eventexecutor.AbstractGlobalEventExecutorModule {
30
31     public GlobalEventExecutorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
32             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
33         super(identifier, dependencyResolver);
34     }
35
36     public GlobalEventExecutorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
37             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
38             GlobalEventExecutorModule oldModule, java.lang.AutoCloseable oldInstance) {
39         super(identifier, dependencyResolver, oldModule, oldInstance);
40     }
41
42     @Override
43     public void validate() {
44         super.validate();
45     }
46
47     @Override
48     public java.lang.AutoCloseable createInstance() {
49         final CloseableGlobalEventExecutorMixin closeableGlobalEventExecutorMixin =
50                 new CloseableGlobalEventExecutorMixin(GlobalEventExecutor.INSTANCE);
51         return Reflection.newProxy(AutoCloseableEventExecutor.class, new AbstractInvocationHandler() {
52             @Override
53             protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
54                 if (method.getName().equals("close")) {
55                     closeableGlobalEventExecutorMixin.close();
56                     return null;
57                 } else {
58                     return method.invoke(GlobalEventExecutor.INSTANCE, args);
59                 }
60             }
61         });
62     }
63
64     public static interface AutoCloseableEventExecutor extends EventExecutor, AutoCloseable {
65
66     }
67
68     public static class CloseableGlobalEventExecutorMixin implements AutoCloseable {
69         private final GlobalEventExecutor eventExecutor;
70
71         public CloseableGlobalEventExecutorMixin(GlobalEventExecutor eventExecutor) {
72             this.eventExecutor = eventExecutor;
73         }
74
75         @Override
76         public void close() {
77             eventExecutor.shutdownGracefully(0, 1, TimeUnit.SECONDS);
78         }
79     }
80 }