gnu.CORBA.GIOP

Class MessageHeader

Implemented Interfaces:
IDLEntity, Serializable
Known Direct Subclasses:
CloseMessage, ErrorMessage

public class MessageHeader
extends Object
implements IDLEntity

The GIOP message header.

Field Summary

static byte
CANCEL_REQUEST
Cancel request message.
static byte
CLOSE_CONNECTION
Instruction to close the connection.
static byte
FRAGMENT
The fragment messge, following the previous message that has more fragments flag set.
static byte
LOCATE_REPLY
Locate reply message, sent in response to the MessageHeader message.
static byte
LOCATE_REQUEST
Locate request message, used to check the server ability to process requests for the object reference.
static byte[]
MAGIC
This must always be "GIOP".
static byte
MESSAGE_ERROR
Error report.
static byte
REPLY
Reply message
static byte
REQUEST
Request message.
byte
flags
The flags field, introduced since GIOP 1.1.
int
message_size
The message size, excluding the message header.
byte
message_type
The message type.
protected static String[]
types
The message type names.
Version
version
The GIOP version.

Constructor Summary

MessageHeader()
Create an empty message header, corresponding version 1.0.
MessageHeader(int major, int minor)
Create an empty message header, corresponding the given version.

Method Summary

CancelHeader
create_cancel_header()
Create the cancel header, matching the message header version number.
ErrorMessage
create_error_message()
Create the error message.
ReplyHeader
create_reply_header()
Creates reply header, matching the message header version number.
RequestHeader
create_request_header()
Creates request header, matching the message header version number.
int
getHeaderSize()
Get the size of the message header itself.
String
getTypeString(int type)
Get the message type as string.
boolean
isBigEndian()
Checks if the message is encoded in the Big Endian, most significant byte first.
boolean
moreFragmentsFollow()
Checks if the message is partial, and more subsequent fragments follow.
void
read(InputStream istream)
Read the header from the stream.
byte[]
readMessage(InputStream source, Socket service, int to_read, int to_pause)
Read data, followed by the message header.
void
setBigEndian(boolean use_big_endian)
Set the encoding to use.
String
toString()
Get the short string summary of the message.
void
write(OutputStream out)
Write the header to stream.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

CANCEL_REQUEST

public static final byte CANCEL_REQUEST
Cancel request message.
Field Value:
2

CLOSE_CONNECTION

public static final byte CLOSE_CONNECTION
Instruction to close the connection.
Field Value:
5

FRAGMENT

public static final byte FRAGMENT
The fragment messge, following the previous message that has more fragments flag set. Added in GIOP 1.1
Field Value:
7

LOCATE_REPLY

public static final byte LOCATE_REPLY
Locate reply message, sent in response to the MessageHeader message.
Field Value:
4

LOCATE_REQUEST

public static final byte LOCATE_REQUEST
Locate request message, used to check the server ability to process requests for the object reference. This message is also used to get the address where the object reference should be sent.
Field Value:
3

MAGIC

public static final byte[] MAGIC
This must always be "GIOP".

MESSAGE_ERROR

public static final byte MESSAGE_ERROR
Error report.
Field Value:
6

REPLY

public static final byte REPLY
Reply message
Field Value:
1

REQUEST

public static final byte REQUEST
Request message.
Field Value:
0

flags

public byte flags
The flags field, introduced since GIOP 1.1.

message_size

public int message_size
The message size, excluding the message header.

message_type

public byte message_type
The message type.

types

protected static String[] types
The message type names.

version

public Version version
The GIOP version. Initialised to 1.0 .

Constructor Details

MessageHeader

public MessageHeader()
Create an empty message header, corresponding version 1.0.

MessageHeader

public MessageHeader(int major,
                     int minor)
Create an empty message header, corresponding the given version.
Parameters:
major - the major message header version.
minor - the minot message header version.

Method Details

create_cancel_header

public CancelHeader create_cancel_header()
Create the cancel header, matching the message header version number.

create_error_message

public ErrorMessage create_error_message()
Create the error message.

create_reply_header

public ReplyHeader create_reply_header()
Creates reply header, matching the message header version number.
Returns:
one of ReplyHeader, ReplyHeader, etc - depending on the version number in this header.

create_request_header

public RequestHeader create_request_header()
Creates request header, matching the message header version number.
Returns:
one of RequestHeader, RequestHeader, etc - depending on the version number in this header.

getHeaderSize

public int getHeaderSize()
Get the size of the message header itself. So far, it is always 12 bytes.

getTypeString

public String getTypeString(int type)
Get the message type as string.
Parameters:
type - the message type as int (the field message_type).
Returns:
the message type as string.

isBigEndian

public boolean isBigEndian()
Checks if the message is encoded in the Big Endian, most significant byte first.

moreFragmentsFollow

public boolean moreFragmentsFollow()
Checks if the message is partial, and more subsequent fragments follow.

read

public void read(InputStream istream)
            throws MARSHAL,
                   EOFException
Read the header from the stream.
Parameters:
istream - a stream to read from.
Throws:
MARSHAL - if this is not a GIOP 1.0 header.

readMessage

public byte[] readMessage(InputStream source,
                          Socket service,
                          int to_read,
                          int to_pause)
Read data, followed by the message header. Handle fragmented messages.
Parameters:
source - the data source to read from.
service - the socket on that the time outs are set. Can be null (no timeouts are set).
to_read - the timeout while reading the message.
to_pause - the timeout for pauses between the message parts.

setBigEndian

public void setBigEndian(boolean use_big_endian)
Set the encoding to use.
Parameters:
use_big_endian - if true (default), the Big Endian encoding is used. If false, the Little Endian encoding is used.

toString

public String toString()
Get the short string summary of the message.
Overrides:
toString in interface Object
Returns:
a short message summary.

write

public void write(OutputStream out)
Write the header to stream.
Parameters:
out - a stream to write into.

MessageHeader.java -- GIOP message header. Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.