summaryrefslogtreecommitdiff
path: root/libjava/classpath/gnu/CORBA
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/CORBA')
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/AbstractCdrInput.java (renamed from libjava/classpath/gnu/CORBA/CDR/cdrInput.java)704
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/AbstractCdrOutput.java (renamed from libjava/classpath/gnu/CORBA/CDR/cdrOutput.java)162
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/AbstractDataInput.java (renamed from libjava/classpath/gnu/CORBA/CDR/abstractDataInputStream.java)4
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/AbstractDataOutput.java (renamed from libjava/classpath/gnu/CORBA/CDR/abstractDataOutputStream.java)4
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/AligningInput.java (renamed from libjava/classpath/gnu/CORBA/CDR/aligningInputStream.java)39
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/AligningOutput.java (renamed from libjava/classpath/gnu/CORBA/CDR/aligningOutputStream.java)37
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/ArrayValueHelper.java254
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/BigEndianInputStream.java2
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/BigEndianOutputStream.java2
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/BufferedCdrOutput.java (renamed from libjava/classpath/gnu/CORBA/CDR/cdrBufOutput.java)69
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/BufferredCdrInput.java (renamed from libjava/classpath/gnu/CORBA/CDR/cdrBufInput.java)58
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/EncapsulationStream.java (renamed from libjava/classpath/gnu/CORBA/CDR/encapsulatedOutput.java)12
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/HeadlessInput.java749
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/IDLTypeHelper.java169
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/LittleEndianInputStream.java2
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/LittleEndianOutputStream.java2
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/UnknownExceptionCtxHandler.java292
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/VMVio.java101
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/Vio.java1459
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/gnuRuntime.java336
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/gnuValueStream.java71
-rw-r--r--libjava/classpath/gnu/CORBA/CDR/noHeaderInput.java166
-rw-r--r--libjava/classpath/gnu/CORBA/CdrEncapsCodecImpl.java (renamed from libjava/classpath/gnu/CORBA/cdrEncapsCodec.java)58
-rw-r--r--libjava/classpath/gnu/CORBA/Connected_objects.java11
-rw-r--r--libjava/classpath/gnu/CORBA/CorbaList.java (renamed from libjava/classpath/gnu/CORBA/corbaArrayList.java)8
-rw-r--r--libjava/classpath/gnu/CORBA/DefaultSocketFactory.java79
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java (renamed from libjava/classpath/gnu/CORBA/DynAn/abstractDynAny.java)14
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/DivideableAny.java (renamed from libjava/classpath/gnu/CORBA/DynAn/anyDivideable.java)16
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/RecordAny.java (renamed from libjava/classpath/gnu/CORBA/DynAn/abstractRecord.java)18
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/UndivideableAny.java (renamed from libjava/classpath/gnu/CORBA/DynAn/anyUndivideable.java)6
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/ValueChangeListener.java (renamed from libjava/classpath/gnu/CORBA/DynAn/valueChangedListener.java)4
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java28
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java8
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java14
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java2
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java2
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java4
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java10
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java14
-rw-r--r--libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java6
-rw-r--r--libjava/classpath/gnu/CORBA/EmptyExceptionHolder.java1
-rw-r--r--libjava/classpath/gnu/CORBA/ExceptionCreator.java245
-rw-r--r--libjava/classpath/gnu/CORBA/ForwardRequestHelper.java1
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/CharSets_OSF.java5
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/CloseMessage.java10
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/CodeSetServiceContext.java (renamed from libjava/classpath/gnu/CORBA/GIOP/cxCodeSet.java)26
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/ContextHandler.java (renamed from libjava/classpath/gnu/CORBA/GIOP/contextSupportingHeader.java)4
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/ErrorMessage.java23
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/MessageHeader.java200
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/ReplyHeader.java10
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/RequestHeader.java10
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java88
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/v1_0/ReplyHeader.java14
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/v1_0/RequestHeader.java14
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/v1_2/ReplyHeader.java16
-rw-r--r--libjava/classpath/gnu/CORBA/GIOP/v1_2/RequestHeader.java27
-rw-r--r--libjava/classpath/gnu/CORBA/GeneralHolder.java (renamed from libjava/classpath/gnu/CORBA/universalHolder.java)26
-rw-r--r--libjava/classpath/gnu/CORBA/HolderLocator.java (renamed from libjava/classpath/gnu/CORBA/holderFactory.java)4
-rw-r--r--libjava/classpath/gnu/CORBA/IOR.java96
-rw-r--r--libjava/classpath/gnu/CORBA/Interceptor/IORInterceptors.java83
-rw-r--r--libjava/classpath/gnu/CORBA/Interceptor/Registrator.java8
-rw-r--r--libjava/classpath/gnu/CORBA/Interceptor/gnuIcCurrent.java4
-rw-r--r--libjava/classpath/gnu/CORBA/Interceptor/gnuIorInfo.java44
-rw-r--r--libjava/classpath/gnu/CORBA/Interceptor/gnuServerRequestInfo.java20
-rw-r--r--libjava/classpath/gnu/CORBA/IorDelegate.java (renamed from libjava/classpath/gnu/CORBA/IOR_Delegate.java)92
-rw-r--r--libjava/classpath/gnu/CORBA/IorObject.java (renamed from libjava/classpath/gnu/CORBA/IOR_contructed_object.java)21
-rw-r--r--libjava/classpath/gnu/CORBA/IorProvider.java52
-rw-r--r--libjava/classpath/gnu/CORBA/Minor.java282
-rw-r--r--libjava/classpath/gnu/CORBA/NamingService/Ext.java2
-rw-r--r--libjava/classpath/gnu/CORBA/NamingService/NameComponentComparator.java (renamed from libjava/classpath/gnu/CORBA/NamingService/cmpNameComponent.java)10
-rw-r--r--libjava/classpath/gnu/CORBA/NamingService/NameParser.java197
-rw-r--r--libjava/classpath/gnu/CORBA/NamingService/NameTransformer.java (renamed from libjava/classpath/gnu/CORBA/NamingService/snConverter.java)6
-rw-r--r--libjava/classpath/gnu/CORBA/NamingService/NamingMap.java2
-rw-r--r--libjava/classpath/gnu/CORBA/NamingService/NamingServiceTransient.java10
-rw-r--r--libjava/classpath/gnu/CORBA/ObjectCreator.java397
-rw-r--r--libjava/classpath/gnu/CORBA/OctetHolder.java4
-rw-r--r--libjava/classpath/gnu/CORBA/OrbFocused.java375
-rw-r--r--libjava/classpath/gnu/CORBA/OrbFunctional.java (renamed from libjava/classpath/gnu/CORBA/Functional_ORB.java)469
-rw-r--r--libjava/classpath/gnu/CORBA/OrbRestricted.java (renamed from libjava/classpath/gnu/CORBA/Restricted_ORB.java)41
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/AOM.java (renamed from libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java)26
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java (renamed from libjava/classpath/gnu/CORBA/Poa/vPolicy.java)4
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java (renamed from libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java)6
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java16
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java79
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/LocalRequest.java42
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java51
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java (renamed from libjava/classpath/gnu/CORBA/Poa/servantDelegate.java)6
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java (renamed from libjava/classpath/gnu/CORBA/Poa/policySets.java)8
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java2
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java2
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java2
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java2
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java2
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuPOA.java471
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java60
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java2
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java60
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java2
-rw-r--r--libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java2
-rw-r--r--libjava/classpath/gnu/CORBA/RawReply.java (renamed from libjava/classpath/gnu/CORBA/binaryReply.java)12
-rw-r--r--libjava/classpath/gnu/CORBA/ResponseHandlerImpl.java (renamed from libjava/classpath/gnu/CORBA/bufferedResponseHandler.java)18
-rw-r--r--libjava/classpath/gnu/CORBA/ServiceRequestAdapter.java10
-rw-r--r--libjava/classpath/gnu/CORBA/SimpleDelegate.java (renamed from libjava/classpath/gnu/CORBA/Simple_delegate.java)48
-rw-r--r--libjava/classpath/gnu/CORBA/SocketRepository.java86
-rw-r--r--libjava/classpath/gnu/CORBA/StreamBasedRequest.java (renamed from libjava/classpath/gnu/CORBA/streamRequest.java)6
-rw-r--r--libjava/classpath/gnu/CORBA/StreamHolder.java (renamed from libjava/classpath/gnu/CORBA/streamReadyHolder.java)11
-rw-r--r--libjava/classpath/gnu/CORBA/StubLocator.java (renamed from libjava/classpath/gnu/CORBA/stubFinder.java)8
-rw-r--r--libjava/classpath/gnu/CORBA/TypeCodeHelper.java35
-rw-r--r--libjava/classpath/gnu/CORBA/TypeKindNamer.java (renamed from libjava/classpath/gnu/CORBA/typeNamer.java)75
-rw-r--r--libjava/classpath/gnu/CORBA/Version.java26
-rw-r--r--libjava/classpath/gnu/CORBA/WCharHolder.java4
-rw-r--r--libjava/classpath/gnu/CORBA/WStringHolder.java6
-rw-r--r--libjava/classpath/gnu/CORBA/_PolicyImplBase.java3
-rw-r--r--libjava/classpath/gnu/CORBA/gnuAny.java139
-rw-r--r--libjava/classpath/gnu/CORBA/gnuCodecFactory.java2
-rw-r--r--libjava/classpath/gnu/CORBA/gnuContextList.java2
-rw-r--r--libjava/classpath/gnu/CORBA/gnuExceptionList.java2
-rw-r--r--libjava/classpath/gnu/CORBA/gnuNVList.java6
-rw-r--r--libjava/classpath/gnu/CORBA/gnuRequest.java134
-rw-r--r--libjava/classpath/gnu/CORBA/gnuValueHolder.java2
-rw-r--r--libjava/classpath/gnu/CORBA/interfaces/SocketFactory.java95
-rw-r--r--libjava/classpath/gnu/CORBA/interfaces/package.html49
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/AliasTypeCode.java (renamed from libjava/classpath/gnu/CORBA/aliasTypeCode.java)16
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/ArrayTypeCode.java (renamed from libjava/classpath/gnu/CORBA/primitiveArrayTypeCode.java)21
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/FixedTypeCode.java (renamed from libjava/classpath/gnu/CORBA/fixedTypeCode.java)19
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/GeneralTypeCode.java (renamed from libjava/classpath/gnu/CORBA/generalTypeCode.java)40
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/PrimitiveTypeCode.java (renamed from libjava/classpath/gnu/CORBA/primitiveTypeCode.java)15
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/RecordTypeCode.java (renamed from libjava/classpath/gnu/CORBA/recordTypeCode.java)21
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/RecursiveTypeCode.java (renamed from libjava/classpath/gnu/CORBA/recursiveTypeCode.java)16
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/StringTypeCode.java (renamed from libjava/classpath/gnu/CORBA/stringTypeCode.java)16
-rw-r--r--libjava/classpath/gnu/CORBA/typecodes/package.html48
131 files changed, 7243 insertions, 2528 deletions
diff --git a/libjava/classpath/gnu/CORBA/CDR/cdrInput.java b/libjava/classpath/gnu/CORBA/CDR/AbstractCdrInput.java
index 69f9c8c5837..866ec2cc945 100644
--- a/libjava/classpath/gnu/CORBA/CDR/cdrInput.java
+++ b/libjava/classpath/gnu/CORBA/CDR/AbstractCdrInput.java
@@ -1,4 +1,4 @@
-/* cdrInput.java --
+/* AbstractCdrInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,16 +39,17 @@ exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.BigDecimalHelper;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.GIOP.CharSets_OSF;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import gnu.CORBA.IOR;
-import gnu.CORBA.IOR_Delegate;
+import gnu.CORBA.IorDelegate;
+import gnu.CORBA.Minor;
import gnu.CORBA.TypeCodeHelper;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
import gnu.CORBA.gnuAny;
-import gnu.CORBA.stubFinder;
+import gnu.CORBA.StubLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnySeqHolder;
@@ -81,38 +82,44 @@ import java.io.Serializable;
import java.math.BigDecimal;
/**
- * A simple CORBA CDR (common data representation)
- * input stream, reading data from the
- * given {@link java.io.InputStream}. The primitive types
- * are aligned on they natural boundaries by implementing the
- * abstract method {@link #align(int boundary)}.
- *
- * The same class also implements {@link org.omg.CORBA.DataInputStream} to
- * read the object content in a user defined way.
- *
+ * A simple CORBA CDR (common data representation) input stream, reading data
+ * from the given {@link java.io.InputStream}. The primitive types are aligned
+ * on they natural boundaries by implementing the abstract method
+ * {@link #align(int boundary)}.
+ *
+ * The same class also implements {@link org.omg.CORBA.DataInputStream} to read
+ * the object content in a user defined way.
+ *
+ * TODO This class uses 16 bits per Unicode character only, as it was until jdk
+ * 1.4 inclusive.
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public abstract class cdrInput
+public abstract class AbstractCdrInput
extends org.omg.CORBA_2_3.portable.InputStream
implements org.omg.CORBA.DataInputStream
{
/**
- * The message, explaining that the exception has been thrown due
- * unexpected end of the input stream. This usually happens the
- * server and client disagree on communication or data representation
- * rules.
+ * The runtime, associated with this stream. This field is only used when
+ * reading and writing value types and filled-in in gnu.CORBA.CDR.Vio.
+ */
+ public transient gnuRuntime runtime;
+
+ /**
+ * The message, explaining that the exception has been thrown due unexpected
+ * end of the input stream. This usually happens the server and client
+ * disagree on communication or data representation rules.
*/
protected static final String UNEXP_EOF = "Unexpected end of stream";
/**
- * This instance is used to convert primitive data types into the
- * byte sequences.
+ * This instance is used to convert primitive data types into the byte
+ * sequences.
*/
- protected abstractDataInputStream b;
+ protected AbstractDataInput b;
/**
- * The input stream, from where the data are actually
- * being read.
+ * The input stream, from where the data are actually being read.
*/
protected java.io.InputStream actual_stream;
@@ -129,71 +136,68 @@ public abstract class cdrInput
/**
* The code set information.
*/
- protected cxCodeSet codeset = cxCodeSet.STANDARD;
+ protected CodeSetServiceContext codeset = CodeSetServiceContext.STANDARD;
/**
- * The name of the currently used narrow charset, null if
- * the native narrow charset is used.
+ * The name of the currently used narrow charset, null if the native narrow
+ * charset is used.
*/
private String narrow_charset = null;
/**
- * The name of the currently used wide charset, null if
- * the native wide charset is used.
+ * The name of the currently used wide charset, null if the native wide
+ * charset is used.
*/
private String wide_charset = null;
/**
- * True if the native code set is used for narrow characters.
- * If the set is native, no the intermediate Reader object
- * is instantiated when writing characters.
+ * True if the native code set is used for narrow characters. If the set is
+ * native, no the intermediate Reader object is instantiated when writing
+ * characters.
*/
private boolean narrow_native;
/**
- * True if the native code set is used for wide characters.
- * If the set is native, no the intermediate Reader object
- * is instantiated when writing characters.
+ * True if the native code set is used for wide characters. If the set is
+ * native, no the intermediate Reader object is instantiated when writing
+ * characters.
*/
private boolean wide_native;
/**
- * If true, the stream expect
- * the multi-byte data in the form "less significant byte
- * first" (Little Endian). This is the opposite to the
- * java standard (Big Endian).
+ * If true, the stream expect the multi-byte data in the form "less
+ * significant byte first" (Little Endian). This is the opposite to the java
+ * standard (Big Endian).
*/
private boolean little_endian;
/**
- * Creates the stream. The stream reads Big Endian by
- * default.
- *
+ * Creates the stream. The stream reads Big Endian by default.
+ *
* @param readFrom a stream to read CORBA input from.
*/
- public cdrInput(java.io.InputStream readFrom)
+ public AbstractCdrInput(java.io.InputStream readFrom)
{
setInputStream(readFrom);
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
- * Creates the stream, requiring the subsequent call
- * of {@link #setInputStream(java.io.InputStream)}.
+ * Creates the stream, requiring the subsequent call of
+ * {@link #setInputStream(java.io.InputStream)}.
*/
- public cdrInput()
+ public AbstractCdrInput()
{
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
- * Set the Big Endian or Little Endian encoding.
- * The stream reads Big Endian by default.
- *
- * @param use_little_endian if true, the stream expect
- * the multi-byte data in the form "less significant byte
- * first" (Little Endian). This is the opposite to the
- * java standard (Big Endian).
+ * Set the Big Endian or Little Endian encoding. The stream reads Big Endian
+ * by default.
+ *
+ * @param use_little_endian if true, the stream expect the multi-byte data in
+ * the form "less significant byte first" (Little Endian). This is the
+ * opposite to the java standard (Big Endian).
*/
public void setBigEndian(boolean use_big_endian)
{
@@ -202,8 +206,29 @@ public abstract class cdrInput
}
/**
+ * Get the used encoding.
+ *
+ * @param true for Big Endian, false for Little Endian.
+ */
+ public boolean isBigEndian()
+ {
+ return !little_endian;
+ }
+
+ /**
+ * Clone all important settings to another stream.
+ */
+ public void cloneSettings(AbstractCdrInput stream)
+ {
+ stream.setBigEndian(isBigEndian());
+ stream.setCodeSet(getCodeSet());
+ stream.setVersion(giop);
+ stream.setOrb(orb);
+ }
+
+ /**
* Set the input stream that receives the CORBA input.
- *
+ *
* @param readFrom the stream.
*/
public void setInputStream(java.io.InputStream readFrom)
@@ -217,13 +242,14 @@ public abstract class cdrInput
}
/**
- * Set the alignment offset, if the index of the first byte in the
- * stream is different from 0.
+ * Set the alignment offset, if the index of the first byte in the stream is
+ * different from 0.
*/
public abstract void setOffset(int offset);
/**
* Set the orb, associated with this stream.
+ *
* @param an_orb
*/
public void setOrb(ORB an_orb)
@@ -232,8 +258,8 @@ public abstract class cdrInput
}
/**
- * Set the GIOP version. Some data types are written differently
- * for the different versions. The default version is 1.0 .
+ * Set the GIOP version. Some data types are written differently for the
+ * different versions. The default version is 1.0 .
*/
public void setVersion(Version giop_version)
{
@@ -246,8 +272,8 @@ public abstract class cdrInput
public abstract void align(int boundary);
/**
- * Reads the CORBA unsigned long (java int), returning the
- * value in the sufficiently large java long.
+ * Reads the CORBA unsigned long (java int), returning the value in the
+ * sufficiently large java long.
*/
public long gnu_read_ulong()
{
@@ -260,6 +286,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -270,8 +297,8 @@ public abstract class cdrInput
}
/**
- * Read the unsigned short integer value and return it as java
- * int, sufficiently large to hold all values.
+ * Read the unsigned short integer value and return it as java int,
+ * sufficiently large to hold all values.
*/
public int gnu_read_ushort()
{
@@ -283,6 +310,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -295,6 +323,7 @@ public abstract class cdrInput
/**
* Return the associated {@link ORB}.
+ *
* @return the associated {@link ORB} or null is no such is set.
*/
public ORB orb()
@@ -306,7 +335,7 @@ public abstract class cdrInput
* Read a single byte directly from the buffer.
*/
public int read()
- throws java.io.IOException
+ throws java.io.IOException
{
try
{
@@ -315,6 +344,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -324,7 +354,7 @@ public abstract class cdrInput
* Read bytes directly from the buffer.
*/
public int read(byte[] x, int ofs, int len)
- throws java.io.IOException
+ throws java.io.IOException
{
try
{
@@ -333,6 +363,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -342,7 +373,7 @@ public abstract class cdrInput
* Read bytes directly from the buffer.
*/
public int read(byte[] x)
- throws java.io.IOException
+ throws java.io.IOException
{
try
{
@@ -351,24 +382,25 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
}
/**
- * Read the CORBA object. The object to read is represented in the
- * form of the plain (not a string-encoded) IOR profile without the
- * heading endian indicator. The responsible method for reading such
- * data is {@link IOR.read_no_endian}.
- *
- * The returned object is usually casted into the given type using
- * the .narrow method of its helper, despite in some cases the direct
- * cast would also work.
- *
- * The null objects are recognised from the empty profile set.
- * For such objects, null is returned.
- *
+ * Read the CORBA object. The object to read is represented in the form of the
+ * plain (not a string-encoded) IOR profile without the heading endian
+ * indicator. The responsible method for reading such data is
+ * {@link IOR.read_no_endian}.
+ *
+ * The returned object is usually casted into the given type using the .narrow
+ * method of its helper, despite in some cases the direct cast would also
+ * work.
+ *
+ * The null objects are recognised from the empty profile set. For such
+ * objects, null is returned.
+ *
* @return the loaded and constructed object.
*/
public org.omg.CORBA.Object read_Object()
@@ -384,41 +416,42 @@ public abstract class cdrInput
// Check maybe this is a remote reference to the local object.
// This is only possible if we access the repository of the
// connected object.
- if (orb instanceof Functional_ORB)
+ if (orb instanceof OrbFunctional)
{
- Functional_ORB forb = (Functional_ORB) orb;
+ OrbFunctional forb = (OrbFunctional) orb;
org.omg.CORBA.Object local = forb.find_local_object(ior);
if (local != null)
return local;
}
// Search for the available stubs.
- ObjectImpl impl = stubFinder.search(orb, ior);
+ ObjectImpl impl = StubLocator.search(orb, ior);
try
{
if (impl._get_delegate() == null)
- impl._set_delegate(new IOR_Delegate(orb, ior));
+ impl._set_delegate(new IorDelegate(orb, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception
// in response to the attempt to get the unset delegate.
- impl._set_delegate(new IOR_Delegate(orb, ior));
+ impl._set_delegate(new IorDelegate(orb, ior));
}
return impl;
}
catch (IOException ex)
{
- BAD_OPERATION bad = new BAD_OPERATION();
+ MARSHAL bad = new MARSHAL();
+ bad.minor = Minor.IOR;
bad.initCause(ex);
throw bad;
}
}
/**
- * Read the type code. The type code format is defined in the
- * CORBA documenation.
+ * Read the type code. The type code format is defined in the CORBA
+ * documenation.
*/
public TypeCode read_TypeCode()
{
@@ -438,9 +471,8 @@ public abstract class cdrInput
}
/**
- * Read the CORBA {@link Any}. This method first reads the
- * type code, then delegates the functionality
- * to {@link Any#read_value}.
+ * Read the CORBA {@link Any}. This method first reads the type code, then
+ * delegates the functionality to {@link Any#read_value}.
*/
public Any read_any()
{
@@ -451,8 +483,7 @@ public abstract class cdrInput
}
/**
- * Read the boolean, treating any non zero byte as true,
- * zero byte as false.
+ * Read the boolean, treating any non zero byte as true, zero byte as false.
*/
public boolean read_boolean()
{
@@ -463,6 +494,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -481,12 +513,13 @@ public abstract class cdrInput
{
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.read() == 0 ? false : true;
+ x[i] = b.read() == 0 ? false : true;
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -498,8 +531,8 @@ public abstract class cdrInput
}
/**
- * Read a character using narrow charset encoding. Depending form
- * which encoding is set, this still can be Unicode or ever wider.
+ * Read a character using narrow charset encoding. Depending form which
+ * encoding is set, this still can be Unicode or ever wider.
*/
public char read_char()
{
@@ -513,6 +546,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -533,18 +567,19 @@ public abstract class cdrInput
if (narrow_native)
{
for (int i = offset; i < offset + length; i++)
- x [ i ] = (char) b.read();
+ x[i] = (char) b.read();
}
else
{
- InputStreamReader reader =
- new InputStreamReader((InputStream) b, narrow_charset);
+ InputStreamReader reader = new InputStreamReader((InputStream) b,
+ narrow_charset);
reader.read(x, offset, length);
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -568,6 +603,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -588,12 +624,13 @@ public abstract class cdrInput
align(8);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readDouble();
+ x[i] = b.readDouble();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -605,26 +642,24 @@ public abstract class cdrInput
}
/**
- * Read the encapsulated stream.
- * If the encapsulated sequence appears to be in the
- * Little endian format, the flag of the returned stream
- * is set to read Little endian.
+ * Read the encapsulated stream. If the encapsulated sequence appears to be in
+ * the Little endian format, the flag of the returned stream is set to read
+ * Little endian.
*/
- public cdrBufInput read_encapsulation()
+ public BufferredCdrInput read_encapsulation()
{
try
{
int l = read_long();
- byte[] r = new byte[ l ];
+ byte[] r = new byte[l];
int n = 0;
- reading:
- while (n < r.length)
+ reading: while (n < r.length)
{
n += read(r, n, r.length - n);
}
- cdrBufInput capsule = new cdrBufInput(r);
+ BufferredCdrInput capsule = new BufferredCdrInput(r);
capsule.setOrb(orb);
int endian = capsule.read_octet();
@@ -639,6 +674,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -650,9 +686,8 @@ public abstract class cdrInput
}
/**
- * Read the CORBA fixed (the end of the <code>fixed</code>
- * can be determined by its last byte). The scale is always
- * assumed to be zero.
+ * Read the CORBA fixed (the end of the <code>fixed</code> can be determined
+ * by its last byte). The scale is always assumed to be zero.
*/
public BigDecimal read_fixed()
{
@@ -663,6 +698,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -686,6 +722,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -706,12 +743,13 @@ public abstract class cdrInput
align(4);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readFloat();
+ x[i] = b.readFloat();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -735,6 +773,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -755,12 +794,13 @@ public abstract class cdrInput
align(4);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readInt();
+ x[i] = b.readInt();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -783,7 +823,9 @@ public abstract class cdrInput
}
catch (EOFException ex)
{
- throw new MARSHAL(UNEXP_EOF);
+ MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
+ throw t;
}
catch (IOException ex)
@@ -802,12 +844,13 @@ public abstract class cdrInput
align(8);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readLong();
+ x[i] = b.readLong();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -830,6 +873,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -852,6 +896,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -863,24 +908,24 @@ public abstract class cdrInput
}
/**
- * Read the length of the byte array as CORBA long and then
- * the array itseld.
+ * Read the length of the byte array as CORBA long and then the array itseld.
*/
public byte[] read_sequence()
{
try
{
int l = read_long();
- byte[] b = new byte[ l ];
+ byte[] buf = new byte[l];
if (l > 0)
{
- read(b);
+ b.readFully(buf);
}
- return b;
+ return buf;
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -904,6 +949,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -924,12 +970,13 @@ public abstract class cdrInput
align(2);
for (int i = offs; i < offs + len; i++)
{
- x [ i ] = b.readShort();
+ x[i] = b.readShort();
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -941,21 +988,21 @@ public abstract class cdrInput
}
/**
- * Read a singe byte string. The method firs reads the
- * byte array and then calls a constructor to create a
- * string from this array. The character encoding, if
- * previously set, is taken into consideration.
- *
+ * Read a singe byte string. The method firs reads the byte array and then
+ * calls a constructor to create a string from this array. The character
+ * encoding, if previously set, is taken into consideration.
+ *
* @return a loaded string.
*/
public String read_string()
{
+ int n = 0;
try
{
align(4);
- int n = b.readInt();
- byte[] s = new byte[ n ];
+ n = b.readInt();
+ byte[] s = new byte[n];
b.read(s);
// Discard the null terminator.
@@ -967,19 +1014,26 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
-
catch (IOException ex)
{
throw new Unexpected();
}
+ catch (NegativeArraySizeException nex)
+ {
+ MARSHAL m = new MARSHAL("Input stream broken, got " + n + "(0x"
+ + Integer.toHexString(n) + ") as a string size");
+ m.minor = Minor.Negative;
+ throw m;
+ }
}
/**
- * Reads the CORBA unsigned long (java int), delegating
- * functionality to {@link #read_long}.
+ * Reads the CORBA unsigned long (java int), delegating functionality to
+ * {@link #read_long}.
*/
public int read_ulong()
{
@@ -987,9 +1041,8 @@ public abstract class cdrInput
}
/**
- * Reads the array of CORBA unsigned long (java integer) values,
- * delegating functionality to
- * {@link #real_long_array}.
+ * Reads the array of CORBA unsigned long (java integer) values, delegating
+ * functionality to {@link #real_long_array}.
*/
public void read_ulong_array(int[] x, int offs, int len)
{
@@ -997,11 +1050,9 @@ public abstract class cdrInput
}
/**
- * Read the CORBA unsigned long long value,
- * delegating functionality to {@link #read_longlong}.
- * There is no way to return values over the limit of
- * the java signed long in other way than returning
- * the negative value.
+ * Read the CORBA unsigned long long value, delegating functionality to
+ * {@link #read_longlong}. There is no way to return values over the limit of
+ * the java signed long in other way than returning the negative value.
*/
public long read_ulonglong()
{
@@ -1009,9 +1060,8 @@ public abstract class cdrInput
}
/**
- * Reads the array of CORBA long long (java long) values,
- * delegating functionality to
- * {@link #real_longlong_array}.
+ * Reads the array of CORBA long long (java long) values, delegating
+ * functionality to {@link #real_longlong_array}.
*/
public void read_ulonglong_array(long[] x, int offs, int len)
{
@@ -1019,10 +1069,9 @@ public abstract class cdrInput
}
/**
- * Read the unsigned short integer value. Due strange specification,
- * the returned value must be the short type as well, so the
- * the best solution seems just to delegete functionality to
- * read_short.
+ * Read the unsigned short integer value. Due strange specification, the
+ * returned value must be the short type as well, so the the best solution
+ * seems just to delegete functionality to read_short.
*/
public short read_ushort()
{
@@ -1030,8 +1079,8 @@ public abstract class cdrInput
}
/**
- * Read an array of unsigned short values, delegating the
- * functionality to {@link read_short_array}.
+ * Read an array of unsigned short values, delegating the functionality to
+ * {@link read_short_array}.
*/
public void read_ushort_array(short[] x, int offs, int len)
{
@@ -1039,24 +1088,64 @@ public abstract class cdrInput
}
/**
- * Reads the wide character using the encoding, specified in the
- * wide_charset.
+ * Reads the wide character using the encoding, specified in the wide_charset.
*/
public char read_wchar()
{
try
{
if (giop.until_inclusive(1, 1))
- align(2);
+ {
+ align(2);
- if (wide_native)
- return (char) b.readShort();
+ if (wide_native)
+ return (char) b.readShort();
+ else
+ return (char) new InputStreamReader((InputStream) b, wide_charset).read();
+ }
else
- return (char) new InputStreamReader((InputStream) b, wide_charset).read();
+ {
+ int l = b.read();
+ if (l == 2 && wide_native)
+ return b.readChar();
+ else if (l <= 0)
+ {
+ MARSHAL m = new MARSHAL("wchar size " + l);
+ m.minor = Minor.Negative;
+ throw m;
+ }
+ else
+ {
+ byte[] bytes = new byte[l];
+ b.readFully(bytes);
+ String cs;
+
+ if (bytes.length > 2 && bytes[0] == 0xFE && bytes[1] == 0xFF)
+ cs = new String(bytes, 2, bytes.length - 2, wide_charset);
+ else if (bytes.length > 2 && bytes[0] == 0xFF
+ && bytes[1] == 0xFE)
+ {
+ // Litle endian detected - swap bytes.
+ byte t;
+ for (int i = 3; i < bytes.length; i = i + 2)
+ {
+ t = bytes[i];
+ bytes[i - 1] = bytes[i];
+ bytes[i] = t;
+ }
+ cs = new String(bytes, 2, bytes.length - 2, wide_charset);
+ }
+ else
+ cs = new String(bytes, wide_charset);
+
+ return cs.charAt(0);
+ }
+ }
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1067,8 +1156,8 @@ public abstract class cdrInput
}
/**
- * Read an array of "wide chars", each representing a two byte
- * Unicode character, high byte first.
+ * Read an array of "wide chars", each representing a two byte Unicode
+ * character, high byte first.
*/
public void read_wchar_array(char[] x, int offset, int length)
{
@@ -1080,18 +1169,19 @@ public abstract class cdrInput
if (wide_native)
{
for (int i = offset; i < offset + length; i++)
- x [ i ] = (char) b.readShort();
+ x[i] = (char) b.readShort();
}
else
{
- InputStreamReader reader =
- new InputStreamReader((InputStream) b, wide_charset);
+ InputStreamReader reader = new InputStreamReader((InputStream) b,
+ wide_charset);
reader.read(x, offset, length);
}
}
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1103,13 +1193,11 @@ public abstract class cdrInput
}
/**
- * Reads the string in wide character format
- * (ussually UTF-16, Unicode). Takes the currently set charset
- * into consideration.
- *
- * If the native (UTF-16) encoding is used
- * of the GIOP protocol is before 1.2, delegates functionality
- * to "plain" {@link #read_wstring_UTF_16}.
+ * Reads the string in wide character format (ussually UTF-16, Unicode). Takes
+ * the currently set charset into consideration.
+ *
+ * If the native (UTF-16) encoding is used of the GIOP protocol is before 1.2,
+ * delegates functionality to "plain" {@link #read_wstring_UTF_16}.
*/
public String read_wstring()
{
@@ -1121,7 +1209,7 @@ public abstract class cdrInput
align(4);
int n = b.readInt();
- byte[] s = new byte[ n ];
+ byte[] s = new byte[n];
b.read(s);
return new String(s, 0, n, wide_charset);
@@ -1129,6 +1217,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1140,9 +1229,9 @@ public abstract class cdrInput
}
/**
- * Reads first length of the string and the all characters as an
- * Unicode (UTF-16) characters. Mind that GIOP 1.1 has the extra
- * null character at the end that must be discarded.
+ * Reads first length of the string and the all characters as an Unicode
+ * (UTF-16) characters. Mind that GIOP 1.1 has the extra null character at the
+ * end that must be discarded.
*/
public String read_wstring_UTF_16()
{
@@ -1150,6 +1239,13 @@ public abstract class cdrInput
{
int p = 0;
int n = read_long();
+
+ if (n<0)
+ {
+ MARSHAL m = new MARSHAL("Negative string size");
+ m.minor = Minor.Negative;
+ throw m;
+ }
// The null terminator that is no longer present since 1.2 .
int nt = giop.since_inclusive(1, 2) ? 0 : 1;
@@ -1157,26 +1253,30 @@ public abstract class cdrInput
// Convert bytes to shorts.
n = n / 2;
- char[] s = new char[ n ];
+ // Empty string.
+ if (n == 0)
+ return "";
+
+ char[] s = new char[n];
for (int i = 0; i < s.length; i++)
- s [ i ] = (char) b.readShort();
+ s[i] = (char) b.readShort();
// Check for the byte order marker here.
- if (s [ 0 ] == 0xFEFF)
+ if (s[0] == 0xFEFF)
{
// Big endian encoding - do nothing, but move the pointer
// one position forward.
p = 1;
}
- else if (s [ 0 ] == 0xFFFE)
+ else if (s[0] == 0xFFFE)
{
// Little endian encoding, swap the bytes and move one
// position forward.
p = 1;
for (int i = p; i < s.length; i++)
- s [ i ] = swap(s [ i ]);
+ s[i] = swap(s[i]);
}
// Discard the null terminator and, if needed, the endian marker.
@@ -1186,6 +1286,7 @@ public abstract class cdrInput
catch (EOFException ex)
{
MARSHAL t = new MARSHAL(UNEXP_EOF);
+ t.minor = Minor.EOF;
t.initCause(ex);
throw t;
}
@@ -1213,7 +1314,7 @@ public abstract class cdrInput
/**
* Set the current code set context.
*/
- public void setCodeSet(cxCodeSet a_codeset)
+ public void setCodeSet(CodeSetServiceContext a_codeset)
{
this.codeset = a_codeset;
narrow_charset = CharSets_OSF.getName(codeset.char_data);
@@ -1226,7 +1327,7 @@ public abstract class cdrInput
/**
* Get the current code set context.
*/
- public cxCodeSet getCodeSet()
+ public CodeSetServiceContext getCodeSet()
{
return codeset;
}
@@ -1235,9 +1336,9 @@ public abstract class cdrInput
* Read the object that is an instance of the given class. The current
* implementation delegates functionality to the parameterless
* {@link readObject()}.
- *
+ *
* @param klass a class of that this object the instance is.
- *
+ *
* @return the returned object.
*/
public org.omg.CORBA.Object read_Object(Class klass)
@@ -1247,11 +1348,11 @@ public abstract class cdrInput
/**
* Read a value type structure from the stream.
- *
- * OMG specification states the writing format is outside the scope
- * of GIOP definition. This implementation uses java serialization
- * mechanism, calling {@link ObjectInputStream#readObject}
- *
+ *
+ * OMG specification states the writing format is outside the scope of GIOP
+ * definition. This implementation uses java serialization mechanism, calling
+ * {@link ObjectInputStream#readObject}
+ *
* @return an value type structure, unmarshaled from the stream
*/
public Serializable read_Value()
@@ -1260,14 +1361,13 @@ public abstract class cdrInput
}
/**
- * Read the abstract interface. An abstract interface can be either
- * CORBA value type or CORBA object and is returned as an abstract
- * java.lang.Object.
- *
- * As specified in OMG specification, this reads a single
- * boolean and then delegates either to {@link #read_Object()} (for false)
- * or to {@link #read_Value()} (for true).
- *
+ * Read the abstract interface. An abstract interface can be either CORBA
+ * value type or CORBA object and is returned as an abstract java.lang.Object.
+ *
+ * As specified in OMG specification, this reads a single boolean and then
+ * delegates either to {@link #read_Object()} (for false) or to
+ * {@link #read_Value()} (for true).
+ *
* @return an abstract interface, unmarshaled from the stream
*/
public java.lang.Object read_Abstract()
@@ -1276,10 +1376,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_char_array(CharSeqHolder holder, int offset, int length)
{
@@ -1288,10 +1388,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
{
@@ -1300,23 +1400,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the char array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the char array to fit the newly read
+ * values.
+ *
* @param holder_value the existing char array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private char[] ensureArray(char[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new char[ offset + length ];
+ return new char[offset + length];
else if (holder_value.length < offset + length)
{
- char[] value = new char[ offset + length ];
+ char[] value = new char[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1325,10 +1425,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
{
@@ -1337,10 +1437,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_long_array(LongSeqHolder holder, int offset, int length)
{
@@ -1349,23 +1449,22 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the int array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the int array to fit the newly read values.
+ *
* @param holder_value the existing int array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private int[] ensureArray(int[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new int[ offset + length ];
+ return new int[offset + length];
else if (holder_value.length < offset + length)
{
- int[] value = new int[ offset + length ];
+ int[] value = new int[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1374,10 +1473,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_float_array(FloatSeqHolder holder, int offset, int length)
{
@@ -1386,23 +1485,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the float array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the float array to fit the newly read
+ * values.
+ *
* @param holder_value the existing float array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private float[] ensureArray(float[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new float[ offset + length ];
+ return new float[offset + length];
else if (holder_value.length < offset + length)
{
- float[] value = new float[ offset + length ];
+ float[] value = new float[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1411,10 +1510,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_double_array(DoubleSeqHolder holder, int offset, int length)
{
@@ -1423,23 +1522,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the double array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the double array to fit the newly read
+ * values.
+ *
* @param holder_value the existing double array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private double[] ensureArray(double[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new double[ offset + length ];
+ return new double[offset + length];
else if (holder_value.length < offset + length)
{
- double[] value = new double[ offset + length ];
+ double[] value = new double[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1448,10 +1547,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_short_array(ShortSeqHolder holder, int offset, int length)
{
@@ -1467,23 +1566,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the short array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the short array to fit the newly read
+ * values.
+ *
* @param holder_value the existing short array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private short[] ensureArray(short[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new short[ offset + length ];
+ return new short[offset + length];
else if (holder_value.length < offset + length)
{
- short[] value = new short[ offset + length ];
+ short[] value = new short[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1492,10 +1591,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_octet_array(OctetSeqHolder holder, int offset, int length)
{
@@ -1504,23 +1603,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the byte array to fit the newly
- * read values.
- *
+ * If required, allocate or resize the byte array to fit the newly read
+ * values.
+ *
* @param holder_value the existing byte array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private byte[] ensureArray(byte[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new byte[ offset + length ];
+ return new byte[offset + length];
else if (holder_value.length < offset + length)
{
- byte[] value = new byte[ offset + length ];
+ byte[] value = new byte[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1529,51 +1628,49 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_longlong_array(LongLongSeqHolder holder, int offset,
- int length
- )
+ int length)
{
holder.value = ensureArray(holder.value, offset, length);
read_longlong_array(holder.value, offset, length);
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
- int length
- )
+ int length)
{
holder.value = ensureArray(holder.value, offset, length);
read_ulonglong_array(holder.value, offset, length);
}
/**
- * If required, allocate or resize the array of longs to fit the newly
- * read values.
- *
+ * If required, allocate or resize the array of longs to fit the newly read
+ * values.
+ *
* @param holder_value the existing array, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private long[] ensureArray(long[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new long[ offset + length ];
+ return new long[offset + length];
else if (holder_value.length < offset + length)
{
- long[] value = new long[ offset + length ];
+ long[] value = new long[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1582,10 +1679,10 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
{
@@ -1594,23 +1691,23 @@ public abstract class cdrInput
}
/**
- * If required, allocate or resize the array of booleans to fit the newly
- * read values.
- *
+ * If required, allocate or resize the array of booleans to fit the newly read
+ * values.
+ *
* @param holder_value the existing array of booleans, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private boolean[] ensureArray(boolean[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new boolean[ offset + length ];
+ return new boolean[offset + length];
else if (holder_value.length < offset + length)
{
- boolean[] value = new boolean[ offset + length ];
+ boolean[] value = new boolean[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1619,38 +1716,38 @@ public abstract class cdrInput
}
/**
- * Read an array. In OMG specification is written that if the data does
- * not fit into the holder value field, that array must be resized.
- * The implementation follows this rule. If the holder value field
- * contains null, it is newly instantiated.
+ * Read an array. In OMG specification is written that if the data does not
+ * fit into the holder value field, that array must be resized. The
+ * implementation follows this rule. If the holder value field contains null,
+ * it is newly instantiated.
*/
public void read_any_array(AnySeqHolder holder, int offset, int length)
{
holder.value = ensureArray(holder.value, offset, length);
for (int i = offset; i < offset + length; i++)
{
- holder.value [ i ] = read_any();
+ holder.value[i] = read_any();
}
}
/**
- * If required, allocate or resize the array of Anys to fit the newly
- * read values.
- *
+ * If required, allocate or resize the array of Anys to fit the newly read
+ * values.
+ *
* @param holder_value the existing array of Anys, may be null.
* @param offset the required offset to read.
* @param length the length of the new sequence.
- *
+ *
* @return the allocated or resized array, same array if no such operations
* are required.
*/
private Any[] ensureArray(Any[] holder_value, int offset, int length)
{
if (holder_value == null)
- return new Any[ offset + length ];
+ return new Any[offset + length];
else if (holder_value.length < offset + length)
{
- Any[] value = new Any[ offset + length ];
+ Any[] value = new Any[offset + length];
System.arraycopy(holder_value, 0, value, 0, holder_value.length);
return value;
}
@@ -1659,11 +1756,10 @@ public abstract class cdrInput
}
/**
- * This method is required to represent the DataInputStream as a value
- * type object.
- *
- * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0",
- * always.
+ * This method is required to represent the DataInputStream as a value type
+ * object.
+ *
+ * @return a single entity "IDL:omg.org/CORBA/DataInputStream:1.0", always.
*/
public String[] _truncatable_ids()
{
diff --git a/libjava/classpath/gnu/CORBA/CDR/cdrOutput.java b/libjava/classpath/gnu/CORBA/CDR/AbstractCdrOutput.java
index 85f341c912d..7b4d5ec58ff 100644
--- a/libjava/classpath/gnu/CORBA/CDR/cdrOutput.java
+++ b/libjava/classpath/gnu/CORBA/CDR/AbstractCdrOutput.java
@@ -1,4 +1,4 @@
-/* cdrOutput.java --
+/* AbstractCdrOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,27 +39,28 @@ exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.BigDecimalHelper;
-import gnu.CORBA.GIOP.CharSets_OSF;
-import gnu.CORBA.GIOP.cxCodeSet;
-import gnu.CORBA.Poa.gnuServantObject;
import gnu.CORBA.IOR;
-import gnu.CORBA.Simple_delegate;
+import gnu.CORBA.IorProvider;
+import gnu.CORBA.Minor;
import gnu.CORBA.TypeCodeHelper;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.GIOP.CharSets_OSF;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
+import org.omg.CORBA.DataInputStream;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.UserException;
+import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.OutputStream;
@@ -68,7 +69,6 @@ import org.omg.CORBA.portable.Streamable;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Serializable;
-
import java.math.BigDecimal;
/**
@@ -79,18 +79,27 @@ import java.math.BigDecimal;
* The same class also implements the {@link DataInputStream},
* providing support for writing the value type objects
* in a user defined way.
+ *
+ * TODO This class uses 16 bits per Unicode character only, as it was until
+ * jdk 1.4 inclusive.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public abstract class cdrOutput
+public abstract class AbstractCdrOutput
extends org.omg.CORBA_2_3.portable.OutputStream
implements org.omg.CORBA.DataOutputStream
{
/**
+ * The runtime, associated with this stream. This field is only used when
+ * reading and writing value types and filled-in in gnu.CORBA.CDR.Vio.
+ */
+ public transient gnuRuntime runtime;
+
+ /**
* This instance is used to convert primitive data types into the
* byte sequences.
*/
- protected abstractDataOutputStream b;
+ protected AbstractDataOutput b;
/**
* The associated orb, if any.
@@ -105,7 +114,7 @@ public abstract class cdrOutput
/**
* The code set information.
*/
- protected cxCodeSet codeset;
+ protected CodeSetServiceContext codeset;
/**
* The name of the currently used narrow charset.
@@ -148,19 +157,19 @@ public abstract class cdrOutput
*
* @param writeTo a stream to write CORBA output to.
*/
- public cdrOutput(java.io.OutputStream writeTo)
+ public AbstractCdrOutput(java.io.OutputStream writeTo)
{
setOutputStream(writeTo);
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
* Creates the stream, requiring the subsequent call
* of {@link #setOutputStream(java.io.OutputStream)}.
*/
- public cdrOutput()
+ public AbstractCdrOutput()
{
- setCodeSet(cxCodeSet.STANDARD);
+ setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
@@ -168,11 +177,22 @@ public abstract class cdrOutput
* stream is different from 0.
*/
public abstract void setOffset(int an_offset);
+
+ /**
+ * Clone all important settings to another stream.
+ */
+ public void cloneSettings(AbstractCdrOutput stream)
+ {
+ stream.setBigEndian(!little_endian);
+ stream.setCodeSet(getCodeSet());
+ stream.setVersion(giop);
+ stream.setOrb(orb);
+ }
/**
* Set the current code set context.
*/
- public void setCodeSet(cxCodeSet a_codeset)
+ public void setCodeSet(CodeSetServiceContext a_codeset)
{
this.codeset = a_codeset;
narrow_charset = CharSets_OSF.getName(codeset.char_data);
@@ -185,7 +205,7 @@ public abstract class cdrOutput
/**
* Get the current code set context.
*/
- public cxCodeSet getCodeSet()
+ public CodeSetServiceContext getCodeSet()
{
return codeset;
}
@@ -255,9 +275,9 @@ public abstract class cdrOutput
*
* @return the encapsulated stream.
*/
- public cdrOutput createEncapsulation()
+ public AbstractCdrOutput createEncapsulation()
{
- return new encapsulatedOutput(this, !little_endian);
+ return new EncapsulationStream(this, !little_endian);
}
/**
@@ -313,53 +333,56 @@ public abstract class cdrOutput
}
/**
- * Read the CORBA object. The object is written
- * form of the plain (not a string-encoded) IOR profile without the
- * heading endian indicator. The responsible method for reading such
- * data is {@link IOR.write_no_endian}.
- *
- * The null value is written as defined in OMG specification
- * (zero length string, followed by an empty set of profiles).
- */
+ * Read the CORBA object. The object is written form of the plain (not a
+ * string-encoded) IOR profile without the heading endian indicator. The
+ * responsible method for reading such data is {@link IOR.write_no_endian}.
+ *
+ * The null value is written as defined in OMG specification (zero length
+ * string, followed by an empty set of profiles).
+ */
public void write_Object(org.omg.CORBA.Object x)
{
- if (x == null)
+ ORB w_orb = orb;
+ if (x instanceof IorProvider)
{
- IOR.write_null(this);
+ ((IorProvider) x).getIor()._write_no_endian(this);
return;
}
- else if (x instanceof gnuServantObject)
+ else if (x == null)
{
- // The ORB may be different if several ORBs coexist
- // in the same machine.
- gnuServantObject g = (gnuServantObject) x;
- IOR ior = g.orb.getLocalIor(x);
- ior._write_no_endian(this);
+ IOR.write_null(this);
return;
}
else if (x instanceof ObjectImpl)
{
Delegate d = ((ObjectImpl) x)._get_delegate();
- if (d instanceof Simple_delegate)
+ if (d instanceof IorProvider)
{
- Simple_delegate ido = (Simple_delegate) d;
- ido.getIor()._write_no_endian(this);
+ ((IorProvider) d).getIor()._write_no_endian(this);
return;
}
+ else
+ {
+ ORB d_orb = d.orb(x);
+ if (d_orb != null)
+ w_orb = d_orb;
+ }
}
// Either this is not an ObjectImpl or it has the
// unexpected delegate. Try to convert via ORBs
// object_to_string().
- if (orb != null)
+ if (w_orb != null)
{
- IOR ior = IOR.parse(orb.object_to_string(x));
+ IOR ior = IOR.parse(w_orb.object_to_string(x));
ior._write_no_endian(this);
return;
}
else
- throw new BAD_OPERATION("Please set the ORB for this stream.");
+ throw new BAD_OPERATION(
+ "Please set the ORB for this stream, cannot write "
+ + x.getClass().getName());
}
/**
@@ -399,7 +422,7 @@ public abstract class cdrOutput
}
else
{
- primitiveTypeCode p = new primitiveTypeCode(TCKind.tk_null);
+ PrimitiveTypeCode p = new PrimitiveTypeCode(TCKind.tk_null);
write_TypeCode(p);
}
}
@@ -726,6 +749,7 @@ public abstract class cdrOutput
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.CDR;
t.initCause(ex);
throw t;
}
@@ -737,7 +761,7 @@ public abstract class cdrOutput
* representing the stream buffer length (the number of
* bytes being subsequently written).
*/
- public void write_sequence(cdrBufOutput from)
+ public void write_sequence(BufferedCdrOutput from)
{
try
{
@@ -747,6 +771,7 @@ public abstract class cdrOutput
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.CDR;
t.initCause(ex);
throw t;
}
@@ -874,28 +899,41 @@ public abstract class cdrOutput
}
/**
- * Writes the character as two byte short integer (Unicode value),
- * high byte first. Writes in Big Endian, but never writes the
- * endian indicator.
- *
- * The character is always written using the native UTF-16BE charset
- * because its size under arbitrary encoding is not evident.
+ * Writes the character as two byte short integer (Unicode value), high byte
+ * first. Writes in Big Endian, but never writes the endian indicator.
+ *
+ * The character is always written using the native UTF-16BE charset because
+ * its size under arbitrary encoding is not evident.
*/
public void write_wchar(char x)
{
try
{
if (giop.until_inclusive(1, 1))
- align(2);
+ {
+ align(2);
- if (wide_native)
- b.writeShort(x);
+ if (wide_native)
+ b.writeShort(x);
+ else
+ {
+ OutputStreamWriter ow = new OutputStreamWriter(
+ (OutputStream) b, wide_charset);
+ ow.write(x);
+ ow.flush();
+ }
+ }
+ else if (wide_native)
+ {
+ b.writeByte(2);
+ b.writeChar(x);
+ }
else
{
- OutputStreamWriter ow =
- new OutputStreamWriter((OutputStream) b, wide_charset);
- ow.write(x);
- ow.flush();
+ String encoded = new String(new char[] { x });
+ byte[] bytes = encoded.getBytes(wide_charset);
+ b.write(bytes.length + 2);
+ b.write(bytes);
}
}
catch (IOException ex)
@@ -906,13 +944,13 @@ public abstract class cdrOutput
/**
* Write the array of wide chars.
- *
+ *
* @param chars the array of wide chars
* @param offset offset
* @param length length
- *
- * The char array is always written using the native UTF-16BE charset
- * because the character size under arbitrary encoding is not evident.
+ *
+ * The char array is always written using the native UTF-16BE charset because
+ * the character size under arbitrary encoding is not evident.
*/
public void write_wchar_array(char[] chars, int offset, int length)
{
@@ -998,12 +1036,12 @@ public abstract class cdrOutput
/** {@inheritDoc} */
public void write_Abstract(java.lang.Object value)
{
- write_Abstract(value);
+ write_abstract_interface(value);
}
/** {@inheritDoc} */
public void write_Value(Serializable value)
{
- write_Value(value);
+ write_value(value);
}
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/CDR/abstractDataInputStream.java b/libjava/classpath/gnu/CORBA/CDR/AbstractDataInput.java
index be926254dd0..4d120fa2c0c 100644
--- a/libjava/classpath/gnu/CORBA/CDR/abstractDataInputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/AbstractDataInput.java
@@ -1,4 +1,4 @@
-/* abstractDataInputStream.java --
+/* AbstractDataInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.io.IOException;
* @author Warren Levy (warrenl@cygnus.com)
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
-public interface abstractDataInputStream
+public interface AbstractDataInput
{
/**
* This method reads bytes from the underlying stream into the specified
diff --git a/libjava/classpath/gnu/CORBA/CDR/abstractDataOutputStream.java b/libjava/classpath/gnu/CORBA/CDR/AbstractDataOutput.java
index 2f9b8c419fc..e37c0cb7ddd 100644
--- a/libjava/classpath/gnu/CORBA/CDR/abstractDataOutputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/AbstractDataOutput.java
@@ -1,4 +1,4 @@
-/* abstractDataOutputStream.java --
+/* AbstractDataOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.io.IOException;
* @author Warren Levy (warrenl@cygnus.com)
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
-public interface abstractDataOutputStream
+public interface AbstractDataOutput
{
/**
* This method flushes any unwritten bytes to the underlying stream.
diff --git a/libjava/classpath/gnu/CORBA/CDR/aligningInputStream.java b/libjava/classpath/gnu/CORBA/CDR/AligningInput.java
index a719b32ee1e..e2710628a52 100644
--- a/libjava/classpath/gnu/CORBA/CDR/aligningInputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/AligningInput.java
@@ -1,4 +1,4 @@
-/* aligningInputStream.java --
+/* AligningInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,7 +48,7 @@ import org.omg.CORBA.BAD_PARAM;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class aligningInputStream
+public class AligningInput
extends ByteArrayInputStream
{
/**
@@ -61,24 +61,12 @@ public class aligningInputStream
*
* @param a_buffer a buffer to read from.
*/
- public aligningInputStream(byte[] a_buffer)
+ public AligningInput(byte[] a_buffer)
{
super(a_buffer);
}
/**
- * Create a stream, reading from the given buffer region.
- *
- * @param a_buffer a buffer to read from.
- * @param offset the offset of the region.
- * @param length thr length of the region.
- */
- public aligningInputStream(byte[] a_buffer, int offset, int length)
- {
- super(a_buffer, offset, length);
- }
-
- /**
* Set the alignment offset, if the index of the first byte in the
* stream is different from 0.
*/
@@ -119,4 +107,25 @@ public class aligningInputStream
{
return buf;
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return pos + offset;
+ }
+
+ /**
+ * Jump to the given position, taking offset into consideration.
+ */
+ public void seek(int position)
+ {
+ if (position < offset || position > (count+offset))
+ throw new ArrayIndexOutOfBoundsException(position
+ + " is out of valid ["+offset+".." + (count+offset) + "[ range");
+ pos = position - offset;
+ }
}
diff --git a/libjava/classpath/gnu/CORBA/CDR/aligningOutputStream.java b/libjava/classpath/gnu/CORBA/CDR/AligningOutput.java
index 8a682c1fd6d..135f75af6a7 100644
--- a/libjava/classpath/gnu/CORBA/CDR/aligningOutputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/AligningOutput.java
@@ -1,4 +1,4 @@
-/* aligningOutputStream.java --
+/* AligningOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.CORBA.CDR;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.omg.CORBA.BAD_PARAM;
@@ -49,7 +48,7 @@ import org.omg.CORBA.BAD_PARAM;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class aligningOutputStream
+public class AligningOutput
extends ByteArrayOutputStream
{
/**
@@ -60,14 +59,14 @@ public class aligningOutputStream
/**
* Create a stream with the default intial buffer size.
*/
- public aligningOutputStream()
+ public AligningOutput()
{
}
/**
* Create a stream with the given intial buffer size.
*/
- public aligningOutputStream(int initial_size)
+ public AligningOutput(int initial_size)
{
super(initial_size);
}
@@ -118,4 +117,32 @@ public class aligningOutputStream
write(0);
}
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return size()+offset;
+ }
+
+ /**
+ * Seek to the given position (not in use).
+ */
+ public void seek(int position)
+ {
+ count = position - offset;
+ }
+
+ /**
+ * Get the buffer without copying it. Use with care.
+ */
+ public byte[] getBuffer()
+ {
+ return buf;
+ }
+
+
}
diff --git a/libjava/classpath/gnu/CORBA/CDR/ArrayValueHelper.java b/libjava/classpath/gnu/CORBA/CDR/ArrayValueHelper.java
new file mode 100644
index 00000000000..7a4d9c5aa8f
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/CDR/ArrayValueHelper.java
@@ -0,0 +1,254 @@
+/* ArrayValueHelper.java --
+ 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. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.ObjectCreator;
+
+import org.omg.CORBA.BooleanSeqHelper;
+import org.omg.CORBA.CharSeqHelper;
+import org.omg.CORBA.DoubleSeqHelper;
+import org.omg.CORBA.FloatSeqHelper;
+import org.omg.CORBA.LongLongSeqHelper;
+import org.omg.CORBA.LongSeqHelper;
+import org.omg.CORBA.OctetSeqHelper;
+import org.omg.CORBA.ShortSeqHelper;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.rmi.Remote;
+
+import javax.rmi.CORBA.Util;
+import javax.rmi.CORBA.ValueHandler;
+
+/**
+ * Writes arrays as a boxed value types. A single instance is used to write a
+ * single array. This class is only used with RMI/IIOP, to handle array boxed
+ * values.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+class ArrayValueHelper
+ implements BoxedValueHelper
+{
+ /**
+ * The value handler (one for all instances).
+ */
+ static ValueHandler handler = Util.createValueHandler();
+
+ /**
+ * A class of the array being written.
+ */
+ Class arrayClass;
+
+ /**
+ * The array component class.
+ */
+ Class component;
+
+ /**
+ * The array component repository Id.
+ */
+ String componentId;
+
+ /**
+ * If true, the array members are written as objects rather than as values.
+ * True for Remotes and CORBA objects.
+ */
+ boolean written_as_object()
+ {
+ return org.omg.CORBA.Object.class.isAssignableFrom(component)
+ || Remote.class.isAssignableFrom(component);
+ }
+
+ /**
+ * Creates the instance of the helper to write this specific array class.
+ */
+ ArrayValueHelper(Class an_arrayClass)
+ {
+ arrayClass = an_arrayClass;
+ }
+
+ /**
+ * Get the array repository Id that will be the RMI repository id.
+ */
+ public String get_id()
+ {
+ return ObjectCreator.getRepositoryId(arrayClass);
+ }
+
+ /**
+ * Read the array from the input stream.
+ */
+ public Serializable read_value(InputStream input)
+ {
+ if (input instanceof HeadlessInput)
+ {
+ ((HeadlessInput) input).subsequentCalls = true;
+ }
+
+ component = arrayClass.getComponentType();
+
+ if (component.equals(byte.class))
+ return OctetSeqHelper.read(input);
+ else if (component.equals(String.class))
+ {
+ // String array is optimized because this may be frequent.
+ String[] s = new String[input.read_long()];
+
+ for (int i = 0; i < s.length; i++)
+ s[i] = (String) Vio.read(input, Vio.m_StringValueHelper);
+ return s;
+ }
+ else if (component.equals(int.class))
+ return LongSeqHelper.read(input);
+ else if (component.equals(long.class))
+ return LongLongSeqHelper.read(input);
+ else if (component.equals(double.class))
+ return DoubleSeqHelper.read(input);
+ else if (component.equals(float.class))
+ return FloatSeqHelper.read(input);
+ else if (component.equals(boolean.class))
+ return BooleanSeqHelper.read(input);
+ else if (component.equals(short.class))
+ return ShortSeqHelper.read(input);
+ else if (component.equals(char.class))
+ return CharSeqHelper.read(input);
+ else
+ {
+ // Read others, use reflection.
+ int n = input.read_long();
+
+ gnuValueStream s = null;
+
+ Serializable array = (Serializable) Array.newInstance(component, n);
+ if (written_as_object())
+ for (int i = 0; i < n; i++)
+ {
+ gnuRuntime g;
+ int position;
+ if (input instanceof gnuValueStream)
+ {
+ s = (gnuValueStream) input;
+ g = s.getRunTime();
+ position = s.getPosition();
+ }
+ else
+ {
+ g = null;
+ position = -1;
+ }
+
+ if (input instanceof HeadlessInput)
+ ((HeadlessInput) input).subsequentCalls = true;
+
+ Object o = handler.readValue(input, position, component, null, g);
+ Array.set(array, i, o);
+ }
+ else
+ for (int i = 0; i < n; i++)
+ Array.set(array, i, Vio.read(input, component));
+ return array;
+ }
+ }
+
+ /**
+ * Write the array to the input stream.
+ */
+ public void write_value(OutputStream output, Serializable value)
+ {
+ if (output instanceof gnuValueStream)
+ {
+ gnuRuntime r = ((gnuValueStream) output).getRunTime();
+ if (r != null)
+ r.target = null;
+ }
+
+ if (value instanceof byte[])
+ OctetSeqHelper.write(output, (byte[]) value);
+ else if (value instanceof String[])
+ {
+ String[] s = (String[]) value;
+ output.write_long(s.length);
+ for (int i = 0; i < s.length; i++)
+ Vio.write(output, s[i], Vio.m_StringValueHelper);
+ }
+ else if (value instanceof int[])
+ LongSeqHelper.write(output, (int[]) value);
+ else if (value instanceof long[])
+ LongLongSeqHelper.write(output, (long[]) value);
+ else if (value instanceof double[])
+ DoubleSeqHelper.write(output, (double[]) value);
+ else if (value instanceof float[])
+ FloatSeqHelper.write(output, (float[]) value);
+ else if (value instanceof boolean[])
+ BooleanSeqHelper.write(output, (boolean[]) value);
+ else if (value instanceof short[])
+ ShortSeqHelper.write(output, (short[]) value);
+ else if (value instanceof char[])
+ CharSeqHelper.write(output, (char[]) value);
+ else
+ {
+ // Write others, use reflection.
+ component = arrayClass.getComponentType();
+
+ int n = Array.getLength(value);
+ output.write_long(n);
+ if (written_as_object())
+ for (int i = 0; i < n; i++)
+ {
+ Object o = Array.get(value, i);
+ if (o == null)
+ output.write_Object(null);
+ else
+ // CORBA objects have another notation.
+ handler.writeValue(output, (Serializable) o);
+ }
+ else
+ {
+ for (int i = 0; i < n; i++)
+ Vio.write(output, (Serializable) Array.get(value, i),
+ component);
+ }
+
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/CORBA/CDR/BigEndianInputStream.java b/libjava/classpath/gnu/CORBA/CDR/BigEndianInputStream.java
index bc019396adb..1559d75a41e 100644
--- a/libjava/classpath/gnu/CORBA/CDR/BigEndianInputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/BigEndianInputStream.java
@@ -49,7 +49,7 @@ import java.io.InputStream;
*/
public class BigEndianInputStream
extends DataInputStream
- implements abstractDataInputStream
+ implements AbstractDataInput
{
/**
* Delegates to the parent constructor.
diff --git a/libjava/classpath/gnu/CORBA/CDR/BigEndianOutputStream.java b/libjava/classpath/gnu/CORBA/CDR/BigEndianOutputStream.java
index e0aa7da773e..7d3b02ec950 100644
--- a/libjava/classpath/gnu/CORBA/CDR/BigEndianOutputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/BigEndianOutputStream.java
@@ -50,7 +50,7 @@ import java.io.OutputStream;
*/
public class BigEndianOutputStream
extends DataOutputStream
- implements abstractDataOutputStream
+ implements AbstractDataOutput
{
/**
* Delegate functionality to the parent constructor.
diff --git a/libjava/classpath/gnu/CORBA/CDR/cdrBufOutput.java b/libjava/classpath/gnu/CORBA/CDR/BufferedCdrOutput.java
index 47f5f176b39..69bf95beb66 100644
--- a/libjava/classpath/gnu/CORBA/CDR/cdrBufOutput.java
+++ b/libjava/classpath/gnu/CORBA/CDR/BufferedCdrOutput.java
@@ -1,4 +1,4 @@
-/* cdrBufOutput.java --
+/* BufferedCdrOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,41 +41,47 @@ package gnu.CORBA.CDR;
import java.io.ByteArrayOutputStream;
/**
- * A CORBA output stream, writing data into the internal
- * buffer ({@link ByteArrayOutputStream}).
- *
+ * A CORBA output stream, writing data into the internal buffer ({@link ByteArrayOutputStream}).
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class cdrBufOutput
- extends cdrOutput
+public class BufferedCdrOutput
+ extends AbstractCdrOutput
+ implements gnuValueStream
{
/**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
* The byte buffer.
*/
- public final aligningOutputStream buffer;
+ public final AligningOutput buffer;
/**
* Creates the instance with the given initial buffer size.
+ *
* @param bufSize the buffer size.
*/
- public cdrBufOutput(int bufSize)
+ public BufferedCdrOutput(int bufSize)
{
- buffer = new aligningOutputStream(bufSize);
+ buffer = new AligningOutput(bufSize);
setOutputStream(buffer);
}
/**
* Creates the instance with the default buffer size.
*/
- public cdrBufOutput()
+ public BufferedCdrOutput()
{
- buffer = new aligningOutputStream();
+ buffer = new AligningOutput();
setOutputStream(buffer);
}
/**
- * Set the alignment offset, if the index of the first byte in the
- * stream is different from 0.
+ * Set the alignment offset, if the index of the first byte in the stream is
+ * different from 0.
*/
public void setOffset(int an_offset)
{
@@ -95,7 +101,7 @@ public class cdrBufOutput
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
- cdrBufInput in = new cdrBufInput(buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(buffer.toByteArray());
in.setOrb(orb);
in.setVersion(giop);
@@ -112,4 +118,39 @@ public class cdrBufOutput
buffer.reset();
setOutputStream(buffer);
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return buffer.getPosition();
+ }
+
+ /**
+ * Get the associated RunTime.
+ */
+ public gnuRuntime getRunTime()
+ {
+ return runtime;
+ }
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime)
+ {
+ runtime = a_runtime;
+ }
+
+ /**
+ * Seek to the given position.
+ */
+ public void seek(int position)
+ {
+ buffer.seek(position);
+ }
+
}
diff --git a/libjava/classpath/gnu/CORBA/CDR/cdrBufInput.java b/libjava/classpath/gnu/CORBA/CDR/BufferredCdrInput.java
index 3cab7216c3b..f0159a88dac 100644
--- a/libjava/classpath/gnu/CORBA/CDR/cdrBufInput.java
+++ b/libjava/classpath/gnu/CORBA/CDR/BufferredCdrInput.java
@@ -1,4 +1,4 @@
-/* cdrBufInput.java --
+/* BufferredCdrInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,18 +43,20 @@ package gnu.CORBA.CDR;
* The CDR input stream that reads data from the byte buffer.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- *
- * TODO character encoding. Now the encoding can be set, but it is ignored.
- * If you take this task, scan 'TODO character encoding' for
- * relevant places.
*/
-public class cdrBufInput
- extends cdrInput
+public class BufferredCdrInput
+ extends AbstractCdrInput
+ implements gnuValueStream
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The byte array input stream to read data from.
*/
- public final aligningInputStream buffer;
+ public final AligningInput buffer;
/**
* Creates the CDR input stream that reads from the given buffer
@@ -62,9 +64,9 @@ public class cdrBufInput
*
* @param a_buffer an array to read from.
*/
- public cdrBufInput(byte[] a_buffer)
+ public BufferredCdrInput(byte[] a_buffer)
{
- buffer = new aligningInputStream(a_buffer);
+ buffer = new AligningInput(a_buffer);
setInputStream(buffer);
}
@@ -112,4 +114,40 @@ public class cdrBufInput
buffer.reset();
setInputStream(buffer);
}
+
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition()
+ {
+ return buffer.getPosition();
+ }
+
+ /**
+ * Jump to the given position, taking offset into consideration.
+ */
+ public void seek(int position)
+ {
+ buffer.seek(position);
+ setInputStream(buffer);
+ }
+
+ /**
+ * Get the associated RunTime.
+ */
+ public gnuRuntime getRunTime()
+ {
+ return runtime;
+ }
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime)
+ {
+ runtime = a_runtime;
+ }
+
}
diff --git a/libjava/classpath/gnu/CORBA/CDR/encapsulatedOutput.java b/libjava/classpath/gnu/CORBA/CDR/EncapsulationStream.java
index 3350291bc73..4945d9c906a 100644
--- a/libjava/classpath/gnu/CORBA/CDR/encapsulatedOutput.java
+++ b/libjava/classpath/gnu/CORBA/CDR/EncapsulationStream.java
@@ -48,8 +48,8 @@ import java.io.IOException;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class encapsulatedOutput
- extends cdrOutput
+public class EncapsulationStream
+ extends AbstractCdrOutput
{
/**
* The Big Endian (most siginificant byte first flag).
@@ -64,7 +64,7 @@ public class encapsulatedOutput
/**
* The byte buffer.
*/
- public final aligningOutputStream buffer;
+ public final AligningOutput buffer;
/**
* The stream, where the data are being encapsulated.
@@ -75,11 +75,11 @@ public class encapsulatedOutput
* Create the EncapsulationOutput with the given parent stream
* and the specified encoding.
*/
- public encapsulatedOutput(org.omg.CORBA.portable.OutputStream _parent,
+ public EncapsulationStream(org.omg.CORBA.portable.OutputStream _parent,
boolean use_big_endian)
{
super();
- buffer = new aligningOutputStream();
+ buffer = new AligningOutput();
setOutputStream(buffer);
parent = _parent;
write(use_big_endian?BIG_ENDIAN:LITTLE_ENDIAN);
@@ -126,7 +126,7 @@ public class encapsulatedOutput
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
- cdrBufInput in = new cdrBufInput(buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(buffer.toByteArray());
in.setOrb(orb);
in.setVersion(giop);
diff --git a/libjava/classpath/gnu/CORBA/CDR/HeadlessInput.java b/libjava/classpath/gnu/CORBA/CDR/HeadlessInput.java
new file mode 100644
index 00000000000..0c18dafb195
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/CDR/HeadlessInput.java
@@ -0,0 +1,749 @@
+/* HeadlessInput.java --
+ 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. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.AnySeqHolder;
+import org.omg.CORBA.BooleanSeqHolder;
+import org.omg.CORBA.CharSeqHolder;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.DataInputStream;
+import org.omg.CORBA.DoubleSeqHolder;
+import org.omg.CORBA.FloatSeqHolder;
+import org.omg.CORBA.LongLongSeqHolder;
+import org.omg.CORBA.LongSeqHolder;
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.OctetSeqHolder;
+import org.omg.CORBA.Principal;
+import org.omg.CORBA.ShortSeqHolder;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.ULongLongSeqHolder;
+import org.omg.CORBA.ULongSeqHolder;
+import org.omg.CORBA.UShortSeqHolder;
+import org.omg.CORBA.WCharSeqHolder;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * Substitutes the main stream in factories when the header is already behind.
+ * Overrides methods that may be invoked from the factory, forcing not to read
+ * the header if called first time on this stream.
+ *
+ * This stream reverts to default behavior if one or more call are made (reading
+ * value types that are nested fields of the value type).
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class HeadlessInput
+ extends org.omg.CORBA_2_3.portable.InputStream
+ implements DataInputStream, gnuValueStream
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Indicates that no positional information is available.
+ */
+ static final int NONE = -1;
+
+ /**
+ * If true, this is not the first call.
+ */
+ public boolean subsequentCalls;
+
+ /**
+ * The enclosed stream.
+ */
+ final BufferredCdrInput stream;
+
+ /**
+ * Create an instance, reading from the given buffer.
+ *
+ * @param a_stram a stream from where the data will be read.
+ * @param inheritSettings a stream from that endian and other settings are
+ * inherited.
+ */
+ public HeadlessInput(BufferredCdrInput a_stream, InputStream inheritSettings)
+ {
+ stream = a_stream;
+
+ if (inheritSettings instanceof AbstractCdrInput)
+ {
+ AbstractCdrInput t = (AbstractCdrInput) inheritSettings;
+ t.cloneSettings(stream);
+ }
+ else if (stream.orb() == null)
+ stream.setOrb(inheritSettings.orb());
+
+ if (inheritSettings instanceof gnuValueStream
+ && stream.getRunTime() == null)
+ {
+ stream.setRunTime(((gnuValueStream) inheritSettings).getRunTime());
+ }
+ }
+
+ /**
+ * Tries to read using boxed value helper.
+ */
+ public Serializable read_value(BoxedValueHelper helper)
+ {
+ if (subsequentCalls)
+ return stream.read_value(helper);
+ else
+ {
+ subsequentCalls = true;
+ return helper.read_value(this);
+ }
+ }
+
+ /**
+ * Tries to locate a factory using repository id.
+ */
+ public Serializable read_value(String repository_id)
+ {
+ if (subsequentCalls)
+ return stream.read_value(repository_id);
+ else
+ {
+ subsequentCalls = true;
+ Serializable value = (Serializable) Vio.readValue(this, NONE, null,
+ null, repository_id, null, null);
+ return value;
+ }
+ }
+
+ /**
+ * Try to read when having an unitialised value.
+ */
+ public Serializable read_value(Serializable value)
+ {
+ if (subsequentCalls)
+ return stream.read_value(value);
+ else
+ {
+ subsequentCalls = true;
+ value = (Serializable) Vio.readValue(this, NONE, value, null, null,
+ null, null);
+ return value;
+ }
+ }
+
+ /**
+ * Try to read when having an unitialised value.
+ */
+ public Serializable read_value(Class clz)
+ {
+ if (subsequentCalls)
+ return stream.read_value(clz);
+ else
+ {
+ try
+ {
+ subsequentCalls = true;
+ Serializable value = (Serializable) Vio.instantiateAnyWay(clz);
+ value = (Serializable) Vio.readValue(this, NONE, value, null, null,
+ null, null);
+ return value;
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Can't read an instance of "
+ + clz.getName());
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int available()
+ throws IOException
+ {
+ return stream.available();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void close()
+ throws IOException
+ {
+ stream.close();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void mark(int readlimit)
+ {
+ stream.mark(readlimit);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public boolean markSupported()
+ {
+ return stream.markSupported();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public ORB orb()
+ {
+ return stream.orb();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Object read_abstract_interface()
+ {
+ return stream.read_abstract_interface();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Object read_abstract_interface(Class clz)
+ {
+ return stream.read_abstract_interface(clz);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Any read_any()
+ {
+ return stream.read_any();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_boolean_array(boolean[] value, int offset, int length)
+ {
+ stream.read_boolean_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public boolean read_boolean()
+ {
+ return stream.read_boolean();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_char_array(char[] value, int offset, int length)
+ {
+ stream.read_char_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public char read_char()
+ {
+ return stream.read_char();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Context read_Context()
+ {
+ return stream.read_Context();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_double_array(double[] value, int offset, int length)
+ {
+ stream.read_double_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public double read_double()
+ {
+ return stream.read_double();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public BigDecimal read_fixed()
+ {
+ return stream.read_fixed();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_float_array(float[] value, int offset, int length)
+ {
+ stream.read_float_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public float read_float()
+ {
+ return stream.read_float();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_long_array(int[] value, int offset, int length)
+ {
+ stream.read_long_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read_long()
+ {
+ return stream.read_long();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_longlong_array(long[] value, int offset, int length)
+ {
+ stream.read_longlong_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public long read_longlong()
+ {
+ return stream.read_longlong();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public org.omg.CORBA.Object read_Object()
+ {
+ return stream.read_Object();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public org.omg.CORBA.Object read_Object(Class klass)
+ {
+ return stream.read_Object(klass);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_octet_array(byte[] value, int offset, int length)
+ {
+ stream.read_octet_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public byte read_octet()
+ {
+ return stream.read_octet();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Principal read_Principal()
+ {
+ return stream.read_Principal();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_short_array(short[] value, int offset, int length)
+ {
+ stream.read_short_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public short read_short()
+ {
+ return stream.read_short();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public String read_string()
+ {
+ return stream.read_string();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public TypeCode read_TypeCode()
+ {
+ return stream.read_TypeCode();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulong_array(int[] value, int offset, int length)
+ {
+ stream.read_ulong_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read_ulong()
+ {
+ return stream.read_ulong();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulonglong_array(long[] value, int offset, int length)
+ {
+ stream.read_ulonglong_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public long read_ulonglong()
+ {
+ return stream.read_ulonglong();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ushort_array(short[] value, int offset, int length)
+ {
+ stream.read_ushort_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public short read_ushort()
+ {
+ return stream.read_ushort();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Serializable read_value()
+ {
+ return read_value((Serializable) null);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_wchar_array(char[] value, int offset, int length)
+ {
+ stream.read_wchar_array(value, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public char read_wchar()
+ {
+ return stream.read_wchar();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public String read_wstring()
+ {
+ return stream.read_wstring();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read()
+ throws IOException
+ {
+ return stream.read();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read(byte[] b, int off, int len)
+ throws IOException
+ {
+ return stream.read(b, off, len);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int read(byte[] b)
+ throws IOException
+ {
+ return stream.read(b);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void reset()
+ throws IOException
+ {
+ stream.reset();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public long skip(long n)
+ throws IOException
+ {
+ return stream.skip(n);
+ }
+
+ /**
+ * Get a string representation.
+ */
+ public String toString()
+ {
+ return "HeadlessInput+" + stream.toString();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public String[] _truncatable_ids()
+ {
+ return stream._truncatable_ids();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public Object read_Abstract()
+ {
+ return stream.read_Abstract();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_any_array(AnySeqHolder holder, int offset, int length)
+ {
+ stream.read_any_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
+ {
+ stream.read_boolean_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_char_array(CharSeqHolder holder, int offset, int length)
+ {
+ stream.read_char_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_double_array(DoubleSeqHolder holder, int offset, int length)
+ {
+ stream.read_double_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_float_array(FloatSeqHolder holder, int offset, int length)
+ {
+ stream.read_float_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_long_array(LongSeqHolder holder, int offset, int length)
+ {
+ stream.read_long_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_longlong_array(LongLongSeqHolder holder, int offset,
+ int length)
+ {
+ stream.read_longlong_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_octet_array(OctetSeqHolder holder, int offset, int length)
+ {
+ stream.read_octet_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_short_array(ShortSeqHolder holder, int offset, int length)
+ {
+ stream.read_short_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
+ {
+ stream.read_ulong_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
+ int length)
+ {
+ stream.read_ulonglong_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_ushort_array(UShortSeqHolder holder, int offset, int length)
+ {
+ stream.read_ushort_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to read_value.
+ */
+ public Serializable read_Value()
+ {
+ return read_value();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
+ {
+ stream.read_wchar_array(holder, offset, length);
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public int getPosition()
+ {
+ return stream.getPosition();
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public gnuRuntime getRunTime()
+ {
+ return stream.runtime;
+ }
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime)
+ {
+ stream.runtime = a_runtime;
+ }
+
+ /**
+ * Delegates functionality to the underlying stream.
+ */
+ public void seek(int position)
+ {
+ stream.seek(position);
+ }
+
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/CDR/IDLTypeHelper.java b/libjava/classpath/gnu/CORBA/CDR/IDLTypeHelper.java
new file mode 100644
index 00000000000..3259a48770c
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/CDR/IDLTypeHelper.java
@@ -0,0 +1,169 @@
+/* IDLTypeHelper.java --
+ 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. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.portable.BoxedValueHelper;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+/**
+ * Handles case when the CORBA IDL type with the known helper is wrapped into
+ * Value type.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class IDLTypeHelper
+ implements BoxedValueHelper
+{
+ /**
+ * A helper class.
+ */
+ protected Class helper;
+
+ /**
+ * Argument values for Helper.id().
+ */
+ static final Object[] ARGS_ID_V = new Object[0];
+
+ /**
+ * Argument types for Helper.id()).
+ */
+ static final Class[] ARGS_ID = new Class[0];
+
+ /**
+ * Argument types for Helper.read.
+ */
+ static final Class[] ARGS_READ = new Class[] { org.omg.CORBA.portable.InputStream.class };
+
+ /**
+ * Create an IDLTypeHelper that works via given helper class.
+ */
+ public IDLTypeHelper(Class a_helperClass)
+ {
+ helper = a_helperClass;
+ }
+
+ /**
+ * Get the Id, returned by this helper (use reflection).
+ */
+ public String get_id()
+ {
+ try
+ {
+ Method m = helper.getMethod("id", ARGS_ID);
+ return (String) m.invoke(null, ARGS_ID_V);
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL(msg() + " id()");
+ m.minor = Minor.Boxed;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Read an instance from the stream.
+ */
+ public Serializable read_value(InputStream input)
+ {
+ try
+ {
+ Method m = helper.getMethod("read", ARGS_READ);
+ return (Serializable) m.invoke(null, new Object[] { input });
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL(msg() + " read(..)");
+ m.minor = Minor.Boxed;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Write the instance to the stream.
+ */
+ public void write_value(OutputStream output, Serializable value)
+ {
+ try
+ {
+ Method[] m = helper.getMethods();
+
+ for (int i = 0; i < m.length; i++)
+ {
+ if (m[i].getName().equals("write")
+ && ((m[i].getModifiers() & Modifier.STATIC) != 0))
+ {
+ Class[] p = m[i].getParameterTypes();
+
+ if (p.length == 2 && OutputStream.class.isAssignableFrom(p[0])
+ && p[1].isAssignableFrom(value.getClass()))
+ {
+ m[i].invoke(null, new Object[] { output, value });
+ return;
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL(msg() + " write(..)");
+ m.minor = Minor.Boxed;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+
+ /**
+ * Create the start of message for exceptions.
+ */
+ String msg()
+ {
+ return "Failed calling " + helper.getName() + " method: ";
+ }
+
+}
diff --git a/libjava/classpath/gnu/CORBA/CDR/LittleEndianInputStream.java b/libjava/classpath/gnu/CORBA/CDR/LittleEndianInputStream.java
index b71a9a4f66d..02cfa08ae8e 100644
--- a/libjava/classpath/gnu/CORBA/CDR/LittleEndianInputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/LittleEndianInputStream.java
@@ -55,7 +55,7 @@ import java.io.PushbackInputStream;
*/
public class LittleEndianInputStream
extends FilterInputStream
- implements abstractDataInputStream
+ implements AbstractDataInput
{
// Byte buffer, used to make primitive read calls more efficient.
byte[] buf = new byte[ 8 ];
diff --git a/libjava/classpath/gnu/CORBA/CDR/LittleEndianOutputStream.java b/libjava/classpath/gnu/CORBA/CDR/LittleEndianOutputStream.java
index a6d56cfa6d0..6791a82e7c3 100644
--- a/libjava/classpath/gnu/CORBA/CDR/LittleEndianOutputStream.java
+++ b/libjava/classpath/gnu/CORBA/CDR/LittleEndianOutputStream.java
@@ -55,7 +55,7 @@ import java.io.OutputStream;
*/
public class LittleEndianOutputStream
extends FilterOutputStream
- implements abstractDataOutputStream
+ implements AbstractDataOutput
{
/**
* This method initializes an instance of <code>DataOutputStream</code> to
diff --git a/libjava/classpath/gnu/CORBA/CDR/UnknownExceptionCtxHandler.java b/libjava/classpath/gnu/CORBA/CDR/UnknownExceptionCtxHandler.java
new file mode 100644
index 00000000000..314dd8eb948
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/CDR/UnknownExceptionCtxHandler.java
@@ -0,0 +1,292 @@
+/* UnknownExceptionCtxHandler.java --
+ 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. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+import gnu.CORBA.ObjectCreator;
+import gnu.CORBA.GIOP.ServiceContext;
+
+import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.StringValueHelper;
+import org.omg.CORBA.portable.OutputStream;
+
+import java.lang.reflect.Constructor;
+import java.util.StringTokenizer;
+
+import javax.rmi.CORBA.Util;
+
+/**
+ * Reads the data about an unknown exception from the UnknownExceptionInfo.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class UnknownExceptionCtxHandler
+ extends Vio
+{
+ /**
+ * Encode exception and add its recored to the message service contexts.
+ */
+ public static ServiceContext[] addExceptionContext(ServiceContext[] current,
+ Throwable exception, Object details)
+ {
+ try
+ {
+ ServiceContext[] c = new ServiceContext[current.length + 1];
+ if (current.length > 0)
+ System.arraycopy(current, 0, c, 0, current.length);
+
+ BufferedCdrOutput output = new BufferedCdrOutput();
+
+ if (details instanceof OutputStream)
+ output.setOrb(((OutputStream) output).orb());
+
+ if (details instanceof AbstractCdrOutput)
+ ((AbstractCdrOutput) details).cloneSettings(output);
+
+ write(output, exception);
+
+ ServiceContext xc = new ServiceContext();
+ xc.context_id = ServiceContext.UnknownExceptionInfo;
+ xc.context_data = output.buffer.toByteArray();
+ c[current.length] = xc;
+ return c;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return current;
+ }
+ }
+
+ /**
+ * Write data about unknown exception.
+ */
+ public static void write(BufferedCdrOutput output, Throwable t)
+ {
+ t.fillInStackTrace();
+ output.write_Value(t);
+ }
+
+ /**
+ * Read the data about an unknown exception from the UnknownExceptionInfo.
+ * Following the documentation, this must be just value type, but it seems
+ * that in Sun's implementation is is not, as starts from 0x0. For value type,
+ * this would be null.
+ *
+ * TODO Implement reading and writing in Sun format, making Classpath IIOP
+ * interoperable with Sun's implementation. Current inmplementation reads and
+ * reproduces the exception class type only.
+ *
+ * @param input the input stream to read the context (orb and other settings
+ * are inherited from the main stream that received the message).
+ *
+ * @param contexts all service contexts that were present in the message.
+ *
+ * @return the Throwable, extracted from context, on null, if this has failed.
+ */
+ public static Throwable read(BufferredCdrInput input, ServiceContext[] contexts)
+ {
+ input.mark(Integer.MAX_VALUE);
+
+ int h = input.read_long();
+ if (h == 0)
+ {
+ // This block reads exception info in the Sun specific format.
+ // (currently we read the exception name only).
+ try
+ {
+ // We may need to jump back if the value is read via value
+ // factory.
+ input.mark(512);
+
+ int value_tag = input.read_long();
+ checkTag(value_tag);
+
+ String codebase = null;
+ String[] ids = null;
+ String id = null;
+
+ // Check for the agreed null value.
+ if (value_tag == vt_NULL)
+ return null;
+ else if (value_tag == vt_INDIRECTION)
+ return (Throwable) readIndirection(input);
+ else
+ {
+ // Read the value.
+ if ((value_tag & vf_CODEBASE) != 0)
+ {
+ // The codebase is present. The codebase is a space
+ // separated list of URLs from where the implementing
+ // code can be downloaded.
+ codebase = read_string(input);
+ }
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0)
+ {
+ // Multiple supported repository ids are present.
+ ids = read_string_array(input);
+ }
+ else if ((value_tag & vf_ID) != 0)
+ {
+ // Single supported repository id is present.
+ id = read_string(input);
+ }
+ }
+
+ java.lang.Object ox = createInstance(id, ids, codebase);
+
+ return (Throwable) ox;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+ else
+ {
+ input.reset();
+ // Read as defined in OMG documentation.
+ return (Throwable) input.read_Value();
+ }
+ }
+
+ /**
+ * Load exception by name and create the instance. The reason why this is
+ * different from Vio is because some exceptions have no parameterless
+ * constructor, but have a constructor with the string parameter instead.
+ */
+ static Object createInstance(String id, String[] ids, String codebase)
+ {
+ Object o = _createInstance(id, codebase);
+
+ if (ids != null)
+ for (int i = 0; i < ids.length && o == null; i++)
+ o = _createInstance(ids[i], codebase);
+ return o;
+ }
+
+ static Object _createInstance(String id, String codebase)
+ {
+ if (id == null)
+ return null;
+ if (id.equals(StringValueHelper.id()))
+ return "";
+ StringTokenizer st = new StringTokenizer(id, ":");
+
+ String prefix = st.nextToken();
+ if (prefix.equalsIgnoreCase("IDL"))
+ return ObjectCreator.Idl2Object(id);
+ else if (prefix.equalsIgnoreCase("RMI"))
+ {
+ String className = st.nextToken();
+ String hashCode = st.nextToken();
+ String sid = null;
+ if (st.hasMoreElements())
+ sid = st.nextToken();
+
+ try
+ {
+ Class objectClass = Util.loadClass(className, codebase,
+ Vio.class.getClassLoader());
+
+ String rid = ObjectCreator.getRepositoryId(objectClass);
+
+ if (!rid.equals(id))
+ {
+ // If direct string comparison fails, compare by meaning.
+ StringTokenizer st2 = new StringTokenizer(rid, ":");
+ if (!st2.nextToken().equals("RMI"))
+ throw new InternalError("RMI format expected: '" + rid + "'");
+ if (!st2.nextToken().equals(className))
+ throwIt("Class name mismatch", id, rid, null);
+
+ try
+ {
+ long h1 = Long.parseLong(hashCode, 16);
+ long h2 = Long.parseLong(st2.nextToken(), 16);
+ if (h1 != h2)
+ throwIt("Hashcode mismatch", id, rid, null);
+
+ if (sid != null && st2.hasMoreTokens())
+ {
+ long s1 = Long.parseLong(hashCode, 16);
+ long s2 = Long.parseLong(st2.nextToken(), 16);
+ if (s1 != s2)
+ throwIt("serialVersionUID mismatch", id, rid, null);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throwIt("Invalid hashcode or svuid format: ", id, rid, e);
+ }
+ }
+
+ // Some RemoteExceptions have no public parameterless constructor,
+ // but they have constructor taking string as parameter.
+ try
+ {
+ return objectClass.newInstance();
+ }
+ catch (Exception ex)
+ {
+ // Try instantiate passing string as parameter.
+ Constructor c = objectClass.getConstructor(new Class[] { String.class });
+ return c.newInstance(new Object[] { "<message unavailable>" });
+ }
+ }
+ catch (MARSHAL m)
+ {
+ m.minor = Minor.Instantiation;
+ throw m;
+ }
+ catch (Exception ex)
+ {
+ MARSHAL m = new MARSHAL("Unable to instantiate " + id);
+ m.minor = Minor.Instantiation;
+ m.initCause(ex);
+ throw m;
+ }
+ }
+ else
+ throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
+ }
+}
diff --git a/libjava/classpath/gnu/CORBA/CDR/VMVio.java b/libjava/classpath/gnu/CORBA/CDR/VMVio.java
new file mode 100644
index 00000000000..9b719fd7c50
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/CDR/VMVio.java
@@ -0,0 +1,101 @@
+/* VMVio.java -- Native operations, required by value IO.
+ 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. */
+
+/**
+ * This is a temporary replacement for the native call that would allocate
+ * objects without public constructors. The replacement only allocates
+ * objects with public parameterless constructor and objects with public
+ * constructor taking string (like some Throwables).
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ *
+ * TODO FIXME replace by native call like in VMObjectInputStream.
+ * Required modification of Classpath the build system.
+ */
+
+
+package gnu.CORBA.CDR;
+
+import java.lang.reflect.Constructor;
+
+public class VMVio
+{
+ /**
+ * Allocates a new Object of type clazz but without running the default
+ * constructor on it. It then calls the given constructor on it. The given
+ * constructor method comes from the constr_clazz which is a super class of
+ * the given clazz.
+ */
+ public static Object allocateObject(Class clazz, Class constr_clazz,
+ Constructor constructor)
+ throws InstantiationException
+ {
+ try
+ {
+ Constructor c = clazz.getConstructor(new Class[0]);
+ c.setAccessible(true);
+ return c.newInstance(new Object[0]);
+ }
+ catch (Exception ex)
+ {
+ try
+ {
+ Constructor c = clazz.getConstructor(new Class[] { String.class });
+ return c.newInstance(new Object[] { "" });
+ }
+ catch (Exception ex2)
+ {
+ Constructor c[] = clazz.getConstructors();
+
+ for (int i = 0; i < c.length; i++)
+ {
+ try
+ {
+ c[i].setAccessible(true);
+ Class[] args = c[i].getParameterTypes();
+ return c[i].newInstance(new Object[args.length]);
+ }
+ catch (Exception ex3)
+ {
+ // Try another one.
+ }
+ }
+ }
+ throw new InstantiationException(clazz.getName());
+ }
+ }
+}
diff --git a/libjava/classpath/gnu/CORBA/CDR/Vio.java b/libjava/classpath/gnu/CORBA/CDR/Vio.java
index 0a37132b26f..fd878cb3555 100644
--- a/libjava/classpath/gnu/CORBA/CDR/Vio.java
+++ b/libjava/classpath/gnu/CORBA/CDR/Vio.java
@@ -1,4 +1,4 @@
-/* gnuValueBaseHelper.java --
+/* Vio.java -- Value type IO operations.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.CORBA.CDR;
+import gnu.CORBA.Minor;
import gnu.CORBA.ObjectCreator;
import org.omg.CORBA.CustomMarshal;
@@ -46,106 +47,144 @@ import org.omg.CORBA.DataOutputStream;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.StringSeqHelper;
+import org.omg.CORBA.StringValueHelper;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.WStringValueHelper;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
import org.omg.CORBA.portable.ValueFactory;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Modifier;
+import java.util.StringTokenizer;
-import java.lang.reflect.Method;
+import javax.rmi.CORBA.Util;
+import javax.rmi.CORBA.ValueHandler;
/**
* A specialised class for reading and writing the value types.
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class Vio
{
/**
- * If true, wrap value type data into chunks. This decrease the
- * performance, but is required for the interoperability with
- * Sun's CORBA implementation. Chunking may increase the security,
- * as there is more control on the number of bytes being transferred.
- *
+ * If true, wrap value type data into chunks. This decrease the performance,
+ * and is not required for interoperability with jdk 1.5, but is left in the
+ * implementation as the optional mode for solving possible interoperability
+ * problems with non-Sun CORBA implementations.
+ *
* The current implementation would accept both single chunk or multiple
- * chunks, but will always send a single chunk.
+ * chunks, but will always send a single chunk (if true) or unchunked data (if
+ * false).
*/
- public static boolean USE_CHUNKING = true;
+ public static boolean USE_CHUNKING = false;
/**
- * The first field in the value record. The last octet may contain
- * additional flags (vf_CODEBASE, vf_ID and vf_MULTIPLE_IDS). The tag
- * value is different for the indirections (vt_INDIRECTION) and
- * nulls (vt_NULL).
+ * The first field in the value record. The last octet may contain additional
+ * flags (vf_CODEBASE, vf_ID and vf_MULTIPLE_IDS). The tag value is different
+ * for the indirections (vt_INDIRECTION) and nulls (vt_NULL).
*/
public static final int vt_VALUE_TAG = 0x7fffff00;
/**
- * The value tag flag, indicating that the codebase URL is present
- * in the value tag record.
+ * The value tag flag, indicating that the codebase URL is present in the
+ * value tag record.
*/
public static final int vf_CODEBASE = 0x1;
/**
- * The value tag flag, indicating that a single repository id is present
- * in the value tag record.
+ * The value tag flag, indicating that a single repository id is present in
+ * the value tag record.
*/
public static final int vf_ID = 0x2;
/**
- * The value tag flag, indicating, that there are multiple repository
- * ids present in the record. If this flag is set, the flag vf_ID must
- * also be set, resulting the value of the least significant byte 0x6.
+ * The value tag flag, indicating, that there are multiple repository ids
+ * present in the record. If this flag is set, the flag vf_ID must also be
+ * set, resulting the value of the least significant byte 0x6.
*/
public static final int vf_MULTIPLE_IDS = 0x4;
/**
* The value tag flag, indicating the presence of chunking. Each chunk is
- * preceeded by a positive int, indicating the number of bytes in the chunk.
- * A sequence of chunks is terminated by a non positive int.
+ * preceeded by a positive int, indicating the number of bytes in the chunk. A
+ * sequence of chunks is terminated by a non positive int.
*/
public static final int vf_CHUNKING = 0x8;
/**
* The indirection tag value. Such tag must be followed by the CORBA long,
* indicating the offset in the CORBA message, where the indirected
- * information is present. This offset is assumed zero at the position
- * where the mentioned CORBA long starts and can refer both forward
- * (positive values) and backward (negative values).
+ * information is present. This offset is assumed zero at the position where
+ * the mentioned CORBA long starts and can refer both forward (positive
+ * values) and backward (negative values).
*/
public static final int vt_INDIRECTION = 0xffffffff;
/**
- * This tag value means that the value object being transferred is equal
- * to null.
+ * This tag value means that the value object being transferred is equal to
+ * null.
*/
public static final int vt_NULL = 0x0;
/**
- * Read the value base from the given input stream. Determines the
- * required class from the repository id. This includes operations
- * that are not required when an unitialised instance or at least
- * class of the value type is known. Hence it may be faster to use
- * the alternative methods, read(InputStream, Class) or
- * read(InputStream, Serializable).
- *
+ * The size of CORBA long (java int).
+ */
+ static final int INT_SIZE = 4;
+
+ /**
+ * The String value helper (one instance is sufficient).
+ */
+ public static final WStringValueHelper m_StringValueHelper = new WStringValueHelper();
+
+ /**
+ * An instance of the value handler.
+ */
+ static ValueHandler handler = Util.createValueHandler();
+
+ /**
+ * Read the value base from the given input stream. Determines the required
+ * class from the repository id. This includes operations that are not
+ * required when an unitialised instance or at least class of the value type
+ * is known. Hence it may be faster to use the alternative methods,
+ * read(InputStream, Class) or read(InputStream, Serializable).
+ *
* @param input a stream to read from.
- *
+ * @param repository_id a repository id of the object being read, may be null.
+ *
* @return the loaded value.
- *
+ *
* @throws MARSHAL if the reading has failed due any reason.
*/
public static Serializable read(InputStream input)
{
- // Explicitly prevent the stream from closing as we may need
- // to read the subsequent bytes as well. Stream may be auto-closed
- // in its finalizer.
+ return read(input, (String) null);
+ }
+
+ /**
+ * Read the value base from the given input stream. Determines the required
+ * class from the repository id. This includes operations that are not
+ * required when an unitialised instance or at least class of the value type
+ * is known. Hence it may be faster to use the alternative methods,
+ * read(InputStream, Class) or read(InputStream, Serializable).
+ *
+ * @param an_input a stream to read from.
+ * @param repository_id a repository id of the object being read, may be null.
+ *
+ * @return the loaded value.
+ *
+ * @throws MARSHAL if the reading has failed due any reason.
+ */
+ public static Serializable read(InputStream input, String repository_id)
+ {
try
{
+ final int position = getCurrentPosition(input);
// We may need to jump back if the value is read via value factory.
input.mark(512);
@@ -154,18 +193,13 @@ public abstract class Vio
String codebase = null;
String[] ids = null;
- String id = null;
-
- // The existing implementing object.
- java.lang.Object ox = null;
+ String id = repository_id;
// Check for the agreed null value.
if (value_tag == vt_NULL)
return null;
else if (value_tag == vt_INDIRECTION)
-
- // TODO FIXME Implement support for indirections.
- throw new NO_IMPLEMENT("Indirections unsupported");
+ return readIndirection(input);
else
{
// Read the value.
@@ -174,152 +208,173 @@ public abstract class Vio
// The codebase is present. The codebase is a space
// separated list of URLs from where the implementing
// code can be downloaded.
- codebase = input.read_string();
+ codebase = read_string(input);
}
if ((value_tag & vf_MULTIPLE_IDS) != 0)
{
// Multiple supported repository ids are present.
- ids = StringSeqHelper.read(input);
- for (int i = 0; (i < ids.length) && (ox == null); i++)
- {
- ox = ObjectCreator.Idl2Object(ids [ i ]);
-
- if (ox == null)
- {
- // Try to find the value factory.
- ValueFactory f =
- ((org.omg.CORBA_2_3.ORB) input.orb()).lookup_value_factory(ids [ i ]);
-
- if (f != null)
- {
- // Reset, as the value factory reads from beginning.
- input.reset();
- return f.read_value((org.omg.CORBA_2_3.portable.InputStream) input);
- }
- }
- }
+ ids = read_string_array(input);
}
else if ((value_tag & vf_ID) != 0)
{
// Single supported repository id is present.
- id = input.read_string();
- ox = ObjectCreator.Idl2Object(id);
-
- if (ox == null)
- {
- // Try to find the value factory.
- ValueFactory f =
- ((org.omg.CORBA_2_3.ORB) input.orb()).lookup_value_factory(id);
-
- if (f != null)
- {
- input.reset();
- return f.read_value((org.omg.CORBA_2_3.portable.InputStream) input);
- }
- }
+ id = read_string(input);
}
}
- if (ox == null)
- throw new MARSHAL("Unable to instantiate the value type");
+ BoxedValueHelper helper = getHelper(null, id);
+ // The existing implementing object.
+ java.lang.Object ox = null;
+
+ if (helper != null)
+ ox = null; // Helper will care about the instantiating.
+ else if (id.equals(WStringValueHelper.id()))
+ helper = m_StringValueHelper;
else
- {
- read_instance(input, ox, value_tag, null);
- return (Serializable) ox;
- }
+ ox = createInstance(id, ids, codebase);
+ return (Serializable) read_instance(input, position, ox, value_tag,
+ helper, id, ids, codebase);
}
catch (Exception ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL();
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
}
}
/**
- * Read the value base from the given input stream when
- * the value base class is available. Hence there is no need
- * to guess it from the repository id.
- *
+ * Read the value base from the given input stream when the value base class
+ * is available. Hence there is no need to guess it from the repository id.
+ *
* @param input a stream to read from.
* @param value_class the class of the value being read.
- *
+ *
* @return the loaded value.
- *
+ *
* @throws MARSHAL if the reading has failed due any reason.
*/
public static Serializable read(InputStream input, Class value_class)
{
- // Explicitly prevent the stream from closing as we may need
- // to read the subsequent bytes as well. Stream may be auto-closed
- // in its finalizer.
+ final int position = getCurrentPosition(input);
+
+ String id = null;
+ String[] ids = null;
+ String codebase = null;
+
try
{
int value_tag = input.read_long();
checkTag(value_tag);
- // The existing implementing object.
- java.lang.Object ox = value_class.newInstance();
-
// Check for the agreed null value.
if (value_tag == vt_NULL)
return null;
else if (value_tag == vt_INDIRECTION)
-
- // TODO FIXME Implement support for indirections.
- throw new NO_IMPLEMENT("Indirections unsupported");
+ return readIndirection(input);
else
{
// Read the value.
if ((value_tag & vf_CODEBASE) != 0)
{
- // The codebase is present, but skip it.
- input.read_string();
+ // The codebase is present.
+ codebase = read_string(input);
}
if ((value_tag & vf_MULTIPLE_IDS) != 0)
{
- // Multiple supported repository ids are present, but skip them.
- StringSeqHelper.read(input);
+ // Multiple supported repository ids are present.
+ ids = read_string_array(input);
}
else if ((value_tag & vf_ID) != 0)
{
- // Single supported repository id is present, but skip it.
- input.read_string();
+ // Single supported repository id is present.
+ id = read_string(input);
}
}
- read_instance(input, ox, value_tag, null);
+ BoxedValueHelper vHelper = id != null ? getHelper(value_class, id)
+ : getHelper(value_class, ids);
+
+ java.lang.Object ox;
+
+ if (vHelper == null)
+ {
+ try
+ {
+ ox = createInstance(id, ids, codebase);
+ }
+ catch (Exception e)
+ {
+ ox = null;
+ }
+
+ if (ox != null)
+ {
+ if (value_class != null
+ && !value_class.isAssignableFrom(ox.getClass()))
+ {
+ MARSHAL m = new MARSHAL(ox.getClass() + " is not a "
+ + value_class.getName());
+ m.minor = Minor.ClassCast;
+ throw m;
+ }
+ }
+ }
+ else
+ ox = null;
+
+ ox = read_instance(input, position, ox, value_tag, vHelper, id, ids,
+ codebase);
return (Serializable) ox;
}
+ catch (MARSHAL m)
+ {
+ throw m;
+ }
+ catch (SystemException sysEx)
+ {
+ // OK.
+ throw sysEx;
+ }
catch (Exception ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL("Cant read " + value_class);
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
}
}
/**
- * Read the value base from the given input stream when
- * the unitialised instance is available. Hence there is no need
- * to guess the class from the repository id and then to instantiate
- * an instance.
- *
+ * Read the value base from the given input stream when the unitialised
+ * instance is available. Hence there is no need to guess the class from the
+ * repository id and then to instantiate an instance.
+ *
* @param input a stream to read from.
- *
- * @param value_instance an pre-created instance of the value. If the
- * helper is not null, this parameter is ignored an should be null.
- *
- * @param helper a helper to create an instance and read the object-
- * specific part of the record. If the value_instance is used instead,
- * this parameter should be null.
- *
+ *
+ * @param value_instance an pre-created instance of the value. If the helper
+ * is not null, this parameter is ignored an should be null.
+ *
+ * @param helper a helper to create an instance and read the object- specific
+ * part of the record. If the value_instance is used instead, this parameter
+ * should be null.
+ *
* @return the loaded value.
- *
+ *
* @throws MARSHAL if the reading has failed due any reason.
*/
public static Object read(InputStream input, Object value_instance,
- Object helper
- )
+ BoxedValueHelper helper)
{
+ final int position = getCurrentPosition(input);
+
+ String id = null;
+ String[] ids = null;
+ String codebase = null;
+
try
{
int value_tag = input.read_long();
@@ -329,207 +384,396 @@ public abstract class Vio
if (value_tag == vt_NULL)
return null;
else if (value_tag == vt_INDIRECTION)
-
- // TODO FIXME Implement support for indirections.
- throw new NO_IMPLEMENT("Indirections unsupported");
+ return readIndirection(input);
else
{
// Read the value.
if ((value_tag & vf_CODEBASE) != 0)
{
- // The codebase is present, but skip it.
- input.read_string();
+ // The codebase is present.
+ codebase = read_string(input);
}
if ((value_tag & vf_MULTIPLE_IDS) != 0)
{
- // Multiple supported repository ids are present, but skip them.
- StringSeqHelper.read(input);
+ // Multiple supported repository ids are present.
+ ids = read_string_array(input);
}
else if ((value_tag & vf_ID) != 0)
{
- // Single supported repository id is present, but skip it.
- input.read_string();
+ // Single supported repository id is present.
+ id = read_string(input);
}
}
- value_instance =
- read_instance(input, value_instance, value_tag, helper);
+ Class value_class = value_instance == null ? null
+ : value_instance.getClass();
+
+ if (helper == null)
+ helper = id != null ? getHelper(value_class, id) : getHelper(
+ value_class, ids);
+
+ value_instance = read_instance(input, position, value_instance,
+ value_tag, helper, id, ids, codebase);
return value_instance;
}
catch (Exception ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL();
+ m.minor = Minor.Value;
+ m.initCause(ex);
+ throw m;
}
}
/**
- * Read using provided boxed value helper. This method expects
- * the full value type header, followed by contents, that are
- * delegated to the provided helper. It handles null.
- *
+ * Read using provided boxed value helper. This method expects the full value
+ * type header, followed by contents, that are delegated to the provided
+ * helper. It handles null.
+ *
* @param input the stream to read from.
- * @param helper the helper that reads the type-specific part of
- * the content.
- *
- * @return the value, created by the helper, or null if the
- * header indicates that null was previously written.
+ * @param helper the helper that reads the type-specific part of the content.
+ *
+ * @return the value, created by the helper, or null if the header indicates
+ * that null was previously written.
*/
- public static Serializable read(InputStream input, Object helper)
+ public static Serializable read(InputStream input, BoxedValueHelper helper)
{
return (Serializable) read(input, null, helper);
}
/**
- * Fill in the instance fields by the data from the input stream.
- * The method assumes that the value header, if any, is already
- * behind. The information from the stream is stored into the
- * passed ox parameter.
- *
+ * Fill in the instance fields by the data from the input stream. The method
+ * assumes that the value header, if any, is already behind. The information
+ * from the stream is stored into the passed ox parameter.
+ *
* @param input an input stream to read from.
- *
+ *
* @param value a pre-instantiated value type object, must be either
- * Streamable or CustomMarshal. If the helper is used, this parameter
- * is ignored and should be null.
- *
+ * Streamable or CustomMarshal. If the helper is used, this parameter is
+ * ignored and should be null.
+ *
* @param value_tag the tag that must be read previously.
- * @param helper the helper for read object specific part; may be
- * null to read in using other methods.
- *
+ * @param helper the helper for read object specific part; may be null to read
+ * in using other methods.
+ *
* @return the value that was read.
*/
- private static Object read_instance(InputStream input, Object value,
- int value_tag, Object helper
- )
+ static Object read_instance(InputStream input, final int position,
+ Object value, int value_tag, BoxedValueHelper helper, String id,
+ String[] ids, String codebase)
{
+ if (helper != m_StringValueHelper && id != null)
+ if (id.equals(StringValueHelper.id()))
+ {
+ value = null;
+ helper = m_StringValueHelper;
+ }
+
try
{
if ((value_tag & vf_CHUNKING) != 0)
{
- ByteArrayOutputStream bout = null;
- int n = -1;
-
- // Read all chunks.
- int chunk_size = input.read_long();
- if (chunk_size < 0)
- throw new MARSHAL("Invalid first chunk size " + chunk_size);
-
- byte[] r = new byte[ chunk_size ];
-
- while (chunk_size > 0)
- {
- if (r.length < chunk_size)
- r = new byte[ chunk_size + 256 ];
-
- n = 0;
- reading:
- while (n < chunk_size)
- n += input.read(r, n, r.length - n);
-
- // Read the size of the next chunk.
- chunk_size = input.read_long();
-
- // If the value is non negative, there is more than one chunk.
- // Accumulate chunks in the buffer.
- // The last chunk (or the only chunk, if only one chunk is
- // present) is not written in the buffer. It is stored in the
- // array r, avoiding unnecessary buffer operations.
- if (chunk_size > 0)
- {
- bout = new ByteArrayOutputStream(2 * chunk_size);
- bout.write(r, 0, chunk_size);
- }
- }
+ BufferedCdrOutput output = createBuffer(input, 1024);
+ // Read the current (not a nested one) value in this spec case.
+ readNestedValue(value_tag, input, output, -1);
+ BufferredCdrInput ci = new BufferredCdrInput(output.buffer.getBuffer());
+ ci.setRunTime(output.getRunTime());
- if (bout != null)
- {
- // More than one chunk was present.
- // Add the last chunk.
- bout.write(r, 0, n);
- input = new noHeaderInput(bout.toByteArray());
- }
- else
- {
- // Only one chunk was present.
- input = new noHeaderInput(r);
- }
+ input = new HeadlessInput(ci, input);
}
else
{
- if (input instanceof cdrBufInput)
+ if (input instanceof BufferredCdrInput)
{
// Highly probable case.
- input =
- new noHeaderInput(((cdrBufInput) input).buffer.getBuffer());
+ input = new HeadlessInput((BufferredCdrInput) input, null);
+ }
+ else if (input instanceof HeadlessInput)
+ {
+ // There is no need to instantiate one more HeadlessInput
+ // as we can just reset.
+ ((HeadlessInput) input).subsequentCalls = false;
}
else
{
- cdrBufOutput bout = new cdrBufOutput();
+ BufferedCdrOutput bout = new BufferedCdrOutput();
int c;
while ((c = input.read()) >= 0)
bout.write((byte) c);
- input = new noHeaderInput(bout.buffer.toByteArray());
+ input = new HeadlessInput(
+ (BufferredCdrInput) bout.create_input_stream(), input);
}
}
}
catch (IOException ex)
{
MARSHAL m = new MARSHAL("Unable to read chunks");
+ m.minor = Minor.Value;
m.initCause(ex);
throw m;
}
- // The user-defines io operations are implemented.
- if (value instanceof CustomMarshal)
+ return readValue(input, position, value, helper, id, ids, codebase);
+ }
+
+ /**
+ * Create a buffer, inheriting critical settings from the passed input stream.
+ */
+ private static BufferedCdrOutput createBuffer(InputStream input, int proposed_size)
+ {
+ BufferedCdrOutput bout;
+ bout = new BufferedCdrOutput(2 * proposed_size + 256);
+
+ if (input instanceof BufferredCdrInput)
{
- CustomMarshal marsh = (CustomMarshal) value;
- try
+ BufferredCdrInput in = (BufferredCdrInput) input;
+ bout.setBigEndian(in.isBigEndian());
+ }
+
+ if (input instanceof gnuValueStream)
+ bout.setRunTime(((gnuValueStream) input).getRunTime());
+ else
+ bout.setRunTime(new gnuRuntime(null, null));
+ return bout;
+ }
+
+ /**
+ * Read the chunked nested value from the given input stream, transferring the
+ * contents to the given output stream.
+ *
+ * @param value_tag the value tag of the value being read.
+ * @param input the input stream from where the remainder of the nested value
+ * must be read.
+ * @param output the output stream where the unchunked nested value must be
+ * copied.
+ *
+ * @return the tag that ended the nested value.
+ */
+ public static int readNestedValue(int value_tag, InputStream input,
+ BufferedCdrOutput output, int level)
+ throws IOException
+ {
+ String id = null;
+ if (level < -1)
+ {
+ // For the first level, this information is already behind.
+ output.write_long(value_tag - vf_CHUNKING);
+
+ // The nested value should be aways chunked.
+ if ((value_tag & vf_CHUNKING) == 0)
+ {
+ MARSHAL m = new MARSHAL("readNestedValue: must be chunked");
+ m.minor = Minor.Chunks;
+ throw m;
+ }
+ else if (value_tag == vt_NULL)
+ {
+ MARSHAL m = new MARSHAL("readNestedValue: nul");
+ m.minor = Minor.Chunks;
+ throw m;
+ }
+ else if (value_tag == vt_INDIRECTION)
{
- marsh.unmarshal((DataInputStream) input);
+ MARSHAL m = new MARSHAL("readNestedValue: indirection");
+ m.minor = Minor.Chunks;
+ throw m;
}
- catch (ClassCastException ex)
+ else
{
- incorrect_plug_in(ex);
+ // Read the value.
+ if ((value_tag & vf_CODEBASE) != 0)
+ {
+ String codebase = read_string(input);
+ write_string(output, codebase);
+ }
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0)
+ {
+ // Multiple supported repository ids are present.
+ String[] ids = read_string_array(input);
+ id = ids[0];
+ write_string_array(output, ids);
+ }
+ else if ((value_tag & vf_ID) != 0)
+ {
+ id = read_string(input);
+ write_string(output, id);
+ }
}
}
+
+ int n = -1;
+
+ // Read all chunks.
+ int chunk_size;
+
+ byte[] r = null;
+
+ while (true)
+ {
+ // Read the size of the next chunk or it may also be the
+ // header of the nested value.
+ chunk_size = input.read_long();
+
+ // End of chunk terminator.
+ if (chunk_size < 0 && chunk_size >= level)
+ return chunk_size;
+ else if (chunk_size >= 0x7FFFFF00)
+ {
+ int onInput = getCurrentPosition(input) - 4;
+ int onOutput = output.getPosition();
+ output.getRunTime().redirect(onInput, onOutput);
+ // Value over 0x7FFFFF00 indicates that the nested value
+ // starts here. Read the nested value, storing it into the output.
+ // First parameter is actually the value tag.
+ chunk_size = readNestedValue(chunk_size, input, output, level - 1);
+ if (chunk_size < 0 && chunk_size >= level)
+ return chunk_size;
+ }
+ else
+ {
+ // The chunk follows.
+ if (r == null || r.length < chunk_size)
+ r = new byte[chunk_size + 256];
+
+ n = 0;
+ reading: while (n < chunk_size)
+ n += input.read(r, n, chunk_size - n);
+ output.write(r, 0, n);
+ }
+ }
+ }
+
+ /**
+ * Read the value (the header must be behind).
+ */
+ public static Serializable readValue(InputStream input, final int position,
+ Object value, BoxedValueHelper helper, String id, String[] ids,
+ String codebase)
+ {
+ gnuRuntime g;
+ gnuValueStream c = ((gnuValueStream) input);
+ if (c.getRunTime() == null)
+ {
+ g = new gnuRuntime(codebase, value);
+ c.setRunTime(g);
+ }
+ else
+ {
+ g = c.getRunTime();
+ g.addCodeBase(codebase);
+ g.target = (Serializable) value;
+ }
+ if (value != null)
+ g.objectWritten(value, position);
+
+ if (input instanceof HeadlessInput)
+ ((HeadlessInput) input).subsequentCalls = false;
+
+ boolean ok = true;
+
+ // The user-defined io operations are implemented.
+ if (value instanceof CustomMarshal)
+ {
+ CustomMarshal marsh = (CustomMarshal) value;
+ marsh.unmarshal((DataInputStream) input);
+ }
else
// The IDL-generated io operations are implemented.
if (value instanceof Streamable)
{
((Streamable) value)._read(input);
}
- else if (helper instanceof BoxedValueHelper)
- value = ((BoxedValueHelper) helper).read_value(input);
- else if (helper instanceof ValueFactory)
- value =
- ((ValueFactory) helper).read_value((org.omg.CORBA_2_3.portable.InputStream) input);
+ else if (helper != null)
+ {
+ // If helper is non-null the value should normally be null.
+ value = helper.read_value(input);
+ g.objectWritten(value, position);
+ }
else
+ {
+ ok = false;
+ ValueFactory factory = null;
+ org.omg.CORBA_2_3.ORB orb = (org.omg.CORBA_2_3.ORB) input.orb();
- // Stating the interfaces that the USER should use.
- throw new MARSHAL("The " + value.getClass().getName() +
- " must implement either StreamableValue or CustomValue."
- );
+ if (id != null)
+ factory = orb.lookup_value_factory(id);
- // The negative end of state marker is expected from OMG standard.
- // If the chunking is used, this marker is already extracted.
- if ((value_tag & vf_CHUNKING) == 0)
+ if (factory == null && ids != null)
+ {
+ for (int i = 0; i < ids.length && factory == null; i++)
+ {
+ factory = orb.lookup_value_factory(ids[i]);
+ }
+ }
+
+ if (factory != null)
+ {
+ value = factory.read_value((org.omg.CORBA_2_3.portable.InputStream) input);
+ ok = true;
+ }
+ }
+
+ if (!ok && value instanceof Serializable)
+ // Delegate to ValueHandler
{
- int eor = input.read_long();
- if (eor >= 0)
- throw new MARSHAL("End of state marker has an invalid value " + eor);
+ if (ids != null && ids.length > 0)
+ id = ids[0];
+
+ value = handler.readValue(input, position, value.getClass(), id, g);
+ ok = true;
}
- return value;
+ if (!ok)
+ {
+ if (value != null)
+ {
+ MARSHAL m = new MARSHAL(value.getClass().getName()
+ + " must be Streamable, CustomMarshal or Serializable");
+ m.minor = Minor.UnsupportedValue;
+ throw m;
+ }
+ else
+ {
+ MARSHAL m = new MARSHAL("Unable to instantiate " + id + ":" + list(ids)
+ + " helper " + helper);
+ m.minor = Minor.UnsupportedValue;
+ throw m;
+ }
+ }
+ else
+ return (Serializable) value;
+ }
+
+ /**
+ * Conveniency method to list ids in exception reports.
+ */
+ static String list(String[] s)
+ {
+ if (s == null)
+ return "null";
+ else
+ {
+ StringBuffer b = new StringBuffer("{");
+ for (int i = 0; i < s.length; i++)
+ {
+ b.append(s[i]);
+ b.append(" ");
+ }
+ b.append("}");
+ return b.toString();
+ }
}
/**
* Write the value base into the given stream.
- *
+ *
* @param output a stream to write to.
- *
+ *
* @param value a value type object, must be either Streamable or
* CustomMarshal.
- *
+ *
* @throws MARSHAL if the writing failed due any reason.
*/
public static void write(OutputStream output, Serializable value)
@@ -537,45 +781,82 @@ public abstract class Vio
// Write null if this is a null value.
if (value == null)
output.write_long(vt_NULL);
+ else if (value instanceof String)
+ write(output, value, m_StringValueHelper);
else
- write(output, value, ObjectCreator.toIDL(value.getClass().getName()));
- }
-
- /**
- * Write the value base into the given stream, stating that it is an
- * instance of the given class. The written record has no repository
- * id and requires to supply a class or initialised instance for reading
- * rather than an actual class it is.
- *
- * This results writing a different repository id.
- *
- * If the passed value implements the {@link CustomMarshal},
- * the helper uses {@link CustomMarshal#marshal}
- * to write the content in a user defined way. Otherwise,
- * this implementation initialises the {@link ObjectOutputStream}
- * and writes through it.
- *
+ write(output, value, value.getClass());
+ }
+
+ /**
+ * Write the value base into the given stream, stating that it is an instance
+ * of the given class.
+ *
* @param output a stream to write to.
- *
+ *
* @param value a value to write.
- *
+ *
* @throws MARSHAL if the writing failed due any reason.
*/
public static void write(OutputStream output, Serializable value,
- Class substitute
- )
+ Class substitute)
{
// Write null if this is a null value.
if (value == null)
output.write_long(vt_NULL);
+ else if (value instanceof String || substitute == String.class)
+ writeString(output, value);
+ else
+ {
+ String vId = ObjectCreator.getRepositoryId(value.getClass());
+ if (substitute == null || value.getClass().equals(substitute))
+ write_instance(output, value, vId, getHelper(value.getClass(), vId));
+ else
+ {
+ String vC = ObjectCreator.getRepositoryId(substitute);
+ String[] ids = new String[] { vId, vC };
+ BoxedValueHelper h = getHelper(substitute.getClass(), ids);
+ // If the helper is available, it is also responsible for
+ // providing the repository Id. Otherwise, write both
+ // ids.
+ if (h == null)
+ write_instance(output, value, ids, null);
+ else
+ write_instance(output, value, h.get_id(), null);
+ }
+ }
+ }
+ /**
+ * Write the value base into the given stream, supplementing it with an array
+ * of the provided repository ids plus the repository id, derived from the
+ * passed value.
+ *
+ * @param output a stream to write to.
+ *
+ * @param value a value to write.
+ *
+ * @throws MARSHAL if the writing failed due any reason.
+ */
+ public static void write(OutputStream output, Serializable value,
+ String[] multiple_ids)
+ {
+ // Write null if this is a null value.
+ if (value == null)
+ output.write_long(vt_NULL);
else
- write(output, value, ObjectCreator.toIDL(substitute.getName()));
+ {
+ String[] ids = new String[multiple_ids.length + 1];
+ ids[0] = ObjectCreator.getRepositoryId(value.getClass());
+ System.arraycopy(multiple_ids, 0, ids, 1, multiple_ids.length);
+ BoxedValueHelper h = getHelper(value.getClass(), ids);
+ write_instance(output, value, ids, h);
+ }
}
/**
- * Write value when its repository Id is explicitly given.
- *
+ * Write value when its repository Id is explicitly given. Only this Id is
+ * written, the type of value is not taken into consideration.
+ *
* @param output an output stream to write into.
* @param value a value to write.
* @param id a value repository id.
@@ -585,172 +866,608 @@ public abstract class Vio
if (value == null)
output.write_long(vt_NULL);
else
- write_instance(output, value, id, null);
+ write_instance(output, value, id, getHelper(value.getClass(), id));
}
/**
- * Write standard value type header, followed by contents, produced
- * by the boxed value helper.
- *
+ * Write standard value type header, followed by contents, produced by the
+ * boxed value helper.
+ *
* @param output the stream to write to.
* @param value the value to write, can be null.
- * @param helper the helper that writes the value content if it is
- * not null.
+ * @param helper the helper that writes the value content if it is not null
+ * (must be provided for this method).
*/
public static void write(OutputStream output, Serializable value,
- Object helper
- )
+ BoxedValueHelper helper)
{
+ if (helper == null)
+ throw new AssertionError("Helper must be provided");
if (value == null)
output.write_long(vt_NULL);
else
+ write_instance(output, value, helper.get_id(), helper);
+ }
+
+ /**
+ * Write the parameter that is surely a string and not null.
+ */
+ private static void writeString(OutputStream output, Serializable string)
+ {
+ write_instance(output, string, m_StringValueHelper.get_id(),
+ m_StringValueHelper);
+ }
+
+ /**
+ * Write value when its repository Id is explicitly given. Does not handle
+ * null.
+ *
+ * @param output an output stream to write into.
+ * @param value a value to write.
+ * @param id a value repository id (can be either single string or string
+ * array).
+ * @param helper a helper, writing object - specifical part. Can be null if
+ * the value should be written using other methods.
+ */
+ static void write_instance(OutputStream output, Serializable value,
+ Object ids, BoxedValueHelper helper)
+ {
+ gnuValueStream rout = null;
+ gnuRuntime runtime = null;
+
+ try
{
- String id;
+ if (output instanceof gnuValueStream)
+ {
+ int position;
+ rout = (gnuValueStream) output;
+ runtime = rout.getRunTime();
+
+ if (runtime == null)
+ {
+ runtime = new gnuRuntime(null, value);
+ rout.setRunTime(runtime);
+ rout.getRunTime().objectWritten(value,
+ position = rout.getPosition());
+ }
+ else if (runtime.target == value)
+ {
+ if (!writeSelf(output, value))
+ throw new InternalError("Recursive helper call for "
+ + value.getClass().getName());
+ return;
+ }
+ else
+ {
+ position = runtime.isWrittenAt(value);
+ if (position >= 0)
+ {
+ // The object was already written.
+ output.write_long(vt_INDIRECTION);
+ output.write_long(position - rout.getPosition());
+ // Replacing object write data by indirection reference.
+ return;
+ }
+ else
+ {
+ runtime.objectWritten(value, position = rout.getPosition());
+ }
+ }
+ }
+
+ int value_tag = vt_VALUE_TAG;
+
+ if (ids instanceof String)
+ value_tag |= vf_ID;
+ else if (ids instanceof String[])
+ // OMG standard requires to set both flags.
+ value_tag |= vf_MULTIPLE_IDS | vf_ID;
- if (helper instanceof BoxedValueHelper)
- id = ((BoxedValueHelper) helper).get_id();
+ int chunkSizeLocation;
+
+ OutputStream outObj;
+
+ if (USE_CHUNKING)
+ {
+ // Wrap the value being written into one chunk (makes sense only for
+ // compatibility reasons).
+ outObj = output;
+ value_tag |= vf_CHUNKING;
+ }
+ else
+ outObj = output;
+
+ output.write_long(value_tag);
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0)
+ write_string_array(output, (String[]) ids);
+ else if ((value_tag & vf_ID) != 0)
+ write_string(output, (String) ids);
+
+ if (USE_CHUNKING)
+ {
+ // So far, write 0x55555555 instead of the chunk size (alignment may
+ // take place).
+ output.write_long(0x55555555);
+ // If the chunking is involved, the chunk size must be written here.
+ chunkSizeLocation = rout.getPosition() - INT_SIZE;
+ }
else
- id = "";
+ // Not in use for this case.
+ chunkSizeLocation = -1;
+
+ writeValue(outObj, value, helper);
- write_instance(output, value, id, helper);
+ if (USE_CHUNKING)
+ {
+ // Write the chunk size where the place for it was reserved.
+ int chunkSize = rout.getPosition() - chunkSizeLocation - INT_SIZE;
+ int current = rout.getPosition();
+ rout.seek(chunkSizeLocation);
+ output.write_long(chunkSize);
+ rout.seek(current);
+
+ // The end of record marker.
+ output.write_long(-1);
+ }
+ }
+ finally
+ {
+ if (runtime != null)
+ runtime.target = null;
}
}
/**
- * Write value when its repository Id is explicitly given.
- * Does not handle null.
- *
- * @param output an output stream to write into.
- * @param value a value to write.
- * @param id a value repository id.
- * @param helper a helper, writing object - specifica part. Can be null
- * if the value should be written unsing other methods.
+ * Write value (after header).
*/
- private static void write_instance(OutputStream output, Serializable value,
- String id, Object helper
- )
+ static void writeValue(OutputStream output, Serializable value,
+ BoxedValueHelper helper)
{
- // This implementation always writes a single repository id.
- // It never writes multiple repository ids and currently does not use
- // a codebase.
- int value_tag = vt_VALUE_TAG | vf_ID;
+ ((gnuValueStream) output).getRunTime().target = value;
+ if (helper != null)
+ helper.write_value(output, value);
+ else if (!writeSelf(output, value))
+ {
+ // Try to find helper via class loader.
+ boolean ok = false;
- OutputStream outObj;
- cdrBufOutput out = null;
+ if (!ok)
+ {
+ if (output instanceof BufferedCdrOutput)
+ {
+ BufferedCdrOutput b = (BufferedCdrOutput) output;
+ if (b.runtime == null)
+ b.runtime = new gnuRuntime(null, value);
+ }
- if (USE_CHUNKING)
+ handler.writeValue(output, value);
+ }
+ }
+ }
+
+ /**
+ * Try to write value supposing that it implements self-streamable interfaces.
+ * Return false if it does not or true on success.
+ */
+ static boolean writeSelf(OutputStream output, Serializable value)
+ {
+ // User defined write method is present.
+ if (value instanceof CustomMarshal)
{
- out = new cdrBufOutput();
- out.setOrb(output.orb());
- outObj = out;
- value_tag |= vf_CHUNKING;
+ ((CustomMarshal) value).marshal((DataOutputStream) output);
+ return true;
}
- else
- outObj = output;
+ else if (value instanceof Streamable)
+ {
+ ((Streamable) value)._write(output);
+ return true;
+ }
+ return false;
+ }
- output.write_long(value_tag);
- output.write_string(id);
+ /**
+ * Read the indirection data and return the object that was already written to
+ * this stream.
+ *
+ * @param an_input the input stream, must be BufferredCdrInput.
+ */
+ static Serializable readIndirection(InputStream an_input)
+ {
+ if (!(an_input instanceof gnuValueStream))
+ throw new NO_IMPLEMENT(gnuValueStream.class.getName()
+ + " expected as parameter");
- if (helper instanceof BoxedValueHelper)
+ gnuValueStream in = (gnuValueStream) an_input;
+
+ int current_pos = in.getPosition();
+
+ int offset = an_input.read_long();
+ if (offset > -INT_SIZE)
{
- ((BoxedValueHelper) helper).write_value(outObj, value);
+ MARSHAL m = new MARSHAL("Indirection tag refers to " + offset
+ + " (must be less than -" + INT_SIZE + ")");
+ m.minor = Minor.Offset;
+ throw m;
}
- else
- // User defince write method is present.
- if (value instanceof CustomMarshal)
+
+ int stored_at = current_pos + offset;
+
+ if (in.getRunTime() == null)
+ {
+ MARSHAL m = new MARSHAL(stored_at + " offset " + offset + ": not written");
+ m.minor = Minor.Value;
+ throw m;
+ }
+
+ return (Serializable) in.getRunTime().isObjectWrittenAt(stored_at, offset);
+ }
+
+ /**
+ * Check the passed value tag for correctness.
+ *
+ * @param value_tag a tag to check, must be between 0x7fffff00 and 0x7fffffff
+ *
+ * @throws MARSHAL if the tag is outside this interval.
+ */
+ static void checkTag(int value_tag)
+ {
+ if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff)
+ && value_tag != vt_NULL && value_tag != vt_INDIRECTION)
+ {
+ MARSHAL m = new MARSHAL("Invalid value record, unsupported header tag: "
+ + value_tag + " (0x" + Integer.toHexString(value_tag) + ")");
+ m.minor = Minor.ValueHeaderTag;
+ throw m;
+ }
+
+ if ((value_tag & vf_MULTIPLE_IDS) != 0 && (value_tag & vf_ID) == 0)
{
+ MARSHAL m = new MARSHAL("Invalid value record header flag combination (0x"
+ + Integer.toHexString(value_tag) + ")");
+ m.minor = Minor.ValueHeaderFlags;
+ throw m;
+ }
+ }
+
+ /**
+ * Throw MARSHAL.
+ */
+ static void throwIt(String msg, String id1, String id2, Throwable e)
+ throws MARSHAL
+ {
+ MARSHAL m = new MARSHAL(msg + ":'" + id1 + "' versus '" + id2 + "'");
+ if (e != null)
+ m.initCause(e);
+ m.minor = Minor.Value;
+ throw m;
+ }
+
+ /**
+ * Load class by name and create the instance.
+ */
+ static Object createInstance(String id, String[] ids, String codebase)
+ {
+ Object o = null;
+
+ if (id != null)
+ o = _createInstance(id, codebase);
+
+ if (ids != null)
+ for (int i = 0; i < ids.length && o == null; i++)
+ o = _createInstance(ids[i], codebase);
+ return o;
+ }
+
+ static Object _createInstance(String id, String codebase)
+ {
+ if (id == null)
+ return null;
+ if (id.equals(StringValueHelper.id()))
+ return "";
+ StringTokenizer st = new StringTokenizer(id, ":");
+
+ String prefix = st.nextToken();
+ if (prefix.equalsIgnoreCase("IDL"))
+ return ObjectCreator.Idl2Object(id);
+ else if (prefix.equalsIgnoreCase("RMI"))
+ {
+ String className = st.nextToken();
+ String hashCode = st.nextToken();
+ String sid = null;
+ if (st.hasMoreElements())
+ sid = st.nextToken();
+
try
{
- ((CustomMarshal) value).marshal((DataOutputStream) outObj);
+ Class objectClass = Util.loadClass(className, codebase,
+ Vio.class.getClassLoader());
+
+ String rid = ObjectCreator.getRepositoryId(objectClass);
+
+ if (!rid.equals(id))
+ {
+ // If direct string comparison fails, compare by meaning.
+ StringTokenizer st2 = new StringTokenizer(rid, ":");
+ if (!st2.nextToken().equals("RMI"))
+ throw new InternalError("RMI format expected: '" + rid + "'");
+ if (!st2.nextToken().equals(className))
+ throwIt("Class name mismatch", id, rid, null);
+
+ try
+ {
+ long h1 = Long.parseLong(hashCode, 16);
+ long h2 = Long.parseLong(st2.nextToken(), 16);
+ if (h1 != h2)
+ throwIt("Hashcode mismatch", id, rid, null);
+
+ if (sid != null && st2.hasMoreTokens())
+ {
+ long s1 = Long.parseLong(hashCode, 16);
+ long s2 = Long.parseLong(st2.nextToken(), 16);
+ if (s1 != s2)
+ throwIt("serialVersionUID mismatch", id, rid, null);
+ }
+ }
+ catch (NumberFormatException e)
+ {
+ throwIt("Invalid hashcode or svuid format: ", id, rid, e);
+ }
+ }
+
+ // Low - level instantiation required here.
+ return instantiateAnyWay(objectClass);
}
- catch (ClassCastException ex)
+ catch (Exception ex)
{
- incorrect_plug_in(ex);
+ MARSHAL m = new MARSHAL("Unable to instantiate " + id);
+ m.minor = Minor.Instantiation;
+ m.initCause(ex);
+ throw m;
}
}
- else if (value instanceof Streamable)
+ else
+ throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
+ }
+
+ /**
+ * Read string, expecting the probable indirection.
+ */
+ static String read_string(InputStream input)
+ {
+ gnuValueStream g = (gnuValueStream) input;
+ int previous = g.getPosition();
+ int l = input.read_long();
+ if (l != vt_INDIRECTION)
{
- ((Streamable) value)._write(outObj);
+ g.seek(previous);
+ String s = input.read_string();
+ if (g.getRunTime() == null)
+ g.setRunTime(new gnuRuntime(null, null));
+ g.getRunTime().singleIdWritten(s, previous);
+ return s;
}
else
{
- // Try to find helper via class loader.
- boolean ok = false;
- try
+ gnuRuntime r = g.getRunTime();
+ int base = g.getPosition();
+ int delta = input.read_long();
+ if (r == null)
{
- Class helperClass = Class.forName(ObjectCreator.toHelperName(id));
-
- // It will be the helper for the encapsulated boxed value, not the
- // for the global boxed value type itself.
- Method write =
- helperClass.getMethod("write",
- new Class[]
- {
- org.omg.CORBA.portable.OutputStream.class, value.getClass()
- }
- );
- write.invoke(null, new Object[] { outObj, value });
- ok = true;
+ previous = g.getPosition();
+ g.seek(base + delta);
+ String indir = input.read_string();
+ g.seek(previous);
+ return indir;
}
- catch (Exception ex)
+ else
{
- ok = false;
+ return (String) r.isObjectWrittenAt(base + delta, delta);
}
+ }
+ }
- // Stating the interfaces that the USER should use.
- if (!ok)
- throw new MARSHAL("The " + value.getClass().getName() +
- " must implement either StreamableValue" + " or CustomValue."
- );
+ /**
+ * Read string array, expecting the probable indirection.
+ */
+ static String[] read_string_array(InputStream input)
+ {
+ gnuValueStream g = (gnuValueStream) input;
+ int previous = g.getPosition();
+ int l = input.read_long();
+ if (l != vt_INDIRECTION)
+ {
+ g.seek(previous);
+ String[] s = StringSeqHelper.read(input);
+ if (g.getRunTime() == null)
+ g.setRunTime(new gnuRuntime(null, null));
+ g.getRunTime().objectWritten(s, previous);
+ return s;
}
+ else
+ {
+ gnuRuntime r = g.getRunTime();
+ int base = g.getPosition();
+ int delta = input.read_long();
+ if (r == null)
+ {
+ previous = g.getPosition();
+ g.seek(base + delta);
+ String[] indir = StringSeqHelper.read(input);
+ g.seek(previous);
+ return indir;
+ }
+ else
+ {
+ return (String[]) r.isObjectWrittenAt(base + delta, delta);
+ }
+ }
+ }
- if (USE_CHUNKING)
+ /**
+ * Write repository Id, probably shared.
+ */
+ static void write_string(OutputStream output, String id)
+ {
+ if (output instanceof gnuValueStream)
{
- output.write_long(out.buffer.size());
- try
+ gnuValueStream b = (gnuValueStream) output;
+ if (b != null)
+ {
+ int written = b.getRunTime().idWrittenAt(id);
+ if (written >= 0)
+ {
+ // Reuse existing id record.
+ output.write_long(vt_INDIRECTION);
+ int p = b.getPosition();
+ output.write_long(written - p);
+ }
+ else
+ {
+ b.getRunTime().singleIdWritten(id, b.getPosition());
+ output.write_string(id);
+ }
+ }
+ }
+ else
+ output.write_string(id);
+ }
+
+ /**
+ * Write repository Id, probably shared.
+ */
+ static void write_string_array(OutputStream output, String[] ids)
+ {
+ if (output instanceof gnuValueStream)
+ {
+ gnuValueStream b = (gnuValueStream) output;
+ if (b != null)
{
- out.buffer.writeTo(output);
+ int written = b.getRunTime().idWrittenAt(ids);
+ if (written >= 0)
+ {
+ // Reuse existing id record.
+ output.write_long(vt_INDIRECTION);
+ int p = b.getPosition();
+ output.write_long(written - p);
+ }
+ else
+ {
+ b.getRunTime().multipleIdsWritten(ids, b.getPosition());
+ StringSeqHelper.write(output, ids);
+ }
}
- catch (IOException ex)
+ }
+ else
+ StringSeqHelper.write(output, ids);
+ }
+
+ /**
+ * Get the helper that could write the given object, or null if no pre-defined
+ * helper available for this object.
+ */
+ public static BoxedValueHelper getHelper(Class x, Object ids)
+ {
+ if (x != null && x.equals(String.class))
+ return m_StringValueHelper;
+ else if (x != null && x.isArray())
+ return new ArrayValueHelper(x);
+ else if (ids instanceof String)
+ return locateHelper((String) ids);
+ else if (ids instanceof String[])
+ {
+ String[] ia = (String[]) ids;
+ BoxedValueHelper h;
+ for (int i = 0; i < ia.length; i++)
{
- MARSHAL m = new MARSHAL();
- m.initCause(ex);
- throw m;
+ h = locateHelper(ia[i]);
+ if (h != null)
+ return h;
}
+ return null;
}
+ else
+ return null;
+ }
- // The end of record marker, required by OMG standard.
- output.write_long(-1);
+ /**
+ * Get the helper that could write the given object, or null if no pre-defined
+ * helper available for this object.
+ */
+ public static BoxedValueHelper getHelper(Class x, String id)
+ {
+ if (x != null && x.equals(String.class))
+ return m_StringValueHelper;
+ else if (x != null && x.isArray())
+ return new ArrayValueHelper(x);
+ else
+ return locateHelper(id);
}
/**
- * This can be called if the alternative CORBA implementation
- * is incorrectly plugged in.
- *
- * @throws NO_IMPLEMENT, always.
+ * Try to locate helper from the repository id.
*/
- static void incorrect_plug_in(Throwable ex) throws NO_IMPLEMENT
+ static BoxedValueHelper locateHelper(String id)
{
- NO_IMPLEMENT no = new NO_IMPLEMENT("Incorrect CORBA plug-in");
- no.initCause(ex);
- throw no;
+ if (id != null)
+ {
+ if (id.equals(m_StringValueHelper.get_id()))
+ return m_StringValueHelper;
+ else
+ // Try to locate helper for IDL type.
+ if (id.startsWith("IDL:"))
+ {
+ try
+ {
+ Class helperClass = ObjectCreator.findHelper(id);
+ if (BoxedValueHelper.class.isAssignableFrom(helperClass))
+ return (BoxedValueHelper) helperClass.newInstance();
+ else if (helperClass != null)
+ return new IDLTypeHelper(helperClass);
+ else
+ return null;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+ }
+ return null;
}
/**
- * Check the passed value tag for correctness.
- *
- * @param value_tag a tag to check, must be between 0x7fffff00 and 0x7fffffff
- *
- * @throws MARSHAL if the tag is outside this interval.
+ * Get the current position.
*/
- private static final void checkTag(int value_tag)
+ static int getCurrentPosition(InputStream x)
{
- if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff) &&
- value_tag != vt_NULL &&
- value_tag != vt_INDIRECTION
- )
- throw new MARSHAL("Invalid value record, unsupported header tag: " +
- value_tag
- );
+ if (x instanceof gnuValueStream)
+ return ((gnuValueStream) x).getPosition();
+ else
+ return 0;
+ }
+
+ /**
+ * Instantiate an instance of this class anyway; also in the case when it has
+ * no parameterless or any other constructor. The fields will be assigned
+ * while reading the class from the stream.
+ *
+ * @param clazz a class for that the instance should be instantiated.
+ */
+ public static Object instantiateAnyWay(Class clazz)
+ throws Exception
+ {
+ Class first_nonserial = clazz;
+
+ while (Serializable.class.isAssignableFrom(first_nonserial)
+ || Modifier.isAbstract(first_nonserial.getModifiers()))
+ first_nonserial = first_nonserial.getSuperclass();
+
+ final Class local_constructor_class = first_nonserial;
+
+ Constructor constructor = local_constructor_class.getDeclaredConstructor(new Class[0]);
+
+ return VMVio.allocateObject(clazz, constructor.getDeclaringClass(),
+ constructor);
}
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/CDR/gnuRuntime.java b/libjava/classpath/gnu/CORBA/CDR/gnuRuntime.java
new file mode 100644
index 00000000000..774c92816ae
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/CDR/gnuRuntime.java
@@ -0,0 +1,336 @@
+/* gnuRuntime.java --
+ 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. */
+
+
+package gnu.CORBA.CDR;
+
+import gnu.CORBA.Minor;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.MARSHAL;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+/**
+ * Our implementation of the sending context runtime.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class gnuRuntime
+ extends LocalObject
+ implements org.omg.SendingContext.RunTime
+{
+ /**
+ * The data entry about the object that was written.
+ */
+ static class Entry
+ {
+ /**
+ * The stream position, where the object was written.
+ */
+ int at;
+
+ /**
+ * The object that was written.
+ */
+ Object object;
+
+ public String toString()
+ {
+ return object + "[" + at + "] "+object.getClass().getName();
+ }
+ }
+
+ /**
+ * The instruction that the actual object is stored at different location.
+ * Used when processing chunked data where positions shifts due removing the
+ * chunking tags.
+ */
+ static class Redirection
+ extends Entry
+ {
+ public String toString()
+ {
+ return "->" + at;
+ }
+ }
+
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The history of the written objects, maps object to records. The different
+ * objects must be treated as different regardless that .equals returns.
+ */
+ private Map sh_objects = new IdentityHashMap();
+
+ /**
+ * The written repository Ids that can be shared.
+ */
+ private Map sh_ids = new TreeMap(new Comparator()
+ {
+ public int compare(Object a, Object b)
+ {
+ if (a instanceof String && b instanceof String)
+ // Comparing string with string.
+ return ((String) a).compareTo((String) b);
+ else if (a instanceof String[] && b instanceof String[])
+ {
+ // Comparing array with array.
+ String[] sa = (String[]) a;
+ String[] sb = (String[]) b;
+
+ if (sa.length != sb.length)
+ return sa.length - sb.length;
+ else
+ {
+ int c;
+ for (int i = 0; i < sa.length; i++)
+ {
+ c = sa[i].compareTo(sb[i]);
+ if (c != 0)
+ return c;
+ }
+ return 0;
+ }
+ }
+ else
+ // Comparing string with array.
+ return a instanceof String ? 1 : -1;
+ }
+ });
+
+ /**
+ * The history of the written objects, maps positions to records. The
+ * different objects must be treated as different regardless that .equals
+ * returns.
+ */
+ private Map positions = new HashMap();
+
+ /**
+ * The Codebase.
+ */
+ private String codebase;
+
+ /**
+ * The pre-created instance of the object being written (avoid
+ * re-instantiation).
+ */
+ public Serializable target;
+
+ /**
+ * Create Runtime.
+ *
+ * @param a_id a repository Id, if only one Id was specified in the stream.
+ * @param a_ids a repository Ids, if the multiple Ids were specified in te
+ * stream.
+ * @param a_codabase a codebase, if it was specified in the stream.
+ */
+ public gnuRuntime(String a_codebase, Object a_target)
+ {
+ if (a_target instanceof Serializable)
+ target = (Serializable) a_target;
+
+ codebase = a_codebase;
+ }
+
+ /**
+ * Mark the given object as written at the given position.
+ */
+ public void objectWritten(Object object, int at)
+ {
+ if (object == null || at < 0)
+ return; // No positional information provided.
+ if (sh_objects.containsKey(object))
+ throw new AssertionError("Repetetive writing of the same object "
+ + object + " at " + at + dump());
+
+ Entry e = new Entry();
+ e.at = at;
+ e.object = object;
+
+ sh_objects.put(object, e);
+ positions.put(new Integer(at), e);
+ }
+
+ /**
+ * Check if the object is already written.
+ *
+ * @return the position, at that the object is allready written or -1 if it is
+ * not yet written.
+ */
+ public int isWrittenAt(Object x)
+ {
+ Entry e = (Entry) sh_objects.get(x);
+ return e == null ? -1 : e.at;
+ }
+
+ /**
+ * Set redirection, indicating that the object, searched at the p_searched
+ * position can be actually found at the p_present position.
+ */
+ public void redirect(int p_searched, int p_present)
+ {
+ Redirection redirection = new Redirection();
+ redirection.at = p_present;
+ positions.put(new Integer(p_searched), redirection);
+ }
+
+ /**
+ * Get the object, written at the given position. This returs both shared
+ * objects and repository Ids.
+ *
+ * @return the position, at that the object is allready written.
+ *
+ * @throws MARSHAL if there is no object written at that position.
+ */
+ public Object isObjectWrittenAt(int x, int offset)
+ {
+ Entry e = (Entry) positions.get(new Integer(x));
+ if (e instanceof Redirection)
+ return isObjectWrittenAt(e.at, offset);
+ else if (e != null)
+ return e.object;
+ else
+ {
+ MARSHAL m = new MARSHAL("No object was written at " + x +
+ " (offset " + offset + ") r " + this + dump());
+ m.minor = Minor.Graph;
+ throw m;
+ }
+ }
+
+ /**
+ * Mark the given object as written at the given position.
+ */
+ public void singleIdWritten(String id, int at)
+ {
+ if (sh_ids.containsKey(id))
+ throw new InternalError("Repetetive writing of the same string " +
+ id + dump());
+
+ Entry e = new Entry();
+ e.at = at;
+ e.object = id;
+
+ sh_ids.put(id, e);
+ positions.put(new Integer(at), e);
+ }
+
+ /**
+ * Mark the given object as written at the given position.
+ */
+ public void multipleIdsWritten(String[] ids, int at)
+ {
+ if (sh_ids.containsKey(ids))
+ throw new InternalError("Repetetive writing of the same string " +
+ ids + dump());
+
+ Entry e = new Entry();
+ e.at = at;
+ e.object = ids;
+
+ sh_ids.put(ids, e);
+ positions.put(new Integer(at), e);
+ }
+
+ /**
+ * Check if the object is already written.
+ *
+ * @return the position, at that the object is allready written or -1 if it is
+ * not yet written.
+ */
+ public int idWrittenAt(Object x)
+ {
+ Entry e = (Entry) sh_ids.get(x);
+ return e == null ? -1 : e.at;
+ }
+
+ /**
+ * Get the codebase.
+ */
+ public String getCodeBase()
+ {
+ return codebase;
+ }
+
+ /**
+ * Set the codebase, preserving the old value if the passed parameter is null
+ * and forming the space delimited list if both new and old values are not
+ * null.
+ */
+ public void addCodeBase(String base)
+ {
+ if (base != null)
+ {
+ if (codebase == null)
+ codebase = base;
+ else
+ codebase = codebase + " " + base;
+ }
+ }
+
+ /**
+ * Dump all objects that are currently stored.
+ */
+ public String dump()
+ {
+ StringBuffer b = new StringBuffer(" Stream content: \n");
+
+ // Sort by position.
+ TreeSet t = new TreeSet(positions.keySet());
+ Iterator p = t.iterator();
+
+ while (p.hasNext())
+ {
+ Object k = p.next();
+ b.append(" " + k + ": " + ((Entry) positions.get(k)).toString()
+ + "\n");
+ }
+ return b.toString();
+ }
+
+}
diff --git a/libjava/classpath/gnu/CORBA/CDR/gnuValueStream.java b/libjava/classpath/gnu/CORBA/CDR/gnuValueStream.java
new file mode 100644
index 00000000000..663c9901861
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/CDR/gnuValueStream.java
@@ -0,0 +1,71 @@
+/* gnuValueStream.java --
+ 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. */
+
+
+package gnu.CORBA.CDR;
+
+/**
+ * A stream, implementing this interface, provides methods to get/set a position
+ * and get the RunTime.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface gnuValueStream
+{
+ /**
+ * Get the current position in the buffer.
+ *
+ * @return The position in the buffer, taking offset into consideration.
+ */
+ public int getPosition();
+
+ /**
+ * Jump to the given position, taking offset into consideration.
+ */
+ public void seek(int position);
+
+ /**
+ * Get the RunTime information.
+ */
+ public gnuRuntime getRunTime();
+
+ /**
+ * Replace the instance of RunTime.
+ */
+ public void setRunTime(gnuRuntime a_runtime);
+
+}
diff --git a/libjava/classpath/gnu/CORBA/CDR/noHeaderInput.java b/libjava/classpath/gnu/CORBA/CDR/noHeaderInput.java
deleted file mode 100644
index 0c787ddc2df..00000000000
--- a/libjava/classpath/gnu/CORBA/CDR/noHeaderInput.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/* noHeaderInput.java --
- 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. */
-
-
-package gnu.CORBA.CDR;
-
-import org.omg.CORBA.CustomMarshal;
-import org.omg.CORBA.DataInputStream;
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.portable.BoxedValueHelper;
-import org.omg.CORBA.portable.Streamable;
-import org.omg.CORBA.portable.ValueFactory;
-
-import java.io.Serializable;
-
-/**
- * Substitutes the main stream in factories when the header is already
- * behind. Overrides methods that may be invoked from the factory,
- * forcing not to read the header if called first time on this stream.
- *
- * This stream reverts to default behavior if one or more call are
- * made (reading value types that are nested fields of the value type).
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
- */
-class noHeaderInput
- extends cdrBufInput
- implements DataInputStream
-{
- /**
- * If true, this is not the first call.
- */
- boolean notFirst;
-
- /**
- * Create an instance, reading from the given buffer.
- */
- public noHeaderInput(byte[] buffer)
- {
- super(buffer);
- }
-
- /**
- * Read when knowning the class instance.
- */
- public Serializable read_value(Class clz)
- {
- if (notFirst)
- return super.read_value(clz);
- else
- {
- try
- {
- notFirst = true;
- return read_value((Serializable) clz.newInstance());
- }
- catch (Exception ex)
- {
- MARSHAL m = new MARSHAL("Unable to create an instance");
- m.initCause(ex);
- throw m;
- }
- }
- }
-
- /**
- * Tries to read using boxed value helper.
- */
- public Serializable read_value(BoxedValueHelper helper)
- {
- if (notFirst)
- return super.read_value(helper);
- else
- {
- notFirst = true;
- return helper.read_value(this);
- }
- }
-
- /**
- * Tries to locate a factory using repository id.
- */
- public Serializable read_value(String repository_id)
- {
- if (notFirst)
- return super.read_value(repository_id);
- else
- {
- notFirst = true;
-
- ValueFactory factory =
- ((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);
- if (factory == null)
- throw new MARSHAL("No factory");
- return factory.read_value(this);
- }
- }
-
- /**
- * Try to read when having an unitialised value.
- */
- public Serializable read_value(Serializable value)
- {
- if (notFirst)
- return super.read_value(value);
- else
- {
- notFirst = true;
-
- // The user-defines io operations are implemented.
- if (value instanceof CustomMarshal)
- {
- CustomMarshal marsh = (CustomMarshal) value;
- try
- {
- marsh.unmarshal((DataInputStream) this);
- }
- catch (ClassCastException ex)
- {
- Vio.incorrect_plug_in(ex);
- }
- }
- else
- // The IDL-generated io operations are implemented.
- if (value instanceof Streamable)
- {
- ((Streamable) value)._read(this);
- }
- return value;
- }
- }
-} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/cdrEncapsCodec.java b/libjava/classpath/gnu/CORBA/CdrEncapsCodecImpl.java
index 699c6f76a9c..93dd1cdcdfb 100644
--- a/libjava/classpath/gnu/CORBA/cdrEncapsCodec.java
+++ b/libjava/classpath/gnu/CORBA/CdrEncapsCodecImpl.java
@@ -1,4 +1,4 @@
-/* cdrEncapsCodec.java --
+/* CdrEncapsCodecImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,9 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -57,19 +57,19 @@ import org.omg.IOP.CodecPackage.TypeMismatch;
/**
* The local {@link Codec} implementation for ENCODING_CDR_ENCAPS
* encoding. This is a local implementation; the remote side should
- * have its own Codec of this kind.
+ * have its own Codec of this kind.
*
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class cdrEncapsCodec
+public class CdrEncapsCodecImpl
extends LocalObject
implements Codec
{
- /**
- * The default version of encoding, used in parameterless constructor.
+ /**
+ * Use serialVersionUID for interoperability.
*/
- private static final Version DEFAULT_VERSION = new Version(1, 2);
+ private static final long serialVersionUID = 1;
/**
* If set to true, no wide string or wide character is allowed (GIOP 1.0).
@@ -99,7 +99,7 @@ public class cdrEncapsCodec
/**
* Create an instance of this Codec, encoding following the given version.
*/
- public cdrEncapsCodec(ORB _orb, Version _version)
+ public CdrEncapsCodecImpl(ORB _orb, Version _version)
{
orb = _orb;
version = _version;
@@ -125,8 +125,8 @@ public class cdrEncapsCodec
public Any decode(byte[] them)
throws FormatMismatch
{
- cdrBufInput input = createInput(them);
- cdrBufInput encapsulation = createEncapsulation(them, input);
+ BufferredCdrInput input = createInput(them);
+ BufferredCdrInput encapsulation = createEncapsulation(them, input);
TypeCode type = encapsulation.read_TypeCode();
@@ -142,9 +142,9 @@ public class cdrEncapsCodec
return readAny(type, encapsulation);
}
- private cdrBufInput createEncapsulation(byte[] them, cdrBufInput input)
+ private BufferredCdrInput createEncapsulation(byte[] them, BufferredCdrInput input)
{
- cdrBufInput encapsulation;
+ BufferredCdrInput encapsulation;
if ((them [ 0 ] | them [ 1 ] | them [ 2 ] | them [ 3 ]) == 0)
{
@@ -163,10 +163,10 @@ public class cdrEncapsCodec
{
checkTypePossibility("", that.type());
- cdrBufOutput output = createOutput(that);
+ BufferedCdrOutput output = createOutput(that);
- // cdrBufOutput has internal support for this encoding.
- cdrOutput encapsulation = output.createEncapsulation();
+ // BufferedCdrOutput has internal support for this encoding.
+ AbstractCdrOutput encapsulation = output.createEncapsulation();
try
{
@@ -179,6 +179,7 @@ public class cdrEncapsCodec
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Encapsulation;
m.initCause(ex);
throw m;
}
@@ -206,8 +207,8 @@ public class cdrEncapsCodec
throw new TypeMismatch(ex.getMessage());
}
- cdrBufInput input = createInput(them);
- cdrBufInput encapsulation = createEncapsulation(them, input);
+ BufferredCdrInput input = createInput(them);
+ BufferredCdrInput encapsulation = createEncapsulation(them, input);
return readAny(type, encapsulation);
}
@@ -217,13 +218,13 @@ public class cdrEncapsCodec
* @param type a type of the Any to read.
* @param input the encapsulation stream.
*/
- private Any readAny(TypeCode type, cdrBufInput encapsulation)
+ private Any readAny(TypeCode type, BufferredCdrInput encapsulation)
throws MARSHAL
{
gnuAny a = new gnuAny();
a.setOrb(orb);
- // cdrBufInput has internal support for this encoding.
+ // BufferredCdrInput has internal support for this encoding.
a.read_value(encapsulation, type);
return a;
}
@@ -234,9 +235,9 @@ public class cdrEncapsCodec
{
checkTypePossibility("", that.type());
- cdrBufOutput output = createOutput(that);
+ BufferedCdrOutput output = createOutput(that);
- cdrOutput encapsulation = output.createEncapsulation();
+ AbstractCdrOutput encapsulation = output.createEncapsulation();
try
{
@@ -248,6 +249,7 @@ public class cdrEncapsCodec
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Encapsulation;
m.initCause(ex);
throw m;
}
@@ -256,7 +258,7 @@ public class cdrEncapsCodec
/**
* Create the CDR output stream for writing the given Any.
- * The cdrBufOutput has internal support for encapsulation encodings.
+ * The BufferedCdrOutput has internal support for encapsulation encodings.
*
* @param that the Any that will be written.
*
@@ -265,10 +267,10 @@ public class cdrEncapsCodec
* @throws InvalidTypeForEncoding if that Any cannot be written under the
* given version.
*/
- private cdrBufOutput createOutput(Any that)
+ private BufferedCdrOutput createOutput(Any that)
throws InvalidTypeForEncoding
{
- cdrBufOutput output = new cdrBufOutput();
+ BufferedCdrOutput output = new BufferedCdrOutput();
output.setOrb(orb);
output.setVersion(version);
return output;
@@ -325,9 +327,9 @@ public class cdrEncapsCodec
*
* @return the stream.
*/
- private cdrBufInput createInput(byte[] them)
+ private BufferredCdrInput createInput(byte[] them)
{
- cdrBufInput input = new cdrBufInput(them);
+ BufferredCdrInput input = new BufferredCdrInput(them);
input.setOrb(orb);
input.setVersion(version);
return input;
diff --git a/libjava/classpath/gnu/CORBA/Connected_objects.java b/libjava/classpath/gnu/CORBA/Connected_objects.java
index b7eefb133a2..ce5761007c0 100644
--- a/libjava/classpath/gnu/CORBA/Connected_objects.java
+++ b/libjava/classpath/gnu/CORBA/Connected_objects.java
@@ -90,17 +90,6 @@ public class Connected_objects
* applicable.
*/
public final java.lang.Object identity;
-
- public boolean equals(java.lang.Object other)
- {
- if (other instanceof cObject)
- {
- cObject o = (cObject) other;
- return o.object.equals(object) && o.port == port;
- }
- else
- return false;
- }
}
/**
diff --git a/libjava/classpath/gnu/CORBA/corbaArrayList.java b/libjava/classpath/gnu/CORBA/CorbaList.java
index 1690f0583cb..25bea923099 100644
--- a/libjava/classpath/gnu/CORBA/corbaArrayList.java
+++ b/libjava/classpath/gnu/CORBA/CorbaList.java
@@ -1,4 +1,4 @@
-/* corbaArrayList.java --
+/* CorbaList.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import org.omg.CORBA.Bounds;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class corbaArrayList
+public class CorbaList
extends ArrayList
implements Serializable
{
@@ -64,7 +64,7 @@ public class corbaArrayList
/**
* Creates the list with the given initial size.
*/
- public corbaArrayList(int initial_size)
+ public CorbaList(int initial_size)
{
super(initial_size);
}
@@ -72,7 +72,7 @@ public class corbaArrayList
/**
* Creates the list with the default size.
*/
- public corbaArrayList()
+ public CorbaList()
{
}
diff --git a/libjava/classpath/gnu/CORBA/DefaultSocketFactory.java b/libjava/classpath/gnu/CORBA/DefaultSocketFactory.java
new file mode 100644
index 00000000000..51df047192c
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/DefaultSocketFactory.java
@@ -0,0 +1,79 @@
+/* DefaultSocketFactory.java --
+ 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. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.interfaces.SocketFactory;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * The default socket factory that forges "plain" server and client sockets. The
+ * class can be replaced by setting the gnu.CORBA.SocketFactory property.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class DefaultSocketFactory
+ implements SocketFactory
+{
+ /**
+ * It is enough to have one instance of this class for all ORBs.
+ */
+ public static final DefaultSocketFactory Singleton = new DefaultSocketFactory();
+
+ /**
+ * Create a client socket.
+ */
+ public Socket createClientSocket(String host, int port)
+ throws IOException
+ {
+ return new Socket(host, port);
+ }
+
+ /**
+ * Create a server socket.
+ */
+ public ServerSocket createServerSocket(int port)
+ throws IOException
+ {
+ return new ServerSocket(port);
+ }
+
+}
diff --git a/libjava/classpath/gnu/CORBA/DynAn/abstractDynAny.java b/libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java
index 47176c4b589..7060f86b27f 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/abstractDynAny.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/AbstractAny.java
@@ -1,4 +1,4 @@
-/* abstractDynAny.java --
+/* AbstractAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
-import gnu.CORBA.typeNamer;
+import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -54,7 +54,7 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class abstractDynAny
+public abstract class AbstractAny
extends LocalObject
implements Serializable
{
@@ -108,12 +108,12 @@ public abstract class abstractDynAny
/**
* The change value listener.
*/
- valueChangedListener listener;
+ ValueChangeListener listener;
/**
* Create the abstract dyn any.
*/
- public abstractDynAny(TypeCode oType, TypeCode aType,
+ public AbstractAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -163,8 +163,8 @@ public abstract class abstractDynAny
*/
String typeMismatch(TypeCode expected, TypeCode actual)
{
- return typeNamer.nameIt(expected) + " expected " +
- typeNamer.nameIt(actual);
+ return TypeKindNamer.nameIt(expected) + " expected " +
+ TypeKindNamer.nameIt(actual);
}
/**
diff --git a/libjava/classpath/gnu/CORBA/DynAn/anyDivideable.java b/libjava/classpath/gnu/CORBA/DynAn/DivideableAny.java
index 5f52c8078eb..c96cbedc73b 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/anyDivideable.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/DivideableAny.java
@@ -1,4 +1,4 @@
-/* anyDivideable.java --
+/* DivideableAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
-import gnu.CORBA.typeNamer;
+import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.CompletionStatus;
@@ -58,8 +58,8 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class anyDivideable
- extends abstractDynAny
+public abstract class DivideableAny
+ extends AbstractAny
implements Serializable
{
/**
@@ -78,7 +78,7 @@ public abstract class anyDivideable
*/
protected int pos = 0;
- public anyDivideable(TypeCode oType, TypeCode aType,
+ public DivideableAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -486,9 +486,9 @@ public abstract class anyDivideable
{
if (!official_type.equal(other.type()))
return false;
- else if (other instanceof anyDivideable)
+ else if (other instanceof DivideableAny)
{
- anyDivideable x = (anyDivideable) other;
+ DivideableAny x = (DivideableAny) other;
if (x.array.length != array.length)
return false;
@@ -499,7 +499,7 @@ public abstract class anyDivideable
}
return true;
}
- else if (other == null || other instanceof abstractDynAny)
+ else if (other == null || other instanceof AbstractAny)
return false;
else
return other.to_any().equal(to_any());
diff --git a/libjava/classpath/gnu/CORBA/DynAn/abstractRecord.java b/libjava/classpath/gnu/CORBA/DynAn/RecordAny.java
index 8d8b7a559b1..a3e3680d966 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/abstractRecord.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/RecordAny.java
@@ -1,4 +1,4 @@
-/* abstractRecord.java --
+/* RecordAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
+import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -65,8 +65,8 @@ import java.lang.reflect.Field;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class abstractRecord
- extends anyDivideable
+public abstract class RecordAny
+ extends DivideableAny
implements DynAny, Serializable
{
/**
@@ -80,7 +80,7 @@ public abstract class abstractRecord
*
* @param fields The DynAny's, representing the fields of the structure.
*/
- public abstractRecord(TypeCode oType, TypeCode aType,
+ public RecordAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -277,7 +277,7 @@ public abstract class abstractRecord
c [ i ] = array [ i ].copy();
}
- abstractRecord d = newInstance(official_type, final_type, factory, orb);
+ RecordAny d = newInstance(official_type, final_type, factory, orb);
d.array = c;
return d;
}
@@ -285,7 +285,7 @@ public abstract class abstractRecord
/**
* Create a new instance when copying.
*/
- protected abstract abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ protected abstract RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory,
ORB anOrb
);
@@ -297,7 +297,7 @@ public abstract class abstractRecord
{
try
{
- Streamable sHolder = holderFactory.createHolder(official_type);
+ Streamable sHolder = HolderLocator.createHolder(official_type);
Class sHolderClass = sHolder.getClass();
Field sHolderValue = sHolderClass.getField("value");
@@ -371,7 +371,7 @@ public abstract class abstractRecord
fField = structure.getClass().getField(fNames [ i ]);
field = fField.get(structure);
fType = array [ i ].type();
- holder = holderFactory.createHolder(fType);
+ holder = HolderLocator.createHolder(fType);
member = createAny();
holder.getClass().getField("value").set(holder, field);
diff --git a/libjava/classpath/gnu/CORBA/DynAn/anyUndivideable.java b/libjava/classpath/gnu/CORBA/DynAn/UndivideableAny.java
index b31a6b357f9..da4e9618ee7 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/anyUndivideable.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/UndivideableAny.java
@@ -55,8 +55,8 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class anyUndivideable
- extends abstractDynAny
+public abstract class UndivideableAny
+ extends AbstractAny
implements Serializable
{
/**
@@ -67,7 +67,7 @@ public abstract class anyUndivideable
/**
* Create a new instance with the given typecode.
*/
- public anyUndivideable(TypeCode oType, TypeCode aType,
+ public UndivideableAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb)
{
super(oType, aType, aFactory, anOrb);
diff --git a/libjava/classpath/gnu/CORBA/DynAn/valueChangedListener.java b/libjava/classpath/gnu/CORBA/DynAn/ValueChangeListener.java
index 94ddffbecf7..59727615999 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/valueChangedListener.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/ValueChangeListener.java
@@ -1,4 +1,4 @@
-/* valueChangedListener.java --
+/* ValueChangeListener.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ package gnu.CORBA.DynAn;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public interface valueChangedListener
+public interface ValueChangeListener
{
void changed();
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java
index 015628ebf90..23141de3d96 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAny.java
@@ -38,14 +38,14 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.OctetHolder;
import gnu.CORBA.Unexpected;
import gnu.CORBA.WCharHolder;
import gnu.CORBA.WStringHolder;
-import gnu.CORBA.holderFactory;
-import gnu.CORBA.typeNamer;
-import gnu.CORBA.universalHolder;
+import gnu.CORBA.HolderLocator;
+import gnu.CORBA.TypeKindNamer;
+import gnu.CORBA.GeneralHolder;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnyHolder;
@@ -84,7 +84,7 @@ import java.util.Arrays;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
+public class gnuDynAny extends AbstractAny implements DynAny, Serializable
{
/**
* Use serialVersionUID for interoperability.
@@ -132,7 +132,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
{
if (holder != null)
{
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
holder._write(buffer);
gnuDynAny other;
@@ -165,7 +165,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
public DynAny current_component() throws TypeMismatch
{
throw new TypeMismatch("Not applicable for " +
- typeNamer.nameIt(final_type)
+ TypeKindNamer.nameIt(final_type)
);
}
@@ -193,14 +193,14 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
{
throw new InvalidValue(ISNULL);
}
- else if (a_holder instanceof universalHolder)
+ else if (a_holder instanceof GeneralHolder)
{
- holder = holderFactory.createHolder(official_type);
+ holder = HolderLocator.createHolder(official_type);
if (holder == null)
- holder = holderFactory.createHolder(final_type);
+ holder = HolderLocator.createHolder(final_type);
if (holder == null)
- holder = ((universalHolder) a_holder).Clone();
+ holder = ((GeneralHolder) a_holder).Clone();
else
{
InputStream in = an_any.create_input_stream();
@@ -890,7 +890,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
*/
public boolean equal(DynAny other)
{
- if (other instanceof abstractDynAny)
+ if (other instanceof AbstractAny)
{
if (other instanceof gnuDynAny)
{
@@ -899,10 +899,10 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
if (!x.holder.getClass().equals(holder.getClass()))
return false;
- cdrBufOutput b1 = new cdrBufOutput();
+ BufferedCdrOutput b1 = new BufferedCdrOutput();
x.holder._write(b1);
- cdrBufOutput b2 = new cdrBufOutput(b1.buffer.size() + 10);
+ BufferedCdrOutput b2 = new BufferedCdrOutput(b1.buffer.size() + 10);
holder._write(b2);
return Arrays.equals(b1.buffer.toByteArray(),
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java
index dd1762890de..b8b39bfbcdf 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynAnyFactory.java
@@ -40,8 +40,8 @@ package gnu.CORBA.DynAn;
import gnu.CORBA.Poa.ORB_1_4;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
-import gnu.CORBA.typeNamer;
+import gnu.CORBA.HolderLocator;
+import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -227,7 +227,7 @@ public class gnuDynAnyFactory
*/
public DynAny create_simple(TypeCode official, TypeCode type)
{
- Streamable holder = holderFactory.createHolder(type);
+ Streamable holder = HolderLocator.createHolder(type);
return new gnuDynAny(holder, official, type, this, orb);
}
@@ -314,7 +314,7 @@ public class gnuDynAnyFactory
case TCKind._tk_Principal :
case TCKind._tk_abstract_interface :
throw new InconsistentTypeCode("Following API, the " +
- typeNamer.nameIt(type) +
+ TypeKindNamer.nameIt(type) +
" must not be supported."
);
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java
index 1c08496d423..825cd0a5638 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynArray.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
+import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
@@ -66,7 +66,7 @@ import java.lang.reflect.Field;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynArray
- extends anyDivideable
+ extends DivideableAny
implements DynArray, Serializable
{
/**
@@ -238,10 +238,10 @@ public class gnuDynArray
try
{
Streamable memberHolder =
- holderFactory.createHolder(official_components);
+ HolderLocator.createHolder(official_components);
if (memberHolder == null)
- memberHolder = holderFactory.createHolder(final_components);
+ memberHolder = HolderLocator.createHolder(final_components);
Class memberHolderClass = memberHolder.getClass();
Class memberClass = memberHolderClass.getField("value").getType();
@@ -260,7 +260,7 @@ public class gnuDynArray
Array.set(members, i, member);
}
- Streamable arrayHolder = holderFactory.createHolder(official_type);
+ Streamable arrayHolder = HolderLocator.createHolder(official_type);
arrayHolder.getClass().getField("value").set(arrayHolder, members);
Any g = createAny();
@@ -296,9 +296,9 @@ public class gnuDynArray
{
if (holderClass == null)
{
- holder = holderFactory.createHolder(official_components);
+ holder = HolderLocator.createHolder(official_components);
if (holder == null)
- holder = holderFactory.createHolder(final_components);
+ holder = HolderLocator.createHolder(final_components);
holderClass = holder.getClass();
}
else
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java
index 2fccc85c59d..6eb7fe2bcac 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynEnum.java
@@ -60,7 +60,7 @@ import java.util.Arrays;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynEnum extends anyUndivideable implements DynEnum
+public class gnuDynEnum extends UndivideableAny implements DynEnum
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java
index 39b00226245..9655f0387da 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynFixed.java
@@ -57,7 +57,7 @@ import java.math.BigDecimal;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynFixed extends anyUndivideable implements DynFixed
+public class gnuDynFixed extends UndivideableAny implements DynFixed
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java
index b086d6478cc..b15aff3e124 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynStruct.java
@@ -54,7 +54,7 @@ import org.omg.DynamicAny.DynAny;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynStruct
- extends abstractRecord
+ extends RecordAny
implements DynStruct, Serializable
{
/**
@@ -89,7 +89,7 @@ public class gnuDynStruct
}
/** @inheritDoc */
- protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ protected RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb)
{
return new gnuDynStruct(oType, aType, aFactory, anOrb);
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java
index ad41e24b6ae..ef5aed64512 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynUnion.java
@@ -62,8 +62,8 @@ import java.io.Serializable;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynUnion
- extends anyDivideable
- implements DynUnion, Serializable, valueChangedListener
+ extends DivideableAny
+ implements DynUnion, Serializable, ValueChangeListener
{
/**
* Use serialVersionUID for interoperability.
@@ -96,7 +96,7 @@ public class gnuDynUnion
discriminator =
factory.create_dyn_any_from_type_code(final_type.discriminator_type());
- ((abstractDynAny) discriminator).listener = this;
+ ((AbstractAny) discriminator).listener = this;
if (final_type.default_index() >= 0)
set_to_default_member();
@@ -114,7 +114,7 @@ public class gnuDynUnion
/*
* (non-Javadoc)
*
- * @see gnu.CORBA.DynAn.anyDivideable#to_any()
+ * @see gnu.CORBA.DynAn.DivideableAny#to_any()
*/
public Any to_any()
{
@@ -171,7 +171,7 @@ public class gnuDynUnion
gnuDynUnion other =
new gnuDynUnion(official_type, final_type, factory, orb);
other.discriminator = discriminator.copy();
- ((abstractDynAny) other.discriminator).listener = other;
+ ((AbstractAny) other.discriminator).listener = other;
if (array.length == 1)
{
other.array = new DynAny[] { other.discriminator };
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java
index c2db9479785..0c31d4093e2 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValue.java
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
+import gnu.CORBA.Minor;
import gnu.CORBA.Unexpected;
import org.omg.CORBA.Any;
@@ -66,7 +67,7 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class gnuDynValue extends abstractRecord implements DynValue,
+public class gnuDynValue extends RecordAny implements DynValue,
Serializable
{
/**
@@ -243,7 +244,7 @@ public class gnuDynValue extends abstractRecord implements DynValue,
/**
* Create a new instance.
*/
- protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
+ protected RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -301,9 +302,12 @@ public class gnuDynValue extends abstractRecord implements DynValue,
ValueFactory factory =
((org.omg.CORBA_2_3.ORB) orb).lookup_value_factory(official_type.id());
if (factory == null)
- throw new MARSHAL("Factory for " + official_type.id() +
- " not registered."
- );
+ {
+ MARSHAL m = new MARSHAL("Factory for " + official_type.id() +
+ " not registered.");
+ m.minor = Minor.Factory;
+ throw m;
+ }
OutputStream out = orb.create_output_stream();
diff --git a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java
index 66e18f3b2fe..a13e9fc2c50 100644
--- a/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java
+++ b/libjava/classpath/gnu/CORBA/DynAn/gnuDynValueBox.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.holderFactory;
+import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -65,7 +65,7 @@ import java.lang.reflect.Field;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynValueBox
- extends anyDivideable
+ extends DivideableAny
implements DynValueBox, Serializable
{
/**
@@ -208,7 +208,7 @@ public class gnuDynValueBox
{
try
{
- Streamable holder = holderFactory.createHolder(content);
+ Streamable holder = HolderLocator.createHolder(content);
Field v = holder.getClass().getField("value");
v.set(holder, s);
diff --git a/libjava/classpath/gnu/CORBA/EmptyExceptionHolder.java b/libjava/classpath/gnu/CORBA/EmptyExceptionHolder.java
index 890ca5fe51c..8fc8697a4f3 100644
--- a/libjava/classpath/gnu/CORBA/EmptyExceptionHolder.java
+++ b/libjava/classpath/gnu/CORBA/EmptyExceptionHolder.java
@@ -125,6 +125,7 @@ public class EmptyExceptionHolder
catch (Exception ex)
{
BAD_OPERATION bad = new BAD_OPERATION();
+ bad.minor = Minor.CDR;
bad.initCause(ex);
throw bad;
}
diff --git a/libjava/classpath/gnu/CORBA/ExceptionCreator.java b/libjava/classpath/gnu/CORBA/ExceptionCreator.java
deleted file mode 100644
index 8b75205056b..00000000000
--- a/libjava/classpath/gnu/CORBA/ExceptionCreator.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/* ExceptionCreator.java --
- 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. */
-
-
-package gnu.CORBA;
-
-import org.omg.CORBA.CompletionStatus;
-import org.omg.CORBA.CompletionStatusHelper;
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.SystemException;
-import org.omg.CORBA.UNKNOWN;
-import org.omg.CORBA.UserException;
-import org.omg.CORBA.portable.InputStream;
-import org.omg.CORBA.portable.OutputStream;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-
-/**
- * Creates the objects from the agreed IDL names.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class ExceptionCreator
-{
- /**
- * The standard OMG prefix.
- */
- public static final String OMG_PREFIX = "omg.org/";
-
- /**
- * The standard java prefix.
- */
- public static final String JAVA_PREFIX = "org.omg.";
-
- /**
- * Create the system exception with the given idl name.
- *
- * @param idl the exception IDL name, must match the syntax
- * "IDL:<class/name>:1.0".
- * @param minor the exception minor code.
- * @param completed the exception completion status.
- *
- * @return the created exception.
- */
- public static SystemException createSystemException(String idl, int minor,
- CompletionStatus completed
- )
- {
- try
- {
- String cl = toClassName(idl);
- Class exClass = Class.forName(cl);
-
- Constructor constructor =
- exClass.getConstructor(new Class[]
- {
- String.class, int.class,
- CompletionStatus.class
- }
- );
-
- Object exception =
- constructor.newInstance(new Object[]
- {
- " Remote exception " + idl + ", minor " +
- minor + ", " + completed + ".",
- new Integer(minor), completed
- }
- );
-
- return (SystemException) exception;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- return new UNKNOWN("Unsupported system exception", minor, completed);
- }
- }
-
- /**
- * Read the system exception from the given stream.
- * @param input the CDR stream to read from.
- * @return the exception that has been stored in the stream
- * (IDL name, minor code and completion status).
- */
- public static SystemException readSystemException(InputStream input)
- {
- String idl = input.read_string();
- int minor = input.read_ulong();
- CompletionStatus status = CompletionStatusHelper.read(input);
-
- SystemException exception =
- ExceptionCreator.createSystemException(idl, minor, status);
-
- return exception;
- }
-
- /**
- * Reads the user exception, having the given Id, from the
- * input stream. The id is expected to be in the form like
- * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
- * @param idl the exception idl name.
- * @param input the stream to read from.
- *
- * @return the loaded exception.
- * @return null if the helper class cannot be found.
- */
- public static UserException readUserException(String idl, InputStream input)
- {
- try
- {
- String helper = toHelperName(idl);
- Class helperClass = Class.forName(helper);
-
- Method read =
- helperClass.getMethod("read",
- new Class[]
- {
- org.omg.CORBA.portable.InputStream.class
- }
- );
-
- return (UserException) read.invoke(null, new Object[] { input });
- }
- catch (MARSHAL mex)
- {
- // This one is ok to throw
- throw mex;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- return null;
- }
- }
-
- /**
- * Writes the system exception data to CDR output stream.
- *
- * @param output a stream to write data to.
- * @param ex an exception to write.
- */
- public static void writeSystemException(OutputStream output,
- SystemException ex
- )
- {
- String exIDL = toIDL(ex.getClass().getName());
- output.write_string(exIDL);
- output.write_ulong(ex.minor);
- CompletionStatusHelper.write(output, ex.completed);
- }
-
- /**
- * Converts teh given IDL name to class name.
- *
- * @param IDL the idl name.
- *
- */
- protected static String toClassName(String IDL)
- {
- String s = IDL;
- int a = s.indexOf(':') + 1;
- int b = s.lastIndexOf(':');
-
- s = IDL.substring(a, b);
-
- if (s.startsWith(OMG_PREFIX))
- s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
-
- return s.replace('/', '.');
- }
-
- /**
- * Gets the helper class name from the string like
- * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
- * @param IDL the idl name.
- */
- protected static String toHelperName(String IDL)
- {
- String s = IDL;
- int a = s.indexOf(':') + 1;
- int b = s.lastIndexOf(':');
-
- s = IDL.substring(a, b);
-
- if (s.startsWith(OMG_PREFIX))
- s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
-
- return s.replace('/', '.') + "Helper";
- }
-
- /**
- * Convert the class name to IDL name.
- *
- * @param cn the class name.
- *
- * @return the idl name.
- */
- protected static String toIDL(String cn)
- {
- if (cn.startsWith(JAVA_PREFIX))
- cn = cn.substring(JAVA_PREFIX.length());
-
- cn = cn.replace('.', '/');
-
- return "IDL:" + OMG_PREFIX + cn + ":1.0";
- }
-}
diff --git a/libjava/classpath/gnu/CORBA/ForwardRequestHelper.java b/libjava/classpath/gnu/CORBA/ForwardRequestHelper.java
index c7fae5b061b..cbdf46f259a 100644
--- a/libjava/classpath/gnu/CORBA/ForwardRequestHelper.java
+++ b/libjava/classpath/gnu/CORBA/ForwardRequestHelper.java
@@ -81,6 +81,7 @@ public abstract class ForwardRequestHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ForwardRequest expected");
+ bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/CharSets_OSF.java b/libjava/classpath/gnu/CORBA/GIOP/CharSets_OSF.java
index f3f35dbaa21..bffb02678aa 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/CharSets_OSF.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/CharSets_OSF.java
@@ -47,7 +47,10 @@ import java.util.Set;
/**
* This class contains the codes, used to identify character sets
* in CORBA. These codes are defined in Open Software Foundation (OSF)
- * code set registry
+ * code set registry.
+ *
+ * The name of this class specially sets "OSF" apart if somebody would start
+ * searching Open Software Foundation abbreviation.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
diff --git a/libjava/classpath/gnu/CORBA/GIOP/CloseMessage.java b/libjava/classpath/gnu/CORBA/GIOP/CloseMessage.java
index d884329c440..38039c2ed21 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/CloseMessage.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/CloseMessage.java
@@ -38,15 +38,13 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.IOR;
+import gnu.CORBA.Minor;
import org.omg.CORBA.MARSHAL;
import java.io.IOException;
import java.io.OutputStream;
-import java.net.Socket;
-
/**
* The explicit command to close the connection.
*
@@ -60,6 +58,11 @@ import java.net.Socket;
public class CloseMessage
extends MessageHeader
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The singleton close message is typically enough, despite new
* instances may be instantiated if the specific version field
@@ -95,6 +98,7 @@ public class CloseMessage
catch (IOException ex)
{
MARSHAL m = new MARSHAL("Unable to flush the stream");
+ m.minor = Minor.Header;
m.initCause(ex);
throw m;
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/cxCodeSet.java b/libjava/classpath/gnu/CORBA/GIOP/CodeSetServiceContext.java
index 7f42c07f236..ab565db3797 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/cxCodeSet.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/CodeSetServiceContext.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.IOR;
import gnu.CORBA.IOR.CodeSets_profile;
@@ -51,7 +51,7 @@ import java.io.IOException;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class cxCodeSet
+public class CodeSetServiceContext
extends ServiceContext
{
/**
@@ -62,7 +62,7 @@ public class cxCodeSet
/**
* The standard component to include in the messages.
*/
- public static final cxCodeSet STANDARD = new cxCodeSet();
+ public static final CodeSetServiceContext STANDARD = new CodeSetServiceContext();
/**
* The encoding, used to transfer the narrow (1 byte) character data.
@@ -84,13 +84,13 @@ public class cxCodeSet
*
* @param contexts the array of contexts, can be null.
*/
- public static cxCodeSet find(ServiceContext[] contexts)
+ public static CodeSetServiceContext find(ServiceContext[] contexts)
{
if (contexts != null)
for (int i = 0; i < contexts.length; i++)
{
- if (contexts [ i ] instanceof cxCodeSet)
- return (cxCodeSet) contexts [ i ];
+ if (contexts [ i ] instanceof CodeSetServiceContext)
+ return (CodeSetServiceContext) contexts [ i ];
}
return STANDARD;
}
@@ -102,12 +102,12 @@ public class cxCodeSet
* If you take this task, scan 'TODO character encoding' for
* relevant places.
*/
- public static cxCodeSet negotiate(IOR.CodeSets_profile profile)
+ public static CodeSetServiceContext negotiate(IOR.CodeSets_profile profile)
{
if (profile.negotiated != null)
return profile.negotiated;
- cxCodeSet use = new cxCodeSet();
+ CodeSetServiceContext use = new CodeSetServiceContext();
use.char_data =
negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);
@@ -124,9 +124,9 @@ public class cxCodeSet
* Read the context from the given stream. Does not read the
* code sets id.
*/
- public void readContext(cdrInput input)
+ public void readContext(AbstractCdrInput input)
{
- cdrInput encap = input.read_encapsulation();
+ AbstractCdrInput encap = input.read_encapsulation();
char_data = encap.read_ulong();
wide_char_data = encap.read_ulong();
@@ -145,11 +145,11 @@ public class cxCodeSet
* Write the context to the given stream, including the code
* sets id.
*/
- public void write(cdrOutput output)
+ public void write(AbstractCdrOutput output)
{
output.write_ulong(ID);
- cdrOutput enout = output.createEncapsulation();
+ AbstractCdrOutput enout = output.createEncapsulation();
enout.write_long(char_data);
enout.write_ulong(wide_char_data);
diff --git a/libjava/classpath/gnu/CORBA/GIOP/contextSupportingHeader.java b/libjava/classpath/gnu/CORBA/GIOP/ContextHandler.java
index ba6c1f88d8f..77ea20e38f0 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/contextSupportingHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/ContextHandler.java
@@ -1,4 +1,4 @@
-/* contextSupportingHeader.java --
+/* ContextHandler.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import org.omg.CORBA.BAD_INV_ORDER;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public abstract class contextSupportingHeader
+public abstract class ContextHandler
{
/**
diff --git a/libjava/classpath/gnu/CORBA/GIOP/ErrorMessage.java b/libjava/classpath/gnu/CORBA/GIOP/ErrorMessage.java
index 8d3b3539be5..99942fee359 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/ErrorMessage.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/ErrorMessage.java
@@ -38,7 +38,9 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
+import gnu.CORBA.Minor;
import java.io.IOException;
import java.io.OutputStream;
@@ -46,6 +48,7 @@ import java.io.OutputStream;
import java.net.Socket;
import org.omg.CORBA.MARSHAL;
+import org.omg.CORBA.ORB;
/**
* The error message is sent in response to the message, encoded
@@ -59,6 +62,11 @@ import org.omg.CORBA.MARSHAL;
public class ErrorMessage
extends MessageHeader
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* Create a new error message, setting the message field
* to the {@link MESSAGE_ERROR} and the version number to
@@ -73,14 +81,22 @@ public class ErrorMessage
/**
* Send the error message to the given IOR address.
*
- * @param to the IOR address (host and port, other fields
+ * @param ior the IOR address (host and port, other fields
* are not used).
+ *
+ * @param orb the ORB, sending the error message.
*/
- public void send(IOR ior)
+ public void send(IOR ior, ORB orb)
{
try
{
- Socket socket = new Socket(ior.Internet.host, ior.Internet.port);
+ Socket socket;
+
+ if (orb instanceof OrbFunctional)
+ socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
+ ior.Internet.host, ior.Internet.port);
+ else
+ socket = new Socket(ior.Internet.host, ior.Internet.port);
OutputStream socketOutput = socket.getOutputStream();
write(socketOutput);
@@ -90,6 +106,7 @@ public class ErrorMessage
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/MessageHeader.java b/libjava/classpath/gnu/CORBA/GIOP/MessageHeader.java
index 61c46e11ea4..e1bdb512bfb 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/MessageHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/MessageHeader.java
@@ -1,4 +1,4 @@
-/* MessageHeader.java -- GIOP 1.0 message header.
+/* MessageHeader.java -- GIOP message header.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,33 +38,39 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
+import gnu.CORBA.Minor;
+import gnu.CORBA.Version;
+import gnu.CORBA.CDR.BigEndianInputStream;
import gnu.CORBA.CDR.BigEndianOutputStream;
import gnu.CORBA.CDR.LittleEndianInputStream;
import gnu.CORBA.CDR.LittleEndianOutputStream;
-import gnu.CORBA.CDR.abstractDataOutputStream;
-import gnu.CORBA.Version;
+import gnu.CORBA.CDR.AbstractDataInput;
+import gnu.CORBA.CDR.AbstractDataOutput;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.portable.IDLEntity;
-import java.io.DataInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
-
+import java.net.Socket;
import java.util.Arrays;
-import gnu.CORBA.CDR.BigEndianInputStream;
-import gnu.CORBA.CDR.abstractDataInputStream;
-import java.io.InputStream;
/**
* The GIOP message header.
- *
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class MessageHeader
implements IDLEntity
{
/**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
* Request message.
*/
public static final byte REQUEST = 0;
@@ -80,16 +86,15 @@ public class MessageHeader
public static final byte CANCEL_REQUEST = 2;
/**
- * Locate request message, used to check the server ability to
- * process requests for the object reference.
- * This message is also used to get the
+ * 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.
*/
public static final byte LOCATE_REQUEST = 3;
/**
- * Locate reply message, sent in response to the
- * {@link #LocateRequest} message.
+ * Locate reply message, sent in response to the {@link #LocateRequest}
+ * message.
*/
public static final byte LOCATE_REPLY = 4;
@@ -104,8 +109,8 @@ public class MessageHeader
public static final byte MESSAGE_ERROR = 6;
/**
- * The fragment messge, following the previous message that
- * has more fragments flag set. Added in GIOP 1.1
+ * The fragment messge, following the previous message that has more fragments
+ * flag set. Added in GIOP 1.1
*/
public static final byte FRAGMENT = 7;
@@ -117,12 +122,9 @@ public class MessageHeader
/**
* The message type names.
*/
- protected static String[] types =
- new String[]
- {
- "Request", "Reply", "Cancel", "Locate request", "Locate reply",
- "Close connection", "Error", "Fragment"
- };
+ protected static String[] types = new String[] { "Request", "Reply",
+ "Cancel", "Locate request", "Locate reply", "Close connection", "Error",
+ "Fragment" };
/**
* The GIOP version. Initialised to 1.0 .
@@ -154,7 +156,7 @@ public class MessageHeader
/**
* Create an empty message header, corresponding the given version.
- *
+ *
* @param major the major message header version.
* @param minor the minot message header version.
*/
@@ -164,8 +166,8 @@ public class MessageHeader
}
/**
- * Checks if the message is encoded in the Big Endian, most significant
- * byte first.
+ * Checks if the message is encoded in the Big Endian, most significant byte
+ * first.
*/
public boolean isBigEndian()
{
@@ -173,10 +175,18 @@ public class MessageHeader
}
/**
+ * Checks if the message is partial, and more subsequent fragments follow.
+ */
+ public boolean moreFragmentsFollow()
+ {
+ return (flags & 0x2) != 0;
+ }
+
+ /**
* Set the encoding to use.
- *
- * @param use_big_endian if true (default), the Big Endian
- * encoding is used. If false, the Little Endian encoding is used.
+ *
+ * @param use_big_endian if true (default), the Big Endian encoding is used.
+ * If false, the Little Endian encoding is used.
*/
public void setBigEndian(boolean use_big_endian)
{
@@ -196,16 +206,16 @@ public class MessageHeader
/**
* Get the message type as string.
- *
+ *
* @param type the message type as int (the field {@link message_type}).
- *
+ *
* @return the message type as string.
*/
public String getTypeString(int type)
{
try
{
- return types [ type ];
+ return types[type];
}
catch (ArrayIndexOutOfBoundsException ex)
{
@@ -215,10 +225,10 @@ public class MessageHeader
/**
* Creates reply header, matching the message header version number.
- *
+ *
* @return one of {@link gnu.CORBA.GIOP.v1_0.ReplyHeader},
- * {@link gnu.CORBA.GIOP.v1_2.ReplyHeader}, etc - depending on
- * the version number in this header.
+ * {@link gnu.CORBA.GIOP.v1_2.ReplyHeader}, etc - depending on the version
+ * number in this header.
*/
public ReplyHeader create_reply_header()
{
@@ -230,10 +240,10 @@ public class MessageHeader
/**
* Creates request header, matching the message header version number.
- *
+ *
* @return one of {@link gnu.CORBA.GIOP.v1_0.RequestHeader},
- * {@link gnu.CORBA.GIOP.v1_2.RequestHeader}, etc - depending on
- * the version number in this header.
+ * {@link gnu.CORBA.GIOP.v1_2.RequestHeader}, etc - depending on the version
+ * number in this header.
*/
public RequestHeader create_request_header()
{
@@ -261,24 +271,28 @@ public class MessageHeader
/**
* Read the header from the stream.
- *
+ *
* @param istream a stream to read from.
- *
+ *
* @throws MARSHAL if this is not a GIOP 1.0 header.
*/
public void read(java.io.InputStream istream)
- throws MARSHAL
+ throws MARSHAL
{
try
{
- byte[] xMagic = new byte[ MAGIC.length ];
+ byte[] xMagic = new byte[MAGIC.length];
istream.read(xMagic);
if (!Arrays.equals(xMagic, MAGIC))
- throw new MARSHAL("Not a GIOP message");
+ {
+ MARSHAL m = new MARSHAL("Not a GIOP message");
+ m.minor = Minor.Giop;
+ throw m;
+ }
version = Version.read_version(istream);
- abstractDataInputStream din;
+ AbstractDataInput din;
flags = (byte) istream.read();
@@ -295,6 +309,7 @@ public class MessageHeader
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
@@ -302,26 +317,26 @@ public class MessageHeader
/**
* Get the short string summary of the message.
- *
+ *
* @return a short message summary.
*/
public String toString()
{
- return "GIOP " + version + ", " + (isBigEndian() ? "Big" : "Little") +
- " endian, " + getTypeString(message_type) + ", " + message_size +
- " bytes. ";
+ return "GIOP " + version + ", " + (isBigEndian() ? "Big" : "Little")
+ + " endian, " + getTypeString(message_type) + ", " + message_size
+ + " bytes. ";
}
/**
* Write the header to stream.
- *
+ *
* @param out a stream to write into.
*/
public void write(java.io.OutputStream out)
{
try
{
- abstractDataOutputStream dout;
+ AbstractDataOutput dout;
if (isBigEndian())
dout = new BigEndianOutputStream(out);
@@ -333,18 +348,99 @@ public class MessageHeader
// Write version number.
version.write((OutputStream) dout);
-
dout.write(flags);
-
dout.write(message_type);
-
dout.writeInt(message_size);
}
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
}
+
+ /**
+ * Read data, followed by the message header. Handle fragmented messages.
+ *
+ * @param source the data source to read from.
+ * @param service the socket on that the time outs are set. Can be null (no
+ * timeouts are set).
+ * @param to_read the timeout while reading the message.
+ * @param to_pause the timeout for pauses between the message parts.
+ */
+ public byte[] readMessage(InputStream source, Socket service, int to_read,
+ int to_pause)
+ {
+ try
+ {
+ byte[] r = new byte[message_size];
+
+ int n = 0;
+ if (service != null)
+ service.setSoTimeout(to_read);
+
+ reading: while (n < r.length)
+ {
+ n += source.read(r, n, r.length - n);
+ }
+ if (service != null)
+ service.setSoTimeout(to_pause);
+
+ // Read the message remainder if the message is fragmented.
+ if (moreFragmentsFollow())
+ {
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream(
+ 2 * r.length);
+ buffer.write(r);
+
+ if (r.length < 10)
+ // Increase the buffer size if the default value (size of the
+ // previous message) is really too small.
+ r = new byte[1024];
+
+ MessageHeader h2 = new MessageHeader();
+
+ do
+ {
+ h2.read(source);
+
+ int dn;
+
+ n = 0;
+ reading: while (n < h2.message_size)
+ {
+ dn = source.read(r, 0, h2.message_size - n);
+
+ if (n == 0 && service != null)
+ service.setSoTimeout(to_read);
+
+ if (n == 0 && version.since_inclusive(1, 2))
+ {
+ // Skip the four byte request id.
+ buffer.write(r, 4, dn - 4);
+ }
+ else
+ buffer.write(r, 0, dn);
+ n = +dn;
+ }
+
+ if (service != null)
+ service.setSoTimeout(to_pause);
+ }
+ while (h2.moreFragmentsFollow());
+ return buffer.toByteArray();
+ }
+ else
+ return r;
+ }
+ catch (IOException ioex)
+ {
+ MARSHAL m = new MARSHAL("Unable to read the message continuation.");
+ m.minor = Minor.Header;
+ m.initCause(ioex);
+ throw m;
+ }
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/GIOP/ReplyHeader.java b/libjava/classpath/gnu/CORBA/GIOP/ReplyHeader.java
index f0f409394e6..d1448290331 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/ReplyHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/ReplyHeader.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
/**
* The header of the standard reply.
@@ -47,7 +47,7 @@ import gnu.CORBA.CDR.cdrOutput;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class ReplyHeader
- extends contextSupportingHeader
+ extends ContextHandler
{
/**
* Reply status, if no exception occured.
@@ -121,7 +121,7 @@ public abstract class ReplyHeader
*
* @param in a stream to read from.
*/
- public abstract void read(cdrInput in);
+ public abstract void read(AbstractCdrInput in);
/**
* Returns a short string representation.
@@ -141,5 +141,5 @@ public abstract class ReplyHeader
*
* @param out a stream to write into.
*/
- public abstract void write(cdrOutput out);
+ public abstract void write(AbstractCdrOutput out);
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/RequestHeader.java b/libjava/classpath/gnu/CORBA/GIOP/RequestHeader.java
index 17cccb8834a..3cfadfd7867 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/RequestHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/RequestHeader.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.portable.IDLEntity;
@@ -49,7 +49,7 @@ import org.omg.CORBA.portable.IDLEntity;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class RequestHeader
- extends contextSupportingHeader
+ extends ContextHandler
implements IDLEntity
{
/**
@@ -137,7 +137,7 @@ public abstract class RequestHeader
*
* @param in a stream to read from.
*/
- public abstract void read(cdrInput in);
+ public abstract void read(AbstractCdrInput in);
/**
* Return a string representation.
@@ -149,6 +149,6 @@ public abstract class RequestHeader
*
* @param out a stream to write into.
*/
- public abstract void write(cdrOutput out);
+ public abstract void write(AbstractCdrOutput out);
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java b/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java
index 29a8ea8ac77..78519510cb7 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/ServiceContext.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
@@ -48,7 +48,7 @@ import org.omg.CORBA.portable.IDLEntity;
/**
* Contains the ORB service data being passed.
- *
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ServiceContext
@@ -59,6 +59,50 @@ public class ServiceContext
*/
private static final long serialVersionUID = 1;
+ /* Standard values for the context_id. */
+ public static final int TransactionService = 0;
+
+ /**
+ * Defines code sets, used to encode wide and narrow characters. Required for
+ * messages with data structures, involving wide characters.
+ */
+ public static final int CodeSets = 1;
+
+ public static final int ChainBypassCheck = 2;
+
+ public static final int ChainBypassInfo = 3;
+
+ public static final int LogicalThreadId = 4;
+
+ public static final int BI_DIR_IIOP = 5;
+
+ public static final int SendingContextRunTime = 6;
+
+ public static final int INVOCATION_POLICIES = 7;
+
+ public static final int FORWARDED_IDENTITY = 8;
+
+ /**
+ * Contains exception details if exception being transferred is other than
+ * System or User exception. javax.rmi uses this context to transfer arbitrary
+ * java exceptions as CORBA value types.
+ */
+ public static final int UnknownExceptionInfo = 9;
+
+ public static final int RTCorbaPriority = 10;
+
+ public static final int RTCorbaPriorityRange = 11;
+
+ public static final int FT_GROUP_VERSION = 12;
+
+ public static final int FT_REQUEST = 13;
+
+ public static final int ExceptionDetailMessage = 14;
+
+ public static final int SecurityAttributeService = 15;
+
+ public static final int ActivityService = 16;
+
/**
* The context id (for instance, 0x1 for code sets context). At the moment of
* writing, the OMG defines 16 standard values and provides rules to register
@@ -90,18 +134,18 @@ public class ServiceContext
/**
* Read the context values from the stream.
- *
+ *
* @param istream a stream to read from.
*/
- public static ServiceContext read(cdrInput istream)
+ public static ServiceContext read(AbstractCdrInput istream)
{
int id = istream.read_ulong();
switch (id)
{
- case cxCodeSet.ID:
+ case CodeSetServiceContext.ID:
- cxCodeSet codeset = new cxCodeSet();
+ CodeSetServiceContext codeset = new CodeSetServiceContext();
codeset.readContext(istream);
return codeset;
@@ -117,7 +161,7 @@ public class ServiceContext
/**
* Read a sequence of contexts from the input stream.
*/
- public static ServiceContext[] readSequence(cdrInput istream)
+ public static ServiceContext[] readSequence(AbstractCdrInput istream)
{
int size = istream.read_long();
ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[size];
@@ -128,10 +172,10 @@ public class ServiceContext
/**
* Write the context values into the stream.
- *
+ *
* @param ostream a stream to write the data to.
*/
- public void write(cdrOutput ostream)
+ public void write(AbstractCdrOutput ostream)
{
ostream.write_ulong(context_id);
ostream.write_sequence(context_data);
@@ -140,7 +184,7 @@ public class ServiceContext
/**
* Write the sequence of contexts into the input stream.
*/
- public static void writeSequence(cdrOutput ostream, ServiceContext[] value)
+ public static void writeSequence(AbstractCdrOutput ostream, ServiceContext[] value)
{
ostream.write_long(value.length);
for (int i = 0; i < value.length; i++)
@@ -172,8 +216,7 @@ public class ServiceContext
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
- + service_context.context_id, 15,
- CompletionStatus.COMPLETED_NO);
+ + service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
else
cx[exists] = service_context;
}
@@ -205,15 +248,13 @@ public class ServiceContext
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
- + service_context.context_id, 15,
- CompletionStatus.COMPLETED_NO);
+ + service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
else
cx[exists] = new ServiceContext(service_context);
return cx;
}
}
-
/**
* Find context with the given name in the context array.
*/
@@ -227,8 +268,8 @@ public class ServiceContext
}
/**
- * Find context with the given name in the context array,
- * converting into org.omg.IOP.ServiceContext.
+ * Find context with the given name in the context array, converting into
+ * org.omg.IOP.ServiceContext.
*/
public static org.omg.IOP.ServiceContext findContext(int ctx_name,
ServiceContext[] cx)
@@ -240,6 +281,17 @@ public class ServiceContext
}
/**
+ * Find context with the given name in the context array without conversions.
+ */
+ public static ServiceContext find(int ctx_name, ServiceContext[] cx)
+ {
+ for (int i = 0; i < cx.length; i++)
+ if (cx[i].context_id == ctx_name)
+ return cx[i];
+ return null;
+ }
+
+ /**
* Return a string representation.
*/
public String toString()
diff --git a/libjava/classpath/gnu/CORBA/GIOP/v1_0/ReplyHeader.java b/libjava/classpath/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
index 27181ca6347..c085c17fb9b 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/v1_0/ReplyHeader.java
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_0;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
/**
* The header of the standard reply.
@@ -98,13 +98,13 @@ public class ReplyHeader
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
service_context = ServiceContext.readSequence(in);
request_id = in.read_ulong();
reply_status = in.read_ulong();
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -128,12 +128,12 @@ public class ReplyHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
ServiceContext.writeSequence(out, service_context);
out.write_ulong(request_id);
out.write_ulong(reply_status);
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/v1_0/RequestHeader.java b/libjava/classpath/gnu/CORBA/GIOP/v1_0/RequestHeader.java
index 7ede4e5b926..5cf723cbc42 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/v1_0/RequestHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/v1_0/RequestHeader.java
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_0;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.portable.IDLEntity;
@@ -112,7 +112,7 @@ public class RequestHeader
*
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
service_context = ServiceContext.readSequence(in);
request_id = in.read_ulong();
@@ -121,7 +121,7 @@ public class RequestHeader
operation = in.read_string();
requesting_principal = in.read_sequence();
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -143,7 +143,7 @@ public class RequestHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
ServiceContext.writeSequence(out, service_context);
out.write_ulong(request_id);
@@ -152,6 +152,6 @@ public class RequestHeader
out.write_string(operation);
out.write_sequence(requesting_principal);
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/v1_2/ReplyHeader.java b/libjava/classpath/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
index c3f51a37b91..3fc1541d9ab 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/v1_2/ReplyHeader.java
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_2;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
/**
* GIOP 1.2 reply header.
@@ -56,7 +56,7 @@ public class ReplyHeader
*/
public ReplyHeader()
{
- service_context = new ServiceContext[] { cxCodeSet.STANDARD };
+ service_context = new ServiceContext[] { CodeSetServiceContext.STANDARD };
}
/**
@@ -89,13 +89,13 @@ public class ReplyHeader
*
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
request_id = in.read_ulong();
reply_status = in.read_ulong();
service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -107,12 +107,12 @@ public class ReplyHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
out.write_ulong(request_id);
out.write_ulong(reply_status);
gnu.CORBA.GIOP.ServiceContext.writeSequence(out, service_context);
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/libjava/classpath/gnu/CORBA/GIOP/v1_2/RequestHeader.java b/libjava/classpath/gnu/CORBA/GIOP/v1_2/RequestHeader.java
index d294d006723..6b37b6c676c 100644
--- a/libjava/classpath/gnu/CORBA/GIOP/v1_2/RequestHeader.java
+++ b/libjava/classpath/gnu/CORBA/GIOP/v1_2/RequestHeader.java
@@ -38,10 +38,11 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_2;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.Minor;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import java.io.IOException;
@@ -58,6 +59,11 @@ import org.omg.CORBA.NO_IMPLEMENT;
public class RequestHeader
extends gnu.CORBA.GIOP.v1_0.RequestHeader
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* Indicates that the object is addressed by the object key.
*/
@@ -89,7 +95,7 @@ public class RequestHeader
*/
public RequestHeader()
{
- service_context = new ServiceContext[] { cxCodeSet.STANDARD };
+ service_context = new ServiceContext[] { CodeSetServiceContext.STANDARD };
}
/**
@@ -123,7 +129,7 @@ public class RequestHeader
*
* @param in a stream to read from.
*/
- public void read(cdrInput in)
+ public void read(AbstractCdrInput in)
{
try
{
@@ -150,20 +156,23 @@ public class RequestHeader
throw new NO_IMPLEMENT("Object addressing by by IOR addressing info");
default :
- throw new MARSHAL("Unknow addressing method in request, " +
+ MARSHAL m = new MARSHAL("Unknow addressing method in request, " +
AddressingDisposition
);
+ m.minor = Minor.UnsupportedAddressing;
+ throw m;
}
operation = in.read_string();
service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
// No requesting principal in this new format.
- in.setCodeSet(cxCodeSet.find(service_context));
+ in.setCodeSet(CodeSetServiceContext.find(service_context));
}
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
@@ -186,7 +195,7 @@ public class RequestHeader
*
* @param out a stream to write into.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
out.write_ulong(request_id);
@@ -208,6 +217,6 @@ public class RequestHeader
ServiceContext.writeSequence(out, service_context);
// No requesting principal in this new format.
- out.setCodeSet(cxCodeSet.find(service_context));
+ out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
diff --git a/libjava/classpath/gnu/CORBA/universalHolder.java b/libjava/classpath/gnu/CORBA/GeneralHolder.java
index c20dac442dd..ffba69d79f6 100644
--- a/libjava/classpath/gnu/CORBA/universalHolder.java
+++ b/libjava/classpath/gnu/CORBA/GeneralHolder.java
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.MARSHAL;
@@ -60,18 +60,18 @@ import java.io.IOException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class universalHolder
+public class GeneralHolder
implements Streamable
{
/**
* The binary data, stored inside this holder.
*/
- private cdrBufOutput value = new cdrBufOutput();
+ private BufferedCdrOutput value = new BufferedCdrOutput();
/**
* Create the universal holder that uses the given buffer to store the data.
*/
- public universalHolder(cdrBufOutput buffer)
+ public GeneralHolder(BufferedCdrOutput buffer)
{
value = buffer;
}
@@ -89,9 +89,9 @@ public class universalHolder
{
try
{
- if (input instanceof cdrBufInput)
+ if (input instanceof BufferredCdrInput)
{
- cdrBufInput b = (cdrBufInput) input;
+ BufferredCdrInput b = (BufferredCdrInput) input;
value.write(b.buffer.getBuffer());
}
else
@@ -110,6 +110,7 @@ public class universalHolder
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Any;
t.initCause(ex);
throw t;
}
@@ -122,7 +123,9 @@ public class universalHolder
*/
public TypeCode _type()
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.minor = Minor.Inappropriate;
+ throw bad;
}
/**
@@ -142,6 +145,7 @@ public class universalHolder
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
+ t.minor = Minor.Any;
t.initCause(ex);
throw t;
}
@@ -158,13 +162,13 @@ public class universalHolder
/**
* Clone.
*/
- public universalHolder Clone()
+ public GeneralHolder Clone()
{
try
{
- cdrBufOutput nb = new cdrBufOutput(value.buffer.size());
+ BufferedCdrOutput nb = new BufferedCdrOutput(value.buffer.size());
value.buffer.writeTo(nb);
- return new universalHolder(nb);
+ return new GeneralHolder(nb);
}
catch (IOException ex)
{
diff --git a/libjava/classpath/gnu/CORBA/holderFactory.java b/libjava/classpath/gnu/CORBA/HolderLocator.java
index 159d22332dc..edd4d2cf7a4 100644
--- a/libjava/classpath/gnu/CORBA/holderFactory.java
+++ b/libjava/classpath/gnu/CORBA/HolderLocator.java
@@ -1,4 +1,4 @@
-/* holderFactory.java --
+/* HolderLocator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -75,7 +75,7 @@ import org.omg.CORBA.ObjectHolder;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class holderFactory
+public class HolderLocator
{
/**
* The array, sufficiently large to use any {@link TCKind}._tk* constant as
diff --git a/libjava/classpath/gnu/CORBA/IOR.java b/libjava/classpath/gnu/CORBA/IOR.java
index 02e94aa6426..5d6d3152f8f 100644
--- a/libjava/classpath/gnu/CORBA/IOR.java
+++ b/libjava/classpath/gnu/CORBA/IOR.java
@@ -38,12 +38,12 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
-import gnu.CORBA.CDR.cdrInput;
-import gnu.CORBA.CDR.cdrOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.CharSets_OSF;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
@@ -59,6 +59,8 @@ import org.omg.IOP.TaggedProfileHelper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.zip.Adler32;
/**
* The implementaton of the Interoperable Object Reference (IOR). IOR can be
@@ -174,16 +176,16 @@ public class IOR
* The negotiated coding result for this IOR. Saves time, requred for
* negotiation computations.
*/
- public cxCodeSet negotiated;
+ public CodeSetServiceContext negotiated;
/**
* Read the code set profile information from the given input stream.
*
* @param profile a stream to read from.
*/
- public void read(cdrInput profile)
+ public void read(AbstractCdrInput profile)
{
- cdrBufInput encapsulation = profile.read_encapsulation();
+ BufferredCdrInput encapsulation = profile.read_encapsulation();
narrow.read(encapsulation);
wide.read(encapsulation);
}
@@ -201,9 +203,9 @@ public class IOR
*
* @param profile a stream to write into.
*/
- public void write(cdrOutput profile)
+ public void write(AbstractCdrOutput profile)
{
- cdrOutput encapsulation = profile.createEncapsulation();
+ AbstractCdrOutput encapsulation = profile.createEncapsulation();
narrow.write(encapsulation);
wide.write(encapsulation);
try
@@ -274,13 +276,13 @@ public class IOR
/**
* Write the internet profile (except the heading tag.
*/
- public void write(cdrOutput out)
+ public void write(AbstractCdrOutput out)
{
try
{
// Need to write the Internet profile into the separate
// stream as we must know the size in advance.
- cdrOutput b = out.createEncapsulation();
+ AbstractCdrOutput b = out.createEncapsulation();
version.write(b);
b.write_string(host);
@@ -310,6 +312,7 @@ public class IOR
catch (Exception e)
{
MARSHAL m = new MARSHAL("Unable to write Internet profile.");
+ m.minor = Minor.IOR;
m.initCause(e);
throw m;
}
@@ -392,7 +395,7 @@ public class IOR
buf.write(cx);
}
- cdrBufInput cdr = new cdrBufInput(buf.toByteArray());
+ BufferredCdrInput cdr = new BufferredCdrInput(buf.toByteArray());
r._read(cdr);
return r;
@@ -411,7 +414,7 @@ public class IOR
* @param c a stream to read from.
* @throws IOException if the stream throws it.
*/
- public void _read(cdrInput c)
+ public void _read(AbstractCdrInput c)
throws IOException, BAD_PARAM
{
int endian;
@@ -433,13 +436,13 @@ public class IOR
* If the stream contains a null value, the Id and Internet fields become
* equal to null. Otherwise Id contains some string (possibly empty).
*
- * Id is checked for null in cdrInput that then returns null instead of
+ * Id is checked for null in AbstractCdrInput that then returns null instead of
* object.
*
* @param c a stream to read from.
* @throws IOException if the stream throws it.
*/
- public void _read_no_endian(cdrInput c)
+ public void _read_no_endian(AbstractCdrInput c)
throws IOException, BAD_PARAM
{
Id = c.read_string();
@@ -456,7 +459,7 @@ public class IOR
for (int i = 0; i < n_profiles; i++)
{
int tag = c.read_long();
- cdrBufInput profile = c.read_encapsulation();
+ BufferredCdrInput profile = c.read_encapsulation();
if (tag == Internet_profile.TAG_INTERNET_IOP)
{
@@ -515,7 +518,7 @@ public class IOR
* Write this IOR record to the provided CDR stream. This procedure writes the
* zero (Big Endian) marker first.
*/
- public void _write(cdrOutput out)
+ public void _write(AbstractCdrOutput out)
{
// Always use Big Endian.
out.write(0);
@@ -528,7 +531,7 @@ public class IOR
* The null value is written as defined in OMG specification (zero length
* string, followed by an empty set of profiles).
*/
- public static void write_null(cdrOutput out)
+ public static void write_null(AbstractCdrOutput out)
{
// Empty Id string.
out.write_string("");
@@ -541,7 +544,7 @@ public class IOR
* Write this IOR record to the provided CDR stream. The procedure writed data
* in Big Endian, but does NOT add any endian marker to the beginning.
*/
- public void _write_no_endian(cdrOutput out)
+ public void _write_no_endian(AbstractCdrOutput out)
{
// Write repository id.
out.write_string(Id);
@@ -595,7 +598,7 @@ public class IOR
*/
public String toStringifiedReference()
{
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
_write(out);
@@ -675,7 +678,7 @@ public class IOR
TaggedComponent[] present;
if (profile.profile_data.length > 0)
{
- cdrBufInput in = new cdrBufInput(profile.profile_data);
+ BufferredCdrInput in = new BufferredCdrInput(profile.profile_data);
present = new TaggedComponent[in.read_long()];
@@ -687,7 +690,7 @@ public class IOR
else
present = new TaggedComponent[0];
- cdrBufOutput out = new cdrBufOutput(profile.profile_data.length
+ BufferedCdrOutput out = new BufferedCdrOutput(profile.profile_data.length
+ component.component_data.length
+ 8);
@@ -715,4 +718,51 @@ public class IOR
// The future supported tagged profiles should be added here.
throw new BAD_PARAM("Unsupported profile type " + profile.tag);
}
+
+ /**
+ * Checks for equality.
+ */
+ public boolean equals(Object x)
+ {
+ if (x instanceof IOR)
+ {
+ boolean keys;
+ boolean hosts = true;
+
+ IOR other = (IOR) x;
+
+ if (Internet==null || other.Internet==null)
+ return Internet == other.Internet;
+
+ if (key != null && other.key != null)
+ keys = Arrays.equals(key, other.key);
+ else
+ keys = key == other.key;
+
+ if (Internet != null && Internet.host != null)
+ if (other.Internet != null && other.Internet.host != null)
+ hosts = other.Internet.host.equals(Internet.host);
+
+ return keys & hosts && Internet.port==other.Internet.port;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the hashcode of this IOR.
+ */
+ public int hashCode()
+ {
+ Adler32 adler = new Adler32();
+ if (key != null)
+ adler.update(key);
+ if (Internet != null)
+ {
+ if (Internet.host != null)
+ adler.update(Internet.host.getBytes());
+ adler.update(Internet.port);
+ }
+ return (int) adler.getValue();
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/Interceptor/IORInterceptors.java b/libjava/classpath/gnu/CORBA/Interceptor/IORInterceptors.java
index 88756988c92..2b77de58e0e 100644
--- a/libjava/classpath/gnu/CORBA/Interceptor/IORInterceptors.java
+++ b/libjava/classpath/gnu/CORBA/Interceptor/IORInterceptors.java
@@ -38,16 +38,20 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
+import org.omg.CORBA.OBJ_ADAPTER;
+import org.omg.CORBA.OMGVMCID;
import org.omg.PortableInterceptor.IORInfo;
import org.omg.PortableInterceptor.IORInterceptor;
import org.omg.PortableInterceptor.IORInterceptorOperations;
+import org.omg.PortableInterceptor.IORInterceptor_3_0Operations;
+import org.omg.PortableInterceptor.ObjectReferenceTemplate;
/**
* A block of the all registered IOR interceptors.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class IORInterceptors implements IORInterceptorOperations
+public class IORInterceptors implements IORInterceptor_3_0Operations
{
/**
* The array of all registered IOR interceptors.
@@ -106,4 +110,81 @@ public class IORInterceptors implements IORInterceptorOperations
{
return getClass().getName();
}
+
+ /**
+ * Call this method for all registered CORBA 3.0 interceptors.
+ */
+ public void adapter_manager_state_changed(int adapterManagerId, short adapterState)
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ try
+ {
+ if (interceptors[i] instanceof IORInterceptor_3_0Operations)
+ {
+ ((IORInterceptor_3_0Operations) interceptors[i]).
+ adapter_manager_state_changed(adapterManagerId, adapterState);
+ }
+ }
+ catch (Exception exc)
+ {
+ OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed");
+ oa.initCause(exc);
+ oa.minor = 6 | OMGVMCID.value;
+ throw oa;
+ }
+ }
+ }
+
+ /**
+ * Call this method for all registered CORBA 3.0 interceptors.
+ */
+ public void adapter_state_changed(ObjectReferenceTemplate[] adapters, short adaptersState)
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ try
+ {
+ if (interceptors[i] instanceof IORInterceptor_3_0Operations)
+ {
+ ((IORInterceptor_3_0Operations) interceptors[i]).
+ adapter_state_changed(adapters, adaptersState);
+ }
+ }
+ catch (Exception exc)
+ {
+ OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed");
+ oa.initCause(exc);
+ oa.minor = 6 | OMGVMCID.value;
+ throw oa;
+ }
+ }
+ }
+
+ /**
+ * Call this method for all registered CORBA 3.0 interceptors.
+ *
+ * @throws OBJ_ADAPTER minor 6 on any failure (as defined by OMG specs).
+ */
+ public void components_established(IORInfo info)
+ {
+ for (int i = 0; i < interceptors.length; i++)
+ {
+ try
+ {
+ if (interceptors[i] instanceof IORInterceptor_3_0Operations)
+ {
+ ((IORInterceptor_3_0Operations) interceptors[i]).
+ components_established(info);
+ }
+ }
+ catch (Exception exc)
+ {
+ OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed");
+ oa.initCause(exc);
+ oa.minor = 6 | OMGVMCID.value;
+ throw oa;
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/Interceptor/Registrator.java b/libjava/classpath/gnu/CORBA/Interceptor/Registrator.java
index ff35cd0c85e..4bb895bb376 100644
--- a/libjava/classpath/gnu/CORBA/Interceptor/Registrator.java
+++ b/libjava/classpath/gnu/CORBA/Interceptor/Registrator.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.ObjectCreator;
import gnu.CORBA.gnuCodecFactory;
import org.omg.CORBA.BAD_INV_ORDER;
@@ -87,7 +88,7 @@ public class Registrator extends LocalObject implements ORBInitInfo
/**
* The agreed properties prefix.
*/
- public final static String m_prefix =
+ public static final String m_prefix =
"org.omg.PortableInterceptor.ORBInitializerClass.";
/**
@@ -182,7 +183,8 @@ public class Registrator extends LocalObject implements ORBInitInfo
try
{
String cn = sk.substring(m_prefix.length());
- Class iClass = Class.forName(cn);
+ Class iClass = ObjectCreator.forName(cn);
+
ORBInitializer initializer =
(ORBInitializer) iClass.newInstance();
m_initializers.add(initializer);
@@ -467,4 +469,4 @@ public class Registrator extends LocalObject implements ORBInitInfo
{
return m_ior.size() > 0;
}
-}
+} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/Interceptor/gnuIcCurrent.java b/libjava/classpath/gnu/CORBA/Interceptor/gnuIcCurrent.java
index ee8af7fc0b4..a33afc3362e 100644
--- a/libjava/classpath/gnu/CORBA/Interceptor/gnuIcCurrent.java
+++ b/libjava/classpath/gnu/CORBA/Interceptor/gnuIcCurrent.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.Poa.ORB_1_4;
import org.omg.CORBA.Any;
@@ -198,7 +198,7 @@ public class gnuIcCurrent extends ObjectImpl implements Current
Any[] r = get_slots();
Any[] copy = new Any[ r.length ];
- cdrBufOutput buf = new cdrBufOutput();
+ BufferedCdrOutput buf = new BufferedCdrOutput();
buf.setOrb(orb);
for (int i = 0; i < copy.length; i++)
diff --git a/libjava/classpath/gnu/CORBA/Interceptor/gnuIorInfo.java b/libjava/classpath/gnu/CORBA/Interceptor/gnuIorInfo.java
index 1c406cb5e46..256a28cb567 100644
--- a/libjava/classpath/gnu/CORBA/Interceptor/gnuIorInfo.java
+++ b/libjava/classpath/gnu/CORBA/Interceptor/gnuIorInfo.java
@@ -40,12 +40,14 @@ package gnu.CORBA.Interceptor;
import gnu.CORBA.IOR;
import gnu.CORBA.Poa.ORB_1_4;
+import gnu.CORBA.Poa.gnuPOA;
import org.omg.CORBA.LocalObject;
import org.omg.CORBA.Policy;
import org.omg.IOP.TaggedComponent;
import org.omg.PortableInterceptor.IORInfo;
-import org.omg.PortableServer.POA;
+import org.omg.PortableInterceptor.ObjectReferenceFactory;
+import org.omg.PortableInterceptor.ObjectReferenceTemplate;
/**
* Implements IORInfo.
@@ -67,7 +69,7 @@ public class gnuIorInfo extends LocalObject implements IORInfo
/**
* The POA, to that IOR is related.
*/
- public final POA poa;
+ public final gnuPOA poa;
/**
* The IOR itself.
@@ -77,7 +79,7 @@ public class gnuIorInfo extends LocalObject implements IORInfo
/**
* Create an instance.
*/
- public gnuIorInfo(ORB_1_4 an_orb, POA a_poa, IOR an_ior)
+ public gnuIorInfo(ORB_1_4 an_orb, gnuPOA a_poa, IOR an_ior)
{
orb = an_orb;
poa = a_poa;
@@ -113,8 +115,42 @@ public class gnuIorInfo extends LocalObject implements IORInfo
/**
* Return the state of the object POA.
*/
- short state()
+ public short state()
{
return (short) poa.the_POAManager().get_state().value();
}
+
+ /**
+ * Get the adapter template, associated with this poa.
+ */
+ public ObjectReferenceTemplate adapter_template()
+ {
+ return poa.getReferenceTemplate();
+ }
+
+ /**
+ * Get the object factory of the current POA.
+ */
+ public ObjectReferenceFactory current_factory()
+ {
+ return poa.getReferenceFactory();
+ }
+
+ /**
+ * Set the object factory of the current POA.
+ */
+ public void current_factory(ObjectReferenceFactory factory)
+ {
+ poa.setReferenceFactory(factory);
+ }
+
+ /**
+ * The method currently uses system identity hashcode that should be
+ * different for each object.
+ */
+ public int manager_id()
+ {
+ // The System.identityHashCode is also called in gnuPoaManager.
+ return System.identityHashCode(poa.the_POAManager());
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/Interceptor/gnuServerRequestInfo.java b/libjava/classpath/gnu/CORBA/Interceptor/gnuServerRequestInfo.java
index 5f75f76878a..8d5c681e705 100644
--- a/libjava/classpath/gnu/CORBA/Interceptor/gnuServerRequestInfo.java
+++ b/libjava/classpath/gnu/CORBA/Interceptor/gnuServerRequestInfo.java
@@ -42,6 +42,7 @@ import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.GIOP.RequestHeader;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Poa.gnuServantObject;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.Unexpected;
import gnu.CORBA.gnuRequest;
@@ -453,4 +454,23 @@ public class gnuServerRequestInfo extends LocalObject
}
return p;
}
+
+ /** @inheritDoc */
+ public String[] adapter_name()
+ {
+ return m_object.poa.getReferenceTemplate().adapter_name();
+ }
+
+ /** @inheritDoc */
+ public String orb_id()
+ {
+ return m_object.orb.orb_id;
+ }
+
+ /** @inheritDoc */
+ public String server_id()
+ {
+ return OrbFunctional.server_id;
+ }
+
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/IOR_Delegate.java b/libjava/classpath/gnu/CORBA/IorDelegate.java
index 3b64eb585c4..27fb5de9a55 100644
--- a/libjava/classpath/gnu/CORBA/IOR_Delegate.java
+++ b/libjava/classpath/gnu/CORBA/IorDelegate.java
@@ -38,9 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.GIOP.ReplyHeader;
-import gnu.CORBA.Poa.activeObjectMap;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.Context;
@@ -70,23 +69,12 @@ import java.net.Socket;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class IOR_Delegate extends Simple_delegate
+public class IorDelegate extends SimpleDelegate
{
/**
- * True if the current IOR does not map into the local servant. If false, the
- * IOR is either local or should be checked.
- */
- boolean remote_ior;
-
- /**
- * If not null, this field contains data about the local servant.
- */
- activeObjectMap.Obj local_ior;
-
- /**
* Contructs an instance of object using the given IOR.
*/
- public IOR_Delegate(ORB an_orb, IOR an_ior)
+ public IorDelegate(ORB an_orb, IOR an_ior)
{
super(an_orb, an_ior);
}
@@ -168,37 +156,36 @@ public class IOR_Delegate extends Simple_delegate
* request to the new direction. The ReplyHeader.LOCATION_FORWARD_PERM will
* cause additionally to remember the new location by this delegate, so
* subsequent calls will be immediately delivered to the new target.
- *
+ *
* @param target the target object.
* @param output the output stream, previously returned by
* {@link #request(org.omg.CORBA.Object, String, boolean)}.
- *
+ *
* @return the input stream, to read the response from or null for a one-way
* request.
- *
+ *
* @throws SystemException if the SystemException has been thrown on the
* remote side (the exact type and the minor code matches the data of the
* remote exception that has been thrown).
- *
+ *
* @throws org.omg.CORBA.portable.ApplicationException as specified.
* @throws org.omg.CORBA.portable.RemarshalException as specified.
*/
public InputStream invoke(org.omg.CORBA.Object target, OutputStream output)
throws ApplicationException, RemarshalException
{
- streamRequest request = (streamRequest) output;
- Forwardings:
- while (true)
+ StreamBasedRequest request = (StreamBasedRequest) output;
+ Forwardings: while (true)
{
try
{
if (request.response_expected)
{
- binaryReply response = request.request.submit();
+ RawReply response = request.request.submit();
// Read reply header.
ReplyHeader rh = response.header.create_reply_header();
- cdrBufInput input = response.getStream();
+ BufferredCdrInput input = response.getStream();
input.setOrb(orb);
rh.read(input);
request.request.m_rph = rh;
@@ -207,34 +194,33 @@ public class IOR_Delegate extends Simple_delegate
switch (rh.reply_status)
{
- case ReplyHeader.NO_EXCEPTION :
+ case ReplyHeader.NO_EXCEPTION:
if (request.request.m_interceptor != null)
- request.request.m_interceptor.
- receive_reply(request.request.m_info);
+ request.request.m_interceptor.receive_reply(request.request.m_info);
if (response.header.version.since_inclusive(1, 2))
input.align(8);
return input;
- case ReplyHeader.SYSTEM_EXCEPTION :
+ case ReplyHeader.SYSTEM_EXCEPTION:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
- throw ObjectCreator.readSystemException(input);
+ throw ObjectCreator.readSystemException(input,
+ rh.service_context);
- case ReplyHeader.USER_EXCEPTION :
+ case ReplyHeader.USER_EXCEPTION:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
- throw new ApplicationException(request.
- request.m_exception_id, input
- );
+ throw new ApplicationException(
+ request.request.m_exception_id, input);
- case ReplyHeader.LOCATION_FORWARD_PERM :
+ case ReplyHeader.LOCATION_FORWARD_PERM:
moved_permanently = true;
- case ReplyHeader.LOCATION_FORWARD :
+ case ReplyHeader.LOCATION_FORWARD:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
@@ -245,10 +231,8 @@ public class IOR_Delegate extends Simple_delegate
}
catch (IOException ex)
{
- MARSHAL t =
- new MARSHAL("Cant read forwarding info", 5102,
- CompletionStatus.COMPLETED_NO
- );
+ MARSHAL t = new MARSHAL("Cant read forwarding info",
+ 5102, CompletionStatus.COMPLETED_NO);
t.initCause(ex);
throw t;
}
@@ -277,8 +261,8 @@ public class IOR_Delegate extends Simple_delegate
r.setIor(forwarded);
- IOR_contructed_object it =
- new IOR_contructed_object(orb, forwarded);
+ IorObject it = new IorObject(orb,
+ forwarded);
r.m_target = it;
@@ -298,11 +282,10 @@ public class IOR_Delegate extends Simple_delegate
setIor(prev_ior);
}
- default :
- throw new MARSHAL("Unknow reply status: " +
- rh.reply_status, 8000 + rh.reply_status,
- CompletionStatus.COMPLETED_NO
- );
+ default:
+ throw new MARSHAL("Unknow reply status: "
+ + rh.reply_status, 8000 + rh.reply_status,
+ CompletionStatus.COMPLETED_NO);
}
}
else
@@ -314,8 +297,7 @@ public class IOR_Delegate extends Simple_delegate
catch (ForwardRequest forwarded)
{
ForwardRequest fw = forwarded;
- Forwarding2:
- while (true)
+ Forwarding2: while (true)
{
try
{
@@ -356,7 +338,7 @@ public class IOR_Delegate extends Simple_delegate
/**
* Show exception to interceptor.
*/
- void showException(streamRequest request, cdrBufInput input)
+ void showException(StreamBasedRequest request, BufferredCdrInput input)
throws ForwardRequest
{
input.mark(2048);
@@ -408,9 +390,10 @@ public class IOR_Delegate extends Simple_delegate
request.set_target(target);
request.setOperation(operation);
- streamRequest out = request.getParameterStream();
+ StreamBasedRequest out = request.getParameterStream();
out.response_expected = response_expected;
request.setORB(orb);
+ out.setOrb(orb);
return out;
}
@@ -447,8 +430,6 @@ public class IOR_Delegate extends Simple_delegate
public void setIor(IOR an_ior)
{
super.setIor(an_ior);
- remote_ior = false;
- local_ior = null;
}
/**
@@ -456,11 +437,6 @@ public class IOR_Delegate extends Simple_delegate
*/
public boolean is_local(org.omg.CORBA.Object self)
{
- if (remote_ior)
- return false;
- else if (local_ior != null)
- return true;
- else
- return super.is_local(self);
+ return false;
}
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/IOR_contructed_object.java b/libjava/classpath/gnu/CORBA/IorObject.java
index 2fab70799db..02f5a495d49 100644
--- a/libjava/classpath/gnu/CORBA/IOR_contructed_object.java
+++ b/libjava/classpath/gnu/CORBA/IorObject.java
@@ -1,4 +1,4 @@
-/* IOR_contructed_object.java --
+/* IorObject.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,8 +46,9 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class IOR_contructed_object
+public class IorObject
extends ObjectImpl
+ implements IorProvider
{
/**
* The IOR, from which the object was constructed.
@@ -64,10 +65,10 @@ public class IOR_contructed_object
*
* @param an_ior the IOR.
*/
- public IOR_contructed_object(ORB orb, IOR an_ior)
+ public IorObject(ORB orb, IOR an_ior)
{
ior = an_ior;
- _set_delegate(new IOR_Delegate(orb, ior));
+ _set_delegate(new IorDelegate(orb, ior));
id = new String[] { ior.Id };
}
@@ -76,12 +77,20 @@ public class IOR_contructed_object
*
* @param an_ior the IOR in the string form.
*/
- public IOR_contructed_object(Functional_ORB orb, String an_ior)
+ public IorObject(OrbFunctional orb, String an_ior)
{
ior = IOR.parse(an_ior);
- _set_delegate(new IOR_Delegate(orb, ior));
+ _set_delegate(new IorDelegate(orb, ior));
id = new String[] { ior.Id };
}
+
+ /**
+ * Get the IOR of this object.
+ */
+ public IOR getIor()
+ {
+ return ior;
+ }
public String[] _ids()
{
diff --git a/libjava/classpath/gnu/CORBA/IorProvider.java b/libjava/classpath/gnu/CORBA/IorProvider.java
new file mode 100644
index 00000000000..875b5de1f7d
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/IorProvider.java
@@ -0,0 +1,52 @@
+/* IorProvider.java --
+ 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. */
+
+package gnu.CORBA;
+
+/**
+ * Marks the possibility of the implementing object to return the associated
+ * IOR.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface IorProvider
+{
+ /**
+ * Get the IOR of the associated object.
+ */
+ IOR getIor();
+}
diff --git a/libjava/classpath/gnu/CORBA/Minor.java b/libjava/classpath/gnu/CORBA/Minor.java
new file mode 100644
index 00000000000..511a34d559b
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/Minor.java
@@ -0,0 +1,282 @@
+/* Minor.java --
+ 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. */
+
+
+package gnu.CORBA;
+
+
+/**
+ * Provides information and operations, related to about the 20 bit vendor minor
+ * code Id. This code is included into all CORBA system exceptions and is also
+ * transferred to remote side.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface Minor
+{
+ // Note: MARSHAL done.
+
+ /* MARSHAL */
+
+ /**
+ * The GNU Classpath VMCID. The last 12 bits can be used to mark up to 4096
+ * possible exceptions.
+ */
+ int vendor = 0x47430000;
+
+ /*
+ * Minor codes form MARSHAL exception.
+ */
+
+ /**
+ * The message being received is not a GIOP message. It does not start from
+ * the expected magic sequence byte[] { 'G', 'I', 'O', 'P' }.
+ */
+ int Giop = 1 | vendor;
+
+ /**
+ * The unexpected IOException while reading or writing the GIOP message header
+ * or the subsequent request or response header
+ */
+ int Header = 2 | vendor;
+
+ /**
+ * The data stream ended before reading all expected values from it. This
+ * usually means that the CORBA message is corrupted, but may also indicate
+ * that the server expects the remote method being invoked to have more or
+ * different parameters.
+ */
+ int EOF = 3 | vendor;
+
+ /**
+ * The unexpected IOException while reading or writing the data via Commond
+ * Data Representation stream.
+ */
+ int CDR = 5 | vendor;
+
+ /**
+ * The unexpected IOException while reading or writing the Value type.
+ */
+ int Value = 6 | vendor;
+
+ /**
+ * The unexpected IOException while handling request forwarding.
+ */
+ int Forwarding = 7 | vendor;
+
+ /**
+ * The unexpected IOException while handling data encapsulation, tagged
+ * components, tagged profiles, etc.
+ */
+ int Encapsulation = 8 | vendor;
+
+ /**
+ * The unexpected IOException while inserting or extracting data to/from the
+ * Any or DynamicAny.
+ */
+ int Any = 9 | vendor;
+
+ /**
+ * The unexpected UserException in the context where it cannot be handled and
+ * must be converted to the SystemException.
+ */
+ int UserException = 10 | vendor;
+
+ /**
+ * While the operation could formally be applied to the target, the OMG
+ * standard states that it is actually not applicable. For example, some CORBA
+ * objects like POA are always local and should not be passed to or returned
+ * from the remote side.
+ */
+ int Inappropriate = 11 | vendor;
+
+ /**
+ * When reading data, it was discovered that size of the data structure like
+ * string, sequence or character is written as the negative number.
+ */
+ int Negative = 12 | vendor;
+
+ /**
+ * Reference to non-existing node in the data grapth while reading the value
+ * types.
+ */
+ int Graph = 14 | vendor;
+
+ /**
+ * Unexpected exception was thrown from the IDL type helper while handling the
+ * object of this type as a boxed value.
+ */
+ int Boxed = 15 | vendor;
+
+ /**
+ * Unable to instantiate an value type object while reading it from the
+ * stream.
+ */
+ int Instantiation = 16 | vendor;
+
+ /**
+ * The header tag of the value type being read from the CDR stream contains an
+ * unexpected value outside 0x7fffff00 .. 0x7fffffff and also not null and not
+ * an indirection.
+ */
+ int ValueHeaderTag = 17 | vendor;
+
+ /**
+ * The header tag flags of the value type being read from the CDR stream make
+ * the invalid combination (for instance, 0x7fffff04).
+ */
+ int ValueHeaderFlags = 18 | vendor;
+
+ /**
+ * The value type class, written on the wire, is not compatible with the
+ * expected class, passed as a parameter to the InputStream.read_value.
+ */
+ int ClassCast = 19 | vendor;
+
+ /**
+ * Positive or otherwise invalid indirection offset when reading the data
+ * graph of the value type.
+ */
+ int Offset = 20 | vendor;
+
+ /**
+ * Errors while reading the chunked value type.
+ */
+ int Chunks = 21 | vendor;
+
+ /**
+ * No means are provided to write this value type.
+ */
+ int UnsupportedValue = 22 | vendor;
+
+ /**
+ * The value factory, required for the operation being invoked, is not
+ * registered with this ORB.
+ */
+ int Factory = 23 | vendor;
+
+ /**
+ * Unsupported object addressing method in GIOP request header.
+ */
+ int UnsupportedAddressing = 24 | vendor;
+
+ /**
+ * Invalid stringified object reference (IOR).
+ */
+ int IOR = 25 | vendor;
+
+ /**
+ * Problems with converting between stubs, ties, interfaces and
+ * implementations.
+ */
+ int TargetConversion = 26 | vendor;
+
+ /**
+ * Problems with reading or writing the fields of the value type object.
+ */
+ int ValueFields = 27 | vendor;
+
+ /**
+ * The instance of the value type is not serializable.
+ */
+ int NonSerializable = 28 | vendor;
+
+ /* BAD_OPERATION */
+
+ /**
+ * The remote side requested to invoke the method that is not available on
+ * that target (client and server probably disagree in the object definition).
+ */
+ int Method = 0 | vendor;
+
+ /**
+ * Failed to activate the inactive object.
+ */
+ int Activation = 10 | vendor;
+
+ /*
+ * Any - Attempt to extract from the Any value of the different type that was
+ * stored into that Any.
+ */
+
+ /* ClassCast - Unable to narrow the object into stub. */
+
+ /**
+ * The policies, applying to ORB or POA prevent the requested operation.
+ */
+ int Policy = 11 | vendor;
+
+ /**
+ * Socket related errors like failure to open socket on the expected port,
+ * failure to get a free port when required and so on.
+ */
+ int Socket = 12 | vendor;
+
+ /**
+ * The passed value for enumeration is outside the valid range for that
+ * enumeration.
+ */
+ int Enumeration = 14 | vendor;
+
+ /**
+ * The passed policy code is outside the valid range of the possible policies
+ * for the given policy type.
+ */
+ int PolicyType = 15 | vendor;
+
+ /* NO_RESOURCES */
+
+ /**
+ * Unable to get a free port for a new socket. Proably too many objects under
+ * unsuitable POA policy.
+ */
+ int Ports = 20 | vendor;
+
+ /**
+ * Too many parallel calls (too many parallel threads). The thread control
+ * prevents malicios client from knocking the server out by suddenly
+ * submitting large number of requests.
+ */
+ int Threads = 21 | vendor;
+
+ /**
+ * The IOR starts with file://, http:// or ftp://, but this local or remote
+ * resource is not accessible.
+ */
+ int Missing_IOR = 22 | vendor;
+
+}
diff --git a/libjava/classpath/gnu/CORBA/NamingService/Ext.java b/libjava/classpath/gnu/CORBA/NamingService/Ext.java
index fb7406c4618..ee27e68cd79 100644
--- a/libjava/classpath/gnu/CORBA/NamingService/Ext.java
+++ b/libjava/classpath/gnu/CORBA/NamingService/Ext.java
@@ -73,7 +73,7 @@ public class Ext
* The converter class converts between string and array form of the
* name.
*/
- private snConverter converter = new snConverter();
+ private NameTransformer converter = new NameTransformer();
/**
* Create the extensions for the given instance of the context.
diff --git a/libjava/classpath/gnu/CORBA/NamingService/cmpNameComponent.java b/libjava/classpath/gnu/CORBA/NamingService/NameComponentComparator.java
index 1e06fb8ee35..6116ba94e74 100644
--- a/libjava/classpath/gnu/CORBA/NamingService/cmpNameComponent.java
+++ b/libjava/classpath/gnu/CORBA/NamingService/NameComponentComparator.java
@@ -1,4 +1,4 @@
-/* cmpNameComponent.java --
+/* NameComponentComparator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -49,18 +49,18 @@ import java.util.Comparator;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public final class cmpNameComponent
+public final class NameComponentComparator
implements Comparator
{
/**
* The singleton instance of the name comparator.
*/
- public static final cmpNameComponent singleton = new cmpNameComponent();
+ public static final NameComponentComparator singleton = new NameComponentComparator();
/**
* It is enough to have a singleton.
*/
- private cmpNameComponent()
+ private NameComponentComparator()
{
}
@@ -93,6 +93,6 @@ public final class cmpNameComponent
*/
public boolean equals(Object x)
{
- return x instanceof cmpNameComponent;
+ return x instanceof NameComponentComparator;
}
}
diff --git a/libjava/classpath/gnu/CORBA/NamingService/NameParser.java b/libjava/classpath/gnu/CORBA/NamingService/NameParser.java
index f886cf93533..422db1c58da 100644
--- a/libjava/classpath/gnu/CORBA/NamingService/NameParser.java
+++ b/libjava/classpath/gnu/CORBA/NamingService/NameParser.java
@@ -1,44 +1,45 @@
/* NameParser.java --
- 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. */
+ 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. */
package gnu.CORBA.NamingService;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.Minor;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
@@ -51,11 +52,15 @@ import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CosNaming.NamingContext;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.CosNaming.NamingContextHelper;
import org.omg.CosNaming._NamingContextStub;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.StringTokenizer;
@@ -74,7 +79,7 @@ import java.util.StringTokenizer;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class NameParser
- extends snConverter
+ extends NameTransformer
{
/**
* The corbaloc prefix.
@@ -90,6 +95,21 @@ public class NameParser
* The IOR prefix.
*/
public static final String pxIOR = "ior";
+
+ /**
+ * The file:// prefix.
+ */
+ public static final String pxFILE = "file://";
+
+ /**
+ * The ftp:// prefix.
+ */
+ public static final String pxFTP = "ftp://";
+
+ /**
+ * The http:// prefix.
+ */
+ public static final String pxHTTP = "http://";
/**
* Marks iiop protocol.
@@ -114,7 +134,7 @@ public class NameParser
/**
* The string to name converter, initialized on demand.
*/
- static snConverter converter;
+ static NameTransformer converter;
/**
* The current position.
@@ -134,6 +154,9 @@ public class NameParser
* 2. corbaloc:rir:[/key] <br>
* 3. corbaname:[iiop][version.subversion@]:host[:port]/key <br>
* 4. corbaname:rir:[/key] <br>
+ * 5. file://[file name]<br>
+ * 6. http://[url]<br>
+ * 7. ftp://[url]<br>
*
* Protocol defaults to IOP, the object key defaults to the NameService.
*
@@ -143,9 +166,31 @@ public class NameParser
* @return the resolved object.
*/
public synchronized org.omg.CORBA.Object corbaloc(String corbaloc,
- Functional_ORB orb)
+ OrbFunctional orb)
throws BAD_PARAM
{
+ return corbaloc(corbaloc, orb, 0);
+ }
+
+ /**
+ * Parse controlling against the infinite recursion loop.
+ */
+ private org.omg.CORBA.Object corbaloc(String corbaloc,
+ OrbFunctional orb, int recursion)
+ {
+ // The used CORBA specification does not state how many times we should to
+ //redirect, but the infinite loop may be used to knock out the system.
+ // by malicious attempt.
+ if (recursion > 10)
+ throw new DATA_CONVERSION("More than 10 redirections");
+
+ if (corbaloc.startsWith(pxFILE))
+ return corbaloc(readFile(corbaloc.substring(pxFILE.length())), orb, recursion+1);
+ else if (corbaloc.startsWith(pxHTTP))
+ return corbaloc(readUrl(corbaloc), orb, recursion+1);
+ else if (corbaloc.startsWith(pxFTP))
+ return corbaloc(readUrl(corbaloc), orb, recursion+1);
+
boolean corbaname;
// The alternative addresses, if given.
@@ -304,6 +349,70 @@ public class NameParser
else
throw new DATA_CONVERSION("Unsupported protocol '" + t[p] + "'");
}
+
+ /**
+ * Read IOR from the file in the local file system.
+ */
+ String readFile(String file)
+ {
+ File f = new File(file);
+ if (!f.exists())
+ {
+ DATA_CONVERSION err = new DATA_CONVERSION(f.getAbsolutePath()
+ + " does not exist.");
+ err.minor = Minor.Missing_IOR;
+ }
+ try
+ {
+ char[] c = new char[(int) f.length()];
+ FileReader fr = new FileReader(f);
+ fr.read(c);
+ fr.close();
+ return new String(c).trim();
+ }
+ catch (IOException ex)
+ {
+ DATA_CONVERSION d = new DATA_CONVERSION();
+ d.initCause(ex);
+ d.minor = Minor.Missing_IOR;
+ throw (d);
+ }
+ }
+
+ /**
+ * Read IOR from the remote URL.
+ */
+ String readUrl(String url)
+ {
+ URL u;
+ try
+ {
+ u = new URL(url);
+ }
+ catch (MalformedURLException mex)
+ {
+ throw new BAD_PARAM("Malformed URL: '" + url + "'");
+ }
+
+ try
+ {
+ InputStreamReader r = new InputStreamReader(u.openStream());
+
+ StringBuffer b = new StringBuffer();
+ int c;
+
+ while ((c = r.read()) > 0)
+ b.append((char) c);
+
+ return b.toString().trim();
+ }
+ catch (Exception exc)
+ {
+ DATA_CONVERSION d = new DATA_CONVERSION("Reading " + url + " failed.");
+ d.minor = Minor.Missing_IOR;
+ throw d;
+ }
+ }
private org.omg.CORBA.Object resolve(org.omg.CORBA.Object object)
{
@@ -329,7 +438,7 @@ public class NameParser
}
if (converter == null)
- converter = new snConverter();
+ converter = new NameTransformer();
try
{
@@ -380,7 +489,7 @@ public class NameParser
static NameParser n = new NameParser();
- static void corbalocT(String ior, Functional_ORB orb)
+ static void corbalocT(String ior, OrbFunctional orb)
{
System.out.println(ior);
System.out.println(n.corbaloc(ior, orb));
@@ -391,7 +500,7 @@ public class NameParser
{
try
{
- Functional_ORB orb = (Functional_ORB) ORB.init(args, null);
+ OrbFunctional orb = (OrbFunctional) ORB.init(args, null);
corbalocT("corbaloc:iiop:1.3@155axyz.com/Prod/aTradingService", orb);
corbalocT("corbaloc:iiop:2.7@255bxyz.com/Prod/bTradingService", orb);
corbalocT("corbaloc:iiop:355cxyz.com/Prod/cTradingService", orb);
diff --git a/libjava/classpath/gnu/CORBA/NamingService/snConverter.java b/libjava/classpath/gnu/CORBA/NamingService/NameTransformer.java
index a9b9219d76a..0e0782a5756 100644
--- a/libjava/classpath/gnu/CORBA/NamingService/snConverter.java
+++ b/libjava/classpath/gnu/CORBA/NamingService/NameTransformer.java
@@ -1,4 +1,4 @@
-/* snConverter.java --
+/* NameTransformer.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,7 +51,7 @@ import java.util.StringTokenizer;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class snConverter
+public class NameTransformer
{
/**
* A string, indicating the escape character.
@@ -301,7 +301,7 @@ public class snConverter
NameComponent b = new NameComponent("b/z", "b.k");
NameComponent c = new NameComponent("c", "");
- snConverter sn = new snConverter();
+ NameTransformer sn = new NameTransformer();
try
{
diff --git a/libjava/classpath/gnu/CORBA/NamingService/NamingMap.java b/libjava/classpath/gnu/CORBA/NamingService/NamingMap.java
index a69b0617269..95deb0096bd 100644
--- a/libjava/classpath/gnu/CORBA/NamingService/NamingMap.java
+++ b/libjava/classpath/gnu/CORBA/NamingService/NamingMap.java
@@ -66,7 +66,7 @@ public class NamingMap
*/
public NamingMap()
{
- map = new TreeMap(cmpNameComponent.singleton);
+ map = new TreeMap(NameComponentComparator.singleton);
}
/**
diff --git a/libjava/classpath/gnu/CORBA/NamingService/NamingServiceTransient.java b/libjava/classpath/gnu/CORBA/NamingService/NamingServiceTransient.java
index e46bed7f7a1..bf72637d7d7 100644
--- a/libjava/classpath/gnu/CORBA/NamingService/NamingServiceTransient.java
+++ b/libjava/classpath/gnu/CORBA/NamingService/NamingServiceTransient.java
@@ -1,4 +1,4 @@
-/* Server.java --
+/* NamingServiceTransient.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.NamingService;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import org.omg.CosNaming.NamingContextExt;
@@ -102,7 +102,7 @@ public class NamingServiceTransient
try
{
// Create and initialize the ORB
- final Functional_ORB orb = new Functional_ORB();
+ final OrbFunctional orb = new OrbFunctional();
if (args.length > 1)
for (int i = 0; i < args.length - 1; i++)
@@ -114,7 +114,7 @@ public class NamingServiceTransient
iorf = args[i + 1];
}
- Functional_ORB.setPort(port);
+ OrbFunctional.setPort(port);
// Create the servant and register it with the ORB
NamingContextExt namer = new Ext(new TransientContext());
@@ -159,6 +159,6 @@ public class NamingServiceTransient
// Restore the default value for allocating ports for the subsequent
// objects.
- Functional_ORB.setPort(Functional_ORB.DEFAULT_INITIAL_PORT);
+ OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
}
}
diff --git a/libjava/classpath/gnu/CORBA/ObjectCreator.java b/libjava/classpath/gnu/CORBA/ObjectCreator.java
index 81c1d06e775..5937e76b31e 100644
--- a/libjava/classpath/gnu/CORBA/ObjectCreator.java
+++ b/libjava/classpath/gnu/CORBA/ObjectCreator.java
@@ -38,27 +38,37 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.UnknownExceptionCtxHandler;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.CDR.AbstractCdrInput;
+import gnu.CORBA.GIOP.ServiceContext;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.classpath.VMStackWalker;
import org.omg.CORBA.Any;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.CompletionStatusHelper;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.UserException;
+import org.omg.CORBA.portable.IDLEntity;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ValueBase;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import javax.rmi.CORBA.Util;
/**
* Creates java objects from the agreed IDL names for the simple case when the
* CORBA object is directly mapped into the locally defined java class.
- *
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ObjectCreator
@@ -79,91 +89,137 @@ public class ObjectCreator
public static final String CLASSPATH_PREFIX = "gnu.CORBA.";
/**
+ * Maps classes to they IDL or RMI names. Computing RMI name is an expensive
+ * operations, so frequently used RMI keys are reused. The map must be weak to
+ * ensure that the class can be unloaded, when applicable.
+ */
+ public static Map m_names = new WeakHashMap();
+
+ /**
+ * Maps IDL strings into known classes. The map must be weak to ensure that
+ * the class can be unloaded, when applicable.
+ */
+ public static Map m_classes = new WeakHashMap();
+
+ /**
+ * Maps IDL types to they helpers.
+ */
+ public static Map m_helpers = new WeakHashMap();
+
+ /**
* Try to instantiate an object with the given IDL name. The object must be
* mapped to the local java class. The omg.org domain must be mapped into the
* object in either org/omg or gnu/CORBA namespace.
- *
+ *
* @param IDL name
* @return instantiated object instance or null if no such available.
*/
public static java.lang.Object createObject(String idl, String suffix)
{
- try
- {
- return Class.forName(toClassName(JAVA_PREFIX, idl) + suffix)
- .newInstance();
- }
- catch (Exception ex)
+ synchronized (m_classes)
{
- try
+ Class known = (Class) (suffix == null ? m_classes.get(idl)
+ : m_classes.get(idl + 0xff + suffix));
+ Object object;
+
+ if (known != null)
{
- return Class.forName(toClassName(CLASSPATH_PREFIX, idl) + suffix)
- .newInstance();
+ try
+ {
+ return known.newInstance();
+ }
+ catch (Exception ex)
+ {
+ RuntimeException rex = new RuntimeException(idl + " suffix "
+ + suffix, ex);
+ throw rex;
+ }
}
- catch (Exception exex)
+ else
{
- return null;
+ if (suffix == null)
+ suffix = "";
+ try
+ {
+ known = forName(toClassName(JAVA_PREFIX, idl) + suffix);
+ object = known.newInstance();
+ }
+ catch (Exception ex)
+ {
+ try
+ {
+ known = forName(toClassName(CLASSPATH_PREFIX, idl)
+ + suffix);
+ object = known.newInstance();
+ }
+ catch (Exception exex)
+ {
+ return null;
+ }
+ }
+ m_classes.put(idl + 0xff + suffix, known);
+ return object;
}
}
}
/**
- * Create the system exception with the given idl name.
- *
- * @param idl the exception IDL name, must match the syntax "IDL:<class/name>:1.0".
- * @param minor the exception minor code.
- * @param completed the exception completion status.
- *
- * @return the created exception.
+ * Read the system exception from the given stream.
+ *
+ * @param input the CDR stream to read from.
+ * @param contexts the service contexts in request/reply header/
+ *
+ * @return the exception that has been stored in the stream (IDL name, minor
+ * code and completion status).
*/
- public static SystemException createSystemException(String idl, int minor,
- CompletionStatus completed
- )
+ public static SystemException readSystemException(InputStream input,
+ ServiceContext[] contexts)
{
+ SystemException exception;
+
+ String idl = input.read_string();
+ int minor = input.read_ulong();
+ CompletionStatus completed = CompletionStatusHelper.read(input);
+
try
{
- String cl = toClassName(JAVA_PREFIX, idl);
- Class exClass = Class.forName(cl);
-
- Constructor constructor =
- exClass.getConstructor(new Class[]
- {
- String.class, int.class, CompletionStatus.class
- }
- );
-
- Object exception =
- constructor.newInstance(new Object[]
- {
- " Remote exception " + idl + ", minor " + minor + ", " +
- completed + ".", new Integer(minor), completed
- }
- );
-
- return (SystemException) exception;
+ exception = (SystemException) createObject(idl, null);
+ exception.minor = minor;
+ exception.completed = completed;
}
catch (Exception ex)
{
- ex.printStackTrace();
- return new UNKNOWN("Unsupported system exception", minor, completed);
+ UNKNOWN u = new UNKNOWN("Unsupported system exception " + idl, minor,
+ completed);
+ u.initCause(ex);
+ throw u;
}
- }
- /**
- * Read the system exception from the given stream.
- *
- * @param input the CDR stream to read from.
- * @return the exception that has been stored in the stream (IDL name, minor
- * code and completion status).
- */
- public static SystemException readSystemException(InputStream input)
- {
- String idl = input.read_string();
- int minor = input.read_ulong();
- CompletionStatus status = CompletionStatusHelper.read(input);
+ try
+ {
+ // If UnknownExceptionInfo is present in the contexts, read it and
+ // set as a cause of this exception.
+ ServiceContext uEx = ServiceContext.find(
+ ServiceContext.UnknownExceptionInfo, contexts);
- SystemException exception =
- ObjectCreator.createSystemException(idl, minor, status);
+ if (uEx != null)
+ {
+ BufferredCdrInput in = new BufferredCdrInput(uEx.context_data);
+ in.setOrb(in.orb());
+ if (input instanceof AbstractCdrInput)
+ {
+ ((AbstractCdrInput) input).cloneSettings(in);
+ }
+
+ Throwable t = UnknownExceptionCtxHandler.read(in, contexts);
+ exception.initCause(t);
+ }
+ }
+ catch (Exception ex)
+ {
+ // Unsupported context format. Do not terminate as the user program may
+ // not need it.
+ }
return exception;
}
@@ -172,10 +228,10 @@ public class ObjectCreator
* Reads the user exception, having the given Id, from the input stream. The
* id is expected to be in the form like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
+ *
* @param idl the exception idl name.
* @param input the stream to read from.
- *
+ *
* @return the loaded exception.
* @return null if the helper class cannot be found.
*/
@@ -183,13 +239,10 @@ public class ObjectCreator
{
try
{
- String helper = toHelperName(idl);
- Class helperClass = Class.forName(helper);
+ Class helperClass = findHelper(idl);
- Method read =
- helperClass.getMethod("read",
- new Class[] { org.omg.CORBA.portable.InputStream.class }
- );
+ Method read = helperClass.getMethod("read",
+ new Class[] { org.omg.CORBA.portable.InputStream.class });
return (UserException) read.invoke(null, new Object[] { input });
}
@@ -208,7 +261,7 @@ public class ObjectCreator
/**
* Gets the helper class name from the string like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
- *
+ *
* @param IDL the idl name.
*/
public static String toHelperName(String IDL)
@@ -227,15 +280,14 @@ public class ObjectCreator
/**
* Writes the system exception data to CDR output stream.
- *
+ *
* @param output a stream to write data to.
* @param ex an exception to write.
*/
public static void writeSystemException(OutputStream output,
- SystemException ex
- )
+ SystemException ex)
{
- String exIDL = toIDL(ex.getClass().getName());
+ String exIDL = getRepositoryId(ex.getClass());
output.write_string(exIDL);
output.write_ulong(ex.minor);
CompletionStatusHelper.write(output, ex.completed);
@@ -243,9 +295,9 @@ public class ObjectCreator
/**
* Converts the given IDL name to class name.
- *
+ *
* @param IDL the idl name.
- *
+ *
*/
protected static String toClassName(String prefix, String IDL)
{
@@ -265,34 +317,43 @@ public class ObjectCreator
* Converts the given IDL name to class name and tries to load the matching
* class. The OMG prefix (omg.org) is replaced by the java prefix org.omg. No
* other prefixes are added.
- *
+ *
* @param IDL the idl name.
- *
- * TODO Cache the returned classes, avoiding these string manipulations each
- * time the conversion is required.
- *
+ *
* @return the matching class or null if no such is available.
*/
public static Class Idl2class(String IDL)
{
- String s = IDL;
- int a = s.indexOf(':') + 1;
- int b = s.lastIndexOf(':');
-
- s = IDL.substring(a, b);
-
- if (s.startsWith(OMG_PREFIX))
- s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
-
- String cn = s.replace('/', '.');
-
- try
+ synchronized (m_classes)
{
- return Class.forName(cn);
- }
- catch (ClassNotFoundException ex)
- {
- return null;
+ Class c = (Class) m_classes.get(IDL);
+
+ if (c != null)
+ return c;
+ else
+ {
+ String s = IDL;
+ int a = s.indexOf(':') + 1;
+ int b = s.lastIndexOf(':');
+
+ s = IDL.substring(a, b);
+
+ if (s.startsWith(OMG_PREFIX))
+ s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
+
+ String cn = s.replace('/', '.');
+
+ try
+ {
+ c = forName(cn);
+ m_classes.put(IDL, c);
+ return c;
+ }
+ catch (ClassNotFoundException ex)
+ {
+ return null;
+ }
+ }
}
}
@@ -301,9 +362,9 @@ public class ObjectCreator
* and create an object instance with parameterless constructor. The OMG
* prefix (omg.org) is replaced by the java prefix org.omg. No other prefixes
* are added.
- *
+ *
* @param IDL the idl name.
- *
+ *
* @return instantiated object instance or null if such attempt was not
* successful.
*/
@@ -325,34 +386,53 @@ public class ObjectCreator
}
/**
- * Convert the class name to IDL name.
- *
- * @param cn the class name.
- *
- * @return the idl name.
+ * Convert the class name to IDL or RMI name (repository id). If the class
+ * inherits from IDLEntity, ValueBase or SystemException, returns repository
+ * Id in the IDL:(..) form. If it does not, returns repository Id in the
+ * RMI:(..) form.
+ *
+ * @param cx the class for that the name must be computed.
+ *
+ * @return the idl or rmi name.
*/
- public static String toIDL(String cn)
+ public static synchronized String getRepositoryId(Class cx)
{
- if (cn.startsWith(JAVA_PREFIX))
- cn = OMG_PREFIX + cn.substring(JAVA_PREFIX.length()).replace('.', '/');
- else if (cn.startsWith(CLASSPATH_PREFIX))
- cn =
- OMG_PREFIX +
- cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
-
- return "IDL:" + cn + ":1.0";
+ String name = (String) m_names.get(cx);
+ if (name != null)
+ return name;
+
+ String cn = cx.getName();
+ if (!(IDLEntity.class.isAssignableFrom(cx)
+ || ValueBase.class.isAssignableFrom(cx) || SystemException.class.isAssignableFrom(cx)))
+ {
+ // Not an IDL entity.
+ name = Util.createValueHandler().getRMIRepositoryID(cx);
+ }
+ else
+ {
+ if (cn.startsWith(JAVA_PREFIX))
+ cn = OMG_PREFIX
+ + cn.substring(JAVA_PREFIX.length()).replace('.', '/');
+ else if (cn.startsWith(CLASSPATH_PREFIX))
+ cn = OMG_PREFIX
+ + cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
+
+ name = "IDL:" + cn + ":1.0";
+ }
+ m_names.put(cx, name);
+ return name;
}
/**
* Insert the passed parameter into the given Any, assuming that the helper
* class is available. The helper class must have the "Helper" suffix and be
* in the same package as the class of the object being inserted.
- *
+ *
* @param into the target to insert.
- *
+ *
* @param object the object to insert. It can be any object as far as the
* corresponding helper is provided.
- *
+ *
* @return true on success, false otherwise.
*/
public static boolean insertWithHelper(Any into, Object object)
@@ -360,12 +440,10 @@ public class ObjectCreator
try
{
String helperClassName = object.getClass().getName() + "Helper";
- Class helperClass = Class.forName(helperClassName);
+ Class helperClass = forName(helperClassName);
- Method insert =
- helperClass.getMethod("insert",
- new Class[] { Any.class, object.getClass() }
- );
+ Method insert = helperClass.getMethod("insert", new Class[] {
+ Any.class, object.getClass() });
insert.invoke(null, new Object[] { into, object });
@@ -385,20 +463,20 @@ public class ObjectCreator
{
try
{
- cdrBufOutput output = new cdrBufOutput();
+ BufferedCdrOutput output = new BufferedCdrOutput();
- String m_exception_id = toIDL(exception.getClass().getName());
+ String m_exception_id = getRepositoryId(exception.getClass());
output.write_string(m_exception_id);
output.write_ulong(exception.minor);
CompletionStatusHelper.write(output, exception.completed);
String name = getDefaultName(m_exception_id);
- universalHolder h = new universalHolder(output);
+ GeneralHolder h = new GeneralHolder(output);
into.insert_Streamable(h);
- recordTypeCode r = new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_except);
r.setId(m_exception_id);
r.setName(name);
into.type(r);
@@ -444,4 +522,69 @@ public class ObjectCreator
if (!ok)
throw new InternalError("Exception wrapping broken");
}
+
+ /**
+ * Find helper for the class with the given name.
+ */
+ public static Class findHelper(String idl)
+ {
+ synchronized (m_helpers)
+ {
+ Class c = (Class) m_helpers.get(idl);
+ if (c != null)
+ return c;
+ try
+ {
+ String helper = toHelperName(idl);
+ c = forName(helper);
+
+ m_helpers.put(idl, c);
+ return c;
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+ }
+
+ /**
+ * Load the class with the given name. This method tries to use the context
+ * class loader first. If this fails, it searches for the suitable class
+ * loader in the caller stack trace. This method is a central point where all
+ * requests to find a class by name are delegated.
+ */
+ public static Class forName(String className) throws ClassNotFoundException
+ {
+ try
+ {
+ return Class.forName(className, true,
+ Thread.currentThread().getContextClassLoader());
+ }
+ catch (ClassNotFoundException nex)
+ {
+ /**
+ * Returns the first user defined class loader on the call stack, or
+ * null when no non-null class loader was found.
+ */
+ Class[] ctx = VMStackWalker.getClassContext();
+ for (int i = 0; i < ctx.length; i++)
+ {
+ // Since we live in a class loaded by the bootstrap
+ // class loader, getClassLoader is safe to call without
+ // needing to be wrapped in a privileged action.
+ ClassLoader cl = ctx[i].getClassLoader();
+ try
+ {
+ if (cl != null)
+ return Class.forName(className, true, cl);
+ }
+ catch (ClassNotFoundException nex2)
+ {
+ // Try next.
+ }
+ }
+ }
+ throw new ClassNotFoundException(className);
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/OctetHolder.java b/libjava/classpath/gnu/CORBA/OctetHolder.java
index 02fd9a432ec..06d7538d70f 100644
--- a/libjava/classpath/gnu/CORBA/OctetHolder.java
+++ b/libjava/classpath/gnu/CORBA/OctetHolder.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.primitiveTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -64,7 +64,7 @@ public final class OctetHolder
* The default type code for this holder.
*/
private static final TypeCode t_octet =
- new primitiveTypeCode(TCKind.tk_octet);
+ new PrimitiveTypeCode(TCKind.tk_octet);
/**
* The <code>long</code> (CORBA <code>octet</code>) value,
diff --git a/libjava/classpath/gnu/CORBA/OrbFocused.java b/libjava/classpath/gnu/CORBA/OrbFocused.java
new file mode 100644
index 00000000000..a0f9993c1a0
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/OrbFocused.java
@@ -0,0 +1,375 @@
+/* OrbFocused.java --
+ 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. */
+
+
+package gnu.CORBA;
+
+import gnu.CORBA.Poa.ORB_1_4;
+
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.CompletionStatus;
+import org.omg.CORBA.NO_RESOURCES;
+import org.omg.CORBA.portable.InvokeHandler;
+
+import java.applet.Applet;
+import java.net.ServerSocket;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Random;
+import java.util.StringTokenizer;
+
+/**
+ * This class implements the ORB that uses a single port or the restricted port
+ * range for all its objects. It is required to for use together with various
+ * firewalls that does not allow opening multiple randomly selected ports, as
+ * the defauld CORBA implementation used to do. The firewal must be configured
+ * to allow CORBA to work on one fixed port or (for better performance) on a
+ * small fixed range of ports. This does not restrict the maximal number of the
+ * connected objects as the objects can share the same port.
+ *
+ * The used port or the used port range can be specified via property
+ * gnu.CORBA.ListenerPort. The value of this property is a single port or range
+ * of ports, boundary values (inclusive) being separeted by dash (for instance,
+ * "1245-1250").
+ *
+ * It is possible to instantiate multiple instances of the focused ORBs and
+ * combine them with the ordinary ORBs. If you instantiate several instances of
+ * the focused ORBs on the same host, they used port sets should not overlap.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class OrbFocused
+ extends ORB_1_4
+{
+ /**
+ * The name of the fixed port range property. The presence of this property
+ * indicates that the default focused ORB must be used.
+ */
+ public static final String LISTENER_PORT = "gnu.CORBA.ListenerPort";
+
+ /**
+ * The start of the range of the available ports, inclusive.
+ */
+ int m_ports_from = -1;
+
+ /**
+ * The end of the range of the available ports, inclusive.
+ */
+ int m_ports_to = -1;
+
+ /**
+ * The requests to port are served in parallel threads.
+ */
+ static final int PARALLEL = 0;
+
+ /**
+ * The requests to port are served in the same thread.
+ */
+ static final int SEQUENTIAL = 1;
+
+ /**
+ * The random number generator to get a random port in the valid range.
+ */
+ Random m_random = new Random();
+
+ /**
+ * Parse the "gnu.CORBA.ListenerPort" property and initialize the valid port
+ * set range.
+ */
+ public void setPortRange(String property)
+ {
+ int from, to;
+ try
+ {
+ StringTokenizer st = new StringTokenizer(property, " -");
+ if (st.countTokens() == 1)
+ from = to = Integer.parseInt(st.nextToken());
+ else
+ {
+ from = Integer.parseInt(st.nextToken());
+ to = Integer.parseInt(st.nextToken());
+ m_random = new Random();
+ }
+ setPortRange(from, to);
+ }
+ catch (Exception ex)
+ {
+ throw new BAD_PARAM("Unable to parse port range '" + property + "'");
+ }
+ }
+
+ /**
+ * Set the port range.
+ *
+ * @param from - start of the port range, inclusive.
+ * @param to - end of the port range, inclusive.
+ */
+ public void setPortRange(int from, int to)
+ {
+ if (from < 0 || to < 0 || to < from)
+ throw new BAD_PARAM("Invalid range");
+ m_ports_from = from;
+ m_ports_to = to;
+ }
+
+ /**
+ * Get the port from the previously specified usage range.
+ */
+ int getPortFromRange(int attempt)
+ {
+ if (m_ports_from == m_ports_to)
+ return m_ports_from;
+ else if (m_ports_to - m_ports_from < RANDOM_PORT_ATTEMPTS)
+ return m_ports_from + (attempt % (m_ports_to - m_ports_from + 1));
+ else
+ return m_random.nextInt(m_ports_to - m_ports_from + 1) + m_ports_from;
+ }
+
+ /**
+ * Get the shared port server where the new object can be added. This may
+ * result reusing the existing server or instantiating a new server. If the
+ * new server is instantiated and the ORB is already running, the server is
+ * started.
+ */
+ protected portServer getPortServer(int type)
+ {
+ portServer p;
+
+ int n;
+ if (m_ports_from < m_ports_to)
+ n = RANDOM_PORT_ATTEMPTS;
+ else
+ n = 1;
+
+ Ports: for (int a = 0; a < n; a++)
+ {
+ int port = getPortFromRange(a);
+ for (int i = 0; i < portServers.size(); i++)
+ {
+ p = (portServer) portServers.get(i);
+ if (p.s_port == port)
+ {
+ return (portServer) p;
+ }
+ }
+ // The server is not yet instantiated. Instantiate.
+ try
+ {
+ // Check if the port is ok:
+ ServerSocket s = socketFactory.createServerSocket(port);
+ s.close();
+
+ portServer shared;
+
+ switch (type)
+ {
+ case PARALLEL:
+ shared = new portServer(port);
+ break;
+
+ case SEQUENTIAL:
+ shared = new sharedPortServer(port);
+ break;
+
+ default:
+ throw new InternalError("Invalid server type " + type);
+ }
+
+ portServers.add(shared);
+
+ if (running)
+ shared.start();
+
+ return shared;
+ }
+ catch (Exception ex)
+ {
+ // Port is taken or probably other problems.
+ continue Ports;
+ }
+ }
+ throw new NO_RESOURCES("No free port available at " + m_ports_from + "-"
+ + m_ports_to, Minor.Ports, CompletionStatus.COMPLETED_NO);
+ }
+
+ /**
+ * Start the ORBs main working cycle (receive invocation - invoke on the local
+ * object - send response - wait for another invocation).
+ *
+ * The method only returns after calling {@link #shutdown(boolean)}.
+ */
+ public void run()
+ {
+ if (m_ports_from < 0 || m_ports_to < 0)
+ throw new BAD_INV_ORDER("For " + getClass().getName() + " "
+ + LISTENER_PORT + " property must be set");
+
+ running = true;
+
+ // Start all port servers. In the current subclass, the portServers
+ // collection must be already filled in.
+ Iterator iter = portServers.iterator();
+
+ while (iter.hasNext())
+ {
+ portServer subserver = (portServer) iter.next();
+
+ if (!subserver.isAlive())
+ {
+ // Reuse the current thread for the last portServer.
+ if (!iter.hasNext())
+ {
+ // Discard the iterator.
+ iter = null;
+ subserver.run();
+ return;
+ }
+ else
+ subserver.start();
+ }
+ }
+ }
+
+ /**
+ * Get free port from the allowed range. This method instantiates the port
+ * server for the returned port.
+ */
+ public int getFreePort()
+ throws BAD_OPERATION
+ {
+ portServer s = getPortServer(PARALLEL);
+ return s.s_port;
+ }
+
+ /**
+ * Connect the given CORBA object to this ORB, explicitly specifying the
+ * object key and the identity of the thread (and port), where the object must
+ * be served. The identity is normally the POA.
+ *
+ * The new port server will be started only if there is no one already running
+ * for the same identity. Otherwise, the task of the existing port server will
+ * be widened, including duty to serve the given object. All objects,
+ * connected to a single identity by this method, will process they requests
+ * subsequently in the same thread. The method is used when the expected
+ * number of the objects is too large to have a single port and thread per
+ * object. This method is used by POAs, having a single thread policy.
+ *
+ * @param object the object, must implement the {@link InvokeHandler})
+ * interface.
+ * @param key the object key, usually used to identify the object from remote
+ * side.
+ * @param port the port, where the object must be connected.
+ *
+ * @throws BAD_PARAM if the object does not implement the
+ * {@link InvokeHandler}).
+ */
+ public void connect_1_thread(org.omg.CORBA.Object object, byte[] key,
+ java.lang.Object identity)
+ {
+ sharedPortServer shared = (sharedPortServer) identities.get(identity);
+ if (shared == null)
+ {
+ shared = (sharedPortServer) getPortServer(SEQUENTIAL);
+ identities.put(identity, shared);
+ if (running)
+ {
+ shared.start();
+ }
+ }
+
+ Connected_objects.cObject ref = connected_objects.add(key, object,
+ shared.s_port, identity);
+ IOR ior = createIOR(ref);
+ prepareObject(object, ior);
+ }
+
+ /**
+ * In this type of ORB, the service is started by {@link #getPortServer}. The
+ * method below is not in use and should return without action.
+ */
+ public void startService(IOR ior)
+ {
+ }
+
+ /**
+ * Set parameters (additionally search for the port range property).
+ */
+ protected void set_parameters(Applet applet, Properties props)
+ {
+ super.set_parameters(applet, props);
+ String lp = applet.getParameter(LISTENER_PORT);
+ if (lp != null)
+ setPortRange(lp);
+ }
+
+ /**
+ * Set parameters (additionally search for the port range property).
+ */
+ protected void set_parameters(String[] args, Properties props)
+ {
+ super.set_parameters(args, props);
+ String lp = null;
+
+ String lpKey = "-" + LISTENER_PORT;
+
+ if (args != null)
+ if (args.length >= 2)
+ {
+ for (int i = 0; i < args.length - 1; i++)
+ if (args[i].equals(lpKey))
+ lp = args[i + 1];
+ }
+
+ if (lp != null)
+ setPortRange(lp);
+
+ }
+
+ /**
+ * Additionally set the port range property, when applicable.
+ */
+ protected void useProperties(Properties props)
+ {
+ super.useProperties(props);
+ String lp = props.getProperty(LISTENER_PORT);
+ if (lp != null)
+ setPortRange(lp);
+ }
+
+}
diff --git a/libjava/classpath/gnu/CORBA/Functional_ORB.java b/libjava/classpath/gnu/CORBA/OrbFunctional.java
index 1565b2cf14a..f147e817a0f 100644
--- a/libjava/classpath/gnu/CORBA/Functional_ORB.java
+++ b/libjava/classpath/gnu/CORBA/OrbFunctional.java
@@ -1,4 +1,4 @@
-/* Functional_ORB.java --
+/* OrbFunctional.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.UnknownExceptionCtxHandler;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.CloseMessage;
import gnu.CORBA.GIOP.ErrorMessage;
import gnu.CORBA.GIOP.MessageHeader;
@@ -48,38 +49,35 @@ import gnu.CORBA.GIOP.RequestHeader;
import gnu.CORBA.NamingService.NameParser;
import gnu.CORBA.NamingService.NamingServiceTransient;
import gnu.CORBA.Poa.gnuForwardRequest;
+import gnu.CORBA.interfaces.SocketFactory;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
-import org.omg.CORBA.DATA_CONVERSION;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_RESOURCES;
import org.omg.CORBA.OBJECT_NOT_EXIST;
-import org.omg.CORBA.Object;
-import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.Request;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.WrongTransaction;
+import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InvokeHandler;
import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.CORBA.portable.UnknownException;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import java.applet.Applet;
-
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
-
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -87,6 +85,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
+import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
@@ -98,14 +97,15 @@ import java.util.TreeMap;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class Functional_ORB extends Restricted_ORB
+public class OrbFunctional extends OrbRestricted
{
/**
* A server, responsible for listening on requests on some local port. The ORB
* may listen on multiple ports and process the requests in separate threads.
* Normally the server takes one port per object being served.
*/
- class portServer extends Thread
+ protected class portServer
+ extends Thread
{
/**
* The number of the currently running parallel threads.
@@ -133,26 +133,27 @@ public class Functional_ORB extends Restricted_ORB
portServer(int _port)
{
s_port = _port;
- }
-
- /**
- * Enter the serving loop (get request/process it). All portServer normally
- * terminate thy threads when the Functional_ORB.running is set to false.
- */
- public void run()
- {
+ setDaemon(true);
try
{
- service = new ServerSocket(s_port);
+ service = socketFactory.createServerSocket(s_port);
}
catch (IOException ex)
{
- BAD_OPERATION bad =
- new BAD_OPERATION("Unable to open the server socket.");
+ BAD_OPERATION bad = new BAD_OPERATION(
+ "Unable to open the server socket at " + s_port);
+ bad.minor = Minor.Socket;
bad.initCause(ex);
throw bad;
}
+ }
+ /**
+ * Enter the serving loop (get request/process it). All portServer normally
+ * terminate thy threads when the OrbFunctional.running is set to false.
+ */
+ public void run()
+ {
while (running)
{
try
@@ -168,11 +169,11 @@ public class Functional_ORB extends Restricted_ORB
}
catch (Exception iex)
{
- // Wait 5 seconds. Do not terminate the
+ // Wait. Do not terminate the
// service due potentially transient error.
try
{
- Thread.sleep(5000);
+ Thread.sleep(TWAIT_SERVER_ERROR_PAUSE);
}
catch (InterruptedException ex)
{
@@ -183,10 +184,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* Perform a single serving step.
- *
+ *
* @throws java.lang.Exception
*/
- void tick() throws Exception
+ void tick()
+ throws Exception
{
serve(this, service);
}
@@ -222,7 +224,7 @@ public class Functional_ORB extends Restricted_ORB
* serving multiple requests (probably to the different objects) on the same
* thread.
*/
- class sharedPortServer extends portServer
+ protected class sharedPortServer extends portServer
{
/**
* Create a new portServer, serving on specific port.
@@ -249,6 +251,23 @@ public class Functional_ORB extends Restricted_ORB
* for a free port.
*/
public static int DEFAULT_INITIAL_PORT = 1126;
+
+ /**
+ * When trying to open the socket on a random port, start of the interval to
+ * try.
+ */
+ public static int RANDOM_PORT_FROM = 1024;
+
+ /**
+ * When trying to open the socket on a random port, end of the interval to
+ * try.
+ */
+ public static int RANDOM_PORT_TO = 4024;
+
+ /**
+ * The number of attempts to try when opening random port.
+ */
+ public static int RANDOM_PORT_ATTEMPTS = 64;
/**
* The property of port, on that this ORB is listening for requests from
@@ -277,7 +296,18 @@ public class Functional_ORB extends Restricted_ORB
* The string, defining the naming service initial reference.
*/
public static final String NAME_SERVICE = "NameService";
-
+
+ /**
+ * Defines the ORB ID that is accessible by IOR interceptors.
+ */
+ public static final String ORB_ID = "org.omg.CORBA.ORBid";
+
+
+ /**
+ * Defines the SERVER ID that is accessible by IOR interceptors.
+ */
+ public static final String SERVER_ID = "org.omg.CORBA.ServerId";
+
/**
* The if the client has once opened a socket, it should start sending the
* message header in a given time. Otherwise the server will close the socket.
@@ -301,6 +331,13 @@ public class Functional_ORB extends Restricted_ORB
*/
public static String AFTER_RECEIVING =
"gnu.classpath.CORBA.TOUT_AFTER_RECEIVING";
+
+ /**
+ * The server waits for this duration after the potentially transient error
+ * during its servicing cycle.
+ */
+ public static String SERVER_ERROR_PAUSE =
+ "gnu.classpath.CORBA.SERVER_ERROR_PAUSE";
/**
* The address of the local host.
@@ -313,7 +350,7 @@ public class Functional_ORB extends Restricted_ORB
* This prevents server hang when the client opens the socket, but does not
* send any message, usually due crash on the client side.
*/
- private int TOUT_START_READING_MESSAGE = 20 * 1000;
+ public int TOUT_START_READING_MESSAGE = 20 * 1000;
// (Here and below, we use * to make the meaning of the constant clearler).
@@ -321,14 +358,20 @@ public class Functional_ORB extends Restricted_ORB
* If the client has started to send the request message, the socket time out
* changes to the specified value.
*/
- private int TOUT_WHILE_READING = 2 * 60 * 1000;
+ public int TOUT_WHILE_READING = 2 * 60 * 1000;
/**
* If the message body is received, the time out changes to the specifice
* value. This must be longer, as includes time, required to process the
* received task. We make it 40 minutes.
*/
- private int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
+ public int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
+
+ /**
+ * The server waits for this duration after the potentially transient error
+ * during its servicing cycle.
+ */
+ public int TWAIT_SERVER_ERROR_PAUSE = 5000;
/**
* Some clients tend to submit multiple requests over the same socket. The
@@ -338,6 +381,17 @@ public class Functional_ORB extends Restricted_ORB
* seven seconds.
*/
public static int TANDEM_REQUESTS = 7000;
+
+ /**
+ * The Id of this ORB.
+ */
+ public String orb_id = "orb_"+hashCode();
+
+ /**
+ * The Id of this Server. This field is defined static to ensure it has
+ * the same value over all ORB's in this machine.
+ */
+ public static String server_id = "server_"+OrbFunctional.class.hashCode();
/**
* The map of the already conncted objects.
@@ -365,7 +419,7 @@ public class Functional_ORB extends Restricted_ORB
/**
* The currently active portServers.
*/
- private ArrayList portServers = new ArrayList();
+ protected ArrayList portServers = new ArrayList();
/**
* The host, on that the name service is expected to be running.
@@ -414,11 +468,16 @@ public class Functional_ORB extends Restricted_ORB
* exceeding this limit, the NO_RESOURCES is thrown back to the client.
*/
private int MAX_RUNNING_THREADS = 256;
+
+ /**
+ * The producer of the client and server sockets for this ORB.
+ */
+ public SocketFactory socketFactory = DefaultSocketFactory.Singleton;
/**
* Create the instance of the Functional ORB.
*/
- public Functional_ORB()
+ public OrbFunctional()
{
try
{
@@ -457,13 +516,14 @@ public class Functional_ORB extends Restricted_ORB
/**
* Get the currently free port, starting from the initially set port and going
* up max 20 steps, then trying to bind into any free address.
- *
+ *
* @return the currently available free port.
- *
+ *
* @throws NO_RESOURCES if the server socked cannot be opened on the local
* host.
*/
- public int getFreePort() throws BAD_OPERATION
+ public int getFreePort()
+ throws BAD_OPERATION
{
ServerSocket s;
int a_port;
@@ -475,7 +535,7 @@ public class Functional_ORB extends Restricted_ORB
{
Integer free = (Integer) freed_ports.getLast();
freed_ports.removeLast();
- s = new ServerSocket(free.intValue());
+ s = socketFactory.createServerSocket(free.intValue());
s.close();
return free.intValue();
}
@@ -491,7 +551,7 @@ public class Functional_ORB extends Restricted_ORB
{
try
{
- s = new ServerSocket(a_port);
+ s = socketFactory.createServerSocket(a_port);
s.close();
Port = a_port + 1;
return a_port;
@@ -502,21 +562,31 @@ public class Functional_ORB extends Restricted_ORB
}
}
- try
- {
- // Try any port.
- s = new ServerSocket();
- a_port = s.getLocalPort();
- s.close();
- return a_port;
- }
- catch (IOException ex)
+ Random rand = new Random();
+ // Try any random port in the interval RANDOM_PORT_FROM.RANDOM_PORT_TO.
+ int range = RANDOM_PORT_TO - RANDOM_PORT_FROM;
+ IOException ioex = null;
+ for (int i = 0; i < RANDOM_PORT_ATTEMPTS; i++)
{
- NO_RESOURCES bad =
- new NO_RESOURCES("Unable to open the server socket.");
- bad.initCause(ex);
- throw bad;
+ try
+ {
+ a_port = RANDOM_PORT_FROM + rand.nextInt(range);
+ s = socketFactory.createServerSocket(a_port);
+ s.close();
+ return a_port;
+ }
+ catch (IOException ex)
+ {
+ // Repeat the loop if this exception has been thrown.
+ ioex = ex;
+ }
}
+
+ NO_RESOURCES bad = new NO_RESOURCES("Unable to open the server socket.");
+ bad.minor = Minor.Ports;
+ if (ioex != null)
+ bad.initCause(ioex);
+ throw bad;
}
/**
@@ -525,7 +595,7 @@ public class Functional_ORB extends Restricted_ORB
* on this port first. It the port is busy, or if more objects are connected,
* the subsequent object will receive a larger port values, skipping
* unavailable ports, if required. The change applies globally.
- *
+ *
* @param a_Port a port, on that the server is listening for requests.
*/
public static void setPort(int a_Port)
@@ -677,9 +747,9 @@ public class Functional_ORB extends Restricted_ORB
if (object instanceof ObjectImpl)
{
Delegate delegate = ((ObjectImpl) object)._get_delegate();
- if (delegate instanceof Simple_delegate)
+ if (delegate instanceof SimpleDelegate)
{
- byte[] key = ((Simple_delegate) delegate).getIor().key;
+ byte[] key = ((SimpleDelegate) delegate).getIor().key;
rmKey = connected_objects.get(key);
}
}
@@ -756,11 +826,7 @@ public class Functional_ORB extends Restricted_ORB
if (!ior.Internet.host.equals(LOCAL_HOST))
return null;
- // Must be the same port.
- if (ior.Internet.port != Port)
- return null;
-
- return find_connected_object(ior.key);
+ return find_connected_object(ior.key, ior.Internet.port);
}
/**
@@ -806,8 +872,8 @@ public class Functional_ORB extends Restricted_ORB
if (forObject instanceof ObjectImpl)
{
Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
- if (delegate instanceof Simple_delegate)
- return ((Simple_delegate) delegate).getIor().toStringifiedReference();
+ if (delegate instanceof SimpleDelegate)
+ return ((SimpleDelegate) delegate).getIor().toStringifiedReference();
}
// Handle the case when the object is local.
@@ -899,7 +965,7 @@ public class Functional_ORB extends Restricted_ORB
}
else
subserver = (portServer) identities.get(obj.identity);
-
+
if (!subserver.isAlive())
{
// Reuse the current thread for the last portServer.
@@ -915,6 +981,30 @@ public class Functional_ORB extends Restricted_ORB
}
}
}
+
+ /**
+ * Start the server in a new thread, if not already running. This method is
+ * used to ensure that the objects being transfered will be served from the
+ * remote side, if required. If the ORB is started using this method, it
+ * starts as a daemon thread.
+ */
+ public void ensureRunning()
+ {
+ final OrbFunctional THIS = this;
+
+ if (!running)
+ {
+ Thread t = new Thread()
+ {
+ public void run()
+ {
+ THIS.run();
+ }
+ };
+ t.setDaemon(true);
+ t.start();
+ }
+ }
/**
* Shutdown the ORB server.
@@ -961,21 +1051,22 @@ public class Functional_ORB extends Restricted_ORB
org.omg.CORBA.Object object = find_local_object(ior);
if (object == null)
{
- ObjectImpl impl = stubFinder.search(this, ior);
+ ObjectImpl impl = StubLocator.search(this, ior);
try
{
if (impl._get_delegate() == null)
- impl._set_delegate(new IOR_Delegate(this, ior));
+ impl._set_delegate(new IorDelegate(this, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception
// in response to the attempt to get the unset delegate.
- impl._set_delegate(new IOR_Delegate(this, ior));
+ impl._set_delegate(new IorDelegate(this, ior));
}
object = impl;
- connected_objects.add(ior.key, impl, ior.Internet.port, null);
+ // TODO remove commented out code below.
+ // connected_objects.add(ior.key, impl, ior.Internet.port, null);
}
return object;
}
@@ -995,7 +1086,7 @@ public class Functional_ORB extends Restricted_ORB
ior.Internet.port = ns_port;
ior.key = NamingServiceTransient.getDefaultKey();
- IOR_contructed_object iorc = new IOR_contructed_object(this, ior);
+ IorObject iorc = new IorObject(this, ior);
NamingContextExt namer = NamingContextExtHelper.narrow(iorc);
initial_references.put(NAME_SERVICE, namer);
return namer;
@@ -1004,23 +1095,29 @@ public class Functional_ORB extends Restricted_ORB
/**
* Find and return the object, that must be previously connected to this ORB.
* Return null if no such object is available.
- *
+ *
* @param key the object key.
- *
+ * @param port the port where the object is connected.
+ *
* @return the connected object, null if none.
*/
- protected org.omg.CORBA.Object find_connected_object(byte[] key)
+ protected org.omg.CORBA.Object find_connected_object(byte[] key, int port)
{
Connected_objects.cObject ref = connected_objects.get(key);
- return ref == null ? null : ref.object;
+ if (ref == null)
+ return null;
+ if (port >= 0 && ref.port != port)
+ return null;
+ else
+ return ref.object;
}
/**
* Set the ORB parameters. This method is normally called from
* {@link #init(Applet, Properties)}.
- *
+ *
* @param app the current applet.
- *
+ *
* @param props application specific properties, passed as the second
* parameter in {@link #init(Applet, Properties)}. Can be <code>null</code>.
*/
@@ -1033,37 +1130,39 @@ public class Functional_ORB extends Restricted_ORB
{
for (int i = 0; i < para.length; i++)
{
- if (para [ i ] [ 0 ].equals(LISTEN_ON))
- Port = Integer.parseInt(para [ i ] [ 1 ]);
- if (para [ i ] [ 0 ].equals(REFERENCE))
+ if (para[i][0].equals(LISTEN_ON))
+ Port = Integer.parseInt(para[i][1]);
+ if (para[i][0].equals(REFERENCE))
{
- StringTokenizer st =
- new StringTokenizer(para [ i ] [ 1 ], "=");
+ StringTokenizer st = new StringTokenizer(para[i][1], "=");
initial_references.put(st.nextToken(),
- string_to_object(st.nextToken())
- );
+ string_to_object(st.nextToken()));
}
- if (para [ i ] [ 0 ].equals(NS_HOST))
- ns_host = para [ i ] [ 1 ];
- if (para [ i ] [ 0 ].equals(START_READING_MESSAGE))
- TOUT_START_READING_MESSAGE = Integer.parseInt(para [ i ] [ 1 ]);
- if (para [ i ] [ 0 ].equals(WHILE_READING))
- TOUT_WHILE_READING = Integer.parseInt(para [ i ] [ 1 ]);
- if (para [ i ] [ 0 ].equals(AFTER_RECEIVING))
- TOUT_AFTER_RECEIVING = Integer.parseInt(para [ i ] [ 1 ]);
+ if (para[i][0].equals(ORB_ID))
+ orb_id = para[i][1];
+
+ if (para[i][0].equals(SERVER_ID))
+ server_id = para[i][1];
+
+ if (para[i][0].equals(NS_HOST))
+ ns_host = para[i][1];
+ if (para[i][0].equals(START_READING_MESSAGE))
+ TOUT_START_READING_MESSAGE = Integer.parseInt(para[i][1]);
+ if (para[i][0].equals(WHILE_READING))
+ TOUT_WHILE_READING = Integer.parseInt(para[i][1]);
+ if (para[i][0].equals(AFTER_RECEIVING))
+ TOUT_AFTER_RECEIVING = Integer.parseInt(para[i][1]);
try
{
- if (para [ i ] [ 0 ].equals(NS_PORT))
- ns_port = Integer.parseInt(para [ i ] [ 1 ]);
+ if (para[i][0].equals(NS_PORT))
+ ns_port = Integer.parseInt(para[i][1]);
}
catch (NumberFormatException ex)
{
- BAD_PARAM bad =
- new BAD_PARAM("Invalid " + NS_PORT +
- "property, unable to parse '" +
- props.getProperty(NS_PORT) + "'"
- );
+ BAD_PARAM bad = new BAD_PARAM("Invalid " + NS_PORT
+ + "property, unable to parse '" + props.getProperty(NS_PORT)
+ + "'");
bad.initCause(ex);
throw bad;
}
@@ -1074,11 +1173,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* Set the ORB parameters. This method is normally called from
* {@link #init(String[], Properties)}.
- *
+ *
* @param para the parameters, that were passed as the parameters to the
* <code>main(String[] args)</code> method of the current standalone
* application.
- *
+ *
* @param props application specific properties that were passed as a second
* parameter in {@link init(String[], Properties)}). Can be <code>null</code>.
*/
@@ -1088,29 +1187,33 @@ public class Functional_ORB extends Restricted_ORB
{
for (int i = 0; i < para.length - 1; i++)
{
- if (para [ i ].endsWith("ListenOn"))
- Port = Integer.parseInt(para [ i + 1 ]);
- if (para [ i ].endsWith("ORBInitRef"))
+ if (para[i].endsWith("ListenOn"))
+ Port = Integer.parseInt(para[i + 1]);
+ if (para[i].endsWith("ORBInitRef"))
{
- StringTokenizer st = new StringTokenizer(para [ i + 1 ], "=");
+ StringTokenizer st = new StringTokenizer(para[i + 1], "=");
initial_references.put(st.nextToken(),
- string_to_object(st.nextToken())
- );
+ string_to_object(st.nextToken()));
}
- if (para [ i ].endsWith("ORBInitialHost"))
- ns_host = para [ i + 1 ];
+ if (para[i].endsWith("ORBInitialHost"))
+ ns_host = para[i + 1];
+
+ if (para[i].endsWith("ServerId"))
+ server_id = para[i++];
+ else if (para[i].endsWith("ORBid"))
+ orb_id = para[i++];
+
try
{
- if (para [ i ].endsWith("ORBInitialPort"))
- ns_port = Integer.parseInt(para [ i + 1 ]);
+ if (para[i].endsWith("ORBInitialPort"))
+ ns_port = Integer.parseInt(para[i + 1]);
}
catch (NumberFormatException ex)
{
- throw new BAD_PARAM("Invalid " + para [ i ] +
- "parameter, unable to parse '" +
- props.getProperty(para [ i + 1 ]) + "'"
- );
+ throw new BAD_PARAM("Invalid " + para[i]
+ + "parameter, unable to parse '"
+ + props.getProperty(para[i + 1]) + "'");
}
}
}
@@ -1156,7 +1259,7 @@ public class Functional_ORB extends Restricted_ORB
* @throws BAD_PARAM if the object does not implement the
* {@link InvokeHandler}).
*/
- private void prepareObject(org.omg.CORBA.Object object, IOR ior)
+ protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
throws BAD_PARAM
{
/*
@@ -1172,12 +1275,12 @@ public class Functional_ORB extends Restricted_ORB
try
{
if (impl._get_delegate() == null)
- impl._set_delegate(new Simple_delegate(this, ior));
+ impl._set_delegate(new SimpleDelegate(this, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception.
- impl._set_delegate(new Simple_delegate(this, ior));
+ impl._set_delegate(new SimpleDelegate(this, ior));
}
}
}
@@ -1197,7 +1300,7 @@ public class Functional_ORB extends Restricted_ORB
*/
private void respond_to_client(OutputStream net_out,
MessageHeader msh_request, RequestHeader rh_request,
- bufferedResponseHandler handler, SystemException sysEx
+ ResponseHandlerImpl handler, SystemException sysEx
) throws IOException
{
// Set the reply header properties.
@@ -1211,8 +1314,8 @@ public class Functional_ORB extends Restricted_ORB
reply.reply_status = ReplyHeader.NO_EXCEPTION;
reply.request_id = rh_request.request_id;
- cdrBufOutput out =
- new cdrBufOutput(50 + handler.getBuffer().buffer.size());
+ BufferedCdrOutput out =
+ new BufferedCdrOutput(50 + handler.getBuffer().buffer.size());
out.setOrb(this);
out.setOffset(msh_request.getHeaderSize());
@@ -1256,7 +1359,7 @@ public class Functional_ORB extends Restricted_ORB
rh_forward.request_id = rh_request.request_id;
// The forwarding code is either LOCATION_FORWARD or LOCATION_FORWARD_PERM.
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
out.setOrb(this);
out.setOffset(msh_forward.getHeaderSize());
@@ -1324,11 +1427,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* A single servicing step, when the client socket is alrady open.
- *
+ *
* Normally, each task matches a single remote invocation. However under
* frequent tandem submissions the same task may span over several
* invocations.
- *
+ *
* @param service the opened client socket.
* @param no_resources if true, the "NO RESOURCES" exception is thrown to the
* client.
@@ -1337,8 +1440,7 @@ public class Functional_ORB extends Restricted_ORB
{
try
{
- Serving:
- while (true)
+ Serving: while (true)
{
InputStream in = service.getInputStream();
service.setSoTimeout(TOUT_START_READING_MESSAGE);
@@ -1358,9 +1460,7 @@ public class Functional_ORB extends Restricted_ORB
if (max_version != null)
{
if (!msh_request.version.until_inclusive(max_version.major,
- max_version.minor
- )
- )
+ max_version.minor))
{
OutputStream out = service.getOutputStream();
new ErrorMessage(max_version).write(out);
@@ -1368,25 +1468,14 @@ public class Functional_ORB extends Restricted_ORB
}
}
- byte[] r = new byte[ msh_request.message_size ];
-
- int n = 0;
-
- service.setSoTimeout(TOUT_WHILE_READING);
-
- reading:
- while (n < r.length)
- {
- n += in.read(r, n, r.length - n);
- }
-
- service.setSoTimeout(TOUT_AFTER_RECEIVING);
+ byte[] r = msh_request.readMessage(in, service, TOUT_WHILE_READING,
+ TOUT_AFTER_RECEIVING);
if (msh_request.message_type == MessageHeader.REQUEST)
{
RequestHeader rh_request;
- cdrBufInput cin = new cdrBufInput(r);
+ BufferredCdrInput cin = new BufferredCdrInput(r);
cin.setOrb(this);
cin.setVersion(msh_request.version);
cin.setOffset(msh_request.getHeaderSize());
@@ -1406,8 +1495,8 @@ public class Functional_ORB extends Restricted_ORB
// find the target object.
}
- InvokeHandler target =
- (InvokeHandler) find_connected_object(rh_request.object_key);
+ InvokeHandler target = (InvokeHandler) find_connected_object(
+ rh_request.object_key, -1);
// Prepare the reply header. This must be done in advance,
// as the size must be known for handler to set alignments
@@ -1415,17 +1504,19 @@ public class Functional_ORB extends Restricted_ORB
ReplyHeader rh_reply = msh_request.create_reply_header();
// TODO log errors about not existing objects and methods.
- bufferedResponseHandler handler =
- new bufferedResponseHandler(this, msh_request, rh_reply,
- rh_request
- );
+ ResponseHandlerImpl handler = new ResponseHandlerImpl(
+ this, msh_request, rh_reply, rh_request);
SystemException sysEx = null;
try
{
if (no_resources)
- throw new NO_RESOURCES();
+ {
+ NO_RESOURCES no = new NO_RESOURCES("Too many parallel calls");
+ no.minor = Minor.Threads;
+ throw no;
+ }
if (target == null)
throw new OBJECT_NOT_EXIST();
target._invoke(rh_request.operation, cin, handler);
@@ -1442,24 +1533,45 @@ public class Functional_ORB extends Restricted_ORB
continue Serving;
}
}
+ catch (UnknownException uex)
+ {
+ sysEx = new UNKNOWN("Unknown", 2,
+ CompletionStatus.COMPLETED_MAYBE);
+ sysEx.initCause(uex.originalEx);
+
+ org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
+
+ rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
+ rh_reply.service_context, uex.originalEx, ech);
+
+ ObjectCreator.writeSystemException(ech, sysEx);
+ }
catch (SystemException ex)
{
sysEx = ex;
-
- org.omg.CORBA.portable.OutputStream ech =
- handler.createExceptionReply();
+
+ org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
+
+ rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
+ rh_reply.service_context, ex, ech);
+
ObjectCreator.writeSystemException(ech, ex);
}
catch (Exception except)
{
+ // This should never happen under normal operation and
+ // can only indicate errors in user object implementation.
+ // We inform the user.
except.printStackTrace();
- sysEx =
- new UNKNOWN("Unknown", 2,
- CompletionStatus.COMPLETED_MAYBE
- );
- org.omg.CORBA.portable.OutputStream ech =
- handler.createExceptionReply();
+ sysEx = new UNKNOWN("Unknown", 2,
+ CompletionStatus.COMPLETED_MAYBE);
+ sysEx.initCause(except);
+
+ org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
+
+ rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
+ rh_reply.service_context, except, ech);
ObjectCreator.writeSystemException(ech, sysEx);
}
@@ -1469,21 +1581,17 @@ public class Functional_ORB extends Restricted_ORB
{
OutputStream sou = service.getOutputStream();
respond_to_client(sou, msh_request, rh_request, handler,
- sysEx
- );
+ sysEx);
}
}
- else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION ||
- msh_request.message_type == MessageHeader.MESSAGE_ERROR
- )
+ else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION
+ || msh_request.message_type == MessageHeader.MESSAGE_ERROR)
{
CloseMessage.close(service.getOutputStream());
service.close();
return;
}
- ;
- // TODO log error: "Not a request message."
if (service != null && !service.isClosed())
// Wait for the subsequent invocations on the
@@ -1505,8 +1613,12 @@ public class Functional_ORB extends Restricted_ORB
return;
}
}
-
- private void useProperties(Properties props)
+
+ /**
+ * Set the ORB parameters from the properties that were accumulated
+ * from several locations.
+ */
+ protected void useProperties(Properties props)
{
if (props != null)
{
@@ -1527,6 +1639,9 @@ public class Functional_ORB extends Restricted_ORB
if (props.containsKey(AFTER_RECEIVING))
TOUT_AFTER_RECEIVING =
Integer.parseInt(props.getProperty(AFTER_RECEIVING));
+ if (props.containsKey(SERVER_ERROR_PAUSE))
+ TWAIT_SERVER_ERROR_PAUSE =
+ Integer.parseInt(props.getProperty(SERVER_ERROR_PAUSE));
}
catch (NumberFormatException ex)
{
@@ -1535,7 +1650,31 @@ public class Functional_ORB extends Restricted_ORB
"'"
);
}
-
+
+ if (props.containsKey(SocketFactory.PROPERTY))
+ {
+ String factory = null;
+ try
+ {
+ factory = props.getProperty(SocketFactory.PROPERTY);
+ if (factory!=null)
+ socketFactory = (SocketFactory)
+ ObjectCreator.forName(factory).newInstance();
+ }
+ catch (Exception ex)
+ {
+ BAD_PARAM p = new BAD_PARAM("Bad socket factory "+factory);
+ p.initCause(ex);
+ throw p;
+ }
+ }
+
+ if (props.containsKey(ORB_ID))
+ orb_id = props.getProperty(ORB_ID);
+
+ if (props.containsKey(SERVER_ID))
+ server_id = props.getProperty(SERVER_ID);
+
Enumeration en = props.elements();
while (en.hasMoreElements())
{
diff --git a/libjava/classpath/gnu/CORBA/Restricted_ORB.java b/libjava/classpath/gnu/CORBA/OrbRestricted.java
index 247cd205ccb..c0401800a89 100644
--- a/libjava/classpath/gnu/CORBA/Restricted_ORB.java
+++ b/libjava/classpath/gnu/CORBA/OrbRestricted.java
@@ -38,7 +38,11 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.typecodes.AliasTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
@@ -60,6 +64,7 @@ import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ValueFactory;
import org.omg.PortableInterceptor.ClientRequestInterceptorOperations;
import org.omg.PortableInterceptor.IORInterceptorOperations;
+import org.omg.PortableInterceptor.IORInterceptor_3_0Operations;
import org.omg.PortableInterceptor.ServerRequestInterceptorOperations;
import java.applet.Applet;
@@ -82,18 +87,18 @@ import java.util.Properties;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
+public class OrbRestricted extends org.omg.CORBA_2_3.ORB
{
/**
* The singleton instance of this ORB.
*/
- public static final ORB Singleton = new Restricted_ORB();
+ public static final ORB Singleton = new OrbRestricted();
/**
* The cumulated listener for all IOR interceptors. Interceptors are used by
* {@link gnu.CORBA.Poa.ORB_1_4}.
*/
- public IORInterceptorOperations iIor;
+ public IORInterceptor_3_0Operations iIor;
/**
* The cumulated listener for all server request interceptors. Interceptors
@@ -126,14 +131,14 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
* Create a new instance of the RestrictedORB. This is used in derived classes
* only.
*/
- protected Restricted_ORB()
+ protected OrbRestricted()
{
}
/** {@inheritDoc} */
public TypeCode create_alias_tc(String id, String name, TypeCode typecode)
{
- return new aliasTypeCode(typecode, id, name);
+ return new AliasTypeCode(typecode, id, name);
}
/** {@inheritDoc} */
@@ -147,8 +152,8 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_array_tc(int length, TypeCode element_type)
{
- primitiveArrayTypeCode p =
- new primitiveArrayTypeCode(TCKind.tk_array, element_type);
+ ArrayTypeCode p =
+ new ArrayTypeCode(TCKind.tk_array, element_type);
p.setLength(length);
return p;
}
@@ -162,7 +167,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_enum_tc(String id, String name, String[] values)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_enum);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_enum);
for (int i = 0; i < values.length; i++)
{
r.field().name = values [ i ];
@@ -191,7 +196,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
StructMember[] members
)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_except);
r.setId(id);
r.setName(name);
@@ -229,7 +234,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public OutputStream create_output_stream()
{
- cdrBufOutput stream = new cdrBufOutput();
+ BufferedCdrOutput stream = new BufferedCdrOutput();
stream.setOrb(this);
return stream;
}
@@ -237,8 +242,8 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_sequence_tc(int bound, TypeCode element_type)
{
- primitiveArrayTypeCode p =
- new primitiveArrayTypeCode(TCKind.tk_sequence, element_type);
+ ArrayTypeCode p =
+ new ArrayTypeCode(TCKind.tk_sequence, element_type);
p.setLength(bound);
return p;
}
@@ -246,7 +251,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_string_tc(int bound)
{
- stringTypeCode p = new stringTypeCode(TCKind.tk_string);
+ StringTypeCode p = new StringTypeCode(TCKind.tk_string);
p.setLength(bound);
return p;
}
@@ -256,7 +261,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
StructMember[] members
)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_struct);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_struct);
r.setId(id);
r.setName(name);
@@ -273,7 +278,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
TypeCode discriminator_type, UnionMember[] members
)
{
- recordTypeCode r = new recordTypeCode(TCKind.tk_union);
+ RecordTypeCode r = new RecordTypeCode(TCKind.tk_union);
r.setId(id);
r.setName(name);
r.setDiscriminator_type(discriminator_type);
@@ -290,7 +295,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_wstring_tc(int bound)
{
- stringTypeCode p = new stringTypeCode(TCKind.tk_wstring);
+ StringTypeCode p = new StringTypeCode(TCKind.tk_wstring);
p.setLength(bound);
return p;
}
@@ -300,7 +305,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
{
try
{
- return typeNamer.getPrimitveTC(tcKind);
+ return TypeKindNamer.getPrimitveTC(tcKind);
}
catch (BadKind ex)
{
diff --git a/libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java b/libjava/classpath/gnu/CORBA/Poa/AOM.java
index 1354ba9c5e1..9faf0883ded 100644
--- a/libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java
+++ b/libjava/classpath/gnu/CORBA/Poa/AOM.java
@@ -1,4 +1,4 @@
-/* activeObjectMap.java --
+/* AOM.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,7 +40,6 @@ package gnu.CORBA.Poa;
import gnu.CORBA.ByteArrayComparator;
-import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;
import java.util.Iterator;
@@ -57,7 +56,7 @@ import java.util.TreeMap;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class activeObjectMap
+public class AOM
{
/**
* The reference data about the object, placed on the AOM.
@@ -67,7 +66,7 @@ public class activeObjectMap
/**
* Create an initialised instance.
*/
- Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, POA _poa)
+ Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, gnuPOA _poa)
{
object = _object;
key = _key;
@@ -96,7 +95,7 @@ public class activeObjectMap
/**
* The POA, where the object is connected.
*/
- public final POA poa;
+ public final gnuPOA poa;
/**
* The object key.
@@ -142,17 +141,6 @@ public class activeObjectMap
{
deactivated = state;
}
-
- public boolean equals(java.lang.Object other)
- {
- if (other instanceof Obj)
- {
- Obj o = (Obj) other;
- return o.object.equals(object);
- }
- else
- return false;
- }
}
/**
@@ -269,7 +257,7 @@ public class activeObjectMap
*
* @return the newly created object record.
*/
- public Obj add(org.omg.CORBA.Object object, Servant servant, POA poa)
+ public Obj add(org.omg.CORBA.Object object, Servant servant, gnuPOA poa)
{
return add(generateObjectKey(object), object, servant, poa);
}
@@ -283,7 +271,7 @@ public class activeObjectMap
* @param poa the POA, where the object is connected.
*/
public Obj add(byte[] key, org.omg.CORBA.Object object, Servant servant,
- POA poa
+ gnuPOA poa
)
{
Obj rec = new Obj(object, key, servant, poa);
@@ -298,7 +286,7 @@ public class activeObjectMap
* and object.
* @param port the port that this object would take.
*/
- public Obj add(servantDelegate delegate)
+ public Obj add(ServantDelegateImpl delegate)
{
Obj rec =
new Obj(delegate.object, delegate.servant_id, delegate.servant,
diff --git a/libjava/classpath/gnu/CORBA/Poa/vPolicy.java b/libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java
index 9e45b56d7ee..44ebaf45351 100644
--- a/libjava/classpath/gnu/CORBA/Poa/vPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java
@@ -1,4 +1,4 @@
-/* vPolicy.java --
+/* AccessiblePolicy.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import org.omg.CORBA.Policy;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public interface vPolicy
+public interface AccessiblePolicy
extends Policy
{
/**
diff --git a/libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java b/libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java
index 1cc3e131cd7..903f8bfbbe1 100644
--- a/libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java
+++ b/libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java
@@ -1,4 +1,4 @@
-/* dynImpHandler.java --
+/* DynamicImpHandler.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,7 +53,7 @@ import org.omg.PortableServer.DynamicImplementation;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class dynImpHandler
+public class DynamicImpHandler
implements InvokeHandler
{
/**
@@ -66,7 +66,7 @@ public class dynImpHandler
* Create a new instance, wrapping some dyn implementation.
* @param _servant
*/
- public dynImpHandler(DynamicImplementation _servant)
+ public DynamicImpHandler(DynamicImplementation _servant)
{
servant = _servant;
}
diff --git a/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java b/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java
index 2df378df6a4..b1d5eaf8c03 100644
--- a/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java
+++ b/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java
@@ -39,8 +39,9 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.IOR;
-import gnu.CORBA.IOR_Delegate;
-import gnu.CORBA.IOR_contructed_object;
+import gnu.CORBA.IorDelegate;
+import gnu.CORBA.IorObject;
+import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
@@ -101,9 +102,9 @@ public class ForwardedServant
ObjectImpl fto = (ObjectImpl) a_ref;
// Check maybe the remote side forwarded back to our local object.
- if (fto instanceof IOR_contructed_object)
+ if (fto instanceof IorObject)
{
- IOR_contructed_object iref = (IOR_contructed_object) fto;
+ IorObject iref = (IorObject) fto;
// Check maybe the IOR is local.
ORB t_orb = iref._orb();
@@ -111,13 +112,13 @@ public class ForwardedServant
{
ORB_1_4 orb = (ORB_1_4) t_orb;
Delegate d = iref._get_delegate();
- if (d instanceof IOR_Delegate)
+ if (d instanceof IorDelegate)
{
- IOR_Delegate ird = (IOR_Delegate) iref._get_delegate();
+ IorDelegate ird = (IorDelegate) iref._get_delegate();
IOR ior = ird.getIor();
if (orb.LOCAL_HOST.equalsIgnoreCase(ior.Internet.host))
{
- activeObjectMap.Obj rx = orb.rootPOA.findIorKey(ior.key);
+ AOM.Obj rx = orb.rootPOA.findIorKey(ior.key);
if (rx != null)
{
if (rx.object == fto ||
@@ -175,6 +176,7 @@ public class ForwardedServant
catch (IOException io_ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Forwarding;
m.initCause(io_ex);
throw m;
}
diff --git a/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java b/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java
index 7af3369d2e8..72dd8f0cf50 100644
--- a/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java
+++ b/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java
@@ -38,8 +38,10 @@ exception statement from your version. */
package gnu.CORBA.Poa;
-import gnu.CORBA.CDR.cdrOutput;
-import gnu.CORBA.streamRequest;
+import gnu.CORBA.CDR.AbstractCdrOutput;
+import gnu.CORBA.IOR;
+import gnu.CORBA.IorProvider;
+import gnu.CORBA.StreamBasedRequest;
import org.omg.CORBA.ARG_INOUT;
import org.omg.CORBA.Bounds;
@@ -68,17 +70,22 @@ import java.util.Arrays;
* A local delegate, transferring all object requests to the locally available
* servant. This class is involved in handling the method invocations on the
* local object, obtained by POA.create_reference_with_id.
- *
+ *
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
+public class LocalDelegate
+ extends org.omg.CORBA_2_3.portable.Delegate
+ implements IorProvider
{
/**
* The same servant as an invocation handler.
*/
gnuServantObject object;
+
String operation;
- final gnuPOA poa;
+
+ public final gnuPOA poa;
+
final byte[] Id;
/**
@@ -91,6 +98,14 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
poa = a_poa;
Id = an_id;
}
+
+ /**
+ * Get the IOR of the connected object.
+ */
+ public IOR getIor()
+ {
+ return object.getIor();
+ }
public Request request(org.omg.CORBA.Object target, String method)
{
@@ -107,8 +122,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
}
public boolean is_equivalent(org.omg.CORBA.Object target,
- org.omg.CORBA.Object other
- )
+ org.omg.CORBA.Object other)
{
if (target == other)
return true;
@@ -157,9 +171,9 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Check if this object could be named by the given repository id.
- *
+ *
* @param idl_id the repository id to check.
- *
+ *
* @return true if it is one of the possible repository ids of this object.
*/
public boolean is_a(org.omg.CORBA.Object a_servant, String idl_id)
@@ -167,7 +181,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
String[] maybe = object._ids();
for (int i = 0; i < maybe.length; i++)
{
- if (maybe [ i ].equals(idl_id))
+ if (maybe[i].equals(idl_id))
return true;
}
return false;
@@ -186,8 +200,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String method, NVList parameters, NamedValue returns,
- ExceptionList exceptions, ContextList ctx_list
- )
+ ExceptionList exceptions, ContextList ctx_list)
{
operation = method;
@@ -204,8 +217,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
* Create request for using with DII.
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
- String method, NVList parameters, NamedValue returns
- )
+ String method, NVList parameters, NamedValue returns)
{
operation = method;
@@ -226,23 +238,20 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Create a request to invoke the method of this CORBA object.
- *
+ *
* @param operation the name of the method to invoke.
* @param response_expected specifies if this is one way message or the
* response to the message is expected.
- *
+ *
* @return the stream where the method arguments should be written.
*/
public org.omg.CORBA.portable.OutputStream request(
- org.omg.CORBA.Object target,
- String method,
- boolean response_expected
- )
+ org.omg.CORBA.Object target, String method, boolean response_expected)
{
operation = method;
// Check if the object is not explicitly deactivated.
- activeObjectMap.Obj e = poa.aom.get(Id);
+ AOM.Obj e = poa.aom.get(Id);
if (e != null && e.isDeactiveted())
{
if (poa.servant_activator != null || poa.servant_locator != null)
@@ -280,7 +289,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Make an invocation.
- *
+ *
* @param target not in use.
* @param output the stream request that should be returned by
* {@link #m_request} in this method.
@@ -292,31 +301,29 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
{
try
{
- streamRequest sr = (streamRequest) output;
+ StreamBasedRequest sr = (StreamBasedRequest) output;
LocalRequest lr = (LocalRequest) sr.request;
- InvokeHandler handler =
- lr.object.getHandler(lr.operation(), lr.cookie, false);
+ InvokeHandler handler = lr.object.getHandler(lr.operation(), lr.cookie,
+ false);
- if (handler instanceof dynImpHandler)
+ if (handler instanceof DynamicImpHandler)
{
// The local request known how to handle it, but the different
// method must be called.
lr.invoke();
// The encapsulation will inherit orb, endian, charsets, etc.
- cdrOutput buf = sr.createEncapsulation();
+ AbstractCdrOutput buf = sr.createEncapsulation();
// Write all request parameters to the buffer stream.
if (lr.env().exception() != null)
{
try
{
- UnknownUserException uex =
- (UnknownUserException) lr.env().exception();
+ UnknownUserException uex = (UnknownUserException) lr.env().exception();
throw new ApplicationException(uex.except.type().id(),
- uex.except.create_input_stream()
- );
+ uex.except.create_input_stream());
}
catch (BadKind ex)
{
@@ -334,9 +341,8 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
for (int i = 0; i < lr.arguments().count(); i++)
{
a = lr.arguments().item(i);
- if (a.flags() == ARG_INOUT.value ||
- a.flags() == ARG_INOUT.value
- )
+ if (a.flags() == ARG_INOUT.value
+ || a.flags() == ARG_INOUT.value)
{
a.value().write_value(buf);
}
@@ -362,10 +368,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
try
{
return ((ObjectImpl) f.forward_reference)._invoke(f.forward_reference._request(
- operation,
- true
- )
- );
+ operation, true));
}
catch (RemarshalException e)
{
diff --git a/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java b/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java
index a727499fce5..a2c0bb106c3 100644
--- a/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java
+++ b/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java
@@ -38,19 +38,19 @@ exception statement from your version. */
package gnu.CORBA.Poa;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.v1_2.ReplyHeader;
import gnu.CORBA.GIOP.v1_2.RequestHeader;
import gnu.CORBA.Interceptor.gnuClientRequestInfo;
import gnu.CORBA.Interceptor.gnuServerRequestInfo;
+import gnu.CORBA.typecodes.RecordTypeCode;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Unexpected;
import gnu.CORBA.gnuAny;
import gnu.CORBA.gnuRequest;
-import gnu.CORBA.recordTypeCode;
-import gnu.CORBA.streamReadyHolder;
-import gnu.CORBA.streamRequest;
+import gnu.CORBA.StreamHolder;
+import gnu.CORBA.StreamBasedRequest;
import org.omg.CORBA.ARG_OUT;
import org.omg.CORBA.Any;
@@ -115,7 +115,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
/**
* The buffer to write into.
*/
- cdrBufOutput buffer;
+ BufferedCdrOutput buffer;
/**
* The responsible POA.
@@ -252,7 +252,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
handler = object.getHandler(operation(), cookie, false);
}
- cdrBufOutput request_part = new cdrBufOutput();
+ BufferedCdrOutput request_part = new BufferedCdrOutput();
request_part.setOrb(orb());
@@ -288,7 +288,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
request_part.create_input_stream();
// Ensure the servant (handler) has a delegate set.
- servantDelegate sd = null;
+ ServantDelegateImpl sd = null;
Delegate d = null;
@@ -300,19 +300,19 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
// In some cases exception is thrown if the delegate is not set.
}
- if (d instanceof servantDelegate)
+ if (d instanceof ServantDelegateImpl)
{
// If the delegate is already set, try to reuse the existing
// instance.
- sd = (servantDelegate) d;
+ sd = (ServantDelegateImpl) d;
if (sd.object != object)
{
- sd = new servantDelegate(servant, poa, Id);
+ sd = new ServantDelegateImpl(servant, poa, Id);
}
}
else
{
- sd = new servantDelegate(servant, poa, Id);
+ sd = new ServantDelegateImpl(servant, poa, Id);
}
servant._set_delegate(sd);
@@ -368,13 +368,13 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
// Failed due any reason, insert without
// helper.
- a.insert_Streamable(new streamReadyHolder(
+ a.insert_Streamable(new StreamHolder(
buf.create_input_stream()
)
);
- recordTypeCode r =
- new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r =
+ new RecordTypeCode(TCKind.tk_except);
r.setId(uex_idl);
r.setName(ObjectCreator.getDefaultName(uex_idl));
}
@@ -531,9 +531,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
InvokeHandler handler = object.getHandler(operation(), cookie, false);
- if (handler instanceof dynImpHandler)
+ if (handler instanceof DynamicImpHandler)
{
- DynamicImplementation dyn = ((dynImpHandler) handler).servant;
+ DynamicImplementation dyn = ((DynamicImpHandler) handler).servant;
if (serverRequest == null)
{
serverRequest = new LocalServerRequest(this);
@@ -589,7 +589,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
// Prepare an Any that will hold the exception.
gnuAny exc = new gnuAny();
- exc.insert_Streamable(new streamReadyHolder(input));
+ exc.insert_Streamable(new StreamHolder(input));
UnknownUserException unuex = new UnknownUserException(exc);
m_environment.exception(unuex);
@@ -637,7 +637,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
*
* @return the CDR output stream, containing the written output.
*/
- cdrBufOutput getBuffer()
+ BufferedCdrOutput getBuffer()
{
return buffer;
}
@@ -656,7 +656,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
*/
private void prepareStream()
{
- buffer = new cdrBufOutput();
+ buffer = new BufferedCdrOutput();
buffer.setOrb(orb());
}
@@ -664,9 +664,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
* Get the parameter stream, where the invocation arguments should be written
* if they are written into the stream directly.
*/
- public streamRequest getParameterStream()
+ public StreamBasedRequest getParameterStream()
{
- m_parameter_buffer = new streamRequest();
+ m_parameter_buffer = new StreamBasedRequest();
m_parameter_buffer.request = this;
m_parameter_buffer.setOrb(poa.orb());
return m_parameter_buffer;
diff --git a/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java b/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java
index d95bf2be8f6..bb00aab70eb 100644
--- a/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java
+++ b/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.Poa;
-import gnu.CORBA.Functional_ORB;
+import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.Connected_objects.cObject;
import gnu.CORBA.DynAn.gnuDynAnyFactory;
@@ -53,11 +53,13 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.OBJECT_NOT_EXIST;
+import org.omg.CORBA.ORB;
import org.omg.CORBA.Policy;
import org.omg.CORBA.PolicyError;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.PortableInterceptor.PolicyFactory;
-import org.omg.PortableServer.POA;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POAManagerPackage.State;
import org.omg.PortableServer.POAPackage.InvalidPolicy;
import java.applet.Applet;
@@ -69,7 +71,7 @@ import java.util.Properties;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class ORB_1_4
- extends Functional_ORB
+ extends OrbFunctional
{
/**
* The root POA.
@@ -100,7 +102,7 @@ public class ORB_1_4
super();
try
{
- rootPOA = new gnuPOA(null, "RootPOA", null, policySets.rootPoa(), this);
+ rootPOA = new gnuPOA(null, "RootPOA", null, StandardPolicies.rootPoa(), this);
}
catch (InvalidPolicy ex)
{
@@ -130,7 +132,7 @@ public class ORB_1_4
{
try
{
- activeObjectMap.Obj exists = rootPOA.findObject(forObject);
+ AOM.Obj exists = rootPOA.findObject(forObject);
if (exists == null)
throw new OBJECT_NOT_EXIST(forObject == null ? "null"
: forObject.toString());
@@ -201,9 +203,9 @@ public class ORB_1_4
IOR ior = super.createIOR(ref);
if (iIor != null)
{
- activeObjectMap.Obj obj = rootPOA.findIorKey(ior.key);
+ AOM.Obj obj = rootPOA.findIorKey(ior.key);
- POA poa;
+ gnuPOA poa;
// Null means that the object was connected to the ORB directly.
if (obj == null)
@@ -215,6 +217,7 @@ public class ORB_1_4
// This may modify the ior.
iIor.establish_components(info);
+ iIor.components_established(info);
}
return ior;
}
@@ -252,5 +255,39 @@ public class ORB_1_4
super.set_parameters(para, props);
registerInterceptors(props, para);
}
+
+ /**
+ * This method is called by RMI-IIOP {@link javax.rmi.Tie#orb(ORB)}, passing
+ * <code>this</code> as parameter. The ORB will try to connect that tie as
+ * one of its objects, if it is not already connected. If the wrapper is an
+ * instance of Servant this method also activates the root poa (if not already
+ * active).
+ */
+ public void set_delegate(java.lang.Object wrapper)
+ {
+ if (wrapper instanceof org.omg.CORBA.Object)
+ {
+ org.omg.CORBA.Object object = (org.omg.CORBA.Object) wrapper;
+ if (connected_objects.getKey(object) == null)
+ connect(object);
+ }
+ else if (wrapper instanceof Servant)
+ {
+ Servant s = (Servant) wrapper;
+ if (rootPOA.findServant(s) == null)
+ try
+ {
+ rootPOA.servant_to_reference(s);
+ if (rootPOA.the_POAManager().get_state().value() == State._HOLDING)
+ rootPOA.the_POAManager().activate();
+ }
+ catch (Exception e)
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("Unable to connect "
+ + wrapper + " to " + this);
+ throw bad;
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/Poa/servantDelegate.java b/libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java
index f59c01c6b3e..e65214d4a9a 100644
--- a/libjava/classpath/gnu/CORBA/Poa/servantDelegate.java
+++ b/libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java
@@ -1,4 +1,4 @@
-/* servantDelegate.java --
+/* ServantDelegateImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ import org.omg.PortableServer.portable.Delegate;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class servantDelegate
+public class ServantDelegateImpl
implements Delegate
{
/**
@@ -93,7 +93,7 @@ public class servantDelegate
* @param a_servant the servant.
* @param a_servant_id the servant id.
*/
- public servantDelegate(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id)
+ public ServantDelegateImpl(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id)
{
poa = a_poa;
servant = a_servant;
diff --git a/libjava/classpath/gnu/CORBA/Poa/policySets.java b/libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java
index eb688467ae7..b2edc4056ab 100644
--- a/libjava/classpath/gnu/CORBA/Poa/policySets.java
+++ b/libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java
@@ -1,4 +1,4 @@
-/* policySets.java --
+/* StandardPolicies.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,14 +56,14 @@ import java.util.ArrayList;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class policySets
+public class StandardPolicies
{
/**
* The default policy set, as defined in OMG specs. This is also
* the policy set for the root POA.
*/
- private static final vPolicy[] rootPOASet =
- new vPolicy[]
+ private static final AccessiblePolicy[] rootPOASet =
+ new AccessiblePolicy[]
{
new gnuThreadPolicy(ThreadPolicyValue.ORB_CTRL_MODEL),
new gnuLifespanPolicy(LifespanPolicyValue.TRANSIENT),
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java b/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java
index 3019a2ae966..17d5a0f9e04 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java
@@ -69,7 +69,7 @@ public class gnuAdapterActivator
{
try
{
- POA n = parent.create_POA(child_name, null, policySets.rootPoa());
+ POA n = parent.create_POA(child_name, null, StandardPolicies.rootPoa());
n.the_POAManager().activate();
}
catch (Exception ex)
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java
index a404486ce70..91531909a6a 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.IdAssignmentPolicyValue;
*/
public class gnuIdAssignmentPolicy
extends _PolicyImplBase
- implements IdAssignmentPolicy, vPolicy
+ implements IdAssignmentPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java
index 2abd1f4845f..0b5fa1420bd 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.IdUniquenessPolicyValue;
*/
public class gnuIdUniquenessPolicy
extends _PolicyImplBase
- implements IdUniquenessPolicy, vPolicy
+ implements IdUniquenessPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java
index 1e539a2c4e0..f1721beef64 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ImplicitActivationPolicyValue;
*/
public class gnuImplicitActivationPolicy
extends _PolicyImplBase
- implements ImplicitActivationPolicy, vPolicy
+ implements ImplicitActivationPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java
index 97b3f2d7a9b..f26596cd951 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.LifespanPolicyValue;
*/
public class gnuLifespanPolicy
extends _PolicyImplBase
- implements LifespanPolicy, vPolicy
+ implements LifespanPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java b/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java
index 1d9e838532a..6f2a019a3bb 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java
@@ -49,10 +49,15 @@ import org.omg.CORBA.LocalObject;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.OBJ_ADAPTER;
import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
import org.omg.CORBA.Policy;
import org.omg.CORBA.SetOverrideType;
import org.omg.CORBA.TRANSIENT;
import org.omg.CORBA.portable.ObjectImpl;
+import org.omg.PortableInterceptor.NON_EXISTENT;
+import org.omg.PortableInterceptor.ObjectReferenceFactory;
+import org.omg.PortableInterceptor.ObjectReferenceTemplate;
+import org.omg.PortableInterceptor.ObjectReferenceTemplateHelper;
import org.omg.PortableServer.AdapterActivator;
import org.omg.PortableServer.ForwardRequest;
import org.omg.PortableServer.IdAssignmentPolicy;
@@ -87,8 +92,10 @@ import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongAdapter;
import org.omg.PortableServer.POAPackage.WrongPolicy;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+
+import gnu.CORBA.OrbFunctional;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
/**
* Our POA implementation.
@@ -97,12 +104,108 @@ import gnu.CORBA.CDR.cdrBufOutput;
*/
public class gnuPOA
extends LocalObject
- implements POA
+ implements POA, ObjectReferenceFactory
{
/**
+ * The object reference template, associated with this POA.
+ *
+ * @since 1.5
+ */
+ class RefTemplate implements ObjectReferenceTemplate
+ {
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ RefTemplate()
+ {
+ // The adapter name is computed once.
+ ArrayList names = new ArrayList();
+ names.add(the_name());
+
+ POA poa = the_parent();
+ while (poa != null)
+ {
+ names.add(poa.the_name());
+ poa = poa.the_parent();
+ }
+
+ // Fill in the string array in reverse (more natural) order,
+ // root POA first.
+ m_adapter_name = new String[names.size()];
+
+ for (int i = 0; i < m_adapter_name.length; i++)
+ m_adapter_name[i] = (String) names.get(m_adapter_name.length - i - 1);
+ }
+
+ /**
+ * The adapter name
+ */
+ final String[] m_adapter_name;
+
+ /**
+ * Get the name of this POA.
+ */
+ public String[] adapter_name()
+ {
+ return (String[]) m_adapter_name.clone();
+ }
+
+ /**
+ * Get the ORB id.
+ */
+ public String orb_id()
+ {
+ return m_orb.orb_id;
+ }
+
+ /**
+ * Get the server id.
+ */
+ public String server_id()
+ {
+ return OrbFunctional.server_id;
+ }
+
+ /**
+ * Create the object.
+ */
+ public Object make_object(String repositoryId, byte[] objectId)
+ {
+ return create_reference_with_id(objectId, repositoryId);
+ }
+
+ /**
+ * Get the array of truncatible repository ids.
+ */
+ public String[] _truncatable_ids()
+ {
+ return ref_template_ids;
+ }
+ }
+
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The adapter reference template.
+ */
+ ObjectReferenceTemplate refTemplate;
+
+ /**
+ * The reference template repository ids. Defined outside the class as it
+ * cannot have static members.
+ */
+ final static String[] ref_template_ids =
+ new String[] { ObjectReferenceTemplateHelper.id() };
+
+ /**
* The active object map, mapping between object keys, objects and servants.
*/
- public final activeObjectMap aom = new activeObjectMap();
+ public final AOM aom = new AOM();
/**
* The children of this POA.
@@ -182,6 +285,12 @@ public class gnuPOA
* necessity of the frequent checks.
*/
public final boolean retain_servant;
+
+ /**
+ * The object reference factory, used to create the new object
+ * references.
+ */
+ ObjectReferenceFactory m_object_factory = this;
/**
* Create a new abstract POA.
@@ -199,7 +308,7 @@ public class gnuPOA
throws InvalidPolicy
{
// Add default policies.
- Policy[] all_policies = policySets.withDefault(a_policies);
+ Policy[] all_policies = StandardPolicies.withDefault(a_policies);
name = a_name;
parent = a_parent;
@@ -222,12 +331,14 @@ public class gnuPOA
for (int i = 0; i < s_policies.length; i++)
{
s_policies [ i ] = all_policies [ i ].copy();
- m_policies.add(((vPolicy) s_policies [ i ]).getValue());
+ m_policies.add(((AccessiblePolicy) s_policies [ i ]).getValue());
}
retain_servant = applies(ServantRetentionPolicyValue.RETAIN);
validatePolicies(a_policies);
+
+ refTemplate = new RefTemplate();
}
/**
@@ -281,7 +392,7 @@ public class gnuPOA
keys.addAll(aom.keySet());
byte[] key;
- activeObjectMap.Obj obj;
+ AOM.Obj obj;
boolean last;
for (int i = 0; i < keys.size(); i++)
{
@@ -422,30 +533,30 @@ public class gnuPOA
}
/**
- * Generate the Object Id for the given servant and add the servant to
- * the Active Object Map using this Id a a key. If the servant
- * activator is set, its incarnate method will be called.
- *
- * @param a_servant a servant that would serve the object with the
- * returned Object Id. If null is passed, under apporoprate policies the
- * servant activator is invoked.
- *
+ * Generate the Object Id for the given servant and add the servant to the
+ * Active Object Map using this Id a a key. If the servant activator is set,
+ * its incarnate method will be called.
+ *
+ * @param a_servant a servant that would serve the object with the returned
+ * Object Id. If null is passed, under apporoprate policies the servant
+ * activator is invoked.
+ *
* @return the generated objert Id for the given servant.
- *
- * @throws ServantAlreadyActive if this servant is already in the
- * Active Object Map and the UNIQUE_ID policy applies.
- *
- * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN
- * do not apply to this POA.
+ *
+ * @throws ServantAlreadyActive if this servant is already in the Active
+ * Object Map and the UNIQUE_ID policy applies.
+ *
+ * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN do not
+ * apply to this POA.
*/
public byte[] activate_object(Servant a_servant)
- throws ServantAlreadyActive, WrongPolicy
+ throws ServantAlreadyActive, WrongPolicy
{
checkDiscarding();
required(ServantRetentionPolicyValue.RETAIN);
required(IdAssignmentPolicyValue.SYSTEM_ID);
- activeObjectMap.Obj exists = aom.findServant(a_servant);
+ AOM.Obj exists = aom.findServant(a_servant);
if (exists != null)
{
@@ -464,28 +575,30 @@ public class gnuPOA
// activations.
}
- byte[] object_key = activeObjectMap.getFreeId();
- servantDelegate delegate = new servantDelegate(a_servant, this, object_key);
- connectDelegate(object_key, delegate);
+ byte[] object_key = AOM.getFreeId();
+ ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,
+ object_key);
+ create_and_connect(object_key,
+ a_servant._all_interfaces(this, object_key)[0], delegate);
return object_key;
}
/**
- * Add the given servant to the Active Object Map as a servant for the
- * object with the provided Object Id. If the servant activator is
- * set, its incarnate method will be called.
- *
+ * Add the given servant to the Active Object Map as a servant for the object
+ * with the provided Object Id. If the servant activator is set, its incarnate
+ * method will be called.
+ *
* @param an_Object_Id an object id for the given object.
- * @param a_servant a servant that will serve the object with the given
- * Object Id. If null is passed, under apporoprate policies the
- * servant activator is invoked.
- *
- * @throws ObjectAlreadyActive if the given object id is already in the
- * Active Object Map.
- * @throws ServantAlreadyActive if the UNIQUE_ID policy applies and
- * this servant is already in use.
- * @throws WrongPolicy if the required RETAIN policy does not apply to
- * this POA.
+ * @param a_servant a servant that will serve the object with the given Object
+ * Id. If null is passed, under apporoprate policies the servant activator is
+ * invoked.
+ *
+ * @throws ObjectAlreadyActive if the given object id is already in the Active
+ * Object Map.
+ * @throws ServantAlreadyActive if the UNIQUE_ID policy applies and this
+ * servant is already in use.
+ * @throws WrongPolicy if the required RETAIN policy does not apply to this
+ * POA.
* @throws BAD_PARAM if the passed object id is invalid due any reason.
*/
public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant)
@@ -496,16 +609,14 @@ public class gnuPOA
}
/**
- * Same as activate_object_with_id, but permits gnuForwardRequest
- * forwarding exception. This is used when the activation is called
- * from the remote invocation context and we have possibility
- * to return the forwarding message.
+ * Same as activate_object_with_id, but permits gnuForwardRequest forwarding
+ * exception. This is used when the activation is called from the remote
+ * invocation context and we have possibility to return the forwarding
+ * message.
*/
public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant,
- boolean use_forwarding
- )
- throws ServantAlreadyActive, ObjectAlreadyActive,
- WrongPolicy
+ boolean use_forwarding)
+ throws ServantAlreadyActive, ObjectAlreadyActive, WrongPolicy
{
checkDiscarding();
required(ServantRetentionPolicyValue.RETAIN);
@@ -514,12 +625,12 @@ public class gnuPOA
// already active.
if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
{
- activeObjectMap.Obj sx = aom.findServant(a_servant, false);
+ AOM.Obj sx = aom.findServant(a_servant, false);
if (sx != null)
throw new ServantAlreadyActive();
}
- activeObjectMap.Obj exists = aom.get(an_Object_Id);
+ AOM.Obj exists = aom.get(an_Object_Id);
if (exists != null)
{
if (exists.servant == null)
@@ -537,26 +648,27 @@ public class gnuPOA
}
else
{
- servantDelegate delegate =
- new servantDelegate(a_servant, this, an_Object_Id);
- connectDelegate(an_Object_Id, delegate);
+ ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,
+ an_Object_Id);
+ create_and_connect(an_Object_Id, a_servant._all_interfaces(this,
+ an_Object_Id)[0], delegate);
}
}
/**
* Locate the servant for this object Id and connect it to ORB.
- *
+ *
* @param an_Object_Id the object id.
* @param a_servant the servant (may be null).
* @param exists an existing active object map entry.
- * @param use_forwarding allow to throw the gnuForwardRequest
- * if the activator throws ForwardRequest.
- *
- * @throws OBJ_ADAPTER minor 4 if the servant cannot be located
- * (the required servant manager may be missing).
+ * @param use_forwarding allow to throw the gnuForwardRequest if the activator
+ * throws ForwardRequest.
+ *
+ * @throws OBJ_ADAPTER minor 4 if the servant cannot be located (the required
+ * servant manager may be missing).
*/
private void locateServant(byte[] an_Object_Id, Servant a_servant,
- activeObjectMap.Obj exists, boolean use_forwarding
+ AOM.Obj exists, boolean use_forwarding
)
throws InternalError
{
@@ -582,8 +694,8 @@ public class gnuPOA
throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO);
}
- servantDelegate delegate =
- new servantDelegate(exists.servant, this, an_Object_Id);
+ ServantDelegateImpl delegate =
+ new ServantDelegateImpl(exists.servant, this, an_Object_Id);
exists.servant._set_delegate(delegate);
object.setServant(exists.servant);
connect_to_orb(an_Object_Id, delegate.object);
@@ -605,7 +717,7 @@ public class gnuPOA
{
required(ServantRetentionPolicyValue.RETAIN);
- activeObjectMap.Obj exists = aom.get(the_Object_Id);
+ AOM.Obj exists = aom.get(the_Object_Id);
if (exists == null || exists.isDeactiveted())
throw new ObjectNotActive();
@@ -615,7 +727,7 @@ public class gnuPOA
// Check if this servant is serving something else.
aom.remove(the_Object_Id);
- activeObjectMap.Obj other = aom.findServant(exists.servant, false);
+ AOM.Obj other = aom.findServant(exists.servant, false);
boolean remaining = other != null;
@@ -643,7 +755,7 @@ public class gnuPOA
throws WrongPolicy
{
required(IdAssignmentPolicyValue.SYSTEM_ID);
- return create_reference_with_id(activeObjectMap.getFreeId(), a_repository_id);
+ return create_reference_with_id(AOM.getFreeId(), a_repository_id);
}
/**
@@ -662,8 +774,8 @@ public class gnuPOA
* servant.
*/
public org.omg.CORBA.Object create_reference_with_id(byte[] an_object_id,
- String a_repository_id
- )
+ String a_repository_id
+ )
{
String[] ids;
if (a_repository_id == null)
@@ -672,7 +784,7 @@ public class gnuPOA
ids = new String[] { a_repository_id };
// Check maybe such object is already activated.
- activeObjectMap.Obj e = aom.get(an_object_id);
+ AOM.Obj e = aom.get(an_object_id);
Servant servant;
if (e == null)
@@ -847,7 +959,7 @@ public class gnuPOA
return m_poa_id;
else
{
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
POA p = this;
while (p != null)
{
@@ -874,7 +986,7 @@ public class gnuPOA
{
required(ServantRetentionPolicyValue.RETAIN);
- activeObjectMap.Obj ref = aom.get(the_Object_Id);
+ AOM.Obj ref = aom.get(the_Object_Id);
if (ref == null)
throw new ObjectNotActive();
else
@@ -897,7 +1009,7 @@ public class gnuPOA
{
if (applies(ServantRetentionPolicyValue.RETAIN))
{
- activeObjectMap.Obj ref = aom.get(the_Object_Id);
+ AOM.Obj ref = aom.get(the_Object_Id);
if (ref == null || ref.isDeactiveted())
{
if (default_servant != null)
@@ -932,7 +1044,7 @@ public class gnuPOA
public byte[] reference_to_id(org.omg.CORBA.Object the_Object)
throws WrongAdapter, WrongPolicy
{
- activeObjectMap.Obj ref = aom.findObject(the_Object);
+ AOM.Obj ref = aom.findObject(the_Object);
if (ref == null)
throw new WrongAdapter();
return ref.key;
@@ -958,7 +1070,7 @@ public class gnuPOA
{
if (applies(ServantRetentionPolicyValue.RETAIN))
{
- activeObjectMap.Obj ref = aom.findObject(the_Object);
+ AOM.Obj ref = aom.findObject(the_Object);
if (ref == null)
throw new WrongAdapter();
else if (ref.isDeactiveted() || ref.servant == null)
@@ -1017,7 +1129,7 @@ public class gnuPOA
)
)
{
- activeObjectMap.Obj ref = null;
+ AOM.Obj ref = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
ref = aom.findServant(the_Servant);
if (ref == null &&
@@ -1047,31 +1159,31 @@ public class gnuPOA
}
/**
- * <p>Converts the given servant to the object reference.
- * The servant will serve all methods, invoked on the returned object.
- * The returned object reference can be passed to the remote client,
- * enabling remote invocations.
- * </p><p>
- * If the specified servant is active, it is returned. Otherwise,
- * if the POA has the IMPLICIT_ACTIVATION policy the method activates
- * the servant. In this case, if the servant activator is set,
- * the {@link ServantActivatorOperations#incarnate} method will be called.
+ * <p>
+ * Converts the given servant to the object reference. The servant will serve
+ * all methods, invoked on the returned object. The returned object reference
+ * can be passed to the remote client, enabling remote invocations.
* </p>
- *
+ * <p>
+ * If the specified servant is active, it is returned. Otherwise, if the POA
+ * has the IMPLICIT_ACTIVATION policy the method activates the servant. In
+ * this case, if the servant activator is set, the
+ * {@link ServantActivatorOperations#incarnate} method will be called.
+ * </p>
+ *
* @throws ServantNotActive if the servant is inactive and no
* IMPLICIT_ACTIVATION policy applies.
* @throws WrongPolicy This method needs the RETAIN policy and either the
* UNIQUE_ID or IMPLICIT_ACTIVATION policies.
- *
+ *
* @return the object, exposing the given servant in the context of this POA.
*/
public org.omg.CORBA.Object servant_to_reference(Servant the_Servant)
- throws ServantNotActive,
- WrongPolicy
+ throws ServantNotActive, WrongPolicy
{
required(ServantRetentionPolicyValue.RETAIN);
- activeObjectMap.Obj exists = null;
+ AOM.Obj exists = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
exists = aom.findServant(the_Servant);
@@ -1092,17 +1204,17 @@ public class gnuPOA
else
return exists.object;
}
- if (exists == null &&
- applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
- )
+ if (exists == null
+ && applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION))
{
checkDiscarding();
- byte[] object_key = activeObjectMap.getFreeId();
+ byte[] object_key = AOM.getFreeId();
- servantDelegate delegate =
- new servantDelegate(the_Servant, this, object_key);
- connectDelegate(object_key, delegate);
+ ServantDelegateImpl delegate = new ServantDelegateImpl(the_Servant,
+ this, object_key);
+ create_and_connect(object_key, the_Servant._all_interfaces(this,
+ object_key)[0], delegate);
return delegate.object;
}
@@ -1111,22 +1223,22 @@ public class gnuPOA
}
/**
- * Incarnate in cases when request forwarding is not expected
- * because the servant must be provided by the servant activator.
- *
- * @param x the aom entry, where the object is replaced by
- * value, returned by servant activator (if not null).
- *
+ * Incarnate in cases when request forwarding is not expected because the
+ * servant must be provided by the servant activator.
+ *
+ * @param x the aom entry, where the object is replaced by value, returned by
+ * servant activator (if not null).
+ *
* @param key the object key.
- *
+ *
* @param a_servant the servant that was passed as a parameter in the
* activation method.
- *
- * @param use_forwarding if true, the gnuForwardRequest is throw
- * under the forwarding exception (for remote client). Otherwise, the
- * request is internally redirected (for local invocation).
+ *
+ * @param use_forwarding if true, the gnuForwardRequest is throw under the
+ * forwarding exception (for remote client). Otherwise, the request is
+ * internally redirected (for local invocation).
*/
- private Servant incarnate(activeObjectMap.Obj x, byte[] object_key,
+ private Servant incarnate(AOM.Obj x, byte[] object_key,
Servant a_servant, boolean use_forwarding
)
{
@@ -1281,34 +1393,46 @@ public class gnuPOA
}
/**
- * <p> Destroy this POA and all descendant POAs. The destroyed POAs can be
- * later re-created via {@link AdapterActivator} or by invoking
- * {@link #create_POA}.
- * This differs from {@link PoaManagerOperations#deactivate} that does
- * not allow recreation of the deactivated POAs. After deactivation,
- * recreation is only possible if the POAs were later destroyed.
- * </p><p>
- * The remote invocation on the target, belonging to the POA that is
- * currently destroyed return the remote exception ({@link TRANSIENT},
- * minor code 4).
+ * <p>
+ * Destroy this POA and all descendant POAs. The destroyed POAs can be later
+ * re-created via {@link AdapterActivator} or by invoking {@link #create_POA}.
+ * This differs from {@link PoaManagerOperations#deactivate} that does not
+ * allow recreation of the deactivated POAs. After deactivation, recreation is
+ * only possible if the POAs were later destroyed.
* </p>
+ * <p>
+ * The remote invocation on the target, belonging to the POA that is currently
+ * destroyed return the remote exception ({@link TRANSIENT}, minor code 4).
+ * </p>
+ *
* @param etherealize_objects if true, and POA has RETAIN policy, and the
* servant manager is available, the servant manager method
- * {@link ServantActivatorOperations#etherealize} is called for each
- * <i>active</i> object in the Active Object Map. This method should not
- * try to access POA being destroyed. If <code>destroy</code> is called
- * multiple times before the destruction completes,
- * the etherialization should be invoked only once.
- *
+ * {@link ServantActivatorOperations#etherealize} is called for each <i>active</i>
+ * object in the Active Object Map. This method should not try to access POA
+ * being destroyed. If <code>destroy</code> is called multiple times before
+ * the destruction completes, the etherialization should be invoked only once.
+ *
* @param wait_for_completion if true, the method waits till the POA being
- * destroyed completes all current requests and etherialization. If false,
- * the method returns immediately.
+ * destroyed completes all current requests and etherialization. If false, the
+ * method returns immediately.
*/
public void destroy(boolean etherealize_objects, boolean wait_for_completion)
{
+ // Notify the IOR interceptors about that the POA is destroyed.
+ if (m_orb.iIor != null)
+ m_orb.iIor.adapter_state_changed(
+ new ObjectReferenceTemplate[] { getReferenceTemplate() },
+ NON_EXISTENT.value);
+
if (wait_for_completion)
waitWhileRunning();
+ // Nofify the IOR interceptors that the POA is destroyed.
+ if (m_manager instanceof gnuPOAManager)
+ {
+ ((gnuPOAManager) m_manager).poaDestroyed(this);
+ }
+
// Put the brake instead of manager, preventing the subsequent
// requests.
gnuPOAManager g = new gnuPOAManager();
@@ -1328,7 +1452,7 @@ public class gnuPOA
keys.addAll(aom.keySet());
byte[] key;
- activeObjectMap.Obj obj;
+ AOM.Obj obj;
for (int i = 0; i < keys.size(); i++)
{
key = (byte[]) keys.get(i);
@@ -1348,7 +1472,7 @@ public class gnuPOA
POA[] ch = the_children();
for (int i = 0; i < ch.length; i++)
{
- ch [ i ].destroy(etherealize_objects, wait_for_completion);
+ ch[i].destroy(etherealize_objects, wait_for_completion);
}
}
@@ -1430,13 +1554,14 @@ public class gnuPOA
}
/**
- * Connect the given delegate under the given key, also calling
- * incarnate.
+ * Connect the given delegate under the given key, also calling incarnate.
*/
- private void connectDelegate(byte[] object_key, servantDelegate delegate)
+ private void create_and_connect(byte[] object_key, String repository_id,
+ ServantDelegateImpl delegate)
{
aom.add(delegate);
- connect_to_orb(object_key, delegate.object);
+ connect_to_orb(object_key, getReferenceFactory().make_object(repository_id,
+ object_key));
if (servant_activator != null)
incarnate(null, object_key, delegate.servant, false);
}
@@ -1517,9 +1642,9 @@ public class gnuPOA
/**
* Recursively searches for the given object in the POA tree.
*/
- public activeObjectMap.Obj findObject(org.omg.CORBA.Object object)
+ public AOM.Obj findObject(org.omg.CORBA.Object object)
{
- activeObjectMap.Obj h = aom.findObject(object);
+ AOM.Obj h = aom.findObject(object);
if (h != null)
return h;
else
@@ -1533,16 +1658,16 @@ public class gnuPOA
}
return h;
}
-
+
/**
* Recursively searches for the given key in the POA tree.
* @param ior_key the key, ecapsulating both object
* and poa ids.
* @return
*/
- public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id)
+ public AOM.Obj findKey(byte[] object_id, byte[] poa_id)
{
- activeObjectMap.Obj h = null;
+ AOM.Obj h = null;
if (Arrays.equals(poa_id, id()))
h = aom.get(object_id);
if (h != null)
@@ -1563,9 +1688,9 @@ public class gnuPOA
* Parses the given key, extracts poa and object id and searches
* for such reference.
*/
- public activeObjectMap.Obj findIorKey(byte[] ior_key)
+ public AOM.Obj findIorKey(byte[] ior_key)
{
- cdrBufInput in = new cdrBufInput(ior_key);
+ BufferredCdrInput in = new BufferredCdrInput(ior_key);
int signature = in.read_long();
if (signature != SIGNATURE)
return null;
@@ -1582,7 +1707,7 @@ public class gnuPOA
*/
public byte[] toIORKey(byte[] object_id)
{
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
buffer.write_long(SIGNATURE);
buffer.write_sequence(object_id);
buffer.write_sequence(id());
@@ -1600,7 +1725,7 @@ public class gnuPOA
*/
public byte[] idFormIor(byte[] ior_key)
{
- cdrBufInput in = new cdrBufInput(ior_key);
+ BufferredCdrInput in = new BufferredCdrInput(ior_key);
int signature = in.read_long();
if (signature != SIGNATURE)
return null;
@@ -1612,4 +1737,70 @@ public class gnuPOA
else
return null;
}
+
+ /**
+ * Recursively searches for the given servant in the POA tree.
+ */
+ public AOM.Obj findServant(Servant servant)
+ {
+ AOM.Obj h = aom.findServant(servant);
+ if (h != null)
+ return h;
+ else
+ {
+ for (int i = 0; i < children.size(); i++)
+ {
+ h = ((gnuPOA) children.get(i)).findServant(servant);
+ if (h != null)
+ return h;
+ }
+ }
+ return h;
+ }
+
+ /**
+ * Get the object reference template of this POA.
+ * Instantiate a singleton instance, if required.
+ */
+ public ObjectReferenceTemplate getReferenceTemplate()
+ {
+ if (refTemplate == null)
+ refTemplate = new RefTemplate();
+
+ return refTemplate;
+ }
+
+ public ObjectReferenceFactory getReferenceFactory()
+ {
+ return m_object_factory;
+ }
+
+ public void setReferenceFactory(ObjectReferenceFactory factory)
+ {
+ m_object_factory = factory;
+ }
+
+ /**
+ * Create the object (needed by the factory interface).
+ */
+ public Object make_object(String a_repository_id, byte[] an_object_id)
+ {
+ AOM.Obj existing = aom.get(an_object_id);
+ // The object may already exist. In this case, it is just returned.
+ if (existing != null && existing.object != null)
+ return existing.object;
+ else
+ {
+ return new gnuServantObject(new String[] { a_repository_id },
+ an_object_id, this, m_orb);
+ }
+ }
+
+ /**
+ * Required by object reference factory ops.
+ */
+ public String[] _truncatable_ids()
+ {
+ return ref_template_ids;
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java b/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java
index 6c1b5644f36..7710306b748 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java
@@ -40,6 +40,8 @@ package gnu.CORBA.Poa;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.LocalObject;
+import org.omg.PortableInterceptor.NON_EXISTENT;
+import org.omg.PortableInterceptor.ObjectReferenceTemplate;
import org.omg.PortableServer.POAManager;
import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
import org.omg.PortableServer.POAManagerPackage.State;
@@ -59,18 +61,22 @@ public class gnuPOAManager
extends LocalObject
implements POAManager
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
- * The POAs, controlled by this manager. The members must be instances of
- * the gnuAbstractPOA.
+ * The POAs, controlled by this manager.
*/
- HashSet POAs = new HashSet();
+ private HashSet POAs = new HashSet();
/**
* The state of the manager. The newly created manager is always
* in the holding state.
*/
State state = State.HOLDING;
-
+
/**
* Get the state of the POA manager.
*/
@@ -94,6 +100,8 @@ public class gnuPOAManager
state = State.ACTIVE;
else
throw new AdapterInactive();
+
+ notifyInterceptors(state.value());
}
/**
@@ -113,6 +121,9 @@ public class gnuPOAManager
state = State.HOLDING;
else
throw new AdapterInactive();
+
+ notifyInterceptors(state.value());
+
if (wait_for_completion)
waitForIdle();
}
@@ -144,6 +155,9 @@ public class gnuPOAManager
if (state == State.INACTIVE)
throw new AdapterInactive("Repetetive inactivation");
state = State.INACTIVE;
+
+ notifyInterceptors(state.value());
+
if (wait_for_completion)
waitForIdle();
@@ -178,6 +192,9 @@ public class gnuPOAManager
state = State.DISCARDING;
else
throw new AdapterInactive();
+
+ notifyInterceptors(state.value());
+
if (wait_for_completion)
waitForIdle();
}
@@ -193,11 +210,13 @@ public class gnuPOAManager
{
if (state == State.ACTIVE)
throw new BAD_INV_ORDER("The state is active");
-
+
+ gnuPOA poa;
Iterator iter = POAs.iterator();
+
while (iter.hasNext())
{
- gnuPOA poa = (gnuPOA) iter.next();
+ poa = (gnuPOA) iter.next();
poa.waitWhileRunning();
}
}
@@ -222,4 +241,33 @@ public class gnuPOAManager
{
POAs.remove(poa);
}
+
+ /**
+ * This method is called when POA is destryed. The interceptors are
+ * notified.
+ */
+ public void poaDestroyed(gnuPOA poa)
+ {
+ notifyInterceptors(NON_EXISTENT.value);
+ }
+
+ /**
+ * Notify CORBA 3.0 interceptors about the status change.
+ */
+ public synchronized void notifyInterceptors(int new_state)
+ {
+ gnuPOA poa;
+ Iterator iter = POAs.iterator();
+
+ // The System.identityHashCode is also called in gnuIorInfo.
+ while (iter.hasNext())
+ {
+ poa = (gnuPOA) iter.next();
+ if (poa.m_orb.iIor != null)
+ {
+ poa.m_orb.iIor.adapter_manager_state_changed(
+ System.identityHashCode(this), (short) new_state);
+ }
+ }
+ }
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java
index 5bbcd1321b3..2f77639c698 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.RequestProcessingPolicyValue;
*/
public class gnuRequestProcessingPolicy
extends _PolicyImplBase
- implements RequestProcessingPolicy, vPolicy
+ implements RequestProcessingPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java b/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java
index 1ad98d1cecd..020897a45b4 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java
@@ -39,14 +39,17 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.GIOP.ReplyHeader;
-import gnu.CORBA.IOR_Delegate;
-import gnu.CORBA.IOR_contructed_object;
+import gnu.CORBA.IorDelegate;
+import gnu.CORBA.IorObject;
import gnu.CORBA.Interceptor.gnuServerRequestInfo;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.CORBA.IOR;
+import gnu.CORBA.IorProvider;
+import gnu.CORBA.Minor;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Unexpected;
-import gnu.CORBA.bufferedResponseHandler;
-import gnu.CORBA.recordTypeCode;
-import gnu.CORBA.streamReadyHolder;
+import gnu.CORBA.ResponseHandlerImpl;
+import gnu.CORBA.StreamHolder;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -90,7 +93,8 @@ import java.util.Arrays;
public class gnuServantObject extends ObjectImpl
implements org.omg.CORBA.Object,
InvokeHandler,
- CurrentOperations
+ CurrentOperations,
+ IorProvider
{
/**
* The associated servant that must also implement the {@link InvokeHandler}
@@ -144,6 +148,14 @@ public class gnuServantObject extends ObjectImpl
poa = a_poa;
orb = an_orb;
}
+
+ /**
+ * Get the IOR as it would be for this object.
+ */
+ public IOR getIor()
+ {
+ return orb.getLocalIor(this);
+ }
/**
* Create a servant object, associated with the passed servant.
@@ -257,10 +269,8 @@ public class gnuServantObject extends ObjectImpl
}
catch (Exception ex)
{
- ex.printStackTrace();
-
BAD_OPERATION bad =
- new BAD_OPERATION("Unable to activate", 0x5004,
+ new BAD_OPERATION("Unable to activate", Minor.Activation,
CompletionStatus.COMPLETED_NO
);
bad.initCause(ex);
@@ -276,7 +286,7 @@ public class gnuServantObject extends ObjectImpl
// No servant and no servant manager - throw exception.
else
{
- throw new BAD_OPERATION("Unable to activate", 0x5002,
+ throw new BAD_OPERATION("Unable to activate", Minor.Activation,
CompletionStatus.COMPLETED_NO
);
}
@@ -294,7 +304,7 @@ public class gnuServantObject extends ObjectImpl
}
else if (a_servant instanceof DynamicImplementation)
{
- return new dynImpHandler((DynamicImplementation) a_servant);
+ return new DynamicImpHandler((DynamicImplementation) a_servant);
}
else
{
@@ -402,17 +412,17 @@ public class gnuServantObject extends ObjectImpl
boolean intercept = false;
ServerRequestInterceptorOperations interceptor = null;
gnuServerRequestInfo info = null;
- bufferedResponseHandler i_handler = null;
+ ResponseHandlerImpl i_handler = null;
try
{
if (orb.iServer != null &&
- r_handler instanceof bufferedResponseHandler
+ r_handler instanceof ResponseHandlerImpl
)
{
interceptor = orb.iServer;
- i_handler = (bufferedResponseHandler) r_handler;
+ i_handler = (ResponseHandlerImpl) r_handler;
info =
new gnuServerRequestInfo(this, i_handler.request_header,
@@ -426,7 +436,7 @@ public class gnuServantObject extends ObjectImpl
try
{
CookieHolder cookie = null;
- activeObjectMap.Obj self = poa.aom.get(Id);
+ AOM.Obj self = poa.aom.get(Id);
if (poa.servant_locator != null)
{
@@ -467,18 +477,18 @@ public class gnuServantObject extends ObjectImpl
{
// In some cases exception is thrown if the delegate is not set.
}
- if (d instanceof servantDelegate)
+ if (d instanceof ServantDelegateImpl)
{
// If the delegate is already set, check maybe we can
// reuse the existing instance.
- if (((servantDelegate) d).object != this)
+ if (((ServantDelegateImpl) d).object != this)
{
- servant._set_delegate(new servantDelegate(servant, poa, Id));
+ servant._set_delegate(new ServantDelegateImpl(servant, poa, Id));
}
}
else
{
- servant._set_delegate(new servantDelegate(servant, poa, Id));
+ servant._set_delegate(new ServantDelegateImpl(servant, poa, Id));
}
try
@@ -536,13 +546,13 @@ public class gnuServantObject extends ObjectImpl
{
// Failed due any reason, insert without
// helper.
- a.insert_Streamable(new streamReadyHolder(
+ a.insert_Streamable(new StreamHolder(
buf.create_input_stream()
)
);
- recordTypeCode r =
- new recordTypeCode(TCKind.tk_except);
+ RecordTypeCode r =
+ new RecordTypeCode(TCKind.tk_except);
r.setId(uex_idl);
r.setName(ObjectCreator.getDefaultName(
uex_idl
@@ -774,12 +784,12 @@ public class gnuServantObject extends ObjectImpl
gnuServantObject g = (gnuServantObject) other;
return orb == g.orb && poa == g.poa && Arrays.equals(Id, g.Id);
}
- else if (other instanceof IOR_contructed_object)
+ else if (other instanceof IorObject)
{
- IOR_contructed_object ir = ((IOR_contructed_object) other);
+ IorObject ir = ((IorObject) other);
try
{
- IOR_Delegate ird = (IOR_Delegate) ir._get_delegate();
+ IorDelegate ird = (IorDelegate) ir._get_delegate();
byte[] ior_id = poa.idFormIor(ird.getIor().key);
if (ior_id != null && Arrays.equals(ior_id, Id))
{
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java
index 009e70e1b35..9fb61ab3f1f 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ServantRetentionPolicyValue;
*/
public class gnuServantRetentionPolicy
extends _PolicyImplBase
- implements ServantRetentionPolicy, vPolicy
+ implements ServantRetentionPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java
index f42ebefb363..1de94a10145 100644
--- a/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java
+++ b/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ThreadPolicyValue;
*/
public class gnuThreadPolicy
extends _PolicyImplBase
- implements ThreadPolicy, vPolicy
+ implements ThreadPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
diff --git a/libjava/classpath/gnu/CORBA/binaryReply.java b/libjava/classpath/gnu/CORBA/RawReply.java
index 71afa377679..a36f4b4b2d7 100644
--- a/libjava/classpath/gnu/CORBA/binaryReply.java
+++ b/libjava/classpath/gnu/CORBA/RawReply.java
@@ -1,4 +1,4 @@
-/* binaryReply.java --
+/* RawReply.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,7 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
+import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.GIOP.MessageHeader;
import org.omg.CORBA.ORB;
@@ -48,7 +48,7 @@ import org.omg.CORBA.ORB;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-class binaryReply
+class RawReply
{
/**
* The message header.
@@ -71,7 +71,7 @@ class binaryReply
* @param an_header the message header
* @param a_data the message data.
*/
- binaryReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
+ RawReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
{
orb = an_orb;
header = an_header;
@@ -83,9 +83,9 @@ class binaryReply
*
* @return the CDR stream to read the message data.
*/
- cdrBufInput getStream()
+ BufferredCdrInput getStream()
{
- cdrBufInput in = new cdrBufInput(data);
+ BufferredCdrInput in = new BufferredCdrInput(data);
in.setOffset(header.getHeaderSize());
in.setVersion(header.version);
in.setOrb(orb);
diff --git a/libjava/classpath/gnu/CORBA/bufferedResponseHandler.java b/libjava/classpath/gnu/CORBA/ResponseHandlerImpl.java
index 0fe945ca1f0..4d509cc5253 100644
--- a/libjava/classpath/gnu/CORBA/bufferedResponseHandler.java
+++ b/libjava/classpath/gnu/CORBA/ResponseHandlerImpl.java
@@ -1,4 +1,4 @@
-/* bufferedResponseHandler.java --
+/* ResponseHandlerImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,11 +38,11 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.GIOP.RequestHeader;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.ORB;
import org.omg.CORBA.portable.OutputStream;
@@ -53,7 +53,7 @@ import org.omg.CORBA.portable.ResponseHandler;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class bufferedResponseHandler
+public class ResponseHandlerImpl
implements ResponseHandler
{
/**
@@ -86,7 +86,7 @@ public class bufferedResponseHandler
/**
* The buffer to write into.
*/
- private cdrBufOutput buffer;
+ private BufferedCdrOutput buffer;
/**
* Create a new buffered response handler that uses the given message headers.
@@ -96,7 +96,7 @@ public class bufferedResponseHandler
* @param m_header a message header.
* @param r_header a reply header.
*/
- bufferedResponseHandler(ORB an_orb, MessageHeader m_header,
+ ResponseHandlerImpl(ORB an_orb, MessageHeader m_header,
ReplyHeader r_header, RequestHeader rq_header)
{
message_header = m_header;
@@ -147,7 +147,7 @@ public class bufferedResponseHandler
*
* @return the CDR output stream, containing the written output.
*/
- public cdrBufOutput getBuffer()
+ public BufferedCdrOutput getBuffer()
{
return buffer;
}
@@ -166,10 +166,10 @@ public class bufferedResponseHandler
*/
private void prepareStream()
{
- buffer = new cdrBufOutput();
+ buffer = new BufferedCdrOutput();
buffer.setOrb(orb);
buffer.setVersion(message_header.version);
- buffer.setCodeSet(cxCodeSet.find(reply_header.service_context));
+ buffer.setCodeSet(CodeSetServiceContext.find(reply_header.service_context));
// Since 1.2, the data section is always aligned on the 8 byte boundary.
// In older versions, it is necessary to set the offset correctly.
diff --git a/libjava/classpath/gnu/CORBA/ServiceRequestAdapter.java b/libjava/classpath/gnu/CORBA/ServiceRequestAdapter.java
index 7f40fc84d2d..a6f7aa52b8d 100644
--- a/libjava/classpath/gnu/CORBA/ServiceRequestAdapter.java
+++ b/libjava/classpath/gnu/CORBA/ServiceRequestAdapter.java
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import org.omg.CORBA.ARG_IN;
import org.omg.CORBA.ARG_INOUT;
@@ -67,7 +67,7 @@ public class ServiceRequestAdapter
/**
* A buffer for writing the response.
*/
- cdrBufOutput reply = new cdrBufOutput();
+ BufferedCdrOutput reply = new BufferedCdrOutput();
/**
* If set to true, an exception has been thrown during the invocation.
@@ -105,7 +105,7 @@ public class ServiceRequestAdapter
int OUT = ARG_OUT.value;
// Write all arguments to the buffer output stream.
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
gnuNVList args = new gnuNVList();
request.arguments(args);
@@ -127,7 +127,7 @@ public class ServiceRequestAdapter
{
// Write the exception information
gnuAny exc = new gnuAny();
- universalHolder uku = new universalHolder(h.reply);
+ GeneralHolder uku = new GeneralHolder(h.reply);
exc.insert_Streamable(uku);
request.set_exception(exc);
}
@@ -146,7 +146,7 @@ public class ServiceRequestAdapter
{
// Use the universal holder otherwise.
gnuAny r = new gnuAny();
- r.insert_Streamable(new streamReadyHolder(in));
+ r.insert_Streamable(new StreamHolder(in));
}
// Unpack the arguments
diff --git a/libjava/classpath/gnu/CORBA/Simple_delegate.java b/libjava/classpath/gnu/CORBA/SimpleDelegate.java
index 5eabc7da8a0..c6e20e17374 100644
--- a/libjava/classpath/gnu/CORBA/Simple_delegate.java
+++ b/libjava/classpath/gnu/CORBA/SimpleDelegate.java
@@ -57,8 +57,9 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class Simple_delegate
+public class SimpleDelegate
extends Delegate
+ implements IorProvider
{
/**
* The orb.
@@ -70,7 +71,7 @@ public class Simple_delegate
*/
protected IOR ior;
- public Simple_delegate(ORB an_orb, IOR an_ior)
+ public SimpleDelegate(ORB an_orb, IOR an_ior)
{
orb = an_orb;
ior = an_ior;
@@ -195,13 +196,11 @@ public class Simple_delegate
}
/**
- * Returns true if the objects are the same of have
- * the same delegate set. All objects in this implementation
- * have a separate delegate.
+ * Returns true if the objects are the same or have the same delegate set. All
+ * objects in this implementation have a separate delegate.
*/
public boolean is_equivalent(org.omg.CORBA.Object target,
- org.omg.CORBA.Object other
- )
+ org.omg.CORBA.Object other)
{
if (target == other)
return true;
@@ -209,14 +208,26 @@ public class Simple_delegate
{
try
{
- org.omg.CORBA.portable.Delegate a =
- ((ObjectImpl) target)._get_delegate();
- org.omg.CORBA.portable.Delegate b =
- ((ObjectImpl) other)._get_delegate();
+ org.omg.CORBA.portable.Delegate a = ((ObjectImpl) target)._get_delegate();
+ org.omg.CORBA.portable.Delegate b = ((ObjectImpl) other)._get_delegate();
if (a == b)
{
return true;
}
+ else
+ {
+ // We compere the IOR's in this case.
+ if (a instanceof IorProvider && b instanceof IorProvider)
+ {
+ IOR ia = ((IorProvider) a).getIor();
+ IOR ib = ((IorProvider) b).getIor();
+
+ if (ia != null && ib != null)
+ return (ia.equals(ib));
+ else
+ return ia == ib;
+ }
+ }
if (a != null && b != null)
{
return a.equals(b);
@@ -265,12 +276,19 @@ public class Simple_delegate
}
/**
- * This should never be called this type delegate.
- *
- * @throws InternalError, always.
+ * This method assumes that the target is local and connected to the ORB.
*/
public Request request(org.omg.CORBA.Object target, String operation)
{
- throw new InternalError();
+ if (orb instanceof OrbFunctional)
+ {
+ ((OrbFunctional) orb).ensureRunning();
+ }
+ gnuRequest g = new gnuRequest();
+ g.setORB(orb);
+ g.setOperation(operation);
+ g.setIor(ior);
+ g.m_target = target;
+ return g;
}
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/SocketRepository.java b/libjava/classpath/gnu/CORBA/SocketRepository.java
index a6b99200a48..e48a9a5da17 100644
--- a/libjava/classpath/gnu/CORBA/SocketRepository.java
+++ b/libjava/classpath/gnu/CORBA/SocketRepository.java
@@ -40,8 +40,9 @@ package gnu.CORBA;
import java.net.Socket;
import java.net.SocketException;
-
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
/**
* This class caches the opened sockets that are reused during the
@@ -56,9 +57,10 @@ public class SocketRepository
* The socket map.
*/
private static HashMap sockets = new HashMap();
-
+
/**
- * Put a socket.
+ * Put a socket. This method also discards all not reusable sockets from
+ * the map.
*
* @param key as socket key.
*
@@ -66,7 +68,41 @@ public class SocketRepository
*/
public static void put_socket(Object key, Socket s)
{
- sockets.put(key, s);
+ synchronized (sockets)
+ {
+ sockets.put(key, s);
+ gc();
+ }
+ }
+
+ /**
+ * Removes all non reusable sockets. As it is private,
+ * we know we call from the synchronized code already.
+ */
+ private static void gc()
+ {
+ Iterator iter = sockets.entrySet().iterator();
+
+ Map.Entry e;
+ Socket sx;
+
+ while (iter.hasNext())
+ {
+ e = (Map.Entry) iter.next();
+ sx = (Socket) e.getValue();
+
+ if (not_reusable(sx))
+ iter.remove();
+ }
+ }
+
+ /**
+ * Return true if the socket is no longer reusable.
+ */
+ static boolean not_reusable(Socket s)
+ {
+ return (s.isClosed() || !s.isBound() || !s.isConnected() ||
+ s.isInputShutdown() || s.isOutputShutdown());
}
/**
@@ -75,31 +111,41 @@ public class SocketRepository
* @param key a socket key.
*
* @return an opened socket for reuse, null if no such available or it is
- * closed.
+ * closed, its input or output has been shutown or otherwise the socket is not
+ * reuseable.
*/
public static Socket get_socket(Object key)
{
- Socket s = (Socket) sockets.get(key);
- if (s == null)
+ if (true)
return null;
- else if (s.isClosed())
- {
- sockets.remove(key);
- return null;
- }
- else
+
+ synchronized (sockets)
{
- sockets.remove(key);
- try
+ Socket s = (Socket) sockets.get(key);
+ if (s == null)
+ return null;
+
+ // Ensure that the socket is fully reusable.
+ else if (not_reusable(s))
{
- // Set one minute time out that will be changed later.
- s.setSoTimeout(60*1000);
+ sockets.remove(key);
+ return null;
}
- catch (SocketException e)
+ else
{
- s = null;
+ try
+ {
+ // Set one minute time out that will be changed later.
+ s.setSoTimeout(60 * 1000);
+ }
+ catch (SocketException e)
+ {
+ s = null;
+ }
+
+ sockets.remove(key);
+ return s;
}
- return s;
}
}
} \ No newline at end of file
diff --git a/libjava/classpath/gnu/CORBA/streamRequest.java b/libjava/classpath/gnu/CORBA/StreamBasedRequest.java
index a0f7eb09928..66796d653c9 100644
--- a/libjava/classpath/gnu/CORBA/streamRequest.java
+++ b/libjava/classpath/gnu/CORBA/StreamBasedRequest.java
@@ -38,15 +38,15 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
/**
* A stream, additionally holding the gnu request.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class streamRequest
- extends cdrBufOutput
+public class StreamBasedRequest
+ extends BufferedCdrOutput
{
/**
* The enclosed request.
diff --git a/libjava/classpath/gnu/CORBA/streamReadyHolder.java b/libjava/classpath/gnu/CORBA/StreamHolder.java
index a777bd55597..de2fda0ba89 100644
--- a/libjava/classpath/gnu/CORBA/streamReadyHolder.java
+++ b/libjava/classpath/gnu/CORBA/StreamHolder.java
@@ -1,4 +1,4 @@
-/* streamReadyHolder.java --
+/* StreamHolder.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import java.io.IOException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class streamReadyHolder
+public class StreamHolder
implements Streamable
{
/**
@@ -65,7 +65,7 @@ public class streamReadyHolder
*
* @param a_stream a stream.
*/
- public streamReadyHolder(InputStream a_stream)
+ public StreamHolder(InputStream a_stream)
{
stream = a_stream;
}
@@ -98,7 +98,10 @@ public class streamReadyHolder
}
catch (IOException ex)
{
- throw new MARSHAL(ex + ":" + ex.getMessage());
+ MARSHAL m = new MARSHAL();
+ m.initCause(ex);
+ m.minor = Minor.CDR;
+ throw m;
}
}
diff --git a/libjava/classpath/gnu/CORBA/stubFinder.java b/libjava/classpath/gnu/CORBA/StubLocator.java
index 77efd004717..d9e5ee4712c 100644
--- a/libjava/classpath/gnu/CORBA/stubFinder.java
+++ b/libjava/classpath/gnu/CORBA/StubLocator.java
@@ -1,4 +1,4 @@
-/* stubFinder.java --
+/* StubLocator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class stubFinder
+public class StubLocator
{
/**
* Search for the possibly available default stub.
@@ -83,7 +83,7 @@ public class stubFinder
String stub = "_" + s.substring(b + 1) + "Stub";
- Class stubClass = Class.forName(path + stub);
+ Class stubClass = ObjectCreator.forName(path + stub);
return (ObjectImpl) stubClass.newInstance();
}
@@ -105,6 +105,6 @@ public class stubFinder
*/
protected static ObjectImpl createDefaultStub(ORB orb, IOR ior)
{
- return new IOR_contructed_object(orb, ior);
+ return new IorObject(orb, ior);
}
}
diff --git a/libjava/classpath/gnu/CORBA/TypeCodeHelper.java b/libjava/classpath/gnu/CORBA/TypeCodeHelper.java
index c742275420e..4ffb0b74446 100644
--- a/libjava/classpath/gnu/CORBA/TypeCodeHelper.java
+++ b/libjava/classpath/gnu/CORBA/TypeCodeHelper.java
@@ -38,6 +38,13 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.FixedTypeCode;
+import gnu.CORBA.typecodes.GeneralTypeCode;
+import gnu.CORBA.typecodes.ArrayTypeCode;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
@@ -62,10 +69,10 @@ public class TypeCodeHelper
{
TCKind kind = TCKind.from_int(in.read_long());
TypeCode rt;
- generalTypeCode g;
- recordTypeCode r;
- recordTypeCode.Field f;
- stringTypeCode s;
+ GeneralTypeCode g;
+ RecordTypeCode r;
+ RecordTypeCode.Field f;
+ StringTypeCode s;
int n;
switch (kind.value())
@@ -73,21 +80,21 @@ public class TypeCodeHelper
case TCKind._tk_sequence :
case TCKind._tk_array :
- primitiveArrayTypeCode p = new primitiveArrayTypeCode(kind);
+ ArrayTypeCode p = new ArrayTypeCode(kind);
p.setLength(in.read_long());
rt = p;
break;
case TCKind._tk_string :
case TCKind._tk_wstring :
- s = new stringTypeCode(kind);
+ s = new StringTypeCode(kind);
s.setLength(in.read_long());
rt = s;
break;
case TCKind._tk_fixed :
- fixedTypeCode fx = new fixedTypeCode();
+ FixedTypeCode fx = new FixedTypeCode();
fx.setDigits(in.read_short());
fx.setScale(in.read_short());
rt = fx;
@@ -96,7 +103,7 @@ public class TypeCodeHelper
case TCKind._tk_objref :
case TCKind._tk_native :
case TCKind._tk_abstract_interface :
- g = new generalTypeCode(kind);
+ g = new GeneralTypeCode(kind);
g.setId(in.read_string());
g.setName(in.read_string());
rt = g;
@@ -104,7 +111,7 @@ public class TypeCodeHelper
case TCKind._tk_alias :
case TCKind._tk_value_box :
- g = new generalTypeCode(kind);
+ g = new GeneralTypeCode(kind);
g.setId(in.read_string());
g.setName(in.read_string());
g.setContentType(in.read_TypeCode());
@@ -113,7 +120,7 @@ public class TypeCodeHelper
case TCKind._tk_struct :
case TCKind._tk_except :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
@@ -129,7 +136,7 @@ public class TypeCodeHelper
break;
case TCKind._tk_enum :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
@@ -144,7 +151,7 @@ public class TypeCodeHelper
break;
case TCKind._tk_union :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
r.setDiscriminator_type(in.read_TypeCode());
@@ -164,7 +171,7 @@ public class TypeCodeHelper
break;
case TCKind._tk_value :
- r = new recordTypeCode(kind);
+ r = new RecordTypeCode(kind);
r.setId(in.read_string());
r.setName(in.read_string());
r.setTypeModifier(in.read_short());
@@ -183,7 +190,7 @@ public class TypeCodeHelper
break;
default :
- rt = new primitiveTypeCode(kind);
+ rt = new PrimitiveTypeCode(kind);
}
return rt;
}
diff --git a/libjava/classpath/gnu/CORBA/typeNamer.java b/libjava/classpath/gnu/CORBA/TypeKindNamer.java
index f790dc95970..3296db3600a 100644
--- a/libjava/classpath/gnu/CORBA/typeNamer.java
+++ b/libjava/classpath/gnu/CORBA/TypeKindNamer.java
@@ -38,6 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.RecordTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
@@ -48,7 +51,7 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class typeNamer
+public class TypeKindNamer
{
/**
* Names of the primitve types.
@@ -69,46 +72,46 @@ public class typeNamer
protected static final TypeCode[] primitveCodes =
new TypeCode[]
{
- new primitiveTypeCode(TCKind.tk_null),
- new primitiveTypeCode(TCKind.tk_void),
- new primitiveTypeCode(TCKind.tk_short),
- new primitiveTypeCode(TCKind.tk_long),
- new primitiveTypeCode(TCKind.tk_ushort),
- new primitiveTypeCode(TCKind.tk_ulong),
- new primitiveTypeCode(TCKind.tk_float),
- new primitiveTypeCode(TCKind.tk_double),
- new primitiveTypeCode(TCKind.tk_boolean),
- new primitiveTypeCode(TCKind.tk_char),
- new primitiveTypeCode(TCKind.tk_octet),
- new primitiveTypeCode(TCKind.tk_any),
- new primitiveTypeCode(TCKind.tk_TypeCode),
- new primitiveTypeCode(TCKind.tk_Principal),
- new recordTypeCode(TCKind.tk_objref),
- new primitiveTypeCode(TCKind.tk_struct),
- new primitiveTypeCode(TCKind.tk_union),
- new primitiveTypeCode(TCKind.tk_enum),
- new primitiveTypeCode(TCKind.tk_string),
- new primitiveTypeCode(TCKind.tk_sequence),
- new primitiveTypeCode(TCKind.tk_array),
- new primitiveTypeCode(TCKind.tk_alias),
- new primitiveTypeCode(TCKind.tk_except),
- new primitiveTypeCode(TCKind.tk_longlong),
- new primitiveTypeCode(TCKind.tk_ulonglong),
- new primitiveTypeCode(TCKind.tk_longdouble),
- new primitiveTypeCode(TCKind.tk_wchar),
- new primitiveTypeCode(TCKind.tk_wstring),
- new primitiveTypeCode(TCKind.tk_fixed),
- new primitiveTypeCode(TCKind.tk_value),
- new primitiveTypeCode(TCKind.tk_value_box),
- new primitiveTypeCode(TCKind.tk_native),
- new primitiveTypeCode(TCKind.tk_abstract_interface)
+ new PrimitiveTypeCode(TCKind.tk_null),
+ new PrimitiveTypeCode(TCKind.tk_void),
+ new PrimitiveTypeCode(TCKind.tk_short),
+ new PrimitiveTypeCode(TCKind.tk_long),
+ new PrimitiveTypeCode(TCKind.tk_ushort),
+ new PrimitiveTypeCode(TCKind.tk_ulong),
+ new PrimitiveTypeCode(TCKind.tk_float),
+ new PrimitiveTypeCode(TCKind.tk_double),
+ new PrimitiveTypeCode(TCKind.tk_boolean),
+ new PrimitiveTypeCode(TCKind.tk_char),
+ new PrimitiveTypeCode(TCKind.tk_octet),
+ new PrimitiveTypeCode(TCKind.tk_any),
+ new PrimitiveTypeCode(TCKind.tk_TypeCode),
+ new PrimitiveTypeCode(TCKind.tk_Principal),
+ new RecordTypeCode(TCKind.tk_objref),
+ new PrimitiveTypeCode(TCKind.tk_struct),
+ new PrimitiveTypeCode(TCKind.tk_union),
+ new PrimitiveTypeCode(TCKind.tk_enum),
+ new PrimitiveTypeCode(TCKind.tk_string),
+ new PrimitiveTypeCode(TCKind.tk_sequence),
+ new PrimitiveTypeCode(TCKind.tk_array),
+ new PrimitiveTypeCode(TCKind.tk_alias),
+ new PrimitiveTypeCode(TCKind.tk_except),
+ new PrimitiveTypeCode(TCKind.tk_longlong),
+ new PrimitiveTypeCode(TCKind.tk_ulonglong),
+ new PrimitiveTypeCode(TCKind.tk_longdouble),
+ new PrimitiveTypeCode(TCKind.tk_wchar),
+ new PrimitiveTypeCode(TCKind.tk_wstring),
+ new PrimitiveTypeCode(TCKind.tk_fixed),
+ new PrimitiveTypeCode(TCKind.tk_value),
+ new PrimitiveTypeCode(TCKind.tk_value_box),
+ new PrimitiveTypeCode(TCKind.tk_native),
+ new PrimitiveTypeCode(TCKind.tk_abstract_interface)
};
static
{
// The Id of the "abstract object" is defined as empty string.
- recordTypeCode object =
- (recordTypeCode) primitveCodes [ TCKind._tk_objref ];
+ RecordTypeCode object =
+ (RecordTypeCode) primitveCodes [ TCKind._tk_objref ];
object.setId("");
object.setName("Object");
}
diff --git a/libjava/classpath/gnu/CORBA/Version.java b/libjava/classpath/gnu/CORBA/Version.java
index 84f40bf4f39..efc27c22081 100644
--- a/libjava/classpath/gnu/CORBA/Version.java
+++ b/libjava/classpath/gnu/CORBA/Version.java
@@ -70,8 +70,8 @@ public class Version
/**
* Create the version with the given version numbers.
*
- * @param major major number (0..255)
- * @param minor minor number (0..255)
+ * @param _major major number (0..255)
+ * @param _minor minor number (0..255)
*/
public Version(int _major, int _minor)
{
@@ -99,6 +99,15 @@ public class Version
Version that = (Version) other;
return same(that);
}
+
+ /**
+ * Get the hashcode, higher 8 bits being the major version and lower 8 bits
+ * the minor version.
+ */
+ public int hashCode()
+ {
+ return major << 8 | minor;
+ }
/**
* Read from the input stream, major number first.
@@ -114,7 +123,10 @@ public class Version
}
catch (IOException ex)
{
- throw new MARSHAL("IOException while reading message header");
+ MARSHAL m = new MARSHAL("IOException while reading message header");
+ m.initCause(ex);
+ m.minor = Minor.Header;
+ throw m;
}
}
@@ -166,7 +178,7 @@ public class Version
* Returs true if the given version is lower or equal to the
* version, specified by the provided minor and major version
* number. This means, the version, specified by these two numbers,
- * should be supported by teh current version.
+ * should be supported by the current version.
*
* @param a_major a major version number.
* @param a_minor a minor version number.
@@ -200,7 +212,11 @@ public class Version
}
catch (IOException ex)
{
- throw new MARSHAL("IOException while writing message header");
+ MARSHAL m = new MARSHAL("IOException while writing message header");
+ m.minor = Minor.Header;
+ m.initCause(ex);
+ throw m;
}
}
+
}
diff --git a/libjava/classpath/gnu/CORBA/WCharHolder.java b/libjava/classpath/gnu/CORBA/WCharHolder.java
index 23f0ad100f9..3c6a87fbe2d 100644
--- a/libjava/classpath/gnu/CORBA/WCharHolder.java
+++ b/libjava/classpath/gnu/CORBA/WCharHolder.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
@@ -61,7 +63,7 @@ public final class WCharHolder
/**
* The default type code for this holder.
*/
- private static final TypeCode t_char = new primitiveTypeCode(TCKind.tk_wchar);
+ private static final TypeCode t_char = new PrimitiveTypeCode(TCKind.tk_wchar);
/**
* The <code>char</code> (CORBA <code>wchar</code>) value,
diff --git a/libjava/classpath/gnu/CORBA/WStringHolder.java b/libjava/classpath/gnu/CORBA/WStringHolder.java
index c9e8e33234d..7f18791dfee 100644
--- a/libjava/classpath/gnu/CORBA/WStringHolder.java
+++ b/libjava/classpath/gnu/CORBA/WStringHolder.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
+import gnu.CORBA.typecodes.StringTypeCode;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
@@ -62,8 +64,8 @@ public class WStringHolder
/**
* The default type code for this holder.
*/
- private static final stringTypeCode t_string =
- new stringTypeCode(TCKind.tk_wstring);
+ private static final StringTypeCode t_string =
+ new StringTypeCode(TCKind.tk_wstring);
/**
* The <code>String</code> (CORBA <code>string</code>) value,
diff --git a/libjava/classpath/gnu/CORBA/_PolicyImplBase.java b/libjava/classpath/gnu/CORBA/_PolicyImplBase.java
index d9ff9d648ad..17a5f4a40e5 100644
--- a/libjava/classpath/gnu/CORBA/_PolicyImplBase.java
+++ b/libjava/classpath/gnu/CORBA/_PolicyImplBase.java
@@ -165,7 +165,8 @@ public abstract class _PolicyImplBase
output.write_long(policyCode);
}
else
- throw new BAD_OPERATION(method, 0, CompletionStatus.COMPLETED_MAYBE);
+ throw new BAD_OPERATION(method, Minor.Method,
+ CompletionStatus.COMPLETED_MAYBE);
return output;
}
diff --git a/libjava/classpath/gnu/CORBA/gnuAny.java b/libjava/classpath/gnu/CORBA/gnuAny.java
index 7e5ef335149..729386da2c4 100644
--- a/libjava/classpath/gnu/CORBA/gnuAny.java
+++ b/libjava/classpath/gnu/CORBA/gnuAny.java
@@ -39,8 +39,10 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.Vio;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
+import gnu.CORBA.typecodes.PrimitiveTypeCode;
+import gnu.CORBA.typecodes.StringTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnyHolder;
@@ -62,19 +64,14 @@ import org.omg.CORBA.StringHolder;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodeHolder;
-import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.ValueBaseHolder;
-import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.Streamable;
-import java.io.IOException;
import java.io.Serializable;
-
import java.lang.reflect.Field;
-
import java.math.BigDecimal;
-
import java.util.Arrays;
+import java.util.zip.Adler32;
/**
* The implementation of {@link Any}.
@@ -93,12 +90,17 @@ import java.util.Arrays;
public class gnuAny
extends Any
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The value, returned by {@link #type()} if the value has been
* not intialized.
*/
protected static final TypeCode nullType =
- new primitiveTypeCode(TCKind.tk_null);
+ new PrimitiveTypeCode(TCKind.tk_null);
/**
* The Streamable, representing the value, held by this gnuAny.
@@ -137,11 +139,11 @@ public class gnuAny
*/
public gnuAny Clone()
{
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
out.setOrb(orb);
out.write_any(this);
- cdrBufInput in = new cdrBufInput(out.buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
in.setOrb(orb);
return (gnuAny) in.read_any();
}
@@ -152,18 +154,18 @@ public class gnuAny
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
- if (has instanceof universalHolder)
+ if (has instanceof GeneralHolder)
{
- universalHolder u = (universalHolder) has;
+ GeneralHolder u = (GeneralHolder) has;
return u.getInputStream();
}
else
{
- cdrBufOutput out = new cdrBufOutput();
+ BufferedCdrOutput out = new BufferedCdrOutput();
out.setOrb(orb);
write_value(out);
- cdrBufInput in = new cdrBufInput(out.buffer.toByteArray());
+ BufferredCdrInput in = new BufferredCdrInput(out.buffer.toByteArray());
in.setOrb(orb);
return in;
}
@@ -174,7 +176,7 @@ public class gnuAny
*/
public org.omg.CORBA.portable.OutputStream create_output_stream()
{
- cdrBufOutput stream = new cdrBufOutput();
+ BufferedCdrOutput stream = new BufferedCdrOutput();
stream.setOrb(orb);
return stream;
}
@@ -194,11 +196,11 @@ public class gnuAny
if (has.equals(((gnuAny) other).has))
return true;
- cdrBufOutput a = new cdrBufOutput();
+ BufferedCdrOutput a = new BufferedCdrOutput();
a.setOrb(orb);
write_value(a);
- cdrBufOutput b = new cdrBufOutput();
+ BufferedCdrOutput b = new BufferedCdrOutput();
b.setOrb(orb);
other.write_value(b);
@@ -207,6 +209,28 @@ public class gnuAny
return Arrays.equals(ba, bb);
}
+
+ /**
+ * Get the content - dependent hashcode.
+ */
+ public int hashCode()
+ {
+ if (has == null)
+ return type().kind().value();
+ else
+ {
+ Adler32 adler = new Adler32();
+
+ BufferedCdrOutput a = new BufferedCdrOutput();
+ a.setOrb(orb);
+ write_value(a);
+
+ adler.update(a.buffer.toByteArray());
+ adler.update(type().kind().value());
+
+ return (int) adler.getValue() & Integer.MAX_VALUE;
+ }
+ }
/**
* Delegates functionality to {@link #equal(Any)}.
@@ -232,7 +256,10 @@ public class gnuAny
}
catch (ClassCastException ex)
{
- throw new BAD_OPERATION();
+ BAD_OPERATION bad = new BAD_OPERATION();
+ bad.initCause(ex);
+ bad.minor = Minor.Any;
+ throw bad;
}
}
@@ -297,7 +324,10 @@ public class gnuAny
}
catch (Exception ex)
{
- return new BAD_OPERATION("Value type expected");
+ BAD_OPERATION bad = new BAD_OPERATION("Value type expected");
+ bad.minor = Minor.Any;
+ bad.initCause(ex);
+ throw bad;
}
}
@@ -664,7 +694,7 @@ public class gnuAny
else
has = new StringHolder(x);
- typecode = new stringTypeCode(TCKind.tk_string);
+ typecode = new StringTypeCode(TCKind.tk_string);
}
/** {@inheritDoc} */
@@ -751,40 +781,27 @@ public class gnuAny
}
else
{
- has = holderFactory.createHolder(a_type);
+ has = HolderLocator.createHolder(a_type);
if (has == null)
{
// Use the Universal Holder that reads till the end of stream.
// This works with the extract/insert pair of the typical
// Helper.
- cdrBufOutput buffer = new cdrBufOutput();
+ BufferedCdrOutput buffer = new BufferedCdrOutput();
buffer.setOrb(orb);
- has = new universalHolder(buffer);
+ has = new GeneralHolder(buffer);
}
}
type(a_type);
- if (!(has instanceof universalHolder) &&
+ if (!(has instanceof GeneralHolder) &&
(kind == TCKind._tk_value_box))
{
// The streamable only contains operations for
// reading the value, not the value header.
Field vField = has.getClass().getField("value");
- BoxedValueHelper helper;
-
- try
- {
- Class helperClass =
- Class.forName(ObjectCreator.toHelperName(a_type.id()));
- helper = (BoxedValueHelper) helperClass.newInstance();
- }
- catch (Exception ex)
- {
- helper = null;
- }
-
- Object content = Vio.read(input, helper);
+ Object content = Vio.read(input, a_type.id());
vField.set(has, content);
}
else
@@ -793,6 +810,7 @@ public class gnuAny
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
+ m.minor = Minor.Any;
m.initCause(ex);
throw m;
}
@@ -805,7 +823,7 @@ public class gnuAny
return typecode;
else if (xKind >= 0)
{
- typecode = new primitiveTypeCode(TCKind.from_int(xKind));
+ typecode = new PrimitiveTypeCode(TCKind.from_int(xKind));
return typecode;
}
else
@@ -838,38 +856,43 @@ public class gnuAny
/**
* Check if the current value if the value of the given kind.
+ *
* @param kind a kind to check.
* @throws BAD_OPERATION if the value is not set of is different kind.
*/
protected void check(int kind)
- throws BAD_OPERATION
+ throws BAD_OPERATION
{
if (has == null)
- throw new BAD_OPERATION("value not set");
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("value not set");
+ bad.minor = Minor.Any;
+ throw bad;
+ }
if (xKind >= 0)
{
if (xKind != kind)
- if (!(
- xKind == TCKind._tk_alias &&
- has._type().kind().value() == kind
- )
- )
- throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
- " when stored " + typeNamer.nameIt(xKind)
- );
+ if (!(xKind == TCKind._tk_alias && has._type().kind().value() == kind))
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("Extracting "
+ + TypeKindNamer.nameIt(kind) + " when stored "
+ + TypeKindNamer.nameIt(xKind));
+ bad.minor = Minor.Any;
+ throw bad;
+ }
}
else
{
if (type().kind().value() != kind)
- if (!(
- type().kind().value() == TCKind._tk_alias &&
- has._type().kind().value() == kind
- )
- )
- throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
- " stored " + typeNamer.nameIt(type())
- );
+ if (!(type().kind().value() == TCKind._tk_alias && has._type().kind().value() == kind))
+ {
+ BAD_OPERATION bad = new BAD_OPERATION("Extracting "
+ + TypeKindNamer.nameIt(kind) + " stored "
+ + TypeKindNamer.nameIt(type()));
+ bad.minor = Minor.Any;
+ throw bad;
+ }
}
}
diff --git a/libjava/classpath/gnu/CORBA/gnuCodecFactory.java b/libjava/classpath/gnu/CORBA/gnuCodecFactory.java
index 067de498c79..8cf9ccf7bc4 100644
--- a/libjava/classpath/gnu/CORBA/gnuCodecFactory.java
+++ b/libjava/classpath/gnu/CORBA/gnuCodecFactory.java
@@ -83,7 +83,7 @@ public class gnuCodecFactory extends LocalObject implements CodecFactory
"supported by this factory."
);
- return new cdrEncapsCodec(orb,
+ return new CdrEncapsCodecImpl(orb,
new Version(for_encoding.major_version, for_encoding.minor_version)
);
}
diff --git a/libjava/classpath/gnu/CORBA/gnuContextList.java b/libjava/classpath/gnu/CORBA/gnuContextList.java
index 2a26437debe..68584c3891c 100644
--- a/libjava/classpath/gnu/CORBA/gnuContextList.java
+++ b/libjava/classpath/gnu/CORBA/gnuContextList.java
@@ -53,7 +53,7 @@ public class gnuContextList
/**
* The collection, holding the actual list of strings.
*/
- corbaArrayList strings = new corbaArrayList();
+ CorbaList strings = new CorbaList();
/** {@inheritDoc} */
public void add(String name)
diff --git a/libjava/classpath/gnu/CORBA/gnuExceptionList.java b/libjava/classpath/gnu/CORBA/gnuExceptionList.java
index b684ec928cf..5f0c0c9f50d 100644
--- a/libjava/classpath/gnu/CORBA/gnuExceptionList.java
+++ b/libjava/classpath/gnu/CORBA/gnuExceptionList.java
@@ -54,7 +54,7 @@ public class gnuExceptionList
/**
* A list to store the objects.
*/
- protected corbaArrayList list = new corbaArrayList();
+ protected CorbaList list = new CorbaList();
/** {@inheritDoc} */
public void add(TypeCode an_exception)
diff --git a/libjava/classpath/gnu/CORBA/gnuNVList.java b/libjava/classpath/gnu/CORBA/gnuNVList.java
index e436c332caa..3645a3e8dd2 100644
--- a/libjava/classpath/gnu/CORBA/gnuNVList.java
+++ b/libjava/classpath/gnu/CORBA/gnuNVList.java
@@ -53,14 +53,14 @@ public class gnuNVList
/**
* The list of the named values.
*/
- protected corbaArrayList list;
+ protected CorbaList list;
/**
* Creates the list with the default initial size.
*/
public gnuNVList()
{
- list = new corbaArrayList();
+ list = new CorbaList();
}
/**
@@ -68,7 +68,7 @@ public class gnuNVList
*/
public gnuNVList(int initial_size)
{
- list = new corbaArrayList(initial_size);
+ list = new CorbaList(initial_size);
}
/** {@inheritDoc} */
diff --git a/libjava/classpath/gnu/CORBA/gnuRequest.java b/libjava/classpath/gnu/CORBA/gnuRequest.java
index 7d756eddba3..5adf7412926 100644
--- a/libjava/classpath/gnu/CORBA/gnuRequest.java
+++ b/libjava/classpath/gnu/CORBA/gnuRequest.java
@@ -38,12 +38,12 @@ exception statement from your version. */
package gnu.CORBA;
-import gnu.CORBA.CDR.cdrBufInput;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferredCdrInput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.GIOP.RequestHeader;
-import gnu.CORBA.GIOP.cxCodeSet;
+import gnu.CORBA.GIOP.CodeSetServiceContext;
import gnu.CORBA.Interceptor.gnuClientRequestInfo;
import gnu.CORBA.Poa.ORB_1_4;
@@ -54,6 +54,7 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.Bounds;
+import org.omg.CORBA.COMM_FAILURE;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
@@ -134,8 +135,8 @@ public class gnuRequest extends Request implements Cloneable
/**
* The empty byte array.
*/
- private static final binaryReply EMPTY =
- new binaryReply(null, new MessageHeader(), new byte[ 0 ]);
+ private static final RawReply EMPTY =
+ new RawReply(null, new MessageHeader(), new byte[ 0 ]);
/**
* The context holder for methods ctx(Context) and ctx().
@@ -222,7 +223,7 @@ public class gnuRequest extends Request implements Cloneable
* The request arguments in the case when they are directly written into the
* parameter buffer.
*/
- protected streamRequest m_parameter_buffer;
+ protected StreamBasedRequest m_parameter_buffer;
/**
* The array of slots.
@@ -294,8 +295,8 @@ public class gnuRequest extends Request implements Cloneable
orb = an_orb;
// Take the interceptor from the ORB.
- if (orb instanceof Restricted_ORB)
- m_interceptor = ((Restricted_ORB) orb).iClient;
+ if (orb instanceof OrbRestricted)
+ m_interceptor = ((OrbRestricted) orb).iClient;
if (m_interceptor != null && orb instanceof ORB_1_4)
{
@@ -332,12 +333,12 @@ public class gnuRequest extends Request implements Cloneable
* Get the parameter stream, where the invocation arguments should be written
* if they are written into the stream directly.
*/
- public streamRequest getParameterStream()
+ public StreamBasedRequest getParameterStream()
{
- m_parameter_buffer = new streamRequest();
+ m_parameter_buffer = new StreamBasedRequest();
m_parameter_buffer.request = this;
m_parameter_buffer.setVersion(ior.Internet.version);
- m_parameter_buffer.setCodeSet(cxCodeSet.negotiate(ior.Internet.CodeSets));
+ m_parameter_buffer.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
m_parameter_buffer.setOrb(orb);
m_parameter_buffer.setBigEndian(Big_endian);
@@ -345,7 +346,7 @@ public class gnuRequest extends Request implements Cloneable
// correctly.
if (ior.Internet.version.until_inclusive(1, 1))
{
- cdrBufOutput measure = new cdrBufOutput();
+ BufferedCdrOutput measure = new BufferedCdrOutput();
measure.setOffset(12);
if (m_rqh == null)
m_rqh = new gnu.CORBA.GIOP.v1_0.RequestHeader();
@@ -513,8 +514,8 @@ public class gnuRequest extends Request implements Cloneable
try
{
ObjectImpl impl = (ObjectImpl) e.forward;
- Simple_delegate delegate =
- (Simple_delegate) impl._get_delegate();
+ SimpleDelegate delegate =
+ (SimpleDelegate) impl._get_delegate();
ior = delegate.getIor();
}
catch (Exception ex)
@@ -714,14 +715,15 @@ public class gnuRequest extends Request implements Cloneable
/**
* Do the actual invocation. This implementation requires to set the IOR
* property ({@link #setIOR(IOR)} before calling this method.
- *
+ *
* @throws BAD_INV_ORDER, minor code 0, if the IOR has not been previously set
* or if the direct argument addition is mixed with the direct argument
* writing into the output stream.
- *
+ *
* @return the server response in binary form.
*/
- public synchronized binaryReply submit() throws ForwardRequest
+ public synchronized RawReply submit()
+ throws ForwardRequest
{
gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader();
@@ -742,26 +744,25 @@ public class gnuRequest extends Request implements Cloneable
m_interceptor.send_request(m_info);
// Prepare the submission.
- cdrBufOutput request_part = new cdrBufOutput();
+ BufferedCdrOutput request_part = new BufferedCdrOutput();
request_part.setOffset(header.getHeaderSize());
request_part.setVersion(header.version);
- request_part.setCodeSet(cxCodeSet.negotiate(ior.Internet.CodeSets));
+ request_part.setCodeSet(CodeSetServiceContext.negotiate(ior.Internet.CodeSets));
request_part.setOrb(orb);
request_part.setBigEndian(header.isBigEndian());
// This also sets the stream encoding to the encoding, specified
// in the header.
rh.write(request_part);
-
+
if (m_args != null && m_args.count() > 0)
{
write_parameters(header, request_part);
if (m_parameter_buffer != null)
- throw new BAD_INV_ORDER("Please either add parameters or " +
- "write them into stream, but not both " + "at once."
- );
+ throw new BAD_INV_ORDER("Please either add parameters or "
+ + "write them into stream, but not both " + "at once.");
}
if (m_parameter_buffer != null)
@@ -789,12 +790,15 @@ public class gnuRequest extends Request implements Cloneable
{
// The BindException may be thrown under very heavy parallel
// load. For some time, just wait, exceptiong the socket to free.
- Open:
- for (int i = 0; i < PAUSE_STEPS; i++)
+ Open: for (int i = 0; i < PAUSE_STEPS; i++)
{
try
{
- socket = new Socket(ior.Internet.host, ior.Internet.port);
+ if (orb instanceof OrbFunctional)
+ socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
+ ior.Internet.host, ior.Internet.port);
+ else
+ socket = new Socket(ior.Internet.host, ior.Internet.port);
break Open;
}
catch (BindException ex)
@@ -816,9 +820,8 @@ public class gnuRequest extends Request implements Cloneable
}
if (socket == null)
- throw new NO_RESOURCES(ior.Internet.host + ":" + ior.Internet.port +
- " in use"
- );
+ throw new NO_RESOURCES(ior.Internet.host + ":" + ior.Internet.port
+ + " in use");
socket.setKeepAlive(true);
OutputStream socketOutput = socket.getOutputStream();
@@ -836,25 +839,26 @@ public class gnuRequest extends Request implements Cloneable
InputStream socketInput = socket.getInputStream();
response_header.read(socketInput);
- byte[] r = new byte[ response_header.message_size ];
- int n = 0;
- reading:
- while (n < r.length)
+ byte[] r;
+ if (orb instanceof OrbFunctional)
{
- n += socketInput.read(r, n, r.length - n);
+ OrbFunctional fo = (OrbFunctional) orb;
+ r = response_header.readMessage(socketInput, socket,
+ fo.TOUT_WHILE_READING, fo.TOUT_AFTER_RECEIVING);
}
- return new binaryReply(orb, response_header, r);
+ else
+ r = response_header.readMessage(socketInput, null, 0, 0);
+
+ return new RawReply(orb, response_header, r);
}
else
return EMPTY;
}
catch (IOException io_ex)
{
- MARSHAL m =
- new MARSHAL("Unable to open a socket at " + ior.Internet.host + ":" +
- ior.Internet.port, 10000 + ior.Internet.port,
- CompletionStatus.COMPLETED_NO
- );
+ COMM_FAILURE m = new COMM_FAILURE("Unable to open a socket at "
+ + ior.Internet.host + ":" + ior.Internet.port, 0xC9,
+ CompletionStatus.COMPLETED_NO);
m.initCause(io_ex);
throw m;
}
@@ -864,7 +868,7 @@ public class gnuRequest extends Request implements Cloneable
{
if (socket != null && !socket.isClosed())
{
- socket.setSoTimeout(Functional_ORB.TANDEM_REQUESTS);
+ socket.setSoTimeout(OrbFunctional.TANDEM_REQUESTS);
SocketRepository.put_socket(key, socket);
}
}
@@ -929,14 +933,15 @@ public class gnuRequest extends Request implements Cloneable
* Do actual invocation. This method recursively calls itself if the
* redirection is detected.
*/
- private void p_invoke() throws SystemException, ForwardRequest
+ private void p_invoke()
+ throws SystemException, ForwardRequest
{
- binaryReply response = submit();
+ RawReply response = submit();
if (m_rph == null)
m_rph = response.header.create_reply_header();
- cdrBufInput input = response.getStream();
+ BufferredCdrInput input = response.getStream();
input.setOrb(orb);
m_rph.read(input);
@@ -946,7 +951,7 @@ public class gnuRequest extends Request implements Cloneable
switch (m_rph.reply_status)
{
- case ReplyHeader.NO_EXCEPTION :
+ case ReplyHeader.NO_EXCEPTION:
NamedValue arg;
@@ -992,7 +997,7 @@ public class gnuRequest extends Request implements Cloneable
break;
- case ReplyHeader.SYSTEM_EXCEPTION :
+ case ReplyHeader.SYSTEM_EXCEPTION:
if (align)
{
input.align(8);
@@ -1000,7 +1005,8 @@ public class gnuRequest extends Request implements Cloneable
}
readExceptionId(input);
- m_sys_ex = ObjectCreator.readSystemException(input);
+ m_sys_ex = ObjectCreator.readSystemException(input,
+ m_rph.service_context);
m_environment.exception(m_sys_ex);
if (m_interceptor != null)
@@ -1008,7 +1014,7 @@ public class gnuRequest extends Request implements Cloneable
throw m_sys_ex;
- case ReplyHeader.USER_EXCEPTION :
+ case ReplyHeader.USER_EXCEPTION:
if (align)
{
input.align(8);
@@ -1020,7 +1026,7 @@ public class gnuRequest extends Request implements Cloneable
gnuAny exc = new gnuAny();
exc.setOrb(orb);
- exc.insert_Streamable(new streamReadyHolder(input));
+ exc.insert_Streamable(new StreamHolder(input));
UnknownUserException unuex = new UnknownUserException(exc);
m_environment.exception(unuex);
@@ -1030,8 +1036,8 @@ public class gnuRequest extends Request implements Cloneable
break;
- case ReplyHeader.LOCATION_FORWARD_PERM :
- case ReplyHeader.LOCATION_FORWARD :
+ case ReplyHeader.LOCATION_FORWARD_PERM:
+ case ReplyHeader.LOCATION_FORWARD:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
@@ -1043,8 +1049,7 @@ public class gnuRequest extends Request implements Cloneable
catch (IOException ex)
{
new MARSHAL("Cant read forwarding info", 5103,
- CompletionStatus.COMPLETED_NO
- );
+ CompletionStatus.COMPLETED_NO);
}
setIor(forwarded);
@@ -1058,17 +1063,16 @@ public class gnuRequest extends Request implements Cloneable
p_invoke();
return;
- default :
+ default:
throw new MARSHAL("Unknow reply status", 8100 + m_rph.reply_status,
- CompletionStatus.COMPLETED_NO
- );
+ CompletionStatus.COMPLETED_NO);
}
}
/**
* Read exception id without changing the stream pointer position.
*/
- void readExceptionId(cdrBufInput input)
+ void readExceptionId(BufferredCdrInput input)
{
input.mark(2048);
m_exception_id = input.read_string();
@@ -1084,7 +1088,7 @@ public class gnuRequest extends Request implements Cloneable
* @throws MARSHAL if the attempt to write the parameters has failde.
*/
protected void write_parameter_buffer(MessageHeader header,
- cdrBufOutput request_part
+ BufferedCdrOutput request_part
) throws MARSHAL
{
try
@@ -1097,7 +1101,9 @@ public class gnuRequest extends Request implements Cloneable
}
catch (IOException ex)
{
- throw new MARSHAL("Unable to write method arguments to CDR output.");
+ MARSHAL m = new MARSHAL("Unable to write method arguments to CDR output.");
+ m.minor = Minor.CDR;
+ throw m;
}
}
@@ -1110,7 +1116,7 @@ public class gnuRequest extends Request implements Cloneable
* @throws MARSHAL if the attempt to write the parameters has failde.
*/
protected void write_parameters(MessageHeader header,
- cdrBufOutput request_part
+ BufferedCdrOutput request_part
) throws MARSHAL
{
// Align after 1.2, but only once.
@@ -1161,7 +1167,7 @@ public class gnuRequest extends Request implements Cloneable
*/
public TaggedProfile effective_profile()
{
- cdrBufOutput buf = new cdrBufOutput(512);
+ BufferedCdrOutput buf = new BufferedCdrOutput(512);
buf.setOrb(orb);
ior.Internet.write(buf);
@@ -1176,7 +1182,7 @@ public class gnuRequest extends Request implements Cloneable
*/
public org.omg.CORBA.Object effective_target()
{
- return new IOR_contructed_object(orb, ior);
+ return new IorObject(orb, ior);
}
/**
@@ -1188,7 +1194,7 @@ public class gnuRequest extends Request implements Cloneable
if (id == TAG_CODE_SETS.value)
{
// Codesets are encoded separately.
- cdrBufOutput buf = new cdrBufOutput(512);
+ BufferedCdrOutput buf = new BufferedCdrOutput(512);
buf.setOrb(orb);
ior.Internet.CodeSets.write(buf);
@@ -1289,7 +1295,7 @@ public class gnuRequest extends Request implements Cloneable
return m_forwarding_target;
if (m_forward_ior != null)
- return new IOR_contructed_object(orb, m_forward_ior);
+ return new IorObject(orb, m_forward_ior);
else
return null;
}
diff --git a/libjava/classpath/gnu/CORBA/gnuValueHolder.java b/libjava/classpath/gnu/CORBA/gnuValueHolder.java
index 0b382648981..8263113ec2a 100644
--- a/libjava/classpath/gnu/CORBA/gnuValueHolder.java
+++ b/libjava/classpath/gnu/CORBA/gnuValueHolder.java
@@ -123,7 +123,7 @@ public class gnuValueHolder
try
{
Class helperClass =
- Class.forName(ObjectCreator.toHelperName(type.id()));
+ ObjectCreator.forName(ObjectCreator.toHelperName(type.id()));
helper = (BoxedValueHelper) helperClass.newInstance();
}
diff --git a/libjava/classpath/gnu/CORBA/interfaces/SocketFactory.java b/libjava/classpath/gnu/CORBA/interfaces/SocketFactory.java
new file mode 100644
index 00000000000..7797dcbf917
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/interfaces/SocketFactory.java
@@ -0,0 +1,95 @@
+/* SocketFactory.java --
+ 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. */
+
+
+package gnu.CORBA.interfaces;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+/**
+ * This class produces sockets for serving and submitting CORBA requests. The
+ * socket factory can be set using {@link gnuOrb.setSocketFactory()} for
+ * producting all sockets for that ORB. This is needed for using secure sockets,
+ * for implementing the desired timeout policies, for HTTP tunnels and in some
+ * other similar cases. While such functionality is provided by near all
+ * existing CORBA implementations, no standard mechanism is defined.
+ *
+ * The socket factory may need to put additional information to the IORs of the
+ * objects, released by the ORB. Because of this reason, this interface extends
+ * IORInterceptorOperations.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public interface SocketFactory
+{
+ /**
+ * The name of the ORB property that forces the ORB to use the socket
+ * factory class, the name of that (String) is the value of this property.
+ */
+ final String PROPERTY = "gnu.CORBA.SocketFactory";
+
+ /**
+ * Create a server socket that should serve remote invocations on the given
+ * port. The ORB may use this socket to serve either one or more objects.
+ *
+ * @param port the port, on that the socket should be listening for requests.
+ * The port policy can be controlled by {@link gnuPortManager}.
+ *
+ * @throws IOException if the socket cannot be created on the given port due
+ * any reasons. The ORB may try to open the socket on another port, calling
+ * this method with the different parameter.
+ */
+ ServerSocket createServerSocket(int port)
+ throws IOException;
+
+ /**
+ * Create a client socket that should send a request to the remote side. When
+ * returned, the socket should be opened and ready to communicate.
+ *
+ * @param port the port, on that the socket should be openend. The port is
+ * usually part of the internet profile.
+ *
+ * @throws IOException if the socket cannot be created on the given port due
+ * any reasons. The ORB may try to open the socket on another port, calling
+ * this method with the different parameter.
+ */
+ Socket createClientSocket(String host, int port)
+ throws IOException;
+
+}
diff --git a/libjava/classpath/gnu/CORBA/interfaces/package.html b/libjava/classpath/gnu/CORBA/interfaces/package.html
new file mode 100644
index 00000000000..101475b2da1
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/interfaces/package.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html -
+ 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.CORBA.interfaces</title></head>
+
+<body>
+<p>This package contains Classpath specific interfaces that
+the user program may be forced to use in cases when no
+other, better solution of the problem is available. The
+existing classes and methods in this package should not
+be removed without the real need</p>
+</body>
+</html>
diff --git a/libjava/classpath/gnu/CORBA/aliasTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/AliasTypeCode.java
index 88466310142..3cb8ebfb393 100644
--- a/libjava/classpath/gnu/CORBA/aliasTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/AliasTypeCode.java
@@ -1,4 +1,4 @@
-/* aliasTypeCode.java --
+/* AliasTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
@@ -47,9 +48,14 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
-public class aliasTypeCode
- extends primitiveTypeCode
+public class AliasTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The typecode repository id.
*/
@@ -76,7 +82,7 @@ public class aliasTypeCode
*
* @param a_name the name of the newly created typecode.
*/
- public aliasTypeCode(TypeCode an_aliasFor, String an_id, String a_name)
+ public AliasTypeCode(TypeCode an_aliasFor, String an_id, String a_name)
{
super(TCKind.tk_alias);
aliasFor = an_aliasFor;
diff --git a/libjava/classpath/gnu/CORBA/primitiveArrayTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/ArrayTypeCode.java
index fc020bed788..bb798101a99 100644
--- a/libjava/classpath/gnu/CORBA/primitiveArrayTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/ArrayTypeCode.java
@@ -1,4 +1,4 @@
-/* primitiveArrayTypeCode.java --
+/* ArrayTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
@@ -46,9 +47,15 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
* A TypeCode for arrays.
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class primitiveArrayTypeCode
- extends primitiveTypeCode
+public class ArrayTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+
/**
* The array components.
*/
@@ -67,10 +74,10 @@ public class primitiveArrayTypeCode
*
* @param array_of the sequence member type.
*/
- public primitiveArrayTypeCode(TCKind array_of)
+ public ArrayTypeCode(TCKind array_of)
{
super(TCKind.tk_sequence);
- of = new primitiveTypeCode(array_of);
+ of = new PrimitiveTypeCode(array_of);
}
/**
@@ -81,7 +88,7 @@ public class primitiveArrayTypeCode
* sequence of array).
* @param array_of the sequence member type.
*/
- public primitiveArrayTypeCode(TCKind this_type, TypeCode array_of)
+ public ArrayTypeCode(TCKind this_type, TypeCode array_of)
{
super(this_type);
of = array_of;
diff --git a/libjava/classpath/gnu/CORBA/fixedTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/FixedTypeCode.java
index eb610417b29..c5fae63bd28 100644
--- a/libjava/classpath/gnu/CORBA/fixedTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/FixedTypeCode.java
@@ -1,4 +1,4 @@
-/* fixedTypeCode.java --
+/* FixedTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import java.math.BigDecimal;
@@ -48,9 +49,15 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
* A typecode for CORBA <code>fixed</code>
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class fixedTypeCode
- extends primitiveTypeCode
+public class FixedTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+
/**
* The number of the used digits.
*/
@@ -64,7 +71,7 @@ public class fixedTypeCode
/**
* Creates the instance of the fixed type code.
*/
- public fixedTypeCode()
+ public FixedTypeCode()
{
super(TCKind.tk_fixed);
}
@@ -73,7 +80,7 @@ public class fixedTypeCode
* Creates the instance of the fixed type code,
* setting the digits and scale by example.
*/
- public fixedTypeCode(BigDecimal example)
+ public FixedTypeCode(BigDecimal example)
{
super(TCKind.tk_fixed);
if (example != null)
diff --git a/libjava/classpath/gnu/CORBA/generalTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/GeneralTypeCode.java
index 3b7914878c3..0a907844ad9 100644
--- a/libjava/classpath/gnu/CORBA/generalTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/GeneralTypeCode.java
@@ -1,4 +1,4 @@
-/* generalTypeCode.java --
+/* GeneralTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,9 +36,9 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
-import gnu.CORBA.CDR.cdrBufOutput;
+import gnu.CORBA.CDR.BufferedCdrOutput;
import java.util.Arrays;
import java.util.BitSet;
@@ -56,9 +56,15 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class generalTypeCode
- extends primitiveTypeCode
+public class GeneralTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+
/**
* Indicates that the field value has not been previously set.
*/
@@ -87,21 +93,21 @@ public class generalTypeCode
/**
* Create a new instance, setting kind to the given kind.
- * @param kind
+ * @param a_kind the kind of the typecode being created.
*/
- public generalTypeCode(TCKind kind)
+ public GeneralTypeCode(TCKind a_kind)
{
- super(kind);
- if (!lengthAllowed.get(kind.value()))
+ super(a_kind);
+ if (!lengthAllowed.get(a_kind.value()))
len = UNSET;
}
/**
* Set this property.
*/
- public void setConcreteBase_type(TypeCode concrete_base_type)
+ public void setConcreteBase_type(TypeCode a_concrete_base_type)
{
- this.concrete_base_type = concrete_base_type;
+ this.concrete_base_type = a_concrete_base_type;
}
/**
@@ -115,9 +121,9 @@ public class generalTypeCode
/**
* Set this property.
*/
- public void setId(String id)
+ public void setId(String an_id)
{
- this.id = id;
+ this.id = an_id;
}
/**
@@ -132,9 +138,9 @@ public class generalTypeCode
/**
* Set this property.
*/
- public void setName(String name)
+ public void setName(String a_name)
{
- this.name = name;
+ this.name = a_name;
}
/**
@@ -179,8 +185,8 @@ public class generalTypeCode
if (kind() != other.kind())
return false;
- cdrBufOutput a = new cdrBufOutput(16);
- cdrBufOutput b = new cdrBufOutput(16);
+ BufferedCdrOutput a = new BufferedCdrOutput(16);
+ BufferedCdrOutput b = new BufferedCdrOutput(16);
a.write_TypeCode(this);
b.write_TypeCode(other);
diff --git a/libjava/classpath/gnu/CORBA/primitiveTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/PrimitiveTypeCode.java
index 4bf97d0230b..22d39a82c97 100644
--- a/libjava/classpath/gnu/CORBA/primitiveTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/PrimitiveTypeCode.java
@@ -1,4 +1,4 @@
-/* primitiveTypeCode.java --
+/* PrimitiveTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
Copyright (C) 2005 Free Software Foundation, Inc.
@@ -37,17 +37,17 @@ 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. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
import java.io.Serializable;
import org.omg.CORBA.Any;
-import org.omg.CORBA.IDLEntity;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.TypeCodePackage.Bounds;
+import org.omg.CORBA.portable.IDLEntity;
/**
* An information about a primitive CORBA data type
@@ -60,16 +60,21 @@ import org.omg.CORBA.TypeCodePackage.Bounds;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class primitiveTypeCode
+public class PrimitiveTypeCode
extends TypeCode
implements IDLEntity, Serializable
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The kind of this TypeCode.
*/
protected final TCKind kind;
- public primitiveTypeCode(TCKind a_kind)
+ public PrimitiveTypeCode(TCKind a_kind)
{
kind = a_kind;
}
diff --git a/libjava/classpath/gnu/CORBA/recordTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/RecordTypeCode.java
index 8f2ecde7d1a..89f3425465b 100644
--- a/libjava/classpath/gnu/CORBA/recordTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/RecordTypeCode.java
@@ -1,4 +1,4 @@
-/* recordTypeCode.java --
+/* RecordTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,9 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
+import gnu.CORBA.CorbaList;
import org.omg.CORBA.Any;
import org.omg.CORBA.StructMember;
@@ -53,9 +55,14 @@ import org.omg.CORBA.ValueMember;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class recordTypeCode
- extends generalTypeCode
+public class RecordTypeCode
+ extends GeneralTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The individual field of the record.
*/
@@ -85,16 +92,16 @@ public class recordTypeCode
/**
* The members of this data structure.
*/
- protected corbaArrayList members = new corbaArrayList();
+ protected CorbaList members = new CorbaList();
private TypeCode discriminator_type;
private int default_index = UNSET;
/**
* Creates the type code of the given kind.
*/
- public recordTypeCode(TCKind kind)
+ public RecordTypeCode(TCKind a_kind)
{
- super(kind);
+ super(a_kind);
}
/**
diff --git a/libjava/classpath/gnu/CORBA/recursiveTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/RecursiveTypeCode.java
index 6bc672e6e49..0e6ac375e50 100644
--- a/libjava/classpath/gnu/CORBA/recursiveTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/RecursiveTypeCode.java
@@ -1,4 +1,4 @@
-/* recursiveTypeCode.java --
+/* RecursiveTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
@@ -44,9 +45,14 @@ import org.omg.CORBA.TCKind;
* The typecode, serving as a placeholder in defining
* typecodes, containing recursion.
*/
-public class recursiveTypeCode
- extends primitiveTypeCode
+public class RecursiveTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
/**
* The id of the type for that this type serves as a
* placeholder.
@@ -60,7 +66,7 @@ public class recursiveTypeCode
* @param id the Id of the type for that this type serves as a
* placeholder.
*/
- public recursiveTypeCode(String an_id)
+ public RecursiveTypeCode(String an_id)
{
super(TCKind.tk_null);
the_id = an_id;
diff --git a/libjava/classpath/gnu/CORBA/stringTypeCode.java b/libjava/classpath/gnu/CORBA/typecodes/StringTypeCode.java
index 27aa119f30e..2d1689b4560 100644
--- a/libjava/classpath/gnu/CORBA/stringTypeCode.java
+++ b/libjava/classpath/gnu/CORBA/typecodes/StringTypeCode.java
@@ -1,4 +1,4 @@
-/* stringTypeCode.java --
+/* StringTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -36,7 +36,8 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.CORBA;
+package gnu.CORBA.typecodes;
+
import org.omg.CORBA.TCKind;
@@ -44,9 +45,14 @@ import org.omg.CORBA.TCKind;
* The typecode for string and wide string.
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
-public class stringTypeCode
- extends primitiveTypeCode
+public class StringTypeCode
+ extends PrimitiveTypeCode
{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
private int len = 0;
/**
@@ -55,7 +61,7 @@ public class stringTypeCode
* @param a_kind a kind of this typecode, normally
* either tk_string or tk_wstring.
*/
- public stringTypeCode(TCKind a_kind)
+ public StringTypeCode(TCKind a_kind)
{
super(a_kind);
}
diff --git a/libjava/classpath/gnu/CORBA/typecodes/package.html b/libjava/classpath/gnu/CORBA/typecodes/package.html
new file mode 100644
index 00000000000..891b3b96574
--- /dev/null
+++ b/libjava/classpath/gnu/CORBA/typecodes/package.html
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html
+ 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. -->
+
+<html>
+<head><title>GNU Classpath - gnu.CORBA.typecodes</title></head>
+
+<body>
+ Contains GNU Classpath specific typecode definitions.
+
+ @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+</body>
+</html>
+