diff --git a/src/main/java/org/jboss/netty/channel/ChannelPipeline.java b/src/main/java/org/jboss/netty/channel/ChannelPipeline.java index d6305be865..fa1eda1988 100644 --- a/src/main/java/org/jboss/netty/channel/ChannelPipeline.java +++ b/src/main/java/org/jboss/netty/channel/ChannelPipeline.java @@ -17,6 +17,7 @@ package org.jboss.netty.channel; import java.io.InputStream; import java.io.OutputStream; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -488,6 +489,11 @@ public interface ChannelPipeline { */ boolean isAttached(); + /** + * Returns the {@link List} of the handler names. + */ + List getNames(); + /** * Converts this pipeline into an ordered {@link Map} whose keys are * handler names and whose values are handlers. diff --git a/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java b/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java index 3330f63331..5da1b888f4 100644 --- a/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java +++ b/src/main/java/org/jboss/netty/channel/DefaultChannelPipeline.java @@ -15,8 +15,10 @@ */ package org.jboss.netty.channel; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @@ -510,6 +512,24 @@ public class DefaultChannelPipeline implements ChannelPipeline { return null; } + @Override + public List getNames() { + List list = new ArrayList(); + if (name2ctx.isEmpty()) { + return list; + } + + DefaultChannelHandlerContext ctx = head; + for (;;) { + list.add(ctx.getName()); + ctx = ctx.next; + if (ctx == null) { + break; + } + } + return list; + } + @Override public Map toMap() { Map map = new LinkedHashMap(); diff --git a/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java b/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java index bd280f0d54..5f76d99bea 100644 --- a/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java +++ b/src/main/java/org/jboss/netty/channel/StaticChannelPipeline.java @@ -15,8 +15,10 @@ */ package org.jboss.netty.channel; +import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import org.jboss.netty.logging.InternalLogger; @@ -340,6 +342,15 @@ public class StaticChannelPipeline implements ChannelPipeline { return null; } + @Override + public List getNames() { + List list = new ArrayList(); + for (StaticChannelHandlerContext ctx: contexts) { + list.add(ctx.getName()); + } + return list; + } + @Override public Map toMap() { Map map = new LinkedHashMap();