Package org.apache.mina.common

Examples of org.apache.mina.common.IoBuffer


        if (objectSize > maxObjectSize) {
            throw new StreamCorruptedException("ObjectSize too big: "
                    + objectSize + " (expected: <= " + maxObjectSize + ')');
        }

        IoBuffer buf = IoBuffer.allocate(objectSize + 4, false);
        buf.putInt(objectSize);
        in.readFully(buf.array(), 4, objectSize);
        buf.position(0);
        buf.limit(objectSize + 4);

        return buf.getObject(classLoader);
    }
View Full Code Here


    public void write(byte[] b, int off, int len) throws IOException {
        out.write(b, off, len);
    }

    public void writeObject(Object obj) throws IOException {
        IoBuffer buf = IoBuffer.allocate(64, false);
        buf.setAutoExpand(true);
        buf.putObject(obj);

        int objectSize = buf.position() - 4;
        if (objectSize > maxObjectSize) {
            throw new IllegalArgumentException(
                    "The encoded object is too big: " + objectSize + " (> "
                            + maxObjectSize + ')');
        }

        out.write(buf.array(), 0, buf.position());
    }
View Full Code Here

            ProtocolEncoderOutput out) throws Exception {
        if (!(message instanceof Serializable)) {
            throw new NotSerializableException();
        }

        IoBuffer buf = IoBuffer.allocate(64);
        buf.setAutoExpand(true);
        buf.putObject(message);

        int objectSize = buf.position() - 4;
        if (objectSize > maxObjectSize) {
            throw new IllegalArgumentException(
                    "The encoded object is too big: " + objectSize + " (> "
                            + maxObjectSize + ')');
        }

        buf.flip();
        out.write(buf);
    }
View Full Code Here

        if (message instanceof InputStream) {

            InputStream inputStream = (InputStream) message;

            IoBuffer buffer = getNextBuffer(inputStream);
            if (buffer == null) {
                // End of stream reached.
                writeRequest.getFuture().setWritten();
                nextFilter.messageSent(session, writeRequest);
            } else {
View Full Code Here

                .getAttribute(CURRENT_STREAM);

        if (inputStream == null) {
            nextFilter.messageSent(session, writeRequest);
        } else {
            IoBuffer buffer = getNextBuffer(inputStream);

            if (buffer == null) {
                // End of stream reached.
                session.removeAttribute(CURRENT_STREAM);
                WriteRequest currentWriteRequest = (WriteRequest) session
View Full Code Here

                        WriteRequest req;
                        while ((req = queue.poll(session)) != null) {
                            Object message = req.getMessage();
                            Object messageCopy = message;
                            if (message instanceof IoBuffer) {
                                IoBuffer rb = (IoBuffer) message;
                                rb.mark();
                                IoBuffer wb = IoBuffer.allocate(rb.remaining());
                                wb.put(rb);
                                wb.flip();
                                rb.reset();
                                messageCopy = wb;
                            }

                            session.getRemoteSession().getFilterChain().fireMessageReceived(
View Full Code Here

        }

        private Object getMessageCopy(Object message) {
            Object messageCopy = message;
            if (message instanceof IoBuffer) {
                IoBuffer rb = (IoBuffer) message;
                rb.mark();
                IoBuffer wb = IoBuffer.allocate(rb.remaining());
                wb.put(rb);
                wb.flip();
                rb.reset();
                messageCopy = wb;
            }
            return messageCopy;
        }
View Full Code Here

    private void removeSessionBuffer(IoSession session) {
        session.removeAttribute(BUFFER);
    }

    private void storeRemainingInSession(IoBuffer buf, IoSession session) {
        final IoBuffer remainingBuf = new UnderivableBuffer(
                IoBuffer.allocate(buf.capacity()).setAutoExpand(true));
       
        remainingBuf.order(buf.order());
        remainingBuf.put(buf);
       
        session.setAttribute(BUFFER, remainingBuf);
    }
View Full Code Here

        if(message instanceof InputStream) {

            InputStream inputStream = (InputStream) message;

            IoBuffer buffer = getNextBuffer(inputStream);
            if(buffer == null) {
                // End of stream reached.
                writeRequest.getFuture().setWritten();
                nextFilter.messageSent(session, writeRequest);
            } else {
View Full Code Here

        InputStream inputStream = (InputStream) session.getAttribute(CURRENT_STREAM);

        if(inputStream == null) {
            nextFilter.messageSent(session, writeRequest);
        } else {
            IoBuffer buffer = getNextBuffer(inputStream);

            if(buffer == null) {
                // End of stream reached.
                session.removeAttribute(CURRENT_STREAM);
                WriteRequest currentWriteRequest = (WriteRequest) session.removeAttribute(CURRENT_WRITE_REQUEST);
View Full Code Here

TOP

Related Classes of org.apache.mina.common.IoBuffer

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.