HTTP/2 Frame to HttpObject Adapter

Transferring @Scottmitch's personal pull request to @akamai's fork for https://github.com/netty/netty/pull/2695
Because the object will escape the constructor. This could let to receive partial constructed instances.

> Am 09.08.2014 um 21:12 schrieb Nathan Mittler <notifications@github.com>:
> 
> In codec-http2/src/main/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapter.java:
> 
> > +                        Http2HttpHeaders.Names.PATH.toString());
> > +    }
> > +
> > +    /**
> > +     * Creates a new instance
> > +     *
> > +     * @param connection The object which will provide connection notification events for the current connection
> > +     * @param maxContentLength the maximum length of the message content. If the length of the message content exceeds
> > +     *        this value, a {@link TooLongFrameException} will be raised.
> > +     * @throws NullPointerException If {@code connection} is null
> > +     * @throws IllegalArgumentException If {@code maxContentLength} is less than or equal to {@code 0}
> > +     */
> > +    public static InboundHttp2ToHttpAdapter newInstance(Http2Connection connection, long maxContentLength)
> > +                    throws NullPointerException, IllegalArgumentException {
> > +        InboundHttp2ToHttpAdapter adapter = new InboundHttp2ToHttpAdapter(connection, maxContentLength);
> > +        connection.addListener(adapter);
> why doesn't the constructor just call connection.addListener(this)?
> 
> —
> Reply to this email directly or view it on GitHub.