ClassNotFoundException {
throw new UnsupportedOperationException();
}
public Future<?> write(Object msg) {
final ChannelFuture future = channel.write(msg);
future.addListener(completionListener);
return new Future<Void>() {
@Override
public boolean cancel(boolean arg0) {
return future.cancel();
}
@Override
public Void get() throws InterruptedException,
ExecutionException {
future.await();
if (!future.isSuccess()) {
throw new ExecutionException(future.getCause());
}
return null;
}
@Override
public Void get(long arg0, TimeUnit arg1)
throws InterruptedException, ExecutionException,
TimeoutException {
if (future.await(arg0, arg1)) {
if (!future.isSuccess()) {
throw new ExecutionException(future.getCause());
}
return null;
}
throw new TimeoutException();
}
@Override
public boolean isCancelled() {
return future.isCancelled();
}
@Override
public boolean isDone() {
return future.isDone();
}
};
}