From 8b5a652883b55006a859b1f26df329bc56b1b823 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Wed, 17 Jun 2009 05:39:19 +0000 Subject: [PATCH] Javadoc --- .../org/jboss/netty/util/ExternalResourceUtil.java | 3 +++ .../org/jboss/netty/util/ObjectSizeEstimator.java | 9 +++------ .../org/jboss/netty/util/ThreadNameDeterminer.java | 14 +++++++++++++- .../jboss/netty/util/ThreadRenamingRunnable.java | 14 +++++++------- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/jboss/netty/util/ExternalResourceUtil.java b/src/main/java/org/jboss/netty/util/ExternalResourceUtil.java index 36f50918bc..3c69193da2 100644 --- a/src/main/java/org/jboss/netty/util/ExternalResourceUtil.java +++ b/src/main/java/org/jboss/netty/util/ExternalResourceUtil.java @@ -23,6 +23,9 @@ package org.jboss.netty.util; /** + * A utility class that provides the convenient shutdown of + * {@link ExternalResourceReleasable}s. + * * @author The Netty Project (netty-dev@lists.jboss.org) * @author Trustin Lee (tlee@redhat.com) * @version $Rev$, $Date$ diff --git a/src/main/java/org/jboss/netty/util/ObjectSizeEstimator.java b/src/main/java/org/jboss/netty/util/ObjectSizeEstimator.java index 788d917bd7..bbb3c721e1 100644 --- a/src/main/java/org/jboss/netty/util/ObjectSizeEstimator.java +++ b/src/main/java/org/jboss/netty/util/ObjectSizeEstimator.java @@ -22,8 +22,6 @@ */ package org.jboss.netty.util; -import org.jboss.netty.handler.execution.MemoryAwareThreadPoolExecutor; -import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor; /** * Estimates the size of an object in bytes. @@ -32,15 +30,14 @@ import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor; * @author Trustin Lee (tlee@redhat.com) * * @version $Rev$, $Date$ - * */ public interface ObjectSizeEstimator { /** * Returns the estimated size of the specified object in bytes. - * This method must be implemented to return the same value for the same - * object. {@link MemoryAwareThreadPoolExecutor} and - * {@link OrderedMemoryAwareThreadPoolExecutor} will malfunction otherwise. + * + * @return a positive integer which represents the size of the specified + * object in bytes */ int estimateSize(Object o); } diff --git a/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java b/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java index 91ce0e994c..2ff942e1f5 100644 --- a/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java +++ b/src/main/java/org/jboss/netty/util/ThreadNameDeterminer.java @@ -23,10 +23,22 @@ package org.jboss.netty.util; /** + * Overrides the thread name proposed by {@link ThreadRenamingRunnable}. + * * @author The Netty Project (netty-dev@lists.jboss.org) * @author Trustin Lee (tlee@redhat.com) * @version $Rev$, $Date$ */ public interface ThreadNameDeterminer { - String determineThreadName(String oldThreadName, String proposedThreadName) throws Exception; + + /** + * Overrides the thread name proposed by {@link ThreadRenamingRunnable}. + * + * @param currentThreadName the current thread name + * @param proposedThreadName the proposed new thread name + * @return the actual new thread name. + * If {@code null} is returned, the proposed thread name is + * discarded (i.e. no rename). + */ + String determineThreadName(String currentThreadName, String proposedThreadName) throws Exception; } diff --git a/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java b/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java index 53e54f6c5c..95779e6c7a 100644 --- a/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java +++ b/src/main/java/org/jboss/netty/util/ThreadRenamingRunnable.java @@ -27,8 +27,8 @@ import org.jboss.netty.logging.InternalLoggerFactory; /** - * Meta {@link Runnable} that changes the current thread name and reverts it - * back when its execution ends. + * A {@link Runnable} that changes the current thread name and reverts it back + * when its execution ends. * * @author The Netty Project (netty-dev@lists.jboss.org) * @author Trustin Lee (tlee@redhat.com) @@ -50,7 +50,7 @@ public class ThreadRenamingRunnable implements Runnable { }; /** - * Returns the {@link ThreadNameDeterminer} which is used to determine the + * Returns the {@link ThreadNameDeterminer} which overrides the proposed * new thread name. */ public static ThreadNameDeterminer getThreadNameDeterminer() { @@ -58,7 +58,7 @@ public class ThreadRenamingRunnable implements Runnable { } /** - * Sets the {@link ThreadNameDeterminer} which is used to determine the new + * Sets the {@link ThreadNameDeterminer} which overrides the proposed new * thread name. */ public static void setThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer) { @@ -117,17 +117,17 @@ public class ThreadRenamingRunnable implements Runnable { } } - private String getNewThreadName(String oldThreadName) { + private String getNewThreadName(String currentThreadName) { String newThreadName = null; try { newThreadName = getThreadNameDeterminer().determineThreadName( - oldThreadName, proposedThreadName); + currentThreadName, proposedThreadName); } catch (Throwable t) { logger.warn("Failed to determine the thread name", t); } - return newThreadName == null? oldThreadName : newThreadName; + return newThreadName == null? currentThreadName : newThreadName; } }