Package org.apache.mina.filter.codec

Examples of org.apache.mina.filter.codec.ProtocolEncoder


        final String expected = "1234";

        ProtocolCodecSession session = new ProtocolCodecSession();
        ProtocolEncoderOutput out = session.getEncoderOutput();

        ProtocolEncoder encoder = new ObjectSerializationEncoder();
        encoder.encode(session, expected, out);

        assertEquals(1, session.getEncoderOutputQueue().size());
        IoBuffer buf = (IoBuffer) session.getEncoderOutputQueue().poll();

        testDecoderAndInputStream(expected, buf);
View Full Code Here


            protected WriteFuture doFlush(ByteBuffer buf) {
                return null;
            }
        };

        ProtocolEncoder encoder = new ObjectSerializationEncoder();
        encoder.encode(session, expected, out);

        Assert.assertEquals(1, out.getBufferQueue().size());
        ByteBuffer buf = (ByteBuffer) out.getBufferQueue().poll();

        testDecoderAndInputStream(expected, buf);
View Full Code Here

    }

    private static class MyCodec implements ProtocolCodecFactory {

        public ProtocolEncoder getEncoder(IoSession session) throws Exception {
            return new ProtocolEncoder() {

                public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out)
                    throws Exception {
                    // close session instead of returning a reply
                    ioSession.close(true);
View Full Code Here

    public Mina2UdpProtocolCodecFactory(CamelContext context) {
        this.context = context;
    }

    public ProtocolEncoder getEncoder(IoSession session) throws Exception {
        return new ProtocolEncoder() {

            public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
                IoBuffer buf = toIoBuffer(message);
                buf.flip();
                out.write(buf);
View Full Code Here

    }

    private class MyCodec implements ProtocolCodecFactory {

        public ProtocolEncoder getEncoder() throws Exception {
            return new ProtocolEncoder() {
                public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out)
                    throws Exception {
                    ByteBuffer bb = ByteBuffer.allocate(32).setAutoExpand(true);
                    String s = (String) message;                   
                    bb.put(s.getBytes("US-ASCII"));
View Full Code Here

    }

    private class MyCodec implements ProtocolCodecFactory {

        public ProtocolEncoder getEncoder() throws Exception {
            return new ProtocolEncoder() {
                public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out)
                    throws Exception {
                    // close session instead of returning a reply
                    ioSession.close();
                }
View Full Code Here

        this.context = context;
        this.charset = charset;
    }

    public ProtocolEncoder getEncoder() throws Exception {
        return new ProtocolEncoder() {
            private CharsetEncoder encoder;

            public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
                if (encoder == null) {
                    encoder = charset.newEncoder();
View Full Code Here

    }

    private static class MyCodec implements ProtocolCodecFactory {

        public ProtocolEncoder getEncoder(IoSession session) throws Exception {
            return new ProtocolEncoder() {

                public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out)
                    throws Exception {
                    IoBuffer bb = IoBuffer.allocate(32).setAutoExpand(true);
                    String s = (String) message;
View Full Code Here

    private static class MyCodec implements ProtocolCodecFactory {

        @Override
        public ProtocolEncoder getEncoder(IoSession is) throws Exception {
            return new ProtocolEncoder() {

                public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out)
                    throws Exception {
                    IoBuffer bb = IoBuffer.allocate(32).setAutoExpand(true);
                    String s = (String) message;
View Full Code Here

    }

    private class MyCodec implements ProtocolCodecFactory {

        public ProtocolEncoder getEncoder() throws Exception {
            return new ProtocolEncoder() {
                public void encode(IoSession ioSession, Object message, ProtocolEncoderOutput out)
                    throws Exception {
                    ByteBuffer bb = ByteBuffer.allocate(32).setAutoExpand(true);
                    String s = (String) message;                   
                    bb.put(s.getBytes("US-ASCII"));
View Full Code Here

TOP

Related Classes of org.apache.mina.filter.codec.ProtocolEncoder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.