1 7 8 package com.sun.corba.se.impl.protocol.giopmsgheaders; 9 10 import java.nio.ByteBuffer ; 11 import org.omg.CORBA.INTERNAL ; 12 import org.omg.CORBA.CompletionStatus ; 13 14 import com.sun.corba.se.spi.ior.iiop.GIOPVersion; 15 16 import com.sun.corba.se.spi.logging.CORBALogDomains ; 17 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 18 19 25 26 public class Message_1_1 27 extends com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase { 28 29 final static int UPPER_THREE_BYTES_OF_INT_MASK = 0xFF; 31 32 private static ORBUtilSystemException wrapper = 33 ORBUtilSystemException.get( CORBALogDomains.RPC_PROTOCOL ) ; 34 35 int magic = (int) 0; 37 GIOPVersion GIOP_version = null; 38 byte flags = (byte) 0; 39 byte message_type = (byte) 0; 40 int message_size = (int) 0; 41 42 44 Message_1_1() { 45 } 46 47 Message_1_1(int _magic, GIOPVersion _GIOP_version, byte _flags, 48 byte _message_type, int _message_size) { 49 magic = _magic; 50 GIOP_version = _GIOP_version; 51 flags = _flags; 52 message_type = _message_type; 53 message_size = _message_size; 54 } 55 56 58 public GIOPVersion getGIOPVersion() { 59 return this.GIOP_version; 60 } 61 62 public int getType() { 63 return this.message_type; 64 } 65 66 public int getSize() { 67 return this.message_size; 68 } 69 70 public boolean isLittleEndian() { 71 return ((this.flags & LITTLE_ENDIAN_BIT) == LITTLE_ENDIAN_BIT); 72 } 73 74 public boolean moreFragmentsToFollow() { 75 return ( (this.flags & MORE_FRAGMENTS_BIT) == MORE_FRAGMENTS_BIT ); 76 } 77 78 80 public void setThreadPoolToUse(int poolToUse) { 84 int tmpFlags = poolToUse << 2; 89 tmpFlags &= UPPER_THREE_BYTES_OF_INT_MASK; 90 tmpFlags |= flags; 91 flags = (byte)tmpFlags; 92 } 93 94 public void setSize(ByteBuffer byteBuffer, int size) { 95 96 this.message_size = size; 97 98 102 int patch = size - GIOPMessageHeaderLength; 103 if (!isLittleEndian()) { 104 byteBuffer.put(8, (byte)((patch >>> 24) & 0xFF)); 105 byteBuffer.put(9, (byte)((patch >>> 16) & 0xFF)); 106 byteBuffer.put(10, (byte)((patch >>> 8) & 0xFF)); 107 byteBuffer.put(11, (byte)((patch >>> 0) & 0xFF)); 108 } else { 109 byteBuffer.put(8, (byte)((patch >>> 0) & 0xFF)); 110 byteBuffer.put(9, (byte)((patch >>> 8) & 0xFF)); 111 byteBuffer.put(10, (byte)((patch >>> 16) & 0xFF)); 112 byteBuffer.put(11, (byte)((patch >>> 24) & 0xFF)); 113 } 114 } 115 116 119 public FragmentMessage createFragmentMessage() { 120 121 123 switch (this.message_type) { 124 case GIOPCancelRequest : 125 case GIOPCloseConnection : 126 case GIOPMessageError : 127 throw wrapper.fragmentationDisallowed( 128 CompletionStatus.COMPLETED_MAYBE); 129 case GIOPLocateRequest : 130 case GIOPLocateReply : 131 if (this.GIOP_version.equals(GIOPVersion.V1_1)) { 132 throw wrapper.fragmentationDisallowed( 133 CompletionStatus.COMPLETED_MAYBE); 134 } 135 break; 136 } 137 138 146 if (this.GIOP_version.equals(GIOPVersion.V1_1)) { 147 return new FragmentMessage_1_1(this); 148 } else if (this.GIOP_version.equals(GIOPVersion.V1_2)) { 149 return new FragmentMessage_1_2(this); 150 } 151 152 throw wrapper.giopVersionError( CompletionStatus.COMPLETED_MAYBE); 153 } 154 155 157 public void read(org.omg.CORBA.portable.InputStream istream) { 162 169 } 170 171 public void write(org.omg.CORBA.portable.OutputStream ostream) { 172 ostream.write_long(this.magic); 173 nullCheck(this.GIOP_version); 174 this.GIOP_version.write(ostream); 175 ostream.write_octet(this.flags); 176 ostream.write_octet(this.message_type); 177 ostream.write_ulong(this.message_size); 178 } 179 } | Popular Tags |