/** * Creates a new embedder whose pipeline is composed of the specified * handlers. */ protected AbstractCodecEmbedder(ChannelHandler... handlers) { pipeline = new EmbeddedChannelPipeline(); configurePipeline(handlers); channel = new EmbeddedChannel(pipeline, sink); fireInitialEvents(); }
/** * Creates a new embedder whose pipeline is composed of the specified * handlers. * * @param bufferFactory the {@link ChannelBufferFactory} to be used when * creating a new buffer. */ protected AbstractCodecEmbedder(ChannelBufferFactory bufferFactory, ChannelHandler... handlers) { this(handlers); getChannel().getConfig().setBufferFactory(bufferFactory); }
@SuppressWarnings("unchecked") public final <T> T[] pollAll(T[] a) { if (a == null) { throw new NullPointerException("a"); } final int size = size(); // Create a new array if the specified one is too small. if (a.length < size) { a = (T[]) Array.newInstance(a.getClass().getComponentType(), size); } for (int i = 0;; i ++) { T product = (T) poll(); if (product == null) { break; } a[i] = product; } // Put the terminator if necessary. if (a.length > size) { a[size] = null; } return a; }