|
| 1 | +/* |
| 2 | + * Copyright © 2021 Cask Data, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.cdap.http.internal; |
| 18 | + |
| 19 | +import io.netty.util.concurrent.EventExecutor; |
| 20 | +import io.netty.util.concurrent.EventExecutorGroup; |
| 21 | +import io.netty.util.concurrent.Future; |
| 22 | +import io.netty.util.concurrent.ScheduledFuture; |
| 23 | + |
| 24 | +import java.util.Collection; |
| 25 | +import java.util.Iterator; |
| 26 | +import java.util.List; |
| 27 | +import java.util.concurrent.Callable; |
| 28 | +import java.util.concurrent.ExecutionException; |
| 29 | +import java.util.concurrent.TimeUnit; |
| 30 | +import java.util.concurrent.TimeoutException; |
| 31 | + |
| 32 | +/** |
| 33 | + * A {@link EventExecutorGroup} that forwards all methods to another {@link EventExecutorGroup}. |
| 34 | + */ |
| 35 | +public class ForwardingEventExecutorGroup implements EventExecutorGroup { |
| 36 | + |
| 37 | + private final EventExecutorGroup delegate; |
| 38 | + |
| 39 | + public ForwardingEventExecutorGroup(EventExecutorGroup delegate) { |
| 40 | + this.delegate = delegate; |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public boolean isShuttingDown() { |
| 45 | + return delegate.isShuttingDown(); |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + public Future<?> shutdownGracefully() { |
| 50 | + return delegate.shutdownGracefully(); |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + public Future<?> shutdownGracefully(long l, long l1, TimeUnit timeUnit) { |
| 55 | + return delegate.shutdownGracefully(l, l1, timeUnit); |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public Future<?> terminationFuture() { |
| 60 | + return delegate.terminationFuture(); |
| 61 | + } |
| 62 | + |
| 63 | + @Override |
| 64 | + @Deprecated |
| 65 | + public void shutdown() { |
| 66 | + delegate.shutdown(); |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + @Deprecated |
| 71 | + public List<Runnable> shutdownNow() { |
| 72 | + return delegate.shutdownNow(); |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public EventExecutor next() { |
| 77 | + return delegate.next(); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public Iterator<EventExecutor> iterator() { |
| 82 | + return delegate.iterator(); |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public Future<?> submit(Runnable runnable) { |
| 87 | + return delegate.submit(runnable); |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public <T> Future<T> submit(Runnable runnable, T t) { |
| 92 | + return delegate.submit(runnable, t); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public <T> Future<T> submit(Callable<T> callable) { |
| 97 | + return delegate.submit(callable); |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public ScheduledFuture<?> schedule(Runnable runnable, long l, TimeUnit timeUnit) { |
| 102 | + return delegate.schedule(runnable, l, timeUnit); |
| 103 | + } |
| 104 | + |
| 105 | + @Override |
| 106 | + public <V> ScheduledFuture<V> schedule(Callable<V> callable, long l, TimeUnit timeUnit) { |
| 107 | + return delegate.schedule(callable, l, timeUnit); |
| 108 | + } |
| 109 | + |
| 110 | + @Override |
| 111 | + public ScheduledFuture<?> scheduleAtFixedRate(Runnable runnable, long l, long l1, TimeUnit timeUnit) { |
| 112 | + return delegate.scheduleAtFixedRate(runnable, l, l1, timeUnit); |
| 113 | + } |
| 114 | + |
| 115 | + @Override |
| 116 | + public ScheduledFuture<?> scheduleWithFixedDelay(Runnable runnable, long l, long l1, TimeUnit timeUnit) { |
| 117 | + return delegate.scheduleWithFixedDelay(runnable, l, l1, timeUnit); |
| 118 | + } |
| 119 | + |
| 120 | + @Override |
| 121 | + public boolean isShutdown() { |
| 122 | + return delegate.isShutdown(); |
| 123 | + } |
| 124 | + |
| 125 | + @Override |
| 126 | + public boolean isTerminated() { |
| 127 | + return delegate.isTerminated(); |
| 128 | + } |
| 129 | + |
| 130 | + @Override |
| 131 | + public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { |
| 132 | + return delegate.awaitTermination(timeout, unit); |
| 133 | + } |
| 134 | + |
| 135 | + @Override |
| 136 | + public <T> List<java.util.concurrent.Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) |
| 137 | + throws InterruptedException { |
| 138 | + return delegate.invokeAll(tasks); |
| 139 | + } |
| 140 | + |
| 141 | + @Override |
| 142 | + public <T> List<java.util.concurrent.Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, |
| 143 | + long timeout, TimeUnit unit) throws InterruptedException { |
| 144 | + return delegate.invokeAll(tasks, timeout, unit); |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException { |
| 149 | + return delegate.invokeAny(tasks); |
| 150 | + } |
| 151 | + |
| 152 | + @Override |
| 153 | + public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) |
| 154 | + throws InterruptedException, ExecutionException, TimeoutException { |
| 155 | + return delegate.invokeAny(tasks, timeout, unit); |
| 156 | + } |
| 157 | + |
| 158 | + @Override |
| 159 | + public void execute(Runnable command) { |
| 160 | + delegate.execute(command); |
| 161 | + } |
| 162 | +} |
0 commit comments