o Added some missing Javadoc o Fixed some warnings Project: http://git-wip-us.apache.org/repos/asf/mina/repo Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/c2464291 Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/c2464291 Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/c2464291
Branch: refs/heads/2.0 Commit: c24642913a69d36a6f09913160c32ee95ef517b8 Parents: e989f2c Author: Emmanuel Lécharny <elecha...@symas.com> Authored: Mon Dec 5 21:38:19 2016 +0100 Committer: Emmanuel Lécharny <elecha...@symas.com> Committed: Mon Dec 5 21:38:19 2016 +0100 ---------------------------------------------------------------------- .../apache/mina/core/future/CloseFuture.java | 4 ++++ .../mina/core/future/CompositeIoFuture.java | 18 +++++++++++++--- .../apache/mina/core/future/ConnectFuture.java | 7 ++++++- .../mina/core/future/DefaultCloseFuture.java | 2 ++ .../mina/core/future/DefaultConnectFuture.java | 6 ++++++ .../mina/core/future/DefaultIoFuture.java | 14 ++++++++++++- .../mina/core/future/DefaultReadFuture.java | 9 +++++++- .../mina/core/future/DefaultWriteFuture.java | 22 ++++++++++++-------- .../mina/core/future/IoFutureListener.java | 6 ++++++ .../org/apache/mina/core/future/ReadFuture.java | 4 ++++ .../apache/mina/core/future/WriteFuture.java | 4 ++++ 11 files changed, 81 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/CloseFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/CloseFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/CloseFuture.java index 0235c03..7afa4bf 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/CloseFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/CloseFuture.java @@ -52,20 +52,24 @@ public interface CloseFuture extends IoFuture { /** * {@inheritDoc} */ + @Override CloseFuture await() throws InterruptedException; /** * {@inheritDoc} */ + @Override CloseFuture awaitUninterruptibly(); /** * {@inheritDoc} */ + @Override CloseFuture addListener(IoFutureListener<?> listener); /** * {@inheritDoc} */ + @Override CloseFuture removeListener(IoFutureListener<?> listener); } http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/CompositeIoFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/CompositeIoFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/CompositeIoFuture.java index 6bfb483..1903f7e 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/CompositeIoFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/CompositeIoFuture.java @@ -35,28 +35,40 @@ import org.apache.mina.core.IoUtil; * @param <E> the type of the child futures. */ public class CompositeIoFuture<E extends IoFuture> extends DefaultIoFuture { - + /** A listener */ private final NotifyingListener listener = new NotifyingListener(); + /** A thread safe counter that is used to keep a track of the notified futures */ private final AtomicInteger unnotified = new AtomicInteger(); + /** A flag set to TRUE when all the future have been added to the list */ private volatile boolean constructionFinished; + /** + * Creates a new CompositeIoFuture instance + * + * @param children The list of internal futures + */ public CompositeIoFuture(Iterable<E> children) { super(null); - for (E f : children) { - f.addListener(listener); + for (E child : children) { + child.addListener(listener); unnotified.incrementAndGet(); } constructionFinished = true; + if (unnotified.get() == 0) { setValue(true); } } private class NotifyingListener implements IoFutureListener<IoFuture> { + /** + * {@inheritDoc} + */ + @Override public void operationComplete(IoFuture future) { if (unnotified.decrementAndGet() == 0 && constructionFinished) { setValue(true); http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/ConnectFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/ConnectFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/ConnectFuture.java index 5eae6a9..0376af9 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/ConnectFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/ConnectFuture.java @@ -42,6 +42,7 @@ public interface ConnectFuture extends IoFuture { * @return The {link IoSession} instance that has been associated with the connection, * if the connection was successful, {@code null} otherwise */ + @Override IoSession getSession(); /** @@ -49,7 +50,7 @@ public interface ConnectFuture extends IoFuture { * * @return <tt>null</tt> if the connect operation is not finished yet, * or if the connection attempt is successful, otherwise returns - * teh cause of the exception + * the cause of the exception */ Throwable getException(); @@ -94,20 +95,24 @@ public interface ConnectFuture extends IoFuture { /** * {@inheritDoc} */ + @Override ConnectFuture await() throws InterruptedException; /** * {@inheritDoc} */ + @Override ConnectFuture awaitUninterruptibly(); /** * {@inheritDoc} */ + @Override ConnectFuture addListener(IoFutureListener<?> listener); /** * {@inheritDoc} */ + @Override ConnectFuture removeListener(IoFutureListener<?> listener); } http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/DefaultCloseFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/DefaultCloseFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/DefaultCloseFuture.java index 8378694..9e38015 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/DefaultCloseFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/DefaultCloseFuture.java @@ -39,6 +39,7 @@ public class DefaultCloseFuture extends DefaultIoFuture implements CloseFuture { /** * {@inheritDoc} */ + @Override public boolean isClosed() { if (isDone()) { return ((Boolean) getValue()).booleanValue(); @@ -50,6 +51,7 @@ public class DefaultCloseFuture extends DefaultIoFuture implements CloseFuture { /** * {@inheritDoc} */ + @Override public void setClosed() { setValue(Boolean.TRUE); } http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/DefaultConnectFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/DefaultConnectFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/DefaultConnectFuture.java index 1860f0c..83de82d 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/DefaultConnectFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/DefaultConnectFuture.java @@ -74,6 +74,7 @@ public class DefaultConnectFuture extends DefaultIoFuture implements ConnectFutu /** * {@inheritDoc} */ + @Override public Throwable getException() { Object v = getValue(); @@ -87,6 +88,7 @@ public class DefaultConnectFuture extends DefaultIoFuture implements ConnectFutu /** * {@inheritDoc} */ + @Override public boolean isConnected() { return getValue() instanceof IoSession; } @@ -94,6 +96,7 @@ public class DefaultConnectFuture extends DefaultIoFuture implements ConnectFutu /** * {@inheritDoc} */ + @Override public boolean isCanceled() { return getValue() == CANCELED; } @@ -101,6 +104,7 @@ public class DefaultConnectFuture extends DefaultIoFuture implements ConnectFutu /** * {@inheritDoc} */ + @Override public void setSession(IoSession session) { if (session == null) { throw new IllegalArgumentException("session"); @@ -112,6 +116,7 @@ public class DefaultConnectFuture extends DefaultIoFuture implements ConnectFutu /** * {@inheritDoc} */ + @Override public void setException(Throwable exception) { if (exception == null) { throw new IllegalArgumentException("exception"); @@ -123,6 +128,7 @@ public class DefaultConnectFuture extends DefaultIoFuture implements ConnectFutu /** * {@inheritDoc} */ + @Override public boolean cancel() { return setValue(CANCELED); } http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java index 18b1506..c764fbe 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/DefaultIoFuture.java @@ -73,6 +73,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public IoSession getSession() { return session; } @@ -80,6 +81,7 @@ public class DefaultIoFuture implements IoFuture { /** * @deprecated Replaced with {@link #awaitUninterruptibly()}. */ + @Override @Deprecated public void join() { awaitUninterruptibly(); @@ -88,6 +90,7 @@ public class DefaultIoFuture implements IoFuture { /** * @deprecated Replaced with {@link #awaitUninterruptibly(long)}. */ + @Override @Deprecated public boolean join(long timeoutMillis) { return awaitUninterruptibly(timeoutMillis); @@ -96,6 +99,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public IoFuture await() throws InterruptedException { synchronized (lock) { while (!ready) { @@ -122,6 +126,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public boolean await(long timeout, TimeUnit unit) throws InterruptedException { return await0(unit.toMillis(timeout), true); } @@ -129,6 +134,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public boolean await(long timeoutMillis) throws InterruptedException { return await0(timeoutMillis, true); } @@ -136,6 +142,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public IoFuture awaitUninterruptibly() { try { await0(Long.MAX_VALUE, false); @@ -149,6 +156,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public boolean awaitUninterruptibly(long timeout, TimeUnit unit) { try { return await0(unit.toMillis(timeout), false); @@ -160,6 +168,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public boolean awaitUninterruptibly(long timeoutMillis) { try { return await0(timeoutMillis, false); @@ -284,6 +293,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public boolean isDone() { synchronized (lock) { return ready; @@ -331,6 +341,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public IoFuture addListener(IoFutureListener<?> listener) { if (listener == null) { throw new IllegalArgumentException("listener"); @@ -348,7 +359,7 @@ public class DefaultIoFuture implements IoFuture { firstListener = listener; } else { if (otherListeners == null) { - otherListeners = new ArrayList<IoFutureListener<?>>(1); + otherListeners = new ArrayList<>(1); } otherListeners.add(listener); @@ -362,6 +373,7 @@ public class DefaultIoFuture implements IoFuture { /** * {@inheritDoc} */ + @Override public IoFuture removeListener(IoFutureListener<?> listener) { if (listener == null) { throw new IllegalArgumentException("listener"); http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/DefaultReadFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/DefaultReadFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/DefaultReadFuture.java index 97199c1..b2225c3 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/DefaultReadFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/DefaultReadFuture.java @@ -45,6 +45,7 @@ public class DefaultReadFuture extends DefaultIoFuture implements ReadFuture { /** * {@inheritDoc} */ + @Override public Object getMessage() { if (isDone()) { Object v = getValue(); @@ -74,11 +75,12 @@ public class DefaultReadFuture extends DefaultIoFuture implements ReadFuture { /** * {@inheritDoc} */ + @Override public boolean isRead() { if (isDone()) { Object v = getValue(); - return (v != CLOSED && !(v instanceof Throwable)); + return v != CLOSED && !(v instanceof Throwable); } return false; @@ -87,6 +89,7 @@ public class DefaultReadFuture extends DefaultIoFuture implements ReadFuture { /** * {@inheritDoc} */ + @Override public boolean isClosed() { if (isDone()) { return getValue() == CLOSED; @@ -98,6 +101,7 @@ public class DefaultReadFuture extends DefaultIoFuture implements ReadFuture { /** * {@inheritDoc} */ + @Override public Throwable getException() { if (isDone()) { Object v = getValue(); @@ -113,6 +117,7 @@ public class DefaultReadFuture extends DefaultIoFuture implements ReadFuture { /** * {@inheritDoc} */ + @Override public void setClosed() { setValue(CLOSED); } @@ -120,6 +125,7 @@ public class DefaultReadFuture extends DefaultIoFuture implements ReadFuture { /** * {@inheritDoc} */ + @Override public void setRead(Object message) { if (message == null) { throw new IllegalArgumentException("message"); @@ -131,6 +137,7 @@ public class DefaultReadFuture extends DefaultIoFuture implements ReadFuture { /** * {@inheritDoc} */ + @Override public void setException(Throwable exception) { if (exception == null) { throw new IllegalArgumentException("exception"); http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/DefaultWriteFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/DefaultWriteFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/DefaultWriteFuture.java index 59377e2..7b5b0b8 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/DefaultWriteFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/DefaultWriteFuture.java @@ -28,6 +28,15 @@ import org.apache.mina.core.session.IoSession; */ public class DefaultWriteFuture extends DefaultIoFuture implements WriteFuture { /** + * Creates a new instance. + * + * @param session The associated session + */ + public DefaultWriteFuture(IoSession session) { + super(session); + } + + /** * Returns a new {@link DefaultWriteFuture} which is already marked as 'written'. * * @param session The associated session @@ -55,17 +64,9 @@ public class DefaultWriteFuture extends DefaultIoFuture implements WriteFuture { } /** - * Creates a new instance. - * - * @param session The associated session - */ - public DefaultWriteFuture(IoSession session) { - super(session); - } - - /** * {@inheritDoc} */ + @Override public boolean isWritten() { if (isDone()) { Object v = getValue(); @@ -81,6 +82,7 @@ public class DefaultWriteFuture extends DefaultIoFuture implements WriteFuture { /** * {@inheritDoc} */ + @Override public Throwable getException() { if (isDone()) { Object v = getValue(); @@ -96,6 +98,7 @@ public class DefaultWriteFuture extends DefaultIoFuture implements WriteFuture { /** * {@inheritDoc} */ + @Override public void setWritten() { setValue(Boolean.TRUE); } @@ -103,6 +106,7 @@ public class DefaultWriteFuture extends DefaultIoFuture implements WriteFuture { /** * {@inheritDoc} */ + @Override public void setException(Throwable exception) { if (exception == null) { throw new IllegalArgumentException("exception"); http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/IoFutureListener.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/IoFutureListener.java b/mina-core/src/main/java/org/apache/mina/core/future/IoFutureListener.java index 851f1f9..33d7d53 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/IoFutureListener.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/IoFutureListener.java @@ -26,6 +26,8 @@ import org.apache.mina.core.session.IoSession; /** * Something interested in being notified when the completion * of an asynchronous I/O operation : {@link IoFuture}. + * + * @param <F> The Future type * * @author <a href="http://mina.apache.org">Apache MINA Project</a> */ @@ -35,6 +37,10 @@ public interface IoFutureListener<F extends IoFuture> extends EventListener { * associated with the specified {@link IoFuture}. */ IoFutureListener<IoFuture> CLOSE = new IoFutureListener<IoFuture>() { + /** + * {@inheritDoc} + */ + @Override public void operationComplete(IoFuture future) { future.getSession().closeNow(); } http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/ReadFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/ReadFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/ReadFuture.java index 1f03523..62221a0 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/ReadFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/ReadFuture.java @@ -100,20 +100,24 @@ public interface ReadFuture extends IoFuture { /** * {@inheritDoc} */ + @Override ReadFuture await() throws InterruptedException; /** * {@inheritDoc} */ + @Override ReadFuture awaitUninterruptibly(); /** * {@inheritDoc} */ + @Override ReadFuture addListener(IoFutureListener<?> listener); /** * {@inheritDoc} */ + @Override ReadFuture removeListener(IoFutureListener<?> listener); } http://git-wip-us.apache.org/repos/asf/mina/blob/c2464291/mina-core/src/main/java/org/apache/mina/core/future/WriteFuture.java ---------------------------------------------------------------------- diff --git a/mina-core/src/main/java/org/apache/mina/core/future/WriteFuture.java b/mina-core/src/main/java/org/apache/mina/core/future/WriteFuture.java index 3584135..2b65392 100644 --- a/mina-core/src/main/java/org/apache/mina/core/future/WriteFuture.java +++ b/mina-core/src/main/java/org/apache/mina/core/future/WriteFuture.java @@ -80,20 +80,24 @@ public interface WriteFuture extends IoFuture { * @return the created {@link WriteFuture} * @throws InterruptedException If the wait is interrupted */ + @Override WriteFuture await() throws InterruptedException; /** * {@inheritDoc} */ + @Override WriteFuture awaitUninterruptibly(); /** * {@inheritDoc} */ + @Override WriteFuture addListener(IoFutureListener<?> listener); /** * {@inheritDoc} */ + @Override WriteFuture removeListener(IoFutureListener<?> listener); }