Package org.apache.activemq.command

Examples of org.apache.activemq.command.MarshallAware


       
        if( cacheEnabled ) {
            runMarshallCacheEvictionSweep();
        }
       
        MarshallAware ma=null;
        // If not using value caching, then the marshaled form is always the same
        if( !cacheEnabled && ((DataStructure)command).isMarshallAware() ) {
            ma = (MarshallAware) command;
        }
       
        ByteSequence sequence=null;
        if( ma!=null ) {
            sequence = ma.getCachedMarshalledForm(this);
        }
       
        if( sequence == null ) {
           
            int size=1;
            if( command != null) {
               
                DataStructure c = (DataStructure) command;
                byte type = c.getDataStructureType();
                DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[type & 0xFF];
                if( dsm == null )
                    throw new IOException("Unknown data type: "+type);
               
                if( tightEncodingEnabled ) {
                   
                    BooleanStream bs = new BooleanStream();
                    size += dsm.tightMarshal1(this, c, bs);
                    size += bs.marshalledSize();
   
                    bytesOut.restart(size);
                    if( !sizePrefixDisabled ) {
                        bytesOut.writeInt(size);
                    }
                    bytesOut.writeByte(type);
                    bs.marshal(bytesOut);
                    dsm.tightMarshal2(this, c, bytesOut, bs);               
                    sequence = bytesOut.toByteSequence();
                   
                } else {
                    bytesOut.restart();
                    if( !sizePrefixDisabled ) {
                        bytesOut.writeInt(0); // we don't know the final size yet but write this here for now.
                    }
                    bytesOut.writeByte(type);
                    dsm.looseMarshal(this, c, bytesOut);               
                    sequence = bytesOut.toByteSequence();
                   
                    if( !sizePrefixDisabled ) {
                        size = sequence.getLength()-4;
                        int pos = sequence.offset;
                        ByteSequenceData.writeIntBig(sequence, size);
                        sequence.offset = pos;
                    }
                }
               
               
            } else {
                bytesOut.restart(5);
                bytesOut.writeInt(size);
                bytesOut.writeByte(NULL_TYPE);
                sequence = bytesOut.toByteSequence();
            }
           
            if( ma!=null ) {
                ma.setCachedMarshalledForm(this, sequence);
            }
        }
        return sequence;
    }
View Full Code Here


        bs.writeBoolean(o != null);
        if( o == null )
            return 0;

        if( o.isMarshallAware() ) {
            MarshallAware ma = (MarshallAware) o;
            ByteSequence sequence=ma.getCachedMarshalledForm(this);
            bs.writeBoolean(sequence!=null);
            if( sequence!=null ) {
                return 1 + sequence.getLength();          
            }
        }
View Full Code Here

        byte type = o.getDataStructureType();
        ds.writeByte(type);

        if( o.isMarshallAware() && bs.readBoolean() ) {
                       
            MarshallAware ma = (MarshallAware) o;
            ByteSequence sequence=ma.getCachedMarshalledForm(this);
            ds.write(sequence.getData(), sequence.getOffset(), sequence.getLength());
           
        } else {
           
            DataStreamMarshaller dsm = (DataStreamMarshaller) dataMarshallers[type & 0xFF];
View Full Code Here

TOP

Related Classes of org.apache.activemq.command.MarshallAware

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.