NETTY-423 Add ChannelPipeline.getNames()
This commit is contained in:
parent
5c62d54c67
commit
59a349031a
@ -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<String> getNames();
|
||||
|
||||
/**
|
||||
* Converts this pipeline into an ordered {@link Map} whose keys are
|
||||
* handler names and whose values are handlers.
|
||||
|
@ -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<String> getNames() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
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<String, ChannelHandler> toMap() {
|
||||
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
|
||||
|
@ -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<String> getNames() {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (StaticChannelHandlerContext ctx: contexts) {
|
||||
list.add(ctx.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ChannelHandler> toMap() {
|
||||
Map<String, ChannelHandler> map = new LinkedHashMap<String, ChannelHandler>();
|
||||
|
Loading…
Reference in New Issue
Block a user