Package org.apache.mina.codec

Examples of org.apache.mina.codec.ProtocolEncoderException


    @Override
    public void writeTo(INPUT message, ByteBuffer buffer) {
        try {
            buffer.put(prepareBuffer(message));
        } catch (TException e) {
            throw new ProtocolEncoderException(e);
        }
    }
View Full Code Here


                byte[] encoded = out.toByteArray();
                encodedMessage = ByteBuffer.wrap(encoded);
                out.close();
            } catch (IOException ioEx) {
                LOG.error("error while marshalling", ioEx);
                throw new ProtocolEncoderException(ioEx.getMessage());
            }
        } else if (message instanceof SpecificRecord) {
            DatumWriter<T> writer = new SpecificDatumWriter<T>(message.getSchema());
            Encoder encoder = EncoderFactory.get().binaryEncoder(out, null);
            try {
                writer.write(message, encoder);
                encoder.flush();
                byte[] encoded = out.toByteArray();
                encodedMessage = ByteBuffer.wrap(encoded);
                out.close();
            } catch (IOException ioEx) {
                LOG.error("error while marshalling", ioEx);
                throw new ProtocolEncoderException(ioEx.getMessage());
            }
        } else {
            LOG.warn("Unknown object type, serialization method not known for {}", message.getClass());
            throw new ProtocolEncoderException(message.getClass() + " cannot be Serialized");
        }

        return encodedMessage != null ? encodedMessage.capacity() : -1;
    }
View Full Code Here

TOP

Related Classes of org.apache.mina.codec.ProtocolEncoderException

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.