Imported Classpath 0.18.

* sources.am, Makefile.in: Updated.
	* Makefile.am (nat_source_files): Removed natProxy.cc.
	* java/lang/reflect/natProxy.cc: Removed.
	* gnu/classpath/jdwp/VMFrame.java,
	gnu/classpath/jdwp/VMIdManager.java,
	gnu/classpath/jdwp/VMVirtualMachine.java,
	java/lang/reflect/VMProxy.java: New files.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC
	list.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/net/DefaultContentHandlerFactory.java (getContent):
	Remove ClasspathToolkit references.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/awt/xlib/XCanvasPeer.java: Add new peer methods.
	* gnu/awt/xlib/XFramePeer.java: Likewise.
	* gnu/awt/xlib/XGraphicsConfiguration.java: Likewise.

2005-09-23  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c.  Add
	classpath/native/jawt/jawt.c.
	* Makefile.in: Regenerate.
	* jawt.c: Remove file.
	* include/Makefile.am (tool_include__HEADERS): Remove jawt.h and
	jawt_md.h.  Add ../classpath/include/jawt.h and
	../classpath/include/jawt_md.h.
	* include/Makefile.in: Regenerate.
	* include/jawt.h: Regenerate.
	* include/jawt_md.h: Regenerate.

From-SVN: r104586
This commit is contained in:
Tom Tromey
2005-09-23 21:31:04 +00:00
parent 9b044d1951
commit 1ea63ef8be
544 changed files with 34724 additions and 14512 deletions
+152 -34
View File
@@ -46,6 +46,7 @@ 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.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
@@ -55,6 +56,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.lang.reflect.Method;
/**
* A specialised class for reading and writing the value types.
*
@@ -222,7 +225,7 @@ public abstract class Vio
throw new MARSHAL("Unable to instantiate the value type");
else
{
read_instance(input, ox, value_tag);
read_instance(input, ox, value_tag, null);
return (Serializable) ox;
}
}
@@ -285,7 +288,7 @@ public abstract class Vio
}
}
read_instance(input, ox, value_tag);
read_instance(input, ox, value_tag, null);
return (Serializable) ox;
}
catch (Exception ex)
@@ -301,17 +304,22 @@ public abstract class Vio
* an instance.
*
* @param input a stream to read from.
* @param value_instance an instance of the value.
*
* @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 Serializable read(InputStream input, Serializable value_instance)
public static Object read(InputStream input, Object value_instance,
Object helper
)
{
// 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.
try
{
int value_tag = input.read_long();
@@ -345,8 +353,9 @@ public abstract class Vio
}
}
read_instance(input, value_instance, value_tag);
return (Serializable) value_instance;
value_instance =
read_instance(input, value_instance, value_tag, helper);
return value_instance;
}
catch (Exception ex)
{
@@ -354,6 +363,23 @@ public abstract class Vio
}
}
/**
* 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.
*/
public static Serializable read(InputStream input, Object 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
@@ -361,12 +387,20 @@ public abstract class Vio
* passed ox parameter.
*
* @param input an input stream to read from.
* @param value a value type object, must be either Streamable or
* CustomMarshal.
*
* @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.
*
* @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.
*
* @return the value that was read.
*/
public static void read_instance(InputStream input, Object value,
int value_tag
)
private static Object read_instance(InputStream input, Object value,
int value_tag, Object helper
)
{
try
{
@@ -377,7 +411,7 @@ public abstract class Vio
// Read all chunks.
int chunk_size = input.read_long();
if (chunk_size <= 0)
if (chunk_size < 0)
throw new MARSHAL("Invalid first chunk size " + chunk_size);
byte[] r = new byte[ chunk_size ];
@@ -412,12 +446,29 @@ public abstract class Vio
// More than one chunk was present.
// Add the last chunk.
bout.write(r, 0, n);
input = new cdrBufInput(bout.toByteArray());
input = new noHeaderInput(bout.toByteArray());
}
else
{
// Only one chunk was present.
input = new cdrBufInput(r);
input = new noHeaderInput(r);
}
}
else
{
if (input instanceof cdrBufInput)
{
// Highly probable case.
input =
new noHeaderInput(((cdrBufInput) input).buffer.getBuffer());
}
else
{
cdrBufOutput bout = new cdrBufOutput();
int c;
while ((c = input.read()) >= 0)
bout.write((byte) c);
input = new noHeaderInput(bout.buffer.toByteArray());
}
}
}
@@ -447,12 +498,17 @@ public abstract class Vio
{
((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
// Stating the interfaces that the USER should use.
throw new MARSHAL("The " + value.getClass().getName() +
" must implement either StreamableValue or CustomValue."
);
" must implement either StreamableValue or CustomValue."
);
// The negative end of state marker is expected from OMG standard.
// If the chunking is used, this marker is already extracted.
@@ -462,6 +518,8 @@ public abstract class Vio
if (eor >= 0)
throw new MARSHAL("End of state marker has an invalid value " + eor);
}
return value;
}
/**
@@ -504,8 +562,8 @@ public abstract class Vio
* @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)
@@ -527,7 +585,35 @@ public abstract class Vio
if (value == null)
output.write_long(vt_NULL);
else
write_instance(output, value, id);
write_instance(output, value, id, null);
}
/**
* 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.
*/
public static void write(OutputStream output, Serializable value,
Object helper
)
{
if (value == null)
output.write_long(vt_NULL);
else
{
String id;
if (helper instanceof BoxedValueHelper)
id = ((BoxedValueHelper) helper).get_id();
else
id = "";
write_instance(output, value, id, helper);
}
}
/**
@@ -537,10 +623,12 @@ public abstract class Vio
* @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.
*/
private static void write_instance(OutputStream output, Serializable value,
String id
)
String id, Object helper
)
{
// This implementation always writes a single repository id.
// It never writes multiple repository ids and currently does not use
@@ -563,6 +651,11 @@ public abstract class Vio
output.write_long(value_tag);
output.write_string(id);
if (helper instanceof BoxedValueHelper)
{
((BoxedValueHelper) helper).write_value(outObj, value);
}
else
// User defince write method is present.
if (value instanceof CustomMarshal)
{
@@ -580,11 +673,36 @@ public abstract class Vio
((Streamable) value)._write(outObj);
}
else
{
// Try to find helper via class loader.
boolean ok = false;
try
{
Class helperClass = Class.forName(ObjectCreator.toHelperName(id));
// Stating the interfaces that the USER should use.
throw new MARSHAL("The " + value.getClass().getName() +
" must implement either StreamableValue or CustomValue."
);
// 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;
}
catch (Exception ex)
{
ok = false;
}
// Stating the interfaces that the USER should use.
if (!ok)
throw new MARSHAL("The " + value.getClass().getName() +
" must implement either StreamableValue" + " or CustomValue."
);
}
if (USE_CHUNKING)
{
@@ -611,8 +729,7 @@ public abstract class Vio
*
* @throws NO_IMPLEMENT, always.
*/
private static void incorrect_plug_in(Throwable ex)
throws NO_IMPLEMENT
static void incorrect_plug_in(Throwable ex) throws NO_IMPLEMENT
{
NO_IMPLEMENT no = new NO_IMPLEMENT("Incorrect CORBA plug-in");
no.initCause(ex);
@@ -629,10 +746,11 @@ public abstract class Vio
private static final void checkTag(int value_tag)
{
if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff) &&
value_tag != vt_NULL && value_tag != vt_INDIRECTION
)
value_tag != vt_NULL &&
value_tag != vt_INDIRECTION
)
throw new MARSHAL("Invalid value record, unsupported header tag: " +
value_tag
);
value_tag
);
}
}
@@ -1180,7 +1180,8 @@ public abstract class cdrInput
}
// Discard the null terminator and, if needed, the endian marker.
return new String(s, p, n - nt - p);
String r = new String(s, p, n - nt - p);
return r;
}
catch (EOFException ex)
{
+11 -1
View File
@@ -41,6 +41,7 @@ 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.TypeCodeHelper;
@@ -99,7 +100,7 @@ public abstract class cdrOutput
/**
* The GIOP version.
*/
protected Version giop = new Version(1, 0);
protected Version giop = new Version(1, 2);
/**
* The code set information.
@@ -327,6 +328,15 @@ public abstract class cdrOutput
IOR.write_null(this);
return;
}
else if (x instanceof gnuServantObject)
{
// 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);
return;
}
else if (x instanceof ObjectImpl)
{
Delegate d = ((ObjectImpl) x)._get_delegate();
@@ -60,11 +60,14 @@ public class Connected_objects
/**
* Create an initialised instance.
*/
cObject(org.omg.CORBA.Object _object, int _port, byte[] _key)
cObject(org.omg.CORBA.Object _object, int _port, byte[] _key,
java.lang.Object an_identity
)
{
object = _object;
port = _port;
key = _key;
identity = an_identity;
}
/**
@@ -82,6 +85,12 @@ public class Connected_objects
*/
public final byte[] key;
/**
* The shared serving identity (usually POA) or null if no such
* applicable.
*/
public final java.lang.Object identity;
public boolean equals(java.lang.Object other)
{
if (other instanceof cObject)
@@ -118,17 +127,23 @@ public class Connected_objects
*/
public cObject getKey(org.omg.CORBA.Object stored_object)
{
Map.Entry item;
Iterator iter = objects.entrySet().iterator();
cObject ref;
while (iter.hasNext())
synchronized (objects)
{
item = (Map.Entry) iter.next();
ref = (cObject) item.getValue();
if (stored_object.equals(ref.object))
return ref;
Map.Entry item;
Iterator iter = objects.entrySet().iterator();
cObject ref;
while (iter.hasNext())
{
item = (Map.Entry) iter.next();
ref = (cObject) item.getValue();
if (stored_object.equals(ref.object) ||
stored_object._is_equivalent(ref.object)
)
return ref;
}
}
return null;
}
@@ -144,7 +159,7 @@ public class Connected_objects
*/
public cObject add(org.omg.CORBA.Object object, int port)
{
return add(generateObjectKey(object), object, port);
return add(generateObjectKey(object), object, port, null);
}
/**
@@ -155,10 +170,15 @@ public class Connected_objects
* @param port the port, on that the ORB will be listening on the
* remote invocations.
*/
public cObject add(byte[] key, org.omg.CORBA.Object object, int port)
public cObject add(byte[] key, org.omg.CORBA.Object object, int port,
java.lang.Object identity
)
{
cObject rec = new cObject(object, port, key);
objects.put(key, rec);
cObject rec = new cObject(object, port, key, identity);
synchronized (objects)
{
objects.put(key, rec);
}
return rec;
}
@@ -171,12 +191,14 @@ public class Connected_objects
*/
public cObject get(byte[] key)
{
return (cObject) objects.get(key);
synchronized (objects)
{
return (cObject) objects.get(key);
}
}
/**
* Get the map entry set.
* @return
*/
public Set entrySet()
{
@@ -190,9 +212,12 @@ public class Connected_objects
*/
public void remove(org.omg.CORBA.Object object)
{
cObject ref = getKey(object);
if (ref != null)
objects.remove(ref.key);
synchronized (objects)
{
cObject ref = getKey(object);
if (ref != null)
objects.remove(ref.key);
}
}
/**
@@ -46,9 +46,8 @@ import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.Streamable;
/**
* The name-value pair holder. The {@link NameValuePair} has no standard
* holder defined, but it is needed to store the {@link NameValuePair} into
* {@link Any}.
* The name-value pair holder. The {@link NameValuePair} has no standard holder
* defined, but it is needed to store the {@link NameValuePair} into {@link Any}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
@@ -92,4 +91,4 @@ public class NameValuePairHolder
{
NameValuePairHelper.write(output, value);
}
}
}
@@ -145,14 +145,11 @@ public class ExceptionCreator
{
try
{
String holder = toHelperName(idl);
System.out.println("Helper " + holder);
Class holderClass = Class.forName(holder);
String helper = toHelperName(idl);
Class helperClass = Class.forName(helper);
Method read =
holderClass.getMethod("read",
helperClass.getMethod("read",
new Class[]
{
org.omg.CORBA.portable.InputStream.class
File diff suppressed because it is too large Load Diff
@@ -41,13 +41,13 @@ package gnu.CORBA.GIOP;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
/**
* The header of the standard reply.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class ReplyHeader
extends contextSupportingHeader
{
/**
* Reply status, if no exception occured.
@@ -65,9 +65,8 @@ public abstract class ReplyHeader
public static final int SYSTEM_EXCEPTION = 2;
/**
* Reply status, if the client ORB must re - send
* the request to another destination. The body
* contains IOR.
* Reply status, if the client ORB must re - send the request to another
* destination. The body contains IOR.
*/
public static final int LOCATION_FORWARD = 3;
@@ -83,16 +82,6 @@ public abstract class ReplyHeader
*/
public static final int NEEDS_ADDRESSING_MODE = 5;
/**
* Empty array, indicating that no service context is available.
*/
protected static final ServiceContext[] NO_CONTEXT = new ServiceContext[ 0 ];
/**
* The ORB service data.
*/
public ServiceContext[] service_context = NO_CONTEXT;
/**
* The status of this reply, holds one of the reply status constants.
*/
@@ -110,19 +99,19 @@ public abstract class ReplyHeader
{
switch (reply_status)
{
case NO_EXCEPTION :
case NO_EXCEPTION:
return "ok";
case USER_EXCEPTION :
case USER_EXCEPTION:
return "user exception";
case SYSTEM_EXCEPTION :
case SYSTEM_EXCEPTION:
return "system exception";
case LOCATION_FORWARD :
case LOCATION_FORWARD:
return "moved";
default :
default:
return null;
}
}
@@ -41,7 +41,6 @@ package gnu.CORBA.GIOP;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import org.omg.CORBA.portable.IDLEntity;
/**
@@ -50,13 +49,13 @@ import org.omg.CORBA.portable.IDLEntity;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class RequestHeader
extends contextSupportingHeader
implements IDLEntity
{
/**
* The currently free request id. This field is incremented
* each time the new request header is constructed. To facilitate
* error detection, the first free id is equal to 0x01234567
* (19088743).
* The currently free request id. This field is incremented each time the new
* request header is constructed. To facilitate error detection, the first
* free id is equal to 0x01234567 (19088743).
*/
private static int freeId = 0x01234567;
@@ -71,23 +70,17 @@ public abstract class RequestHeader
public byte[] object_key;
/**
* A value identifying the requesting principal.
* Initialised into a single zero byte.
* A value identifying the requesting principal. Initialised into a single
* zero byte.
*
* @deprecated by CORBA 2.2.
*/
public byte[] requesting_principal;
/**
* Contains the ORB service data being passed. Initialised as the
* zero size array by default.
*/
public ServiceContext[] service_context = new ServiceContext[ 0 ];
/**
* This is used to associate the reply message with the
* previous request message. Initialised each time by the
* different value, increasing form 1 to Integer.MAX_VALUE.
* This is used to associate the reply message with the previous request
* message. Initialised each time by the different value, increasing form 1 to
* Integer.MAX_VALUE.
*/
public int request_id = getNextId();
@@ -97,10 +90,9 @@ public abstract class RequestHeader
protected boolean response_expected = true;
/**
* Get next free request id. The value of the free request
* id starts from 0x02345678, it is incremented each time this
* function is called and is reset to 1 after reaching
* Integer.MAX_VALUE.
* Get next free request id. The value of the free request id starts from
* 0x02345678, it is incremented each time this function is called and is
* reset to 1 after reaching Integer.MAX_VALUE.
*
* @return the next free request id.
*/
@@ -126,15 +118,15 @@ public abstract class RequestHeader
public abstract boolean isResponseExpected();
/**
* Converts an byte array into hexadecimal string values.
* Used in various toString() methods.
* Converts an byte array into hexadecimal string values. Used in various
* toString() methods.
*/
public String bytes(byte[] array)
{
StringBuffer b = new StringBuffer();
for (int i = 0; i < array.length; i++)
{
b.append(Integer.toHexString(array [ i ] & 0xFF));
b.append(Integer.toHexString(array[i] & 0xFF));
b.append(" ");
}
return b.toString();
@@ -158,4 +150,5 @@ public abstract class RequestHeader
* @param out a stream to write into.
*/
public abstract void write(cdrOutput out);
}
@@ -41,7 +41,9 @@ package gnu.CORBA.GIOP;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.portable.IDLEntity;
/**
@@ -53,14 +55,38 @@ public class ServiceContext
implements IDLEntity
{
/**
* The context data.
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* 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
* the vendor specific context ids. The range 0-4095 is reserved for the
* future standard OMG contexts.
*/
public int context_id;
/**
* The context_data.
*/
public byte[] context_data;
/**
* The context id.
* Crete unitialised instance.
*/
public int context_id;
public ServiceContext()
{
}
/**
* Create from omg context.
*/
public ServiceContext(org.omg.IOP.ServiceContext from)
{
context_id = from.context_id;
context_data = from.context_data;
}
/**
* Read the context values from the stream.
@@ -73,13 +99,13 @@ public class ServiceContext
switch (id)
{
case cxCodeSet.ID :
case cxCodeSet.ID:
cxCodeSet codeset = new cxCodeSet();
codeset.readContext(istream);
return codeset;
default :
default:
ServiceContext ctx = new ServiceContext();
ctx.context_id = id;
@@ -94,9 +120,9 @@ public class ServiceContext
public static ServiceContext[] readSequence(cdrInput istream)
{
int size = istream.read_long();
ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[ size ];
ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[size];
for (int i = 0; i < value.length; i++)
value [ i ] = read(istream);
value[i] = read(istream);
return value;
}
@@ -118,7 +144,99 @@ public class ServiceContext
{
ostream.write_long(value.length);
for (int i = 0; i < value.length; i++)
value [ i ].write(ostream);
value[i].write(ostream);
}
/**
* Add context to the given array of contexts.
*/
public static void add(org.omg.IOP.ServiceContext[] cx,
org.omg.IOP.ServiceContext service_context, boolean replace)
{
int exists = -1;
for (int i = 0; i < cx.length; i++)
if (cx[i].context_id == service_context.context_id)
exists = i;
if (exists < 0)
{
// Add context.
org.omg.IOP.ServiceContext[] n = new org.omg.IOP.ServiceContext[cx.length + 1];
for (int i = 0; i < cx.length; i++)
n[i] = cx[i];
n[cx.length] = service_context;
}
else
{
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
+ service_context.context_id, 15,
CompletionStatus.COMPLETED_NO);
else
cx[exists] = service_context;
}
}
/**
* Add context to the given array of contexts.
*/
public static ServiceContext[] add(ServiceContext[] cx,
org.omg.IOP.ServiceContext service_context, boolean replace)
{
int exists = -1;
for (int i = 0; i < cx.length; i++)
if (cx[i].context_id == service_context.context_id)
exists = i;
if (exists < 0)
{
// Add context.
ServiceContext[] n = new ServiceContext[cx.length + 1];
for (int i = 0; i < cx.length; i++)
n[i] = cx[i];
n[cx.length] = new ServiceContext(service_context);
return n;
}
else
{
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
+ 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.
*/
public static org.omg.IOP.ServiceContext findContext(int ctx_name,
org.omg.IOP.ServiceContext[] cx)
{
for (int i = 0; i < cx.length; i++)
if (cx[i].context_id == ctx_name)
return cx[i];
throw new BAD_PARAM("No context with id " + ctx_name);
}
/**
* 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)
{
for (int i = 0; i < cx.length; i++)
if (cx[i].context_id == ctx_name)
return new org.omg.IOP.ServiceContext(ctx_name, cx[i].context_data);
throw new BAD_PARAM("No context with id " + ctx_name);
}
/**
@@ -126,6 +244,6 @@ public class ServiceContext
*/
public String toString()
{
return "ctx "+context_id+", size "+context_data.length;
return "ctx " + context_id + ", size " + context_data.length;
}
}
@@ -40,11 +40,11 @@ package gnu.CORBA.GIOP.v1_0;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import org.omg.CORBA.portable.IDLEntity;
import gnu.CORBA.GIOP.ServiceContext;
import gnu.CORBA.GIOP.cxCodeSet;
import org.omg.CORBA.portable.IDLEntity;
/**
* The GIOP 1.0 request message.
*
+258 -103
View File
@@ -47,22 +47,29 @@ import gnu.CORBA.GIOP.cxCodeSet;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.ULongSeqHelper;
import org.omg.IOP.TAG_INTERNET_IOP;
import org.omg.IOP.TAG_MULTIPLE_COMPONENTS;
import org.omg.IOP.TaggedComponent;
import org.omg.IOP.TaggedComponentHelper;
import org.omg.IOP.TaggedProfile;
import org.omg.IOP.TaggedProfileHelper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
/**
* The implementaton of the Interoperable Object Reference (IOR).
* IOR can be compared with the Internet address for a web page,
* it provides means to locate the CORBA service on the web.
* IOR contains the host address, port number, the object identifier
* (key) inside the server, the communication protocol version,
* supported charsets and so on.
* The implementaton of the Interoperable Object Reference (IOR). IOR can be
* compared with the Internet address for a web page, it provides means to
* locate the CORBA service on the web. IOR contains the host address, port
* number, the object identifier (key) inside the server, the communication
* protocol version, supported charsets and so on.
*
* Ths class provides method for encoding and
* decoding the IOR information from/to the stringified references,
* usually returned by {@link org.omg.CORBA.ORB#String object_to_string()}.
* Ths class provides method for encoding and decoding the IOR information
* from/to the stringified references, usually returned by
* {@link org.omg.CORBA.ORB#String object_to_string()}.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*
@@ -72,10 +79,22 @@ import java.io.IOException;
public class IOR
{
/**
* The code sets profile.
* The code sets tagged component, normally part of the Internet profile. This
* compone consists of the two componenets itself.
*/
public static class CodeSets_profile
{
public CodeSets_profile()
{
int[] supported = CharSets_OSF.getSupportedCharSets();
narrow.native_set = CharSets_OSF.NATIVE_CHARACTER;
narrow.conversion = supported;
wide.native_set = CharSets_OSF.NATIVE_WIDE_CHARACTER;
wide.conversion = supported;
}
/**
* The code set component.
*/
@@ -112,7 +131,7 @@ public class IOR
b.append(" conversion ");
for (int i = 0; i < conversion.length; i++)
{
b.append(name(conversion [ i ]));
b.append(name(conversion[i]));
b.append(' ');
}
}
@@ -131,8 +150,8 @@ public class IOR
private String name(int set)
{
return "0x" + Integer.toHexString(set) + " (" +
CharSets_OSF.getName(set) + ") ";
return "0x" + Integer.toHexString(set) + " ("
+ CharSets_OSF.getName(set) + ") ";
}
}
@@ -201,7 +220,7 @@ public class IOR
/**
* The internet profile.
*/
public static class Internet_profile
public class Internet_profile
{
/**
* The agreed tag for the Internet profile.
@@ -223,6 +242,18 @@ public class IOR
*/
public int port;
/**
* The code sets component in the internet profile of this IOR. This is not
* a separate profile.
*/
public CodeSets_profile CodeSets = new CodeSets_profile();
/**
* Reserved for all components of this profile, this array holds the
* components other than code set components.
*/
ArrayList components = new ArrayList();
/**
* Return the human readable representation.
*/
@@ -235,21 +266,62 @@ public class IOR
b.append(" (v");
b.append(version);
b.append(")");
if (components.size() > 0)
b.append(" " + components.size() + " extra components.");
return b.toString();
}
/**
* Write the internet profile (except the heading tag.
*/
public void write(cdrOutput out)
{
try
{
// Need to write the Internet profile into the separate
// stream as we must know the size in advance.
cdrOutput b = out.createEncapsulation();
version.write(b);
b.write_string(host);
b.write_ushort((short) (port & 0xFFFF));
// Write the object key.
b.write_long(key.length);
b.write(key);
// Number of the tagged components.
b.write_long(1 + components.size());
b.write_long(CodeSets_profile.TAG_CODE_SETS);
CodeSets.write(b);
TaggedComponent t;
for (int i = 0; i < components.size(); i++)
{
t = (TaggedComponent) components.get(i);
TaggedComponentHelper.write(b, t);
}
b.close();
}
catch (Exception e)
{
MARSHAL m = new MARSHAL("Unable to write Internet profile.");
m.initCause(e);
throw m;
}
}
}
/**
* The standard minor code, indicating that the string to object
* converstio has failed due non specific reasons.
* The standard minor code, indicating that the string to object converstio
* has failed due non specific reasons.
*/
public static final int FAILED = 10;
/**
* The code sets profile of this IOR.
*/
public CodeSets_profile CodeSets = new CodeSets_profile();
/**
* The internet profile of this IOR.
*/
@@ -260,46 +332,36 @@ public class IOR
*/
public String Id;
/**
* The additional tagged components, encapsulated in
* the byte arrays. They are only supported by the
* later versions, than currently implemented.
*/
public byte[][] extra;
/**
* The object key.
*/
public byte[] key;
/**
* True if the profile was encoded using the Big Endian or
* the encoding is not known.
* All tagged profiles of this IOR, except the separately defined Internet
* profile.
*/
ArrayList profiles = new ArrayList();
/**
* True if the profile was encoded using the Big Endian or the encoding is not
* known.
*
* false if it was encoded using the Little Endian.
*/
public boolean Big_Endian = true;
/**
* Create an empty instance, initialising the code sets to default
* values.
* Create an empty instance, initialising the code sets to default values.
*/
public IOR()
{
int[] supported = CharSets_OSF.getSupportedCharSets();
CodeSets.narrow.native_set = CharSets_OSF.NATIVE_CHARACTER;
CodeSets.narrow.conversion = supported;
CodeSets.wide.native_set = CharSets_OSF.NATIVE_WIDE_CHARACTER;
CodeSets.wide.conversion = supported;
}
/**
* Parse the provided stringifed reference.
*
* @param stringified_reference, in the form of
* IOR:nnnnnn.....
* @param stringified_reference, in the form of IOR:nnnnnn.....
*
* @return the parsed IOR
*
@@ -308,14 +370,13 @@ public class IOR
* TODO corballoc and other alternative formats.
*/
public static IOR parse(String stringified_reference)
throws BAD_PARAM
throws BAD_PARAM
{
try
{
if (!stringified_reference.startsWith("IOR:"))
throw new BAD_PARAM("The string refernce must start with IOR:",
FAILED, CompletionStatus.COMPLETED_NO
);
FAILED, CompletionStatus.COMPLETED_NO);
IOR r = new IOR();
@@ -340,8 +401,7 @@ public class IOR
{
ex.printStackTrace();
throw new BAD_PARAM(ex + " while parsing " + stringified_reference,
FAILED, CompletionStatus.COMPLETED_NO
);
FAILED, CompletionStatus.COMPLETED_NO);
}
}
@@ -352,7 +412,7 @@ public class IOR
* @throws IOException if the stream throws it.
*/
public void _read(cdrInput c)
throws IOException, BAD_PARAM
throws IOException, BAD_PARAM
{
int endian;
@@ -366,23 +426,21 @@ public class IOR
}
/**
* Read the IOR from the provided input stream, not reading
* the endian data at the beginning of the stream. The IOR is
* thansferred in this form in
* Read the IOR from the provided input stream, not reading the endian data at
* the beginning of the stream. The IOR is thansferred in this form in
* {@link write_Object(org.omg.CORBA.Object)}.
*
* If the stream contains a null value, the Id and Internet fields become
* equal to null. Otherwise Id contains some string (possibly
* empty).
* equal to null. Otherwise Id contains some string (possibly empty).
*
* Id is checked for null in cdrInput that then returns
* null instead of object.
* Id is checked for null in cdrInput 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)
throws IOException, BAD_PARAM
throws IOException, BAD_PARAM
{
Id = c.read_string();
@@ -407,9 +465,7 @@ public class IOR
Internet.host = profile.read_string();
Internet.port = profile.gnu_read_ushort();
int lk = profile.read_long();
key = new byte[ lk ];
profile.read(key);
key = profile.read_sequence();
// Read tagged components.
int n_components = 0;
@@ -425,7 +481,16 @@ public class IOR
if (ctag == CodeSets_profile.TAG_CODE_SETS)
{
CodeSets.read(profile);
Internet.CodeSets.read(profile);
}
else
{
// Construct a generic component for codesets
// profile.
TaggedComponent pc = new TaggedComponent();
pc.tag = ctag;
pc.component_data = profile.read_sequence();
Internet.components.add(pc);
}
}
}
@@ -434,12 +499,21 @@ public class IOR
ex.printStackTrace();
}
}
else
{
// Construct a generic profile.
TaggedProfile p = new TaggedProfile();
p.tag = tag;
p.profile_data = profile.buffer.getBuffer();
profiles.add(p);
}
}
}
/**
* Write this IOR record to the provided CDR stream.
* This procedure writes the zero (Big Endian) marker first.
* Write this IOR record to the provided CDR stream. This procedure writes the
* zero (Big Endian) marker first.
*/
public void _write(cdrOutput out)
{
@@ -451,8 +525,8 @@ public class IOR
/**
* Write a null value to the CDR output stream.
*
* The null value is written as defined in OMG specification
* (zero length string, followed by an empty set of profiles).
* 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)
{
@@ -464,47 +538,27 @@ 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.
* 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)
{
try
// Write repository id.
out.write_string(Id);
out.write_long(1 + profiles.size());
// Write the Internet profile.
out.write_long(Internet_profile.TAG_INTERNET_IOP);
Internet.write(out);
// Write other profiles.
TaggedProfile tp;
for (int i = 0; i < profiles.size(); i++)
{
// Write repository id.
out.write_string(Id);
// Always one profile.
out.write_long(1);
// It is the Internet profile.
out.write_long(Internet_profile.TAG_INTERNET_IOP);
// Need to write the Internet profile into the separate
// stream as we must know the size in advance.
cdrOutput b = out.createEncapsulation();
Internet.version.write(b);
b.write_string(Internet.host);
b.write_ushort((short) (Internet.port & 0xFFFF));
// Write the object key.
b.write_long(key.length);
b.write(key);
// One tagged component.
b.write_long(1);
b.write_long(CodeSets_profile.TAG_CODE_SETS);
CodeSets.write(b);
b.close();
}
catch (IOException ex)
{
Unexpected.error(ex);
tp = (TaggedProfile) profiles.get(i);
TaggedProfileHelper.write(out, tp);
}
}
@@ -525,11 +579,11 @@ public class IOR
for (int i = 0; i < key.length; i++)
{
b.append(Integer.toHexString(key [ i ] & 0xFF));
b.append(Integer.toHexString(key[i] & 0xFF));
}
b.append(" ");
b.append(CodeSets);
b.append(Internet.CodeSets);
return b.toString();
}
@@ -552,7 +606,7 @@ public class IOR
for (int i = 0; i < binary.length; i++)
{
s = Integer.toHexString(binary [ i ] & 0xFF);
s = Integer.toHexString(binary[i] & 0xFF);
if (s.length() == 1)
b.append('0');
b.append(s);
@@ -560,4 +614,105 @@ public class IOR
return b.toString();
}
/**
* Adds a service-specific component to the IOR profile. The specified
* component will be included in all profiles, present in the IOR.
*
* @param tagged_component a tagged component being added.
*/
public void add_ior_component(TaggedComponent tagged_component)
{
// Add to the Internet profile.
Internet.components.add(tagged_component);
// Add to others.
for (int i = 0; i < profiles.size(); i++)
{
TaggedProfile profile = (TaggedProfile) profiles.get(i);
addComponentTo(profile, tagged_component);
}
}
/**
* Adds a service-specific component to the IOR profile.
*
* @param tagged_component a tagged component being added.
*
* @param profile_id the IOR profile to that the component must be added. The
* 0 value ({@link org.omg.IOP.TAG_INTERNET_IOP#value}) adds to the Internet
* profile where host and port are stored by default.
*/
public void add_ior_component_to_profile(TaggedComponent tagged_component,
int profile_id)
{
if (profile_id == TAG_INTERNET_IOP.value)
// Add to the Internet profile
Internet.components.add(tagged_component);
else
{
// Add to others.
for (int i = 0; i < profiles.size(); i++)
{
TaggedProfile profile = (TaggedProfile) profiles.get(i);
if (profile.tag == profile_id)
addComponentTo(profile, tagged_component);
}
}
}
/**
* Add given component to the given profile that is NOT an Internet profile.
*
* @param profile the profile, where the component should be added.
* @param component the component to add.
*/
private static void addComponentTo(TaggedProfile profile,
TaggedComponent component)
{
if (profile.tag == TAG_MULTIPLE_COMPONENTS.value)
{
TaggedComponent[] present;
if (profile.profile_data.length > 0)
{
cdrBufInput in = new cdrBufInput(profile.profile_data);
present = new TaggedComponent[in.read_long()];
for (int i = 0; i < present.length; i++)
{
present[i] = TaggedComponentHelper.read(in);
}
}
else
present = new TaggedComponent[0];
cdrBufOutput out = new cdrBufOutput(profile.profile_data.length
+ component.component_data.length
+ 8);
// Write new amount of components.
out.write_long(present.length + 1);
// Write other components.
for (int i = 0; i < present.length; i++)
TaggedComponentHelper.write(out, present[i]);
// Write the passed component.
TaggedComponentHelper.write(out, component);
try
{
out.close();
}
catch (IOException e)
{
throw new Unexpected(e);
}
profile.profile_data = out.buffer.toByteArray();
}
else
// The future supported tagged profiles should be added here.
throw new BAD_PARAM("Unsupported profile type " + profile.tag);
}
}
+238 -83
View File
@@ -40,7 +40,9 @@ package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.Poa.activeObjectMap;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
import org.omg.CORBA.ExceptionList;
@@ -53,6 +55,7 @@ import org.omg.CORBA.portable.ApplicationException;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.RemarshalException;
import org.omg.PortableInterceptor.ForwardRequest;
import java.io.IOException;
@@ -67,9 +70,19 @@ import java.net.Socket;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class IOR_Delegate
extends Simple_delegate
public class IOR_Delegate extends Simple_delegate
{
/**
* 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.
*/
@@ -92,11 +105,10 @@ public class IOR_Delegate
* @return the created request.
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String operation, NVList parameters,
NamedValue returns
)
String operation, NVList parameters, NamedValue returns
)
{
gnuRequest request = new gnuRequest();
gnuRequest request = getRequestInstance(target);
request.setIor(getIor());
request.set_target(target);
@@ -122,12 +134,11 @@ public class IOR_Delegate
* @return the created request.
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String operation, NVList parameters,
NamedValue returns, ExceptionList exceptions,
ContextList ctx_list
)
String operation, NVList parameters, NamedValue returns,
ExceptionList exceptions, ContextList ctx_list
)
{
gnuRequest request = new gnuRequest();
gnuRequest request = getRequestInstance(target);
request.setIor(ior);
request.set_target(target);
@@ -144,97 +155,216 @@ public class IOR_Delegate
}
/**
* Invoke operation on the given object, writing parameters to the given
* output stream.
* Get the instance of request.
*/
protected gnuRequest getRequestInstance(org.omg.CORBA.Object target)
{
return new gnuRequest();
}
/**
* Invoke operation on the given object, als handling temproray and permanent
* redirections. The ReplyHeader.LOCATION_FORWARD will cause to resend the
* 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.
* @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).
* 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
throws ApplicationException, RemarshalException
{
streamRequest request = (streamRequest) output;
if (request.response_expected)
Forwardings:
while (true)
{
binaryReply response = request.request.submit();
// Read reply header.
ReplyHeader rh = response.header.create_reply_header();
cdrBufInput input = response.getStream();
input.setOrb(orb);
rh.read(input);
boolean moved_permanently = false;
switch (rh.reply_status)
try
{
case ReplyHeader.NO_EXCEPTION :
if (response.header.version.since_inclusive(1, 2))
input.align(8);
return input;
if (request.response_expected)
{
binaryReply response = request.request.submit();
case ReplyHeader.SYSTEM_EXCEPTION :
if (response.header.version.since_inclusive(1, 2))
input.align(8);
throw ObjectCreator.readSystemException(input);
// Read reply header.
ReplyHeader rh = response.header.create_reply_header();
cdrBufInput input = response.getStream();
input.setOrb(orb);
rh.read(input);
request.request.m_rph = rh;
case ReplyHeader.USER_EXCEPTION :
if (response.header.version.since_inclusive(1, 2))
input.align(8);
input.mark(2000);
boolean moved_permanently = false;
String uxId = input.read_string();
input.reset();
switch (rh.reply_status)
{
case ReplyHeader.NO_EXCEPTION :
if (request.request.m_interceptor != null)
request.request.m_interceptor.
receive_reply(request.request.m_info);
if (response.header.version.since_inclusive(1, 2))
input.align(8);
return input;
throw new ApplicationException(uxId, input);
case ReplyHeader.SYSTEM_EXCEPTION :
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
case ReplyHeader.LOCATION_FORWARD_PERM :
moved_permanently = true;
throw ObjectCreator.readSystemException(input);
case ReplyHeader.LOCATION_FORWARD :
if (response.header.version.since_inclusive(1, 2))
input.align(8);
case ReplyHeader.USER_EXCEPTION :
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
IOR forwarded = new IOR();
try
{
forwarded._read_no_endian(input);
}
catch (IOException ex)
{
MARSHAL t = new MARSHAL("Cant read forwarding info");
t.initCause(ex);
throw t;
}
throw new ApplicationException(request.
request.m_exception_id, input
);
request.request.setIor(forwarded);
case ReplyHeader.LOCATION_FORWARD_PERM :
moved_permanently = true;
// If the object has moved permanently, its IOR is replaced.
if (moved_permanently)
setIor(forwarded);
case ReplyHeader.LOCATION_FORWARD :
if (response.header.version.since_inclusive(1, 2))
input.align(8);
return invoke(target, request);
IOR forwarded = new IOR();
try
{
forwarded._read_no_endian(input);
}
catch (IOException ex)
{
MARSHAL t =
new MARSHAL("Cant read forwarding info", 5102,
CompletionStatus.COMPLETED_NO
);
t.initCause(ex);
throw t;
}
default :
throw new MARSHAL("Unknow reply status: " + rh.reply_status);
gnuRequest prev = request.request;
gnuRequest r = getRequestInstance(target);
r.m_interceptor = prev.m_interceptor;
r.m_slots = prev.m_slots;
r.m_args = prev.m_args;
r.m_context = prev.m_context;
r.m_context_list = prev.m_context_list;
r.m_environment = prev.m_environment;
r.m_exceptions = prev.m_exceptions;
r.m_operation = prev.m_operation;
r.m_parameter_buffer = prev.m_parameter_buffer;
r.m_parameter_buffer.request = r;
r.m_result = prev.m_result;
r.m_target = prev.m_target;
r.oneWay = prev.oneWay;
r.m_forward_ior = forwarded;
if (r.m_interceptor != null)
r.m_interceptor.receive_other(r.m_info);
r.setIor(forwarded);
IOR_contructed_object it =
new IOR_contructed_object(orb, forwarded);
r.m_target = it;
request.request = r;
IOR prev_ior = getIor();
setIor(forwarded);
try
{
return invoke(it, request);
}
finally
{
if (!moved_permanently)
setIor(prev_ior);
}
default :
throw new MARSHAL("Unknow reply status: " +
rh.reply_status, 8000 + rh.reply_status,
CompletionStatus.COMPLETED_NO
);
}
}
else
{
request.request.send_oneway();
return null;
}
}
catch (ForwardRequest forwarded)
{
ForwardRequest fw = forwarded;
Forwarding2:
while (true)
{
try
{
gnuRequest prev = request.request;
gnuRequest r = getRequestInstance(target);
r.m_interceptor = prev.m_interceptor;
r.m_args = prev.m_args;
r.m_context = prev.m_context;
r.m_context_list = prev.m_context_list;
r.m_environment = prev.m_environment;
r.m_exceptions = prev.m_exceptions;
r.m_operation = prev.m_operation;
r.m_parameter_buffer = prev.m_parameter_buffer;
r.m_parameter_buffer.request = r;
r.m_result = prev.m_result;
r.m_target = prev.m_target;
r.oneWay = prev.oneWay;
r.m_forwarding_target = fw.forward;
if (r.m_interceptor != null)
r.m_interceptor.receive_other(r.m_info);
r.m_target = fw.forward;
request.request = r;
break Forwarding2;
}
catch (ForwardRequest e)
{
forwarded = e;
}
}
}
}
else
{
request.request.send_oneway();
return null;
}
}
/**
* Show exception to interceptor.
*/
void showException(streamRequest request, cdrBufInput input)
throws ForwardRequest
{
input.mark(2048);
request.request.m_exception_id = input.read_string();
input.reset();
if (request.request.m_interceptor != null)
request.request.m_interceptor.receive_exception(request.request.m_info);
}
/**
@@ -247,7 +377,7 @@ public class IOR_Delegate
*/
public Request request(org.omg.CORBA.Object target, String operation)
{
gnuRequest request = new gnuRequest();
gnuRequest request = getRequestInstance(target);
request.setIor(ior);
request.set_target(target);
@@ -269,27 +399,28 @@ public class IOR_Delegate
* @return the stream where the method arguments should be written.
*/
public OutputStream request(org.omg.CORBA.Object target, String operation,
boolean response_expected
)
boolean response_expected
)
{
gnuRequest request = new gnuRequest();
gnuRequest request = getRequestInstance(target);
request.setIor(ior);
request.set_target(target);
request.setOperation(operation);
request.getParameterStream().response_expected = response_expected;
streamRequest out = request.getParameterStream();
out.response_expected = response_expected;
request.setORB(orb);
return request.getParameterStream();
return out;
}
/**
* If there is an opened cache socket to access this object, close
* that socket.
* If there is an opened cache socket to access this object, close that
* socket.
*
* @param target The target is not used, this delegate requires a
* single instance per object.
* @param target The target is not used, this delegate requires a single
* instance per object.
*/
public void release(org.omg.CORBA.Object target)
{
@@ -308,4 +439,28 @@ public class IOR_Delegate
// do nothing, then.
}
}
/**
* Reset the remote_ior flag, forcing to check if the object is local on the
* next getRequestInstance call.
*/
public void setIor(IOR an_ior)
{
super.setIor(an_ior);
remote_ior = false;
local_ior = null;
}
/**
* Checks if the ior is local so far it is easy.
*/
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);
}
}
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.CORBA.NamingService;
import gnu.CORBA.Functional_ORB;
import gnu.CORBA.IOR;
import org.omg.CosNaming.NamingContextExt;
@@ -47,15 +48,14 @@ import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
/**
* The server for the gnu classpath naming service. This is an executable
* class that must be started to launch the GNU Classpath CORBA
* transient naming service.
*
* The server for the gnu classpath naming service. This is an executable class
* that must be started to launch the GNU Classpath CORBA transient naming
* service.
*
* GNU Classpath currently works with this naming service and is also
* interoperable with the Sun Microsystems naming services from
* releases 1.3 and 1.4, both transient <i>tnameserv</i> and persistent
* <i>orbd</i>.
*
* interoperable with the Sun Microsystems naming services from releases 1.3 and
* 1.4, both transient <i>tnameserv</i> and persistent <i>orbd</i>.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class NamingServiceTransient
@@ -67,9 +67,9 @@ public class NamingServiceTransient
public static final int PORT = 900;
/**
* Get the object key for the naming service. The default
* key is the string "NameService" in ASCII.
*
* Get the object key for the naming service. The default key is the string
* "NameService" in ASCII.
*
* @return the byte array.
*/
public static byte[] getDefaultKey()
@@ -85,15 +85,14 @@ public class NamingServiceTransient
}
/**
* Start the naming service on the current host at the given port.
* The parameter -org.omg.CORBA.ORBInitialPort NNN or
* -ORBInitialPort NNN, if present, specifies the port, on that
* the service must be started. If this key is not specified,
* the service starts at the port 900.
*
* The parameter -ior FILE_NAME, if present, forces to store the ior string
* of this naming service to the specified file.
*
* Start the naming service on the current host at the given port. The
* parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
* present, specifies the port, on that the service must be started. If this
* key is not specified, the service starts at the port 900.
*
* The parameter -ior FILE_NAME, if present, forces to store the ior string of
* this naming service to the specified file.
*
* @param args the parameter string.
*/
public static void main(String[] args)
@@ -108,21 +107,24 @@ public class NamingServiceTransient
if (args.length > 1)
for (int i = 0; i < args.length - 1; i++)
{
if (args [ i ].endsWith("ORBInitialPort"))
port = Integer.parseInt(args [ i + 1 ]);
if (args[i].endsWith("ORBInitialPort"))
port = Integer.parseInt(args[i + 1]);
if (args [ i ].equals("-ior"))
iorf = args [ i + 1 ];
if (args[i].equals("-ior"))
iorf = args[i + 1];
}
Functional_ORB.setPort(port);
// Create the servant and register it with the ORB
NamingContextExt namer = new Ext(new TransientContext());
orb.connect(namer, getDefaultKey());
// Case with the key "NameService".
orb.connect(namer, "NameService".getBytes());
// Storing the IOR reference.
String ior = orb.object_to_string(namer);
IOR iorr = IOR.parse(ior);
if (iorf != null)
{
FileOutputStream f = new FileOutputStream(iorf);
@@ -131,22 +133,23 @@ public class NamingServiceTransient
p.close();
}
System.out.println("GNU Classpath, transient naming service. " +
"Copyright (C) 2005 Free Software Foundation\n" +
"This tool comes with ABSOLUTELY NO WARRANTY. " +
"This is free software, and you are\nwelcome to " +
"redistribute it under conditions, defined in " +
"GNU Classpath license.\n\n" + ior
);
System.out.println("GNU Classpath transient naming service "
+ "started at " + iorr.Internet.host + ":" + iorr.Internet.port
+ " key 'NameService'.\n\n"
+ "Copyright (C) 2005 Free Software Foundation\n"
+ "This tool comes with ABSOLUTELY NO WARRANTY. "
+ "This is free software, and you are\nwelcome to "
+ "redistribute it under conditions, defined in "
+ "GNU Classpath license.\n\n" + ior);
new Thread()
{
public void run()
{
public void run()
{
// Wait for invocations from clients.
orb.run();
}
}.start();
// Wait for invocations from clients.
orb.run();
}
}.start();
}
catch (Exception e)
{
@@ -154,7 +157,8 @@ public class NamingServiceTransient
e.printStackTrace(System.out);
}
// Restore the default value for allocating ports for the subsequent objects.
// Restore the default value for allocating ports for the subsequent
// objects.
Functional_ORB.setPort(Functional_ORB.DEFAULT_INITIAL_PORT);
}
}
+147 -48
View File
@@ -1,4 +1,4 @@
/* ExceptionCreator.java --
/* ObjectCreator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,10 +38,15 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufOutput;
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.InputStream;
@@ -51,9 +56,8 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/**
* 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.
* 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)
*/
@@ -70,20 +74,17 @@ public class ObjectCreator
public static final String JAVA_PREFIX = "org.omg.";
/**
* The prefix for classes that are placed instide the
* gnu.CORBA namespace.
* The prefix for classes that are placed instide the gnu.CORBA namespace.
*/
public static final String CLASSPATH_PREFIX = "gnu.CORBA.";
/**
* 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.
* 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.
* @return instantiated object instance or null if no such available.
*/
public static java.lang.Object createObject(String idl, String suffix)
{
@@ -109,16 +110,15 @@ public class ObjectCreator
/**
* 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 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
)
CompletionStatus completed
)
{
try
{
@@ -127,20 +127,18 @@ public class ObjectCreator
Constructor constructor =
exClass.getConstructor(new Class[]
{
String.class, int.class,
CompletionStatus.class
}
);
{
String.class, int.class, CompletionStatus.class
}
);
Object exception =
constructor.newInstance(new Object[]
{
" Remote exception " + idl + ", minor " +
minor + ", " + completed + ".",
new Integer(minor), completed
}
);
{
" Remote exception " + idl + ", minor " + minor + ", " +
completed + ".", new Integer(minor), completed
}
);
return (SystemException) exception;
}
@@ -153,9 +151,10 @@ public class ObjectCreator
/**
* 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).
* @return the exception that has been stored in the stream (IDL name, minor
* code and completion status).
*/
public static SystemException readSystemException(InputStream input)
{
@@ -170,8 +169,8 @@ 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
* 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.
@@ -189,11 +188,8 @@ public class ObjectCreator
Method read =
helperClass.getMethod("read",
new Class[]
{
org.omg.CORBA.portable.InputStream.class
}
);
new Class[] { org.omg.CORBA.portable.InputStream.class }
);
return (UserException) read.invoke(null, new Object[] { input });
}
@@ -236,8 +232,8 @@ public class ObjectCreator
* @param ex an exception to write.
*/
public static void writeSystemException(OutputStream output,
SystemException ex
)
SystemException ex
)
{
String exIDL = toIDL(ex.getClass().getName());
output.write_string(exIDL);
@@ -266,14 +262,14 @@ 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.
* 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.
* 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.
*/
@@ -301,10 +297,10 @@ public class ObjectCreator
}
/**
* Converts the given IDL name to class name, tries to load the
* matching class 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.
* Converts the given IDL name to class name, tries to load the matching class
* 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.
*
@@ -341,8 +337,111 @@ public class ObjectCreator
cn = OMG_PREFIX + cn.substring(JAVA_PREFIX.length()).replace('.', '/');
else if (cn.startsWith(CLASSPATH_PREFIX))
cn =
OMG_PREFIX + cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
OMG_PREFIX +
cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
return "IDL:" + cn + ":1.0";
}
/**
* 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)
{
try
{
String helperClassName = object.getClass().getName() + "Helper";
Class helperClass = Class.forName(helperClassName);
Method insert =
helperClass.getMethod("insert",
new Class[] { Any.class, object.getClass() }
);
insert.invoke(null, new Object[] { into, object });
return true;
}
catch (Exception exc)
{
// Failed due some reason.
return false;
}
}
/**
* Insert the system exception into the given Any.
*/
public static boolean insertSysException(Any into, SystemException exception)
{
try
{
cdrBufOutput output = new cdrBufOutput();
String m_exception_id = toIDL(exception.getClass().getName());
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);
into.insert_Streamable(h);
recordTypeCode r = new recordTypeCode(TCKind.tk_except);
r.setId(m_exception_id);
r.setName(name);
into.type(r);
return true;
}
catch (Exception ex)
{
ex.printStackTrace();
return false;
}
}
/**
* Get the type name from the IDL string.
*/
public static String getDefaultName(String idl)
{
int f1 = idl.lastIndexOf("/");
int p1 = (f1 < 0) ? 0 : f1;
int p2 = idl.indexOf(":", p1);
if (p2 < 0)
p2 = idl.length();
String name = idl.substring(f1 + 1, p2);
return name;
}
/**
* Insert this exception into the given Any. On failure, insert the UNKNOWN
* exception.
*/
public static void insertException(Any into, Throwable exception)
{
boolean ok = false;
if (exception instanceof SystemException)
ok = insertSysException(into, (SystemException) exception);
else if (exception instanceof UserException)
ok = insertWithHelper(into, exception);
if (!ok)
ok = insertSysException(into, new UNKNOWN());
if (!ok)
throw new InternalError("Exception wrapping broken");
}
}
+98 -37
View File
@@ -58,6 +58,9 @@ import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.UnionMember;
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.ServerRequestInterceptorOperations;
import java.applet.Applet;
@@ -66,36 +69,62 @@ import java.util.Properties;
/**
* This class implements so-called Singleton ORB, a highly restricted version
* that cannot communicate over network. This ORB is provided
* for the potentially malicious applets with heavy security restrictions.
* It, however, supports some basic features that might be needed even
* when the network access is not granted.
* that cannot communicate over network. This ORB is provided for the
* potentially malicious applets with heavy security restrictions. It, however,
* supports some basic features that might be needed even when the network
* access is not granted.
*
* This ORB can only create typecodes,
* {@link Any}, {@link ContextList}, {@link NVList} and
* {@link org.omg.CORBA.portable.OutputStream} that writes to an
* internal buffer.
* This ORB can only create typecodes, {@link Any}, {@link ContextList},
* {@link NVList} and {@link org.omg.CORBA.portable.OutputStream} that writes to
* an internal buffer.
*
* All other methods throw the {@link NO_IMPLEMENT} exception.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class Restricted_ORB
extends org.omg.CORBA_2_3.ORB
public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
{
/**
* The singleton instance of this ORB.
*/
public static final ORB Singleton = new Restricted_ORB();
/**
* The cumulated listener for all IOR interceptors. Interceptors are used by
* {@link gnu.CORBA.Poa.ORB_1_4}.
*/
public IORInterceptorOperations iIor;
/**
* The cumulated listener for all server request interceptors. Interceptors
* are used by {@link gnu.CORBA.Poa.ORB_1_4}.
*/
public ServerRequestInterceptorOperations iServer;
/**
* The cumulated listener for all client request interceptros. Interceptors
* are used by {@link gnu.CORBA.Poa.ORB_1_4}.
*/
public ClientRequestInterceptorOperations iClient;
/**
* The required size of the interceptor slot array.
*/
public int icSlotSize = 0;
/**
* The value factories.
*/
protected Hashtable factories = new Hashtable();
/**
* Create a new instance of the RestrictedORB. This is used
* in derived classes only.
* The policy factories.
*/
protected Hashtable policyFactories = new Hashtable();
/**
* Create a new instance of the RestrictedORB. This is used in derived classes
* only.
*/
protected Restricted_ORB()
{
@@ -159,8 +188,8 @@ public class Restricted_ORB
/** {@inheritDoc} */
public TypeCode create_exception_tc(String id, String name,
StructMember[] members
)
StructMember[] members
)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_except);
r.setId(id);
@@ -224,8 +253,8 @@ public class Restricted_ORB
/** {@inheritDoc} */
public TypeCode create_struct_tc(String id, String name,
StructMember[] members
)
StructMember[] members
)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_struct);
r.setId(id);
@@ -240,13 +269,15 @@ public class Restricted_ORB
}
/** {@inheritDoc} */
public TypeCode create_union_tc(String id, String name, TypeCode type,
UnionMember[] members
)
public TypeCode create_union_tc(String id, String name,
TypeCode discriminator_type, UnionMember[] members
)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_union);
r.setId(id);
r.setName(name);
r.setDiscriminator_type(discriminator_type);
r.setDefaultIndex(0);
for (int i = 0; i < members.length; i++)
{
@@ -274,8 +305,8 @@ public class Restricted_ORB
catch (BadKind ex)
{
throw new BAD_PARAM("This is not a primitive type code: " +
tcKind.value()
);
tcKind.value()
);
}
}
@@ -304,13 +335,13 @@ public class Restricted_ORB
/**
* This method is not allowed for a RestrictedORB.
*
* @throws InvalidName never in this class, but it is thrown
* in the derived classes.
* @throws InvalidName never in this class, but it is thrown in the derived
* classes.
*
* @throws NO_IMPLEMENT, always.
*/
public org.omg.CORBA.Object resolve_initial_references(String name)
throws InvalidName
throws InvalidName
{
no();
throw new InternalError();
@@ -366,8 +397,8 @@ public class Restricted_ORB
}
/**
* Throws an exception, stating that the given method is not supported
* by the Restricted ORB.
* Throws an exception, stating that the given method is not supported by the
* Restricted ORB.
*/
private final void no()
{
@@ -381,8 +412,7 @@ public class Restricted_ORB
*
* @throws NO_IMPLEMENT, always.
*/
public Request get_next_response()
throws org.omg.CORBA.WrongTransaction
public Request get_next_response() throws org.omg.CORBA.WrongTransaction
{
no();
throw new InternalError();
@@ -423,8 +453,8 @@ public class Restricted_ORB
* Register the value factory under the given repository id.
*/
public ValueFactory register_value_factory(String repository_id,
ValueFactory factory
)
ValueFactory factory
)
{
factories.put(repository_id, factory);
return factory;
@@ -440,9 +470,9 @@ public class Restricted_ORB
/**
* Look for the value factory for the value, having the given repository id.
* The implementation checks for the registered value factories first.
* If none found, it tries to load and instantiate the class, mathing the
* given naming convention. If this faild, null is returned.
* The implementation checks for the registered value factories first. If none
* found, it tries to load and instantiate the class, mathing the given naming
* convention. If this faild, null is returned.
*
* @param repository_id a repository id.
*
@@ -452,12 +482,43 @@ public class Restricted_ORB
{
ValueFactory f = (ValueFactory) factories.get(repository_id);
if (f != null)
return f;
{
return f;
}
f = (ValueFactory) ObjectCreator.createObject(repository_id, "DefaultFactory");
f = (ValueFactory) ObjectCreator.createObject(repository_id,
"DefaultFactory"
);
if (f != null)
factories.put(repository_id, f);
{
factories.put(repository_id, f);
}
return f;
}
/**
* Destroy the interceptors, if they are present.
*/
public void destroy()
{
if (iIor != null)
{
iIor.destroy();
iIor = null;
}
if (iServer != null)
{
iServer.destroy();
iServer = null;
}
if (iClient != null)
{
iClient.destroy();
iClient = null;
}
super.destroy();
}
}
@@ -53,10 +53,11 @@ import org.omg.CORBA.portable.ResponseHandler;
import org.omg.CORBA.portable.Streamable;
/**
* This class exists to handle obsolete invocation style using
* ServerRequest.
*
* @deprecated The method {@link ObjectImpl#_invoke} is much faster.
* This class supports invocation using ServerRequest. When possible,
* it is better to use the {@link ObjectImpl#_invoke} rather than
* working via ServerRequest. However since 1.4 the ServerRequest is
* involved into POA machinery making this type of call is sometimes
* inavoidable.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
@@ -86,13 +87,13 @@ public class ServiceRequestAdapter
}
/**
* The old style invocation using the currently deprecated server
* request class.
* Make an invocation.
*
* @param request a server request, containg the invocation information.
* @param target the invocation target
* @param result the result holder with the set suitable streamable to read
* the result or null for void.
* @param result the result holder with the set suitable streamable.
* Using this parameter only increase the performance. It can be
* null if the return type is void or unknown.
*/
public static void invoke(ServerRequest request, InvokeHandler target,
Streamable result
@@ -133,12 +134,20 @@ public class ServiceRequestAdapter
else
{
if (result != null)
{
result._read(in);
gnuAny r = new gnuAny();
r.insert_Streamable(result);
request.set_result(r);
};
{
// Use the holder for the return value, if provided.
result._read(in);
gnuAny r = new gnuAny();
r.insert_Streamable(result);
request.set_result(r);
}
else
{
// Use the universal holder otherwise.
gnuAny r = new gnuAny();
r.insert_Streamable(new streamReadyHolder(in));
}
// Unpack the arguments
for (int i = 0; i < args.count(); i++)
@@ -195,13 +195,40 @@ public class Simple_delegate
}
/**
* Only returns true if the objects are equal ('==').
* Returns true if the objects are the same of 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
)
{
return target == other;
if (target == other)
return true;
if ((target instanceof ObjectImpl) && other instanceof ObjectImpl)
{
try
{
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;
}
if (a != null && b != null)
{
return a.equals(b);
}
}
catch (Exception ex)
{
// Unable to get one of the delegates.
return false;
}
}
return false;
}
/**
@@ -246,4 +273,4 @@ public class Simple_delegate
{
throw new InternalError();
}
}
}
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.CORBA;
import java.net.Socket;
import java.net.SocketException;
import java.util.HashMap;
@@ -70,16 +71,18 @@ public class SocketRepository
/**
* Get a socket.
*
*
* @param key a socket key.
*
* @return an opened socket for reuse, null if no such
* available or it is closed.
*
* @return an opened socket for reuse, null if no such available or it is
* closed.
*/
public static Socket get_socket(Object key)
{
Socket s = (Socket) sockets.get(key);
if (s != null && s.isClosed())
if (s == null)
return null;
else if (s.isClosed())
{
sockets.remove(key);
return null;
@@ -87,6 +90,15 @@ public class SocketRepository
else
{
sockets.remove(key);
try
{
// Set one minute time out that will be changed later.
s.setSoTimeout(60*1000);
}
catch (SocketException e)
{
s = null;
}
return s;
}
}
@@ -41,6 +41,7 @@ package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.GIOP.RequestHeader;
import gnu.CORBA.GIOP.cxCodeSet;
import org.omg.CORBA.ORB;
@@ -48,31 +49,33 @@ import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ResponseHandler;
/**
* Provides the CDR output streams for writing the response to the given
* buffer.
* Provides the CDR output streams for writing the response to the given buffer.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
class bufferedResponseHandler
public class bufferedResponseHandler
implements ResponseHandler
{
/**
* The message header.
* This field is used to compute the size and alignments.
* The message header. This field is used to compute the size and alignments.
* It is, however, never directly written to the buffer stream.
*/
final MessageHeader message_header;
public final MessageHeader message_header;
/**
* The associated orb.
*/
final ORB orb;
public final ORB orb;
/**
* The reply header. This field is used to compute the size and alignments.
* It is, however, never directly written to the buffer stream.
* The reply header.
*/
final ReplyHeader reply_header;
public final ReplyHeader reply_header;
/**
* The request header.
*/
public final RequestHeader request_header;
/**
* True if the stream was obtained by invoking {@link #createExceptionReply()},
@@ -86,28 +89,27 @@ class bufferedResponseHandler
private cdrBufOutput buffer;
/**
* Create a new buffered response handler that uses the given message
* headers. The headers are used to compute sizes and check the versions.
* They are not written into a stream inside this class.
* Create a new buffered response handler that uses the given message headers.
* The headers are used to compute sizes and check the versions. They are not
* written into a stream inside this class.
*
* @param m_header a message header.
* @param r_header a reply header.
*/
bufferedResponseHandler(ORB an_orb, MessageHeader m_header,
ReplyHeader r_header
)
ReplyHeader r_header, RequestHeader rq_header)
{
message_header = m_header;
reply_header = r_header;
request_header = rq_header;
orb = an_orb;
prepareStream();
}
/**
* Get an output stream for providing details about the exception.
* Before returning the stream, the handler automatically writes
* the message header and the reply about exception header,
* but not the message header.
* Get an output stream for providing details about the exception. Before
* returning the stream, the handler automatically writes the message header
* and the reply about exception header, but not the message header.
*
* @return the stream to write exception details into.
*/
@@ -121,8 +123,8 @@ class bufferedResponseHandler
/**
* Get an output stream for writing a regular reply (not an exception).
*
* Before returning the stream, the handler automatically writes
* the regular reply header, but not the message header.
* Before returning the stream, the handler automatically writes the regular
* reply header, but not the message header.
*
* @return the output stream for writing a regular reply.
*/
@@ -135,27 +137,26 @@ class bufferedResponseHandler
}
/**
* Get the buffer, normally containing the written reply.
* The reply includes the reply header (or the exception header)
* but does not include the message header.
* Get the buffer, normally containing the written reply. The reply includes
* the reply header (or the exception header) but does not include the message
* header.
*
* The stream buffer can also be empty if no data have been written
* into streams, returned by {@link #createReply()} or
* The stream buffer can also be empty if no data have been written into
* streams, returned by {@link #createReply()} or
* {@link #createExceptionReply()}.
*
* @return the CDR output stream, containing the written output.
*/
cdrBufOutput getBuffer()
public cdrBufOutput getBuffer()
{
return buffer;
}
/**
* True if the stream was obtained by invoking
* {@link #createExceptionReply()}, false otherwise
* (usually no-exception reply).
* True if the stream was obtained by invoking {@link #createExceptionReply()},
* false otherwise (usually no-exception reply).
*/
boolean isExceptionReply()
public boolean isExceptionReply()
{
return exceptionReply;
}
@@ -167,21 +168,22 @@ class bufferedResponseHandler
{
buffer = new cdrBufOutput();
buffer.setOrb(orb);
buffer.setOffset(message_header.getHeaderSize());
// Get the position after the reply header would be written.
reply_header.write(buffer);
int new_offset = message_header.getHeaderSize() + buffer.buffer.size();
buffer.buffer.reset();
buffer.setOffset(new_offset);
if (message_header.version.since_inclusive(1, 2))
buffer.align(8);
buffer.setVersion(message_header.version);
buffer.setCodeSet(cxCodeSet.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.
if (message_header.version.until_inclusive(1, 1))
{
buffer.setOffset(message_header.getHeaderSize());
// Get the position after the reply header would be written.
reply_header.write(buffer);
int new_offset = message_header.getHeaderSize() + buffer.buffer.size();
buffer.buffer.reset();
buffer.setOffset(new_offset);
}
}
}
@@ -109,16 +109,12 @@ public class fixedTypeCode
return number.unscaledValue().abs().toString().length();
}
public boolean equals(Object other)
/**
* Compare with other type code for equality.
*/
public boolean equal(TypeCode other)
{
if (other == this)
{
return true;
}
if (!(other instanceof TypeCode))
{
return false;
}
if (other == this) return true;
try
{
TypeCode that = (TypeCode) other;
+74 -20
View File
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.Vio;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.cdrBufOutput;
@@ -63,6 +64,7 @@ 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;
@@ -499,20 +501,33 @@ public class gnuAny
}
/** {@inheritDoc} */
public void insert_Value(Serializable x, TypeCode typecode)
public void insert_Value(Serializable x, TypeCode c_typecode)
{
type(typecode);
insert_Value(x);
if (typecode != null && typecode.kind() == TCKind.tk_value_box)
{
has = new gnuValueHolder(x, typecode);
}
else
{
type(typecode);
insert_Value(x);
}
}
/** {@inheritDoc} */
public void insert_Value(Serializable x)
{
resetTypes();
if (has instanceof ValueBaseHolder)
((ValueBaseHolder) has).value = x;
if (typecode != null && typecode.kind() == TCKind.tk_value_box)
{
has = new gnuValueHolder(x, typecode);
}
else
has = new ValueBaseHolder(x);
{
if (has instanceof ValueBaseHolder)
((ValueBaseHolder) has).value = x;
else
has = new ValueBaseHolder(x);
}
}
/**
@@ -748,15 +763,38 @@ public class gnuAny
}
}
type(a_type);
has._read(input);
if (!(has instanceof universalHolder) &&
(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);
vField.set(has, content);
}
else
has._read(input);
}
catch (BadKind ex)
catch (Exception ex)
{
throw new MARSHAL("Bad kind: " + ex.getMessage());
}
catch (IOException ex)
{
throw new MARSHAL("IO exception: " + ex.getMessage());
MARSHAL m = new MARSHAL();
m.initCause(ex);
throw m;
}
}
@@ -790,6 +828,12 @@ public class gnuAny
{
if (has != null)
has._write(output);
else
// These kinds support null.
if (xKind == TCKind._tk_null || xKind == TCKind._tk_objref ||
xKind == TCKind._tk_value || xKind == TCKind._tk_value_box
)
output.write_long(0);
}
/**
@@ -806,16 +850,26 @@ public class gnuAny
if (xKind >= 0)
{
if (xKind != kind)
throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
" when stored " + typeNamer.nameIt(xKind)
);
if (!(
xKind == TCKind._tk_alias &&
has._type().kind().value() == kind
)
)
throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
" when stored " + typeNamer.nameIt(xKind)
);
}
else
{
if (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
)
)
throw new BAD_OPERATION("Extracting " + typeNamer.nameIt(kind) +
" stored " + typeNamer.nameIt(type())
);
}
}
@@ -38,12 +38,12 @@ exception statement from your version. */
package gnu.CORBA;
import org.omg.CORBA.*;
import org.omg.CORBA.LocalObject;
import org.omg.IOP.*;
import org.omg.CORBA.ORB;
import org.omg.IOP.Codec;
import org.omg.IOP.CodecFactory;
import org.omg.IOP.CodecFactoryPackage.UnknownEncoding;
import org.omg.IOP.ENCODING_CDR_ENCAPS;
import org.omg.IOP.Encoding;
/**
@@ -52,9 +52,7 @@ import org.omg.IOP.Encoding;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuCodecFactory
extends LocalObject
implements CodecFactory
public class gnuCodecFactory extends LocalObject implements CodecFactory
{
/**
* The associated ORB.
@@ -78,18 +76,15 @@ public class gnuCodecFactory
*
* @throws UnknownEncoding if the encoding is not a ENCODING_CDR_ENCAPS.
*/
public Codec create_codec(Encoding for_encoding)
throws UnknownEncoding
public Codec create_codec(Encoding for_encoding) throws UnknownEncoding
{
if (for_encoding.format != ENCODING_CDR_ENCAPS.value)
throw new UnknownEncoding("Only ENCODING_CDR_ENCAPS is " +
"supported by this factory."
);
"supported by this factory."
);
return new cdrEncapsCodec(orb,
new Version(for_encoding.major_version,
for_encoding.minor_version
)
);
new Version(for_encoding.major_version, for_encoding.minor_version)
);
}
}
File diff suppressed because it is too large Load Diff
+59 -58
View File
@@ -68,74 +68,76 @@ import org.omg.CORBA.UShortSeqHolder;
import org.omg.CORBA.WCharSeqHolder;
import org.omg.CORBA.WStringSeqHolder;
import org.omg.CORBA.portable.Streamable;
import org.omg.CORBA.ObjectHolder;
/**
* Creates the suitable holder for storing the value of the given
* type.
* Creates the suitable holder for storing the value of the given final_type.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class holderFactory
{
/**
* The array, sufficiently large to use any {@link TCKind}._tk* constant
* as an index.
* The array, sufficiently large to use any {@link TCKind}._tk* constant as
* an index.
*/
private static final Class[] holders;
private static final Class[] seqHolders;
static
{
holders = new Class[ 32 ];
holders [ TCKind._tk_Principal ] = PrincipalHolder.class;
holders [ TCKind._tk_TypeCode ] = TypeCodeHolder.class;
holders [ TCKind._tk_any ] = AnyHolder.class;
holders [ TCKind._tk_boolean ] = BooleanHolder.class;
holders [ TCKind._tk_char ] = CharHolder.class;
holders [ TCKind._tk_double ] = DoubleHolder.class;
holders [ TCKind._tk_float ] = FloatHolder.class;
holders [ TCKind._tk_fixed ] = FixedHolder.class;
holders [ TCKind._tk_long ] = IntHolder.class;
holders [ TCKind._tk_longdouble ] = DoubleHolder.class;
holders [ TCKind._tk_longlong ] = LongHolder.class;
holders [ TCKind._tk_octet ] = OctetHolder.class;
holders [ TCKind._tk_short ] = ShortHolder.class;
holders [ TCKind._tk_string ] = StringHolder.class;
holders [ TCKind._tk_ulong ] = IntHolder.class;
holders [ TCKind._tk_ulonglong ] = LongHolder.class;
holders [ TCKind._tk_ushort ] = ShortHolder.class;
holders [ TCKind._tk_wchar ] = WCharHolder.class;
holders [ TCKind._tk_wstring ] = WStringHolder.class;
{
holders = new Class[32];
holders[TCKind._tk_Principal] = PrincipalHolder.class;
holders[TCKind._tk_TypeCode] = TypeCodeHolder.class;
holders[TCKind._tk_any] = AnyHolder.class;
holders[TCKind._tk_boolean] = BooleanHolder.class;
holders[TCKind._tk_char] = CharHolder.class;
holders[TCKind._tk_double] = DoubleHolder.class;
holders[TCKind._tk_float] = FloatHolder.class;
holders[TCKind._tk_fixed] = FixedHolder.class;
holders[TCKind._tk_long] = IntHolder.class;
holders[TCKind._tk_longdouble] = DoubleHolder.class;
holders[TCKind._tk_longlong] = LongHolder.class;
holders[TCKind._tk_octet] = OctetHolder.class;
holders[TCKind._tk_short] = ShortHolder.class;
holders[TCKind._tk_string] = StringHolder.class;
holders[TCKind._tk_ulong] = IntHolder.class;
holders[TCKind._tk_ulonglong] = LongHolder.class;
holders[TCKind._tk_ushort] = ShortHolder.class;
holders[TCKind._tk_wchar] = WCharHolder.class;
holders[TCKind._tk_wstring] = WStringHolder.class;
holders[TCKind._tk_objref] = ObjectHolder.class;
seqHolders = new Class[ 32 ];
seqHolders = new Class[32];
seqHolders [ TCKind._tk_ulonglong ] = ULongLongSeqHolder.class;
seqHolders [ TCKind._tk_short ] = ShortSeqHolder.class;
seqHolders [ TCKind._tk_octet ] = OctetSeqHolder.class;
seqHolders [ TCKind._tk_any ] = AnySeqHolder.class;
seqHolders [ TCKind._tk_long ] = LongSeqHolder.class;
seqHolders [ TCKind._tk_longlong ] = LongLongSeqHolder.class;
seqHolders [ TCKind._tk_float ] = FloatSeqHolder.class;
seqHolders [ TCKind._tk_double ] = DoubleSeqHolder.class;
seqHolders [ TCKind._tk_char ] = CharSeqHolder.class;
seqHolders [ TCKind._tk_boolean ] = BooleanSeqHolder.class;
seqHolders [ TCKind._tk_wchar ] = WCharSeqHolder.class;
seqHolders [ TCKind._tk_ushort ] = UShortSeqHolder.class;
seqHolders [ TCKind._tk_ulong ] = ULongSeqHolder.class;
seqHolders [ TCKind._tk_string ] = StringSeqHolder.class;
seqHolders [ TCKind._tk_wstring ] = WStringSeqHolder.class;
}
seqHolders[TCKind._tk_ulonglong] = ULongLongSeqHolder.class;
seqHolders[TCKind._tk_short] = ShortSeqHolder.class;
seqHolders[TCKind._tk_octet] = OctetSeqHolder.class;
seqHolders[TCKind._tk_any] = AnySeqHolder.class;
seqHolders[TCKind._tk_long] = LongSeqHolder.class;
seqHolders[TCKind._tk_longlong] = LongLongSeqHolder.class;
seqHolders[TCKind._tk_float] = FloatSeqHolder.class;
seqHolders[TCKind._tk_double] = DoubleSeqHolder.class;
seqHolders[TCKind._tk_char] = CharSeqHolder.class;
seqHolders[TCKind._tk_boolean] = BooleanSeqHolder.class;
seqHolders[TCKind._tk_wchar] = WCharSeqHolder.class;
seqHolders[TCKind._tk_ushort] = UShortSeqHolder.class;
seqHolders[TCKind._tk_ulong] = ULongSeqHolder.class;
seqHolders[TCKind._tk_string] = StringSeqHolder.class;
seqHolders[TCKind._tk_wstring] = WStringSeqHolder.class;
}
/**
* Create a holder for storing the value of the given built-in type.
* This function returns the defined holders for the built-in primitive
* types and they sequences.
* Create a holder for storing the value of the given built-in final_type. This
* function returns the defined holders for the built-in primitive types and
* they sequences.
*
* @param t the typecode
*
* @return an instance of the corresponding built-in holder of null
* if no such is defined for this type. The holder is created with a
* parameterless constructor.
* @return an instance of the corresponding built-in holder of null if no such
* is defined for this final_type. The holder is created with a parameterless
* constructor.
*/
public static Streamable createHolder(TypeCode t)
{
@@ -145,24 +147,23 @@ public class holderFactory
int componentKind;
Streamable holder = null;
Streamable component;
if (kind < holders.length && holders [ kind ] != null)
holder = (Streamable) holders [ kind ].newInstance();
if (kind < holders.length && holders[kind] != null)
holder = (Streamable) holders[kind].newInstance();
if (holder != null)
return holder;
switch (kind)
{
case TCKind._tk_sequence :
componentKind = t.content_type().kind().value();
if (componentKind < seqHolders.length)
return (Streamable) seqHolders [ componentKind ].newInstance();
break;
case TCKind._tk_sequence:
componentKind = t.content_type().kind().value();
if (componentKind < seqHolders.length)
return (Streamable) seqHolders[componentKind].newInstance();
break;
default :
break;
default:
break;
}
}
catch (Exception ex)
@@ -1,39 +1,39 @@
/* primitiveArrayTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
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 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.
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.
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.
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. */
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;
@@ -61,10 +61,10 @@ public class primitiveArrayTypeCode
private int length;
/**
* Create a primitive array type code, defining the sequence
* {@link TCKind.tk_sequence)} with
* Create a primitive array type code, defining the sequence
* {@link TCKind.tk_sequence)} with
* the given member type.
*
*
* @param array_of the sequence member type.
*/
public primitiveArrayTypeCode(TCKind array_of)
@@ -76,7 +76,7 @@ public class primitiveArrayTypeCode
/**
* Create a primitive array type code, defining the array, sequence
* or other type with the given member type.
*
*
* @param this_type the type of this type (normally either
* sequence of array).
* @param array_of the sequence member type.
@@ -1,40 +1,41 @@
/* primitiveTypeCode.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
Copyright (C) 2005 Free Software Foundation, Inc.
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.
This file is part of GNU Classpath.
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.
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.
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.
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.
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.
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.
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. */
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;
+11 -2
View File
@@ -83,7 +83,7 @@ public class typeNamer
new primitiveTypeCode(TCKind.tk_any),
new primitiveTypeCode(TCKind.tk_TypeCode),
new primitiveTypeCode(TCKind.tk_Principal),
new primitiveTypeCode(TCKind.tk_objref),
new recordTypeCode(TCKind.tk_objref),
new primitiveTypeCode(TCKind.tk_struct),
new primitiveTypeCode(TCKind.tk_union),
new primitiveTypeCode(TCKind.tk_enum),
@@ -104,6 +104,15 @@ public class typeNamer
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 ];
object.setId("");
object.setName("Object");
}
/**
* Get the primitive type code.
*
@@ -168,4 +177,4 @@ public class typeNamer
return "type of kind '" + type.kind().value() + "'";
}
}
}
}
@@ -60,7 +60,7 @@ import java.io.IOException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
class universalHolder
public class universalHolder
implements Streamable
{
/**
@@ -71,7 +71,7 @@ class universalHolder
/**
* Create the universal holder that uses the given buffer to store the data.
*/
universalHolder(cdrBufOutput buffer)
public universalHolder(cdrBufOutput buffer)
{
value = buffer;
}
@@ -154,4 +154,21 @@ class universalHolder
{
return value.create_input_stream();
}
}
/**
* Clone.
*/
public universalHolder Clone()
{
try
{
cdrBufOutput nb = new cdrBufOutput(value.buffer.size());
value.buffer.writeTo(nb);
return new universalHolder(nb);
}
catch (IOException ex)
{
throw new Unexpected(ex);
}
}
}