Repository: mina Updated Branches: refs/heads/2.0 d95cd1010 -> b8c32d2c0
o Fixed the missing Javadoc o Fixed some SonarLint warnings Project: http://git-wip-us.apache.org/repos/asf/mina/repo Commit: http://git-wip-us.apache.org/repos/asf/mina/commit/d2fcea3a Tree: http://git-wip-us.apache.org/repos/asf/mina/tree/d2fcea3a Diff: http://git-wip-us.apache.org/repos/asf/mina/diff/d2fcea3a Branch: refs/heads/2.0 Commit: d2fcea3a033b4069202f0e90e9e619c746c4efd8 Parents: 0b2de71 7c08089 Author: Emmanuel Lécharny <elecha...@symas.com> Authored: Thu Dec 8 00:03:44 2016 +0100 Committer: Emmanuel Lécharny <elecha...@symas.com> Committed: Thu Dec 8 07:58:43 2016 +0100 ---------------------------------------------------------------------- .../mina/core/service/AbstractIoAcceptor.java | 17 ++++- .../mina/core/service/AbstractIoConnector.java | 74 +++++++++++++++++-- .../mina/core/service/AbstractIoService.java | 78 ++++++++++++++++---- .../core/service/DefaultTransportMetadata.java | 44 ++++++++--- .../apache/mina/core/service/IoConnector.java | 2 + .../mina/core/service/IoHandlerAdapter.java | 8 ++ .../core/service/IoServiceListenerSupport.java | 12 ++- .../mina/core/service/IoServiceStatistics.java | 18 ++--- .../core/service/SimpleIoProcessorPool.java | 12 ++- 9 files changed, 212 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java index 867fb1d,867fb1d..8169a1d --- a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoAcceptor.java @@@ -188,6 -188,6 +188,7 @@@ public abstract class AbstractIoAccepto Collection<SocketAddress> newLocalAddresses = new ArrayList<>(otherLocalAddresses.length + 1); newLocalAddresses.add(firstLocalAddress); ++ for (SocketAddress a : otherLocalAddresses) { newLocalAddresses.add(a); } @@@ -318,9 -318,9 +319,7 @@@ public final void bind(Iterable<? exten synchronized (boundAddresses) { boundAddresses.addAll(addresses); } -- } catch (IOException e) { -- throw e; -- } catch (RuntimeException e) { ++ } catch (IOException | RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeIoException("Failed to bind to: " + getLocalAddresses(), e); @@@ -462,13 -462,13 +461,24 @@@ } } ++ /** ++ * A {@Link IoFuture} ++ */ public static class AcceptorOperationFuture extends ServiceOperationFuture { private final List<SocketAddress> localAddresses; ++ /** ++ * Creates a new AcceptorOperationFuture instance ++ * ++ * @param localAddresses The list of local addresses to listen to ++ */ public AcceptorOperationFuture(List<? extends SocketAddress> localAddresses) { this.localAddresses = new ArrayList<>(localAddresses); } ++ /** ++ * @return The list of local addresses we listen to ++ */ public final List<SocketAddress> getLocalAddresses() { return Collections.unmodifiableList(localAddresses); } @@@ -476,6 -476,6 +486,7 @@@ /** * @see Object#toString() */ ++ @Override public String toString() { StringBuilder sb = new StringBuilder(); http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java index 57170a2,57170a2..1ae1a30 --- a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoConnector.java @@@ -77,6 -77,6 +77,11 @@@ public abstract class AbstractIoConnect return connectTimeoutCheckInterval; } ++ /** ++ * Sets the timeout for the connection check ++ * ++ * @param minimumConnectTimeout The delay we wait before checking the connection ++ */ public void setConnectTimeoutCheckInterval(long minimumConnectTimeout) { if (getConnectTimeoutMillis() < minimumConnectTimeout) { this.connectTimeoutInMillis = minimumConnectTimeout; @@@ -86,9 -86,9 +91,10 @@@ } /** -- * @deprecated -- * Take a look at <tt>getConnectTimeoutMillis()</tt> ++ * @deprecated Take a look at <tt>getConnectTimeoutMillis()</tt> */ ++ @Deprecated ++ @Override public final int getConnectTimeout() { return (int) connectTimeoutInMillis / 1000; } @@@ -96,6 -96,6 +102,7 @@@ /** * {@inheritDoc} */ ++ @Override public final long getConnectTimeoutMillis() { return connectTimeoutInMillis; } @@@ -104,6 -104,6 +111,8 @@@ * @deprecated * Take a look at <tt>setConnectTimeoutMillis(long)</tt> */ ++ @Deprecated ++ @Override public final void setConnectTimeout(int connectTimeout) { setConnectTimeoutMillis(connectTimeout * 1000L); @@@ -113,6 -113,6 +122,7 @@@ * Sets the connect timeout value in milliseconds. * */ ++ @Override public final void setConnectTimeoutMillis(long connectTimeoutInMillis) { if (connectTimeoutInMillis <= connectTimeoutCheckInterval) { this.connectTimeoutCheckInterval = connectTimeoutInMillis; @@@ -123,6 -123,6 +133,7 @@@ /** * {@inheritDoc} */ ++ @Override public SocketAddress getDefaultRemoteAddress() { return defaultRemoteAddress; } @@@ -130,6 -130,6 +141,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void setDefaultLocalAddress(SocketAddress localAddress) { defaultLocalAddress = localAddress; } @@@ -137,6 -137,6 +149,7 @@@ /** * {@inheritDoc} */ ++ @Override public final SocketAddress getDefaultLocalAddress() { return defaultLocalAddress; } @@@ -144,6 -144,6 +157,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void setDefaultRemoteAddress(SocketAddress defaultRemoteAddress) { if (defaultRemoteAddress == null) { throw new IllegalArgumentException("defaultRemoteAddress"); @@@ -159,30 -159,30 +173,35 @@@ /** * {@inheritDoc} */ ++ @Override public final ConnectFuture connect() { -- SocketAddress defaultRemoteAddress = getDefaultRemoteAddress(); -- if (defaultRemoteAddress == null) { ++ SocketAddress remoteAddress = getDefaultRemoteAddress(); ++ ++ if (remoteAddress == null) { throw new IllegalStateException("defaultRemoteAddress is not set."); } -- return connect(defaultRemoteAddress, null, null); ++ return connect(remoteAddress, null, null); } /** * {@inheritDoc} */ ++ @Override public ConnectFuture connect(IoSessionInitializer<? extends ConnectFuture> sessionInitializer) { -- SocketAddress defaultRemoteAddress = getDefaultRemoteAddress(); -- if (defaultRemoteAddress == null) { ++ SocketAddress remoteAddress = getDefaultRemoteAddress(); ++ ++ if (remoteAddress == null) { throw new IllegalStateException("defaultRemoteAddress is not set."); } -- return connect(defaultRemoteAddress, null, sessionInitializer); ++ return connect(remoteAddress, null, sessionInitializer); } /** * {@inheritDoc} */ ++ @Override public final ConnectFuture connect(SocketAddress remoteAddress) { return connect(remoteAddress, null, null); } @@@ -190,6 -190,6 +209,7 @@@ /** * {@inheritDoc} */ ++ @Override public ConnectFuture connect(SocketAddress remoteAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer) { return connect(remoteAddress, null, sessionInitializer); @@@ -198,6 -198,6 +218,7 @@@ /** * {@inheritDoc} */ ++ @Override public ConnectFuture connect(SocketAddress remoteAddress, SocketAddress localAddress) { return connect(remoteAddress, localAddress, null); } @@@ -205,6 -205,6 +226,7 @@@ /** * {@inheritDoc} */ ++ @Override public final ConnectFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, IoSessionInitializer<? extends ConnectFuture> sessionInitializer) { if (isDisposing()) { @@@ -228,34 -228,34 +250,66 @@@ if (getHandler() == null) { if (getSessionConfig().isUseReadOperation()) { setHandler(new IoHandler() { ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void exceptionCaught(IoSession session, Throwable cause) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void messageReceived(IoSession session, Object message) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void messageSent(IoSession session, Object message) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void sessionClosed(IoSession session) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void sessionCreated(IoSession session) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void sessionIdle(IoSession session, IdleStatus status) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void sessionOpened(IoSession session) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void inputClosed(IoSession session) throws Exception { // Empty handler } @@@ -291,6 -291,6 +345,10 @@@ // setSession() is invoked, add a listener that closes the // connection immediately on cancellation. future.addListener(new IoFutureListener<ConnectFuture>() { ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void operationComplete(ConnectFuture future) { if (future.isCanceled()) { session.closeNow(); http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java index 2f58f53,2f58f53..f6a610d --- a/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/AbstractIoService.java @@@ -100,32 -100,32 +100,56 @@@ public abstract class AbstractIoServic protected final IoSessionConfig sessionConfig; private final IoServiceListener serviceActivationListener = new IoServiceListener() { ++ IoServiceStatistics serviceStats; ++ ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void serviceActivated(IoService service) { // Update lastIoTime. -- AbstractIoService s = (AbstractIoService) service; -- IoServiceStatistics _stats = s.getStatistics(); -- _stats.setLastReadTime(s.getActivationTime()); -- _stats.setLastWriteTime(s.getActivationTime()); -- _stats.setLastThroughputCalculationTime(s.getActivationTime()); -- ++ serviceStats = service.getStatistics(); ++ serviceStats.setLastReadTime(service.getActivationTime()); ++ serviceStats.setLastWriteTime(service.getActivationTime()); ++ serviceStats.setLastThroughputCalculationTime(service.getActivationTime()); } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void serviceDeactivated(IoService service) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void serviceIdle(IoService service, IdleStatus idleStatus) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void sessionCreated(IoSession session) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void sessionClosed(IoSession session) throws Exception { // Empty handler } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public void sessionDestroyed(IoSession session) throws Exception { // Empty handler } @@@ -153,9 -153,9 +177,6 @@@ private volatile boolean disposed; -- /** -- * {@inheritDoc} -- */ private IoServiceStatistics stats = new IoServiceStatistics(this); /** @@@ -210,6 -210,6 +231,7 @@@ /** * {@inheritDoc} */ ++ @Override public final IoFilterChainBuilder getFilterChainBuilder() { return filterChainBuilder; } @@@ -217,16 -217,16 +239,19 @@@ /** * {@inheritDoc} */ ++ @Override public final void setFilterChainBuilder(IoFilterChainBuilder builder) { if (builder == null) { -- builder = new DefaultIoFilterChainBuilder(); ++ filterChainBuilder = new DefaultIoFilterChainBuilder(); ++ } else { ++ filterChainBuilder = builder; } -- filterChainBuilder = builder; } /** * {@inheritDoc} */ ++ @Override public final DefaultIoFilterChainBuilder getFilterChain() { if (filterChainBuilder instanceof DefaultIoFilterChainBuilder) { return (DefaultIoFilterChainBuilder) filterChainBuilder; @@@ -238,6 -238,6 +263,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void addListener(IoServiceListener listener) { listeners.add(listener); } @@@ -245,6 -245,6 +271,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void removeListener(IoServiceListener listener) { listeners.remove(listener); } @@@ -252,6 -252,6 +279,7 @@@ /** * {@inheritDoc} */ ++ @Override public final boolean isActive() { return listeners.isActive(); } @@@ -259,6 -259,6 +287,7 @@@ /** * {@inheritDoc} */ ++ @Override public final boolean isDisposing() { return disposing; } @@@ -266,6 -266,6 +295,7 @@@ /** * {@inheritDoc} */ ++ @Override public final boolean isDisposed() { return disposed; } @@@ -273,6 -273,6 +303,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void dispose() { dispose(false); } @@@ -280,6 -280,6 +311,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void dispose(boolean awaitTermination) { if (disposed) { return; @@@ -327,6 -327,6 +359,7 @@@ /** * {@inheritDoc} */ ++ @Override public final Map<Long, IoSession> getManagedSessions() { return listeners.getManagedSessions(); } @@@ -334,6 -334,6 +367,7 @@@ /** * {@inheritDoc} */ ++ @Override public final int getManagedSessionCount() { return listeners.getManagedSessionCount(); } @@@ -341,6 -341,6 +375,7 @@@ /** * {@inheritDoc} */ ++ @Override public final IoHandler getHandler() { return handler; } @@@ -348,6 -348,6 +383,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void setHandler(IoHandler handler) { if (handler == null) { throw new IllegalArgumentException("handler cannot be null"); @@@ -363,6 -363,6 +399,7 @@@ /** * {@inheritDoc} */ ++ @Override public final IoSessionDataStructureFactory getSessionDataStructureFactory() { return sessionDataStructureFactory; } @@@ -370,6 -370,6 +407,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void setSessionDataStructureFactory(IoSessionDataStructureFactory sessionDataStructureFactory) { if (sessionDataStructureFactory == null) { throw new IllegalArgumentException("sessionDataStructureFactory"); @@@ -385,6 -385,6 +423,7 @@@ /** * {@inheritDoc} */ ++ @Override public IoServiceStatistics getStatistics() { return stats; } @@@ -392,6 -392,6 +431,7 @@@ /** * {@inheritDoc} */ ++ @Override public final long getActivationTime() { return listeners.getActivationTime(); } @@@ -399,6 -399,6 +439,7 @@@ /** * {@inheritDoc} */ ++ @Override public final Set<WriteFuture> broadcast(Object message) { // Convert to Set. We do not return a List here because only the // direct caller of MessageBroadcaster knows the order of write @@@ -417,6 -417,6 +458,9 @@@ }; } ++ /** ++ * @return The {@link IoServiceListenerSupport} attached to this service ++ */ public final IoServiceListenerSupport getListeners() { return listeners; } @@@ -433,8 -433,8 +477,6 @@@ executor.execute(new NamePreservingRunnable(worker, actualThreadName)); } -- // TODO Figure out make it work without causing a compiler error / warning. -- @SuppressWarnings("unchecked") protected final void initSession(IoSession session, IoFuture future, IoSessionInitializer sessionInitializer) { // Update lastIoTime if needed. if (stats.getLastReadTime() == 0) { @@@ -494,8 -494,8 +536,7 @@@ } /** -- * A specific class used to -- * @author elecharny ++ * A {@link IoFuture} dedicated class for * */ protected static class ServiceOperationFuture extends DefaultIoFuture { @@@ -503,6 -503,6 +544,10 @@@ super(null); } ++ /** ++ * {@inheritDoc} ++ */ ++ @Override public final boolean isDone() { return getValue() == Boolean.TRUE; } @@@ -531,6 -531,6 +576,7 @@@ /** * {@inheritDoc} */ ++ @Override public int getScheduledWriteBytes() { return stats.getScheduledWriteBytes(); } @@@ -538,8 -538,8 +584,8 @@@ /** * {@inheritDoc} */ ++ @Override public int getScheduledWriteMessages() { return stats.getScheduledWriteMessages(); } -- } http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/DefaultTransportMetadata.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/DefaultTransportMetadata.java index 2c07e8c,2c07e8c..58b08e7 --- a/mina-core/src/main/java/org/apache/mina/core/service/DefaultTransportMetadata.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/DefaultTransportMetadata.java @@@ -48,24 -48,24 +48,39 @@@ public class DefaultTransportMetadata i private final Set<Class<? extends Object>> envelopeTypes; ++ /** ++ * Creates a new DefaultTransportMetadata instance ++ * ++ * @param providerName The provider name ++ * @param name The name ++ * @param connectionless If the transport is UDP ++ * @param fragmentation If fragmentation is supported ++ * @param addressType The address type (IP V4 or IPV6) ++ * @param sessionConfigType The session configuration type ++ * @param envelopeTypes The types of supported messages ++ */ public DefaultTransportMetadata(String providerName, String name, boolean connectionless, boolean fragmentation, Class<? extends SocketAddress> addressType, Class<? extends IoSessionConfig> sessionConfigType, Class<?>... envelopeTypes) { if (providerName == null) { throw new IllegalArgumentException("providerName"); ++ } else { ++ this.providerName = providerName.trim().toLowerCase(); ++ ++ if (this.providerName.length() == 0) { ++ throw new IllegalArgumentException("providerName is empty."); ++ } } ++ if (name == null) { throw new IllegalArgumentException("name"); -- } -- -- providerName = providerName.trim().toLowerCase(); -- if (providerName.length() == 0) { -- throw new IllegalArgumentException("providerName is empty."); -- } -- name = name.trim().toLowerCase(); -- if (name.length() == 0) { -- throw new IllegalArgumentException("name is empty."); ++ } else { ++ this.name = name.trim().toLowerCase(); ++ ++ if (this.name.length() == 0) { ++ throw new IllegalArgumentException("name is empty."); ++ } } if (addressType == null) { @@@ -84,14 -84,14 +99,12 @@@ throw new IllegalArgumentException("sessionConfigType"); } -- this.providerName = providerName; -- this.name = name; this.connectionless = connectionless; this.fragmentation = fragmentation; this.addressType = addressType; this.sessionConfigType = sessionConfigType; -- Set<Class<? extends Object>> newEnvelopeTypes = new IdentityHashSet<Class<? extends Object>>(); ++ Set<Class<? extends Object>> newEnvelopeTypes = new IdentityHashSet<>(); for (Class<? extends Object> c : envelopeTypes) { newEnvelopeTypes.add(c); } @@@ -101,6 -101,6 +114,7 @@@ /** * {@inheritDoc} */ ++ @Override public Class<? extends SocketAddress> getAddressType() { return addressType; } @@@ -108,6 -108,6 +122,7 @@@ /** * {@inheritDoc} */ ++ @Override public Set<Class<? extends Object>> getEnvelopeTypes() { return envelopeTypes; } @@@ -115,6 -115,6 +130,7 @@@ /** * {@inheritDoc} */ ++ @Override public Class<? extends IoSessionConfig> getSessionConfigType() { return sessionConfigType; } @@@ -122,6 -122,6 +138,7 @@@ /** * {@inheritDoc} */ ++ @Override public String getProviderName() { return providerName; } @@@ -129,6 -129,6 +146,7 @@@ /** * {@inheritDoc} */ ++ @Override public String getName() { return name; } @@@ -136,6 -136,6 +154,7 @@@ /** * {@inheritDoc} */ ++ @Override public boolean isConnectionless() { return connectionless; } @@@ -143,6 -143,6 +162,7 @@@ /** * {@inheritDoc} */ ++ @Override public boolean hasFragmentation() { return fragmentation; } http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/IoConnector.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/IoConnector.java index 2387002,2387002..c6a2fdc --- a/mina-core/src/main/java/org/apache/mina/core/service/IoConnector.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/IoConnector.java @@@ -49,6 -49,6 +49,7 @@@ public interface IoConnector extends Io * * @deprecated */ ++ @Deprecated int getConnectTimeout(); /** @@@ -62,6 -62,6 +63,7 @@@ * @deprecated * @param connectTimeout The time out for the connection */ ++ @Deprecated void setConnectTimeout(int connectTimeout); /** http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java index 33c0dcd,33c0dcd..7df46cf --- a/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/IoHandlerAdapter.java @@@ -37,6 -37,6 +37,7 @@@ public class IoHandlerAdapter implement /** * {@inheritDoc} */ ++ @Override public void sessionCreated(IoSession session) throws Exception { // Empty handler } @@@ -44,6 -44,6 +45,7 @@@ /** * {@inheritDoc} */ ++ @Override public void sessionOpened(IoSession session) throws Exception { // Empty handler } @@@ -51,6 -51,6 +53,7 @@@ /** * {@inheritDoc} */ ++ @Override public void sessionClosed(IoSession session) throws Exception { // Empty handler } @@@ -58,6 -58,6 +61,7 @@@ /** * {@inheritDoc} */ ++ @Override public void sessionIdle(IoSession session, IdleStatus status) throws Exception { // Empty handler } @@@ -65,6 -65,6 +69,7 @@@ /** * {@inheritDoc} */ ++ @Override public void exceptionCaught(IoSession session, Throwable cause) throws Exception { if (LOGGER.isWarnEnabled()) { LOGGER.warn("EXCEPTION, please implement " + getClass().getName() @@@ -75,6 -75,6 +80,7 @@@ /** * {@inheritDoc} */ ++ @Override public void messageReceived(IoSession session, Object message) throws Exception { // Empty handler } @@@ -82,6 -82,6 +88,7 @@@ /** * {@inheritDoc} */ ++ @Override public void messageSent(IoSession session, Object message) throws Exception { // Empty handler } @@@ -89,6 -89,6 +96,7 @@@ /** * {@inheritDoc} */ ++ @Override public void inputClosed(IoSession session) throws Exception { session.closeNow(); } http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java index fbdfa4f,fbdfa4f..161b412 --- a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/IoServiceListenerSupport.java @@@ -45,10 -45,10 +45,10 @@@ public class IoServiceListenerSupport private final IoService service; /** A list of {@link IoServiceListener}s. */ -- private final List<IoServiceListener> listeners = new CopyOnWriteArrayList<IoServiceListener>(); ++ private final List<IoServiceListener> listeners = new CopyOnWriteArrayList<>(); /** Tracks managed sessions. */ -- private final ConcurrentMap<Long, IoSession> managedSessions = new ConcurrentHashMap<Long, IoSession>(); ++ private final ConcurrentMap<Long, IoSession> managedSessions = new ConcurrentHashMap<>(); /** Read only version of {@link #managedSessions}. */ private final Map<Long, IoSession> readOnlyManagedSessions = Collections.unmodifiableMap(managedSessions); @@@ -106,10 -106,10 +106,16 @@@ return activationTime; } ++ /** ++ * @return A Map of the managed {@link IoSession}s ++ */ public Map<Long, IoSession> getManagedSessions() { return readOnlyManagedSessions; } ++ /** ++ * @return The number of managed {@link IoSession}s ++ */ public int getManagedSessionCount() { return managedSessions.size(); } @@@ -271,7 -271,7 +277,6 @@@ /** * Close all the sessions -- * TODO disconnectSessions. * */ private void disconnectSessions() { @@@ -312,6 -312,6 +317,7 @@@ this.lock = lock; } ++ @Override public void operationComplete(IoFuture future) { synchronized (lock) { lock.notifyAll(); http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java index 01701aa,01701aa..64b7fe9 --- a/mina-core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/IoServiceStatistics.java @@@ -31,7 -31,7 +31,7 @@@ import java.util.concurrent.locks.Reent */ public class IoServiceStatistics { -- private AbstractIoService service; ++ private IoService service; /** The number of bytes read per second */ private double readBytesThroughput; @@@ -94,7 -94,7 +94,12 @@@ private final Lock throughputCalculationLock = new ReentrantLock(); -- public IoServiceStatistics(AbstractIoService service) { ++ /** ++ * Creates a new IoServiceStatistics instance ++ * ++ * @param service The {@link IoService} for which we want statistics ++ */ ++ public IoServiceStatistics(IoService service) { this.service = service; } @@@ -103,7 -103,7 +108,7 @@@ * same time. */ public final int getLargestManagedSessionCount() { -- return service.getListeners().getLargestManagedSessionCount(); ++ return ((AbstractIoService)service).getListeners().getLargestManagedSessionCount(); } /** @@@ -112,7 -112,7 +117,7 @@@ * session count + closed session count'. */ public final long getCumulativeManagedSessionCount() { -- return service.getListeners().getCumulativeManagedSessionCount(); ++ return ((AbstractIoService)service).getListeners().getCumulativeManagedSessionCount(); } /** @@@ -410,11 -410,11 +415,6 @@@ return; } -- long readBytes = this.readBytes; -- long writtenBytes = this.writtenBytes; -- long readMessages = this.readMessages; -- long writtenMessages = this.writtenMessages; -- readBytesThroughput = (readBytes - lastReadBytes) * 1000.0 / interval; writtenBytesThroughput = (writtenBytes - lastWrittenBytes) * 1000.0 / interval; readMessagesThroughput = (readMessages - lastReadMessages) * 1000.0 / interval; http://git-wip-us.apache.org/repos/asf/mina/blob/d2fcea3a/mina-core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java ---------------------------------------------------------------------- diff --cc mina-core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java index 44c626b,44c626b..8ebc538 --- a/mina-core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java +++ b/mina-core/src/main/java/org/apache/mina/core/service/SimpleIoProcessorPool.java @@@ -79,7 -79,7 +79,7 @@@ import org.slf4j.LoggerFactory */ public class SimpleIoProcessorPool<S extends AbstractIoSession> implements IoProcessor<S> { /** A logger for this class */ -- private final static Logger LOGGER = LoggerFactory.getLogger(SimpleIoProcessorPool.class); ++ private static final Logger LOGGER = LoggerFactory.getLogger(SimpleIoProcessorPool.class); /** The default pool size, when no size is provided. */ private static final int DEFAULT_SIZE = Runtime.getRuntime().availableProcessors() + 1; @@@ -168,7 -168,7 +168,7 @@@ } // Create the executor if none is provided -- createdExecutor = (executor == null); ++ createdExecutor = executor == null; if (createdExecutor) { this.executor = Executors.newCachedThreadPool(); @@@ -257,6 -257,6 +257,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void add(S session) { getProcessor(session).add(session); } @@@ -264,6 -264,6 +265,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void flush(S session) { getProcessor(session).flush(session); } @@@ -271,6 -271,6 +273,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void write(S session, WriteRequest writeRequest) { getProcessor(session).write(session, writeRequest); } @@@ -278,6 -278,6 +281,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void remove(S session) { getProcessor(session).remove(session); } @@@ -285,6 -285,6 +289,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void updateTrafficControl(S session) { getProcessor(session).updateTrafficControl(session); } @@@ -292,6 -292,6 +297,7 @@@ /** * {@inheritDoc} */ ++ @Override public boolean isDisposed() { return disposed; } @@@ -299,6 -299,6 +305,7 @@@ /** * {@inheritDoc} */ ++ @Override public boolean isDisposing() { return disposing; } @@@ -306,6 -306,6 +313,7 @@@ /** * {@inheritDoc} */ ++ @Override public final void dispose() { if (disposed) { return;