Java Code Examples for com.sun.corba.se.impl.orbutil.ORBConstants

The following are top voted examples for showing how to use
com.sun.corba.se.impl.orbutil.ORBConstants. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to generate
more good examples.

/**
* If the RMI-IIOP maximum stream format version service context
* is present, it indicates the maximum stream format version we
* could use for the reply. If it isn't present, the default is
* 2 for GIOP 1.3 or greater, 1 for lower.
*
* This is only sent on requests. Clients can find out the
* server's maximum by looking for a tagged component in the IOR.
*/
public byte getStreamFormatVersionForReply() {
// NOTE: The request service contexts may indicate the max.
ServiceContexts svc = getRequestServiceContexts();
MaxStreamFormatVersionServiceContext msfvsc
= (MaxStreamFormatVersionServiceContext)svc.get(
MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);
if (msfvsc != null) {
byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();
return (byte)Math.min(localMaxVersion, remoteMaxVersion);
} else {
// Defaults to 1 for GIOP 1.2 or less, 2 for
// GIOP 1.3 or higher.
if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
return ORBConstants.STREAM_FORMAT_VERSION_1;
else
return ORBConstants.STREAM_FORMAT_VERSION_2;
}
}

protected void alignAndReserve(int align, int n) {
// headerPadding bit is set by the write operation of RequestMessage_1_2
// or ReplyMessage_1_2 classes. When set, the very first body write
// operation (from the stub code) would trigger an alignAndReserve
// method call, that would in turn add the appropriate header padding,
// such that the body is aligned on a 8-octet boundary. The padding
// is required for GIOP versions 1.2 and above, only if body is present.
if (headerPadding == true) {
headerPadding = false;
alignOnBoundary(ORBConstants.GIOP_12_MSG_BODY_ALIGNMENT);
}
// In GIOP 1.2, we always end fragments at our
// fragment size, which is an "evenly divisible
// 8 byte boundary" (aka divisible by 16). A fragment can
// end with appropriate alignment padding, but no padding
// is needed with respect to the next GIOP fragment
// header since it ends on an 8 byte boundary.
bbwi.position(bbwi.position() + computeAlignment(align));
if (bbwi.position() + n > bbwi.buflen)
grow(align, n);
}

protected void alignAndReserve(int align, int n) {
// headerPadding bit is set by the write operation of RequestMessage_1_2
// or ReplyMessage_1_2 classes. When set, the very first body write
// operation (from the stub code) would trigger an alignAndReserve
// method call, that would in turn add the appropriate header padding,
// such that the body is aligned on a 8-octet boundary. The padding
// is required for GIOP versions 1.2 and above, only if body is present.
if (headerPadding == true) {
headerPadding = false;
alignOnBoundary(ORBConstants.GIOP_12_MSG_BODY_ALIGNMENT);
}
// In GIOP 1.2, we always end fragments at our
// fragment size, which is an "evenly divisible
// 8 byte boundary" (aka divisible by 16). A fragment can
// end with appropriate alignment padding, but no padding
// is needed with respect to the next GIOP fragment
// header since it ends on an 8 byte boundary.
bbwi.position(bbwi.position() + computeAlignment(align));
if (bbwi.position() + n > bbwi.buflen)
grow(align, n);
}

/**
* If the RMI-IIOP maximum stream format version service context
* is present, it indicates the maximum stream format version we
* could use for the reply. If it isn't present, the default is
* 2 for GIOP 1.3 or greater, 1 for lower.
*
* This is only sent on requests. Clients can find out the
* server's maximum by looking for a tagged component in the IOR.
*/
public byte getStreamFormatVersionForReply() {
// NOTE: The request service contexts may indicate the max.
ServiceContexts svc = getRequestServiceContexts();
MaxStreamFormatVersionServiceContext msfvsc
= (MaxStreamFormatVersionServiceContext)svc.get(
MaxStreamFormatVersionServiceContext.SERVICE_CONTEXT_ID);
if (msfvsc != null) {
byte localMaxVersion = ORBUtility.getMaxStreamFormatVersion();
byte remoteMaxVersion = msfvsc.getMaximumStreamFormatVersion();
return (byte)Math.min(localMaxVersion, remoteMaxVersion);
} else {
// Defaults to 1 for GIOP 1.2 or less, 2 for
// GIOP 1.3 or higher.
if (getGIOPVersion().lessThan(GIOPVersion.V1_3))
return ORBConstants.STREAM_FORMAT_VERSION_1;
else
return ORBConstants.STREAM_FORMAT_VERSION_2;
}
}

protected void alignAndCheck(int align, int n) {
// headerPadding bit is set by read method of the RequestMessage_1_2
// or ReplyMessage_1_2 classes. When set, the very first body read
// operation (from the stub code) would trigger an alignAndCheck
// method call, that would in turn skip the header padding that was
// inserted during the earlier write operation by the sender. The
// padding ensures that the body is aligned on an 8-octet boundary,
// for GIOP versions 1.2 and beyond.
if (headerPadding == true) {
headerPadding = false;
alignOnBoundary(ORBConstants.GIOP_12_MSG_BODY_ALIGNMENT);
}
checkBlockLength(align, n);
// WARNING: Must compute real alignment after calling
// checkBlockLength since it may move the position
// In GIOP 1.2, a fragment may end with some alignment
// padding (which leads to all fragments ending perfectly
// on evenly divisible 8 byte boundaries). A new fragment
// never requires alignment with the header since it ends
// on an 8 byte boundary.
int alignIncr = computeAlignment(bbwi.position(),align);
bbwi.position(bbwi.position() + alignIncr);
if (bbwi.position() + n > bbwi.buflen) {
grow(1, n);
}
}