Imported GNU Classpath 0.19 + gcj-import-20051115.

* sources.am: Regenerated.
       * Makefile.in: Likewise.
       * scripts/makemake.tcl: Use glob -nocomplain.

From-SVN: r107049
This commit is contained in:
Mark Wielaard
2005-11-15 23:20:01 +00:00
parent 02e549bfaa
commit 8f523f3a10
1241 changed files with 97711 additions and 25284 deletions
@@ -1,4 +1,4 @@
/* cdrOutput.java --
/* AbstractCdrOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,27 +39,28 @@ exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.BigDecimalHelper;
import gnu.CORBA.GIOP.CharSets_OSF;
import gnu.CORBA.GIOP.cxCodeSet;
import gnu.CORBA.Poa.gnuServantObject;
import gnu.CORBA.IOR;
import gnu.CORBA.Simple_delegate;
import gnu.CORBA.IorProvider;
import gnu.CORBA.Minor;
import gnu.CORBA.TypeCodeHelper;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
import gnu.CORBA.primitiveTypeCode;
import gnu.CORBA.GIOP.CharSets_OSF;
import gnu.CORBA.GIOP.CodeSetServiceContext;
import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.Context;
import org.omg.CORBA.ContextList;
import org.omg.CORBA.DataInputStream;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.UserException;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.OutputStream;
@@ -68,7 +69,6 @@ import org.omg.CORBA.portable.Streamable;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Serializable;
import java.math.BigDecimal;
/**
@@ -79,18 +79,27 @@ import java.math.BigDecimal;
* The same class also implements the {@link DataInputStream},
* providing support for writing the value type objects
* in a user defined way.
*
* TODO This class uses 16 bits per Unicode character only, as it was until
* jdk 1.4 inclusive.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class cdrOutput
public abstract class AbstractCdrOutput
extends org.omg.CORBA_2_3.portable.OutputStream
implements org.omg.CORBA.DataOutputStream
{
/**
* The runtime, associated with this stream. This field is only used when
* reading and writing value types and filled-in in gnu.CORBA.CDR.Vio.
*/
public transient gnuRuntime runtime;
/**
* This instance is used to convert primitive data types into the
* byte sequences.
*/
protected abstractDataOutputStream b;
protected AbstractDataOutput b;
/**
* The associated orb, if any.
@@ -105,7 +114,7 @@ public abstract class cdrOutput
/**
* The code set information.
*/
protected cxCodeSet codeset;
protected CodeSetServiceContext codeset;
/**
* The name of the currently used narrow charset.
@@ -148,19 +157,19 @@ public abstract class cdrOutput
*
* @param writeTo a stream to write CORBA output to.
*/
public cdrOutput(java.io.OutputStream writeTo)
public AbstractCdrOutput(java.io.OutputStream writeTo)
{
setOutputStream(writeTo);
setCodeSet(cxCodeSet.STANDARD);
setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
* Creates the stream, requiring the subsequent call
* of {@link #setOutputStream(java.io.OutputStream)}.
*/
public cdrOutput()
public AbstractCdrOutput()
{
setCodeSet(cxCodeSet.STANDARD);
setCodeSet(CodeSetServiceContext.STANDARD);
}
/**
@@ -168,11 +177,22 @@ public abstract class cdrOutput
* stream is different from 0.
*/
public abstract void setOffset(int an_offset);
/**
* Clone all important settings to another stream.
*/
public void cloneSettings(AbstractCdrOutput stream)
{
stream.setBigEndian(!little_endian);
stream.setCodeSet(getCodeSet());
stream.setVersion(giop);
stream.setOrb(orb);
}
/**
* Set the current code set context.
*/
public void setCodeSet(cxCodeSet a_codeset)
public void setCodeSet(CodeSetServiceContext a_codeset)
{
this.codeset = a_codeset;
narrow_charset = CharSets_OSF.getName(codeset.char_data);
@@ -185,7 +205,7 @@ public abstract class cdrOutput
/**
* Get the current code set context.
*/
public cxCodeSet getCodeSet()
public CodeSetServiceContext getCodeSet()
{
return codeset;
}
@@ -255,9 +275,9 @@ public abstract class cdrOutput
*
* @return the encapsulated stream.
*/
public cdrOutput createEncapsulation()
public AbstractCdrOutput createEncapsulation()
{
return new encapsulatedOutput(this, !little_endian);
return new EncapsulationStream(this, !little_endian);
}
/**
@@ -313,53 +333,56 @@ public abstract class cdrOutput
}
/**
* Read the CORBA object. The object is written
* form of the plain (not a string-encoded) IOR profile without the
* heading endian indicator. The responsible method for reading such
* data is {@link IOR.write_no_endian}.
*
* The null value is written as defined in OMG specification
* (zero length string, followed by an empty set of profiles).
*/
* Read the CORBA object. The object is written form of the plain (not a
* string-encoded) IOR profile without the heading endian indicator. The
* responsible method for reading such data is {@link IOR.write_no_endian}.
*
* The null value is written as defined in OMG specification (zero length
* string, followed by an empty set of profiles).
*/
public void write_Object(org.omg.CORBA.Object x)
{
if (x == null)
ORB w_orb = orb;
if (x instanceof IorProvider)
{
IOR.write_null(this);
((IorProvider) x).getIor()._write_no_endian(this);
return;
}
else if (x instanceof gnuServantObject)
else if (x == null)
{
// The ORB may be different if several ORBs coexist
// in the same machine.
gnuServantObject g = (gnuServantObject) x;
IOR ior = g.orb.getLocalIor(x);
ior._write_no_endian(this);
IOR.write_null(this);
return;
}
else if (x instanceof ObjectImpl)
{
Delegate d = ((ObjectImpl) x)._get_delegate();
if (d instanceof Simple_delegate)
if (d instanceof IorProvider)
{
Simple_delegate ido = (Simple_delegate) d;
ido.getIor()._write_no_endian(this);
((IorProvider) d).getIor()._write_no_endian(this);
return;
}
else
{
ORB d_orb = d.orb(x);
if (d_orb != null)
w_orb = d_orb;
}
}
// Either this is not an ObjectImpl or it has the
// unexpected delegate. Try to convert via ORBs
// object_to_string().
if (orb != null)
if (w_orb != null)
{
IOR ior = IOR.parse(orb.object_to_string(x));
IOR ior = IOR.parse(w_orb.object_to_string(x));
ior._write_no_endian(this);
return;
}
else
throw new BAD_OPERATION("Please set the ORB for this stream.");
throw new BAD_OPERATION(
"Please set the ORB for this stream, cannot write "
+ x.getClass().getName());
}
/**
@@ -399,7 +422,7 @@ public abstract class cdrOutput
}
else
{
primitiveTypeCode p = new primitiveTypeCode(TCKind.tk_null);
PrimitiveTypeCode p = new PrimitiveTypeCode(TCKind.tk_null);
write_TypeCode(p);
}
}
@@ -726,6 +749,7 @@ public abstract class cdrOutput
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.CDR;
t.initCause(ex);
throw t;
}
@@ -737,7 +761,7 @@ public abstract class cdrOutput
* representing the stream buffer length (the number of
* bytes being subsequently written).
*/
public void write_sequence(cdrBufOutput from)
public void write_sequence(BufferedCdrOutput from)
{
try
{
@@ -747,6 +771,7 @@ public abstract class cdrOutput
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.CDR;
t.initCause(ex);
throw t;
}
@@ -874,28 +899,41 @@ public abstract class cdrOutput
}
/**
* Writes the character as two byte short integer (Unicode value),
* high byte first. Writes in Big Endian, but never writes the
* endian indicator.
*
* The character is always written using the native UTF-16BE charset
* because its size under arbitrary encoding is not evident.
* Writes the character as two byte short integer (Unicode value), high byte
* first. Writes in Big Endian, but never writes the endian indicator.
*
* The character is always written using the native UTF-16BE charset because
* its size under arbitrary encoding is not evident.
*/
public void write_wchar(char x)
{
try
{
if (giop.until_inclusive(1, 1))
align(2);
{
align(2);
if (wide_native)
b.writeShort(x);
if (wide_native)
b.writeShort(x);
else
{
OutputStreamWriter ow = new OutputStreamWriter(
(OutputStream) b, wide_charset);
ow.write(x);
ow.flush();
}
}
else if (wide_native)
{
b.writeByte(2);
b.writeChar(x);
}
else
{
OutputStreamWriter ow =
new OutputStreamWriter((OutputStream) b, wide_charset);
ow.write(x);
ow.flush();
String encoded = new String(new char[] { x });
byte[] bytes = encoded.getBytes(wide_charset);
b.write(bytes.length + 2);
b.write(bytes);
}
}
catch (IOException ex)
@@ -906,13 +944,13 @@ public abstract class cdrOutput
/**
* Write the array of wide chars.
*
*
* @param chars the array of wide chars
* @param offset offset
* @param length length
*
* The char array is always written using the native UTF-16BE charset
* because the character size under arbitrary encoding is not evident.
*
* The char array is always written using the native UTF-16BE charset because
* the character size under arbitrary encoding is not evident.
*/
public void write_wchar_array(char[] chars, int offset, int length)
{
@@ -998,12 +1036,12 @@ public abstract class cdrOutput
/** {@inheritDoc} */
public void write_Abstract(java.lang.Object value)
{
write_Abstract(value);
write_abstract_interface(value);
}
/** {@inheritDoc} */
public void write_Value(Serializable value)
{
write_Value(value);
write_value(value);
}
}
@@ -1,4 +1,4 @@
/* abstractDataInputStream.java --
/* AbstractDataInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.io.IOException;
* @author Warren Levy (warrenl@cygnus.com)
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface abstractDataInputStream
public interface AbstractDataInput
{
/**
* This method reads bytes from the underlying stream into the specified
@@ -1,4 +1,4 @@
/* abstractDataOutputStream.java --
/* AbstractDataOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -50,7 +50,7 @@ import java.io.IOException;
* @author Warren Levy (warrenl@cygnus.com)
* @author Aaron M. Renn (arenn@urbanophile.com)
*/
public interface abstractDataOutputStream
public interface AbstractDataOutput
{
/**
* This method flushes any unwritten bytes to the underlying stream.
@@ -1,4 +1,4 @@
/* aligningInputStream.java --
/* AligningInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -48,7 +48,7 @@ import org.omg.CORBA.BAD_PARAM;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class aligningInputStream
public class AligningInput
extends ByteArrayInputStream
{
/**
@@ -61,23 +61,11 @@ public class aligningInputStream
*
* @param a_buffer a buffer to read from.
*/
public aligningInputStream(byte[] a_buffer)
public AligningInput(byte[] a_buffer)
{
super(a_buffer);
}
/**
* Create a stream, reading from the given buffer region.
*
* @param a_buffer a buffer to read from.
* @param offset the offset of the region.
* @param length thr length of the region.
*/
public aligningInputStream(byte[] a_buffer, int offset, int length)
{
super(a_buffer, offset, length);
}
/**
* Set the alignment offset, if the index of the first byte in the
* stream is different from 0.
@@ -119,4 +107,25 @@ public class aligningInputStream
{
return buf;
}
/**
* Get the current position in the buffer.
*
* @return The position in the buffer, taking offset into consideration.
*/
public int getPosition()
{
return pos + offset;
}
/**
* Jump to the given position, taking offset into consideration.
*/
public void seek(int position)
{
if (position < offset || position > (count+offset))
throw new ArrayIndexOutOfBoundsException(position
+ " is out of valid ["+offset+".." + (count+offset) + "[ range");
pos = position - offset;
}
}
@@ -1,4 +1,4 @@
/* aligningOutputStream.java --
/* AligningOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.CORBA.CDR;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.omg.CORBA.BAD_PARAM;
@@ -49,7 +48,7 @@ import org.omg.CORBA.BAD_PARAM;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class aligningOutputStream
public class AligningOutput
extends ByteArrayOutputStream
{
/**
@@ -60,14 +59,14 @@ public class aligningOutputStream
/**
* Create a stream with the default intial buffer size.
*/
public aligningOutputStream()
public AligningOutput()
{
}
/**
* Create a stream with the given intial buffer size.
*/
public aligningOutputStream(int initial_size)
public AligningOutput(int initial_size)
{
super(initial_size);
}
@@ -118,4 +117,32 @@ public class aligningOutputStream
write(0);
}
}
/**
* Get the current position in the buffer.
*
* @return The position in the buffer, taking offset into consideration.
*/
public int getPosition()
{
return size()+offset;
}
/**
* Seek to the given position (not in use).
*/
public void seek(int position)
{
count = position - offset;
}
/**
* Get the buffer without copying it. Use with care.
*/
public byte[] getBuffer()
{
return buf;
}
}
@@ -0,0 +1,254 @@
/* ArrayValueHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.ObjectCreator;
import org.omg.CORBA.BooleanSeqHelper;
import org.omg.CORBA.CharSeqHelper;
import org.omg.CORBA.DoubleSeqHelper;
import org.omg.CORBA.FloatSeqHelper;
import org.omg.CORBA.LongLongSeqHelper;
import org.omg.CORBA.LongSeqHelper;
import org.omg.CORBA.OctetSeqHelper;
import org.omg.CORBA.ShortSeqHelper;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import java.io.Serializable;
import java.lang.reflect.Array;
import java.rmi.Remote;
import javax.rmi.CORBA.Util;
import javax.rmi.CORBA.ValueHandler;
/**
* Writes arrays as a boxed value types. A single instance is used to write a
* single array. This class is only used with RMI/IIOP, to handle array boxed
* values.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
class ArrayValueHelper
implements BoxedValueHelper
{
/**
* The value handler (one for all instances).
*/
static ValueHandler handler = Util.createValueHandler();
/**
* A class of the array being written.
*/
Class arrayClass;
/**
* The array component class.
*/
Class component;
/**
* The array component repository Id.
*/
String componentId;
/**
* If true, the array members are written as objects rather than as values.
* True for Remotes and CORBA objects.
*/
boolean written_as_object()
{
return org.omg.CORBA.Object.class.isAssignableFrom(component)
|| Remote.class.isAssignableFrom(component);
}
/**
* Creates the instance of the helper to write this specific array class.
*/
ArrayValueHelper(Class an_arrayClass)
{
arrayClass = an_arrayClass;
}
/**
* Get the array repository Id that will be the RMI repository id.
*/
public String get_id()
{
return ObjectCreator.getRepositoryId(arrayClass);
}
/**
* Read the array from the input stream.
*/
public Serializable read_value(InputStream input)
{
if (input instanceof HeadlessInput)
{
((HeadlessInput) input).subsequentCalls = true;
}
component = arrayClass.getComponentType();
if (component.equals(byte.class))
return OctetSeqHelper.read(input);
else if (component.equals(String.class))
{
// String array is optimized because this may be frequent.
String[] s = new String[input.read_long()];
for (int i = 0; i < s.length; i++)
s[i] = (String) Vio.read(input, Vio.m_StringValueHelper);
return s;
}
else if (component.equals(int.class))
return LongSeqHelper.read(input);
else if (component.equals(long.class))
return LongLongSeqHelper.read(input);
else if (component.equals(double.class))
return DoubleSeqHelper.read(input);
else if (component.equals(float.class))
return FloatSeqHelper.read(input);
else if (component.equals(boolean.class))
return BooleanSeqHelper.read(input);
else if (component.equals(short.class))
return ShortSeqHelper.read(input);
else if (component.equals(char.class))
return CharSeqHelper.read(input);
else
{
// Read others, use reflection.
int n = input.read_long();
gnuValueStream s = null;
Serializable array = (Serializable) Array.newInstance(component, n);
if (written_as_object())
for (int i = 0; i < n; i++)
{
gnuRuntime g;
int position;
if (input instanceof gnuValueStream)
{
s = (gnuValueStream) input;
g = s.getRunTime();
position = s.getPosition();
}
else
{
g = null;
position = -1;
}
if (input instanceof HeadlessInput)
((HeadlessInput) input).subsequentCalls = true;
Object o = handler.readValue(input, position, component, null, g);
Array.set(array, i, o);
}
else
for (int i = 0; i < n; i++)
Array.set(array, i, Vio.read(input, component));
return array;
}
}
/**
* Write the array to the input stream.
*/
public void write_value(OutputStream output, Serializable value)
{
if (output instanceof gnuValueStream)
{
gnuRuntime r = ((gnuValueStream) output).getRunTime();
if (r != null)
r.target = null;
}
if (value instanceof byte[])
OctetSeqHelper.write(output, (byte[]) value);
else if (value instanceof String[])
{
String[] s = (String[]) value;
output.write_long(s.length);
for (int i = 0; i < s.length; i++)
Vio.write(output, s[i], Vio.m_StringValueHelper);
}
else if (value instanceof int[])
LongSeqHelper.write(output, (int[]) value);
else if (value instanceof long[])
LongLongSeqHelper.write(output, (long[]) value);
else if (value instanceof double[])
DoubleSeqHelper.write(output, (double[]) value);
else if (value instanceof float[])
FloatSeqHelper.write(output, (float[]) value);
else if (value instanceof boolean[])
BooleanSeqHelper.write(output, (boolean[]) value);
else if (value instanceof short[])
ShortSeqHelper.write(output, (short[]) value);
else if (value instanceof char[])
CharSeqHelper.write(output, (char[]) value);
else
{
// Write others, use reflection.
component = arrayClass.getComponentType();
int n = Array.getLength(value);
output.write_long(n);
if (written_as_object())
for (int i = 0; i < n; i++)
{
Object o = Array.get(value, i);
if (o == null)
output.write_Object(null);
else
// CORBA objects have another notation.
handler.writeValue(output, (Serializable) o);
}
else
{
for (int i = 0; i < n; i++)
Vio.write(output, (Serializable) Array.get(value, i),
component);
}
}
}
}
@@ -49,7 +49,7 @@ import java.io.InputStream;
*/
public class BigEndianInputStream
extends DataInputStream
implements abstractDataInputStream
implements AbstractDataInput
{
/**
* Delegates to the parent constructor.
@@ -50,7 +50,7 @@ import java.io.OutputStream;
*/
public class BigEndianOutputStream
extends DataOutputStream
implements abstractDataOutputStream
implements AbstractDataOutput
{
/**
* Delegate functionality to the parent constructor.
@@ -1,4 +1,4 @@
/* cdrBufOutput.java --
/* BufferedCdrOutput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,41 +41,47 @@ package gnu.CORBA.CDR;
import java.io.ByteArrayOutputStream;
/**
* A CORBA output stream, writing data into the internal
* buffer ({@link ByteArrayOutputStream}).
*
* A CORBA output stream, writing data into the internal buffer ({@link ByteArrayOutputStream}).
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class cdrBufOutput
extends cdrOutput
public class BufferedCdrOutput
extends AbstractCdrOutput
implements gnuValueStream
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* The byte buffer.
*/
public final aligningOutputStream buffer;
public final AligningOutput buffer;
/**
* Creates the instance with the given initial buffer size.
*
* @param bufSize the buffer size.
*/
public cdrBufOutput(int bufSize)
public BufferedCdrOutput(int bufSize)
{
buffer = new aligningOutputStream(bufSize);
buffer = new AligningOutput(bufSize);
setOutputStream(buffer);
}
/**
* Creates the instance with the default buffer size.
*/
public cdrBufOutput()
public BufferedCdrOutput()
{
buffer = new aligningOutputStream();
buffer = new AligningOutput();
setOutputStream(buffer);
}
/**
* Set the alignment offset, if the index of the first byte in the
* stream is different from 0.
* Set the alignment offset, if the index of the first byte in the stream is
* different from 0.
*/
public void setOffset(int an_offset)
{
@@ -95,7 +101,7 @@ public class cdrBufOutput
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
cdrBufInput in = new cdrBufInput(buffer.toByteArray());
BufferredCdrInput in = new BufferredCdrInput(buffer.toByteArray());
in.setOrb(orb);
in.setVersion(giop);
@@ -112,4 +118,39 @@ public class cdrBufOutput
buffer.reset();
setOutputStream(buffer);
}
/**
* Get the current position in the buffer.
*
* @return The position in the buffer, taking offset into consideration.
*/
public int getPosition()
{
return buffer.getPosition();
}
/**
* Get the associated RunTime.
*/
public gnuRuntime getRunTime()
{
return runtime;
}
/**
* Replace the instance of RunTime.
*/
public void setRunTime(gnuRuntime a_runtime)
{
runtime = a_runtime;
}
/**
* Seek to the given position.
*/
public void seek(int position)
{
buffer.seek(position);
}
}
@@ -1,4 +1,4 @@
/* cdrBufInput.java --
/* BufferredCdrInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,18 +43,20 @@ package gnu.CORBA.CDR;
* The CDR input stream that reads data from the byte buffer.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*
* TODO character encoding. Now the encoding can be set, but it is ignored.
* If you take this task, scan 'TODO character encoding' for
* relevant places.
*/
public class cdrBufInput
extends cdrInput
public class BufferredCdrInput
extends AbstractCdrInput
implements gnuValueStream
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* The byte array input stream to read data from.
*/
public final aligningInputStream buffer;
public final AligningInput buffer;
/**
* Creates the CDR input stream that reads from the given buffer
@@ -62,9 +64,9 @@ public class cdrBufInput
*
* @param a_buffer an array to read from.
*/
public cdrBufInput(byte[] a_buffer)
public BufferredCdrInput(byte[] a_buffer)
{
buffer = new aligningInputStream(a_buffer);
buffer = new AligningInput(a_buffer);
setInputStream(buffer);
}
@@ -112,4 +114,40 @@ public class cdrBufInput
buffer.reset();
setInputStream(buffer);
}
/**
* Get the current position in the buffer.
*
* @return The position in the buffer, taking offset into consideration.
*/
public int getPosition()
{
return buffer.getPosition();
}
/**
* Jump to the given position, taking offset into consideration.
*/
public void seek(int position)
{
buffer.seek(position);
setInputStream(buffer);
}
/**
* Get the associated RunTime.
*/
public gnuRuntime getRunTime()
{
return runtime;
}
/**
* Replace the instance of RunTime.
*/
public void setRunTime(gnuRuntime a_runtime)
{
runtime = a_runtime;
}
}
@@ -48,8 +48,8 @@ import java.io.IOException;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class encapsulatedOutput
extends cdrOutput
public class EncapsulationStream
extends AbstractCdrOutput
{
/**
* The Big Endian (most siginificant byte first flag).
@@ -64,7 +64,7 @@ public class encapsulatedOutput
/**
* The byte buffer.
*/
public final aligningOutputStream buffer;
public final AligningOutput buffer;
/**
* The stream, where the data are being encapsulated.
@@ -75,11 +75,11 @@ public class encapsulatedOutput
* Create the EncapsulationOutput with the given parent stream
* and the specified encoding.
*/
public encapsulatedOutput(org.omg.CORBA.portable.OutputStream _parent,
public EncapsulationStream(org.omg.CORBA.portable.OutputStream _parent,
boolean use_big_endian)
{
super();
buffer = new aligningOutputStream();
buffer = new AligningOutput();
setOutputStream(buffer);
parent = _parent;
write(use_big_endian?BIG_ENDIAN:LITTLE_ENDIAN);
@@ -126,7 +126,7 @@ public class encapsulatedOutput
*/
public org.omg.CORBA.portable.InputStream create_input_stream()
{
cdrBufInput in = new cdrBufInput(buffer.toByteArray());
BufferredCdrInput in = new BufferredCdrInput(buffer.toByteArray());
in.setOrb(orb);
in.setVersion(giop);
@@ -0,0 +1,749 @@
/* HeadlessInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.Minor;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnySeqHolder;
import org.omg.CORBA.BooleanSeqHolder;
import org.omg.CORBA.CharSeqHolder;
import org.omg.CORBA.Context;
import org.omg.CORBA.DataInputStream;
import org.omg.CORBA.DoubleSeqHolder;
import org.omg.CORBA.FloatSeqHolder;
import org.omg.CORBA.LongLongSeqHolder;
import org.omg.CORBA.LongSeqHolder;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.ORB;
import org.omg.CORBA.OctetSeqHolder;
import org.omg.CORBA.Principal;
import org.omg.CORBA.ShortSeqHolder;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ULongLongSeqHolder;
import org.omg.CORBA.ULongSeqHolder;
import org.omg.CORBA.UShortSeqHolder;
import org.omg.CORBA.WCharSeqHolder;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import java.io.IOException;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* Substitutes the main stream in factories when the header is already behind.
* Overrides methods that may be invoked from the factory, forcing not to read
* the header if called first time on this stream.
*
* This stream reverts to default behavior if one or more call are made (reading
* value types that are nested fields of the value type).
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class HeadlessInput
extends org.omg.CORBA_2_3.portable.InputStream
implements DataInputStream, gnuValueStream
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* Indicates that no positional information is available.
*/
static final int NONE = -1;
/**
* If true, this is not the first call.
*/
public boolean subsequentCalls;
/**
* The enclosed stream.
*/
final BufferredCdrInput stream;
/**
* Create an instance, reading from the given buffer.
*
* @param a_stram a stream from where the data will be read.
* @param inheritSettings a stream from that endian and other settings are
* inherited.
*/
public HeadlessInput(BufferredCdrInput a_stream, InputStream inheritSettings)
{
stream = a_stream;
if (inheritSettings instanceof AbstractCdrInput)
{
AbstractCdrInput t = (AbstractCdrInput) inheritSettings;
t.cloneSettings(stream);
}
else if (stream.orb() == null)
stream.setOrb(inheritSettings.orb());
if (inheritSettings instanceof gnuValueStream
&& stream.getRunTime() == null)
{
stream.setRunTime(((gnuValueStream) inheritSettings).getRunTime());
}
}
/**
* Tries to read using boxed value helper.
*/
public Serializable read_value(BoxedValueHelper helper)
{
if (subsequentCalls)
return stream.read_value(helper);
else
{
subsequentCalls = true;
return helper.read_value(this);
}
}
/**
* Tries to locate a factory using repository id.
*/
public Serializable read_value(String repository_id)
{
if (subsequentCalls)
return stream.read_value(repository_id);
else
{
subsequentCalls = true;
Serializable value = (Serializable) Vio.readValue(this, NONE, null,
null, repository_id, null, null);
return value;
}
}
/**
* Try to read when having an unitialised value.
*/
public Serializable read_value(Serializable value)
{
if (subsequentCalls)
return stream.read_value(value);
else
{
subsequentCalls = true;
value = (Serializable) Vio.readValue(this, NONE, value, null, null,
null, null);
return value;
}
}
/**
* Try to read when having an unitialised value.
*/
public Serializable read_value(Class clz)
{
if (subsequentCalls)
return stream.read_value(clz);
else
{
try
{
subsequentCalls = true;
Serializable value = (Serializable) Vio.instantiateAnyWay(clz);
value = (Serializable) Vio.readValue(this, NONE, value, null, null,
null, null);
return value;
}
catch (Exception ex)
{
MARSHAL m = new MARSHAL("Can't read an instance of "
+ clz.getName());
m.minor = Minor.Value;
m.initCause(ex);
throw m;
}
}
}
/**
* Delegates functionality to the underlying stream.
*/
public int available()
throws IOException
{
return stream.available();
}
/**
* Delegates functionality to the underlying stream.
*/
public void close()
throws IOException
{
stream.close();
}
/**
* Delegates functionality to the underlying stream.
*/
public void mark(int readlimit)
{
stream.mark(readlimit);
}
/**
* Delegates functionality to the underlying stream.
*/
public boolean markSupported()
{
return stream.markSupported();
}
/**
* Delegates functionality to the underlying stream.
*/
public ORB orb()
{
return stream.orb();
}
/**
* Delegates functionality to the underlying stream.
*/
public Object read_abstract_interface()
{
return stream.read_abstract_interface();
}
/**
* Delegates functionality to the underlying stream.
*/
public Object read_abstract_interface(Class clz)
{
return stream.read_abstract_interface(clz);
}
/**
* Delegates functionality to the underlying stream.
*/
public Any read_any()
{
return stream.read_any();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_boolean_array(boolean[] value, int offset, int length)
{
stream.read_boolean_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public boolean read_boolean()
{
return stream.read_boolean();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_char_array(char[] value, int offset, int length)
{
stream.read_char_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public char read_char()
{
return stream.read_char();
}
/**
* Delegates functionality to the underlying stream.
*/
public Context read_Context()
{
return stream.read_Context();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_double_array(double[] value, int offset, int length)
{
stream.read_double_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public double read_double()
{
return stream.read_double();
}
/**
* Delegates functionality to the underlying stream.
*/
public BigDecimal read_fixed()
{
return stream.read_fixed();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_float_array(float[] value, int offset, int length)
{
stream.read_float_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public float read_float()
{
return stream.read_float();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_long_array(int[] value, int offset, int length)
{
stream.read_long_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public int read_long()
{
return stream.read_long();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_longlong_array(long[] value, int offset, int length)
{
stream.read_longlong_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public long read_longlong()
{
return stream.read_longlong();
}
/**
* Delegates functionality to the underlying stream.
*/
public org.omg.CORBA.Object read_Object()
{
return stream.read_Object();
}
/**
* Delegates functionality to the underlying stream.
*/
public org.omg.CORBA.Object read_Object(Class klass)
{
return stream.read_Object(klass);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_octet_array(byte[] value, int offset, int length)
{
stream.read_octet_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public byte read_octet()
{
return stream.read_octet();
}
/**
* Delegates functionality to the underlying stream.
*/
public Principal read_Principal()
{
return stream.read_Principal();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_short_array(short[] value, int offset, int length)
{
stream.read_short_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public short read_short()
{
return stream.read_short();
}
/**
* Delegates functionality to the underlying stream.
*/
public String read_string()
{
return stream.read_string();
}
/**
* Delegates functionality to the underlying stream.
*/
public TypeCode read_TypeCode()
{
return stream.read_TypeCode();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_ulong_array(int[] value, int offset, int length)
{
stream.read_ulong_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public int read_ulong()
{
return stream.read_ulong();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_ulonglong_array(long[] value, int offset, int length)
{
stream.read_ulonglong_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public long read_ulonglong()
{
return stream.read_ulonglong();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_ushort_array(short[] value, int offset, int length)
{
stream.read_ushort_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public short read_ushort()
{
return stream.read_ushort();
}
/**
* Delegates functionality to the underlying stream.
*/
public Serializable read_value()
{
return read_value((Serializable) null);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_wchar_array(char[] value, int offset, int length)
{
stream.read_wchar_array(value, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public char read_wchar()
{
return stream.read_wchar();
}
/**
* Delegates functionality to the underlying stream.
*/
public String read_wstring()
{
return stream.read_wstring();
}
/**
* Delegates functionality to the underlying stream.
*/
public int read()
throws IOException
{
return stream.read();
}
/**
* Delegates functionality to the underlying stream.
*/
public int read(byte[] b, int off, int len)
throws IOException
{
return stream.read(b, off, len);
}
/**
* Delegates functionality to the underlying stream.
*/
public int read(byte[] b)
throws IOException
{
return stream.read(b);
}
/**
* Delegates functionality to the underlying stream.
*/
public void reset()
throws IOException
{
stream.reset();
}
/**
* Delegates functionality to the underlying stream.
*/
public long skip(long n)
throws IOException
{
return stream.skip(n);
}
/**
* Get a string representation.
*/
public String toString()
{
return "HeadlessInput+" + stream.toString();
}
/**
* Delegates functionality to the underlying stream.
*/
public String[] _truncatable_ids()
{
return stream._truncatable_ids();
}
/**
* Delegates functionality to the underlying stream.
*/
public Object read_Abstract()
{
return stream.read_Abstract();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_any_array(AnySeqHolder holder, int offset, int length)
{
stream.read_any_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_boolean_array(BooleanSeqHolder holder, int offset, int length)
{
stream.read_boolean_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_char_array(CharSeqHolder holder, int offset, int length)
{
stream.read_char_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_double_array(DoubleSeqHolder holder, int offset, int length)
{
stream.read_double_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_float_array(FloatSeqHolder holder, int offset, int length)
{
stream.read_float_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_long_array(LongSeqHolder holder, int offset, int length)
{
stream.read_long_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_longlong_array(LongLongSeqHolder holder, int offset,
int length)
{
stream.read_longlong_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_octet_array(OctetSeqHolder holder, int offset, int length)
{
stream.read_octet_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_short_array(ShortSeqHolder holder, int offset, int length)
{
stream.read_short_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_ulong_array(ULongSeqHolder holder, int offset, int length)
{
stream.read_ulong_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_ulonglong_array(ULongLongSeqHolder holder, int offset,
int length)
{
stream.read_ulonglong_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_ushort_array(UShortSeqHolder holder, int offset, int length)
{
stream.read_ushort_array(holder, offset, length);
}
/**
* Delegates functionality to read_value.
*/
public Serializable read_Value()
{
return read_value();
}
/**
* Delegates functionality to the underlying stream.
*/
public void read_wchar_array(WCharSeqHolder holder, int offset, int length)
{
stream.read_wchar_array(holder, offset, length);
}
/**
* Delegates functionality to the underlying stream.
*/
public int getPosition()
{
return stream.getPosition();
}
/**
* Delegates functionality to the underlying stream.
*/
public gnuRuntime getRunTime()
{
return stream.runtime;
}
/**
* Replace the instance of RunTime.
*/
public void setRunTime(gnuRuntime a_runtime)
{
stream.runtime = a_runtime;
}
/**
* Delegates functionality to the underlying stream.
*/
public void seek(int position)
{
stream.seek(position);
}
}
@@ -0,0 +1,169 @@
/* IDLTypeHelper.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.Minor;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
/**
* Handles case when the CORBA IDL type with the known helper is wrapped into
* Value type.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class IDLTypeHelper
implements BoxedValueHelper
{
/**
* A helper class.
*/
protected Class helper;
/**
* Argument values for Helper.id().
*/
static final Object[] ARGS_ID_V = new Object[0];
/**
* Argument types for Helper.id()).
*/
static final Class[] ARGS_ID = new Class[0];
/**
* Argument types for Helper.read.
*/
static final Class[] ARGS_READ = new Class[] { org.omg.CORBA.portable.InputStream.class };
/**
* Create an IDLTypeHelper that works via given helper class.
*/
public IDLTypeHelper(Class a_helperClass)
{
helper = a_helperClass;
}
/**
* Get the Id, returned by this helper (use reflection).
*/
public String get_id()
{
try
{
Method m = helper.getMethod("id", ARGS_ID);
return (String) m.invoke(null, ARGS_ID_V);
}
catch (Exception ex)
{
MARSHAL m = new MARSHAL(msg() + " id()");
m.minor = Minor.Boxed;
m.initCause(ex);
throw m;
}
}
/**
* Read an instance from the stream.
*/
public Serializable read_value(InputStream input)
{
try
{
Method m = helper.getMethod("read", ARGS_READ);
return (Serializable) m.invoke(null, new Object[] { input });
}
catch (Exception ex)
{
MARSHAL m = new MARSHAL(msg() + " read(..)");
m.minor = Minor.Boxed;
m.initCause(ex);
throw m;
}
}
/**
* Write the instance to the stream.
*/
public void write_value(OutputStream output, Serializable value)
{
try
{
Method[] m = helper.getMethods();
for (int i = 0; i < m.length; i++)
{
if (m[i].getName().equals("write")
&& ((m[i].getModifiers() & Modifier.STATIC) != 0))
{
Class[] p = m[i].getParameterTypes();
if (p.length == 2 && OutputStream.class.isAssignableFrom(p[0])
&& p[1].isAssignableFrom(value.getClass()))
{
m[i].invoke(null, new Object[] { output, value });
return;
}
}
}
}
catch (Exception ex)
{
MARSHAL m = new MARSHAL(msg() + " write(..)");
m.minor = Minor.Boxed;
m.initCause(ex);
throw m;
}
}
/**
* Create the start of message for exceptions.
*/
String msg()
{
return "Failed calling " + helper.getName() + " method: ";
}
}
@@ -55,7 +55,7 @@ import java.io.PushbackInputStream;
*/
public class LittleEndianInputStream
extends FilterInputStream
implements abstractDataInputStream
implements AbstractDataInput
{
// Byte buffer, used to make primitive read calls more efficient.
byte[] buf = new byte[ 8 ];
@@ -55,7 +55,7 @@ import java.io.OutputStream;
*/
public class LittleEndianOutputStream
extends FilterOutputStream
implements abstractDataOutputStream
implements AbstractDataOutput
{
/**
* This method initializes an instance of <code>DataOutputStream</code> to
@@ -0,0 +1,292 @@
/* UnknownExceptionCtxHandler.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.Minor;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.GIOP.ServiceContext;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.StringValueHelper;
import org.omg.CORBA.portable.OutputStream;
import java.lang.reflect.Constructor;
import java.util.StringTokenizer;
import javax.rmi.CORBA.Util;
/**
* Reads the data about an unknown exception from the UnknownExceptionInfo.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class UnknownExceptionCtxHandler
extends Vio
{
/**
* Encode exception and add its recored to the message service contexts.
*/
public static ServiceContext[] addExceptionContext(ServiceContext[] current,
Throwable exception, Object details)
{
try
{
ServiceContext[] c = new ServiceContext[current.length + 1];
if (current.length > 0)
System.arraycopy(current, 0, c, 0, current.length);
BufferedCdrOutput output = new BufferedCdrOutput();
if (details instanceof OutputStream)
output.setOrb(((OutputStream) output).orb());
if (details instanceof AbstractCdrOutput)
((AbstractCdrOutput) details).cloneSettings(output);
write(output, exception);
ServiceContext xc = new ServiceContext();
xc.context_id = ServiceContext.UnknownExceptionInfo;
xc.context_data = output.buffer.toByteArray();
c[current.length] = xc;
return c;
}
catch (Exception ex)
{
ex.printStackTrace();
return current;
}
}
/**
* Write data about unknown exception.
*/
public static void write(BufferedCdrOutput output, Throwable t)
{
t.fillInStackTrace();
output.write_Value(t);
}
/**
* Read the data about an unknown exception from the UnknownExceptionInfo.
* Following the documentation, this must be just value type, but it seems
* that in Sun's implementation is is not, as starts from 0x0. For value type,
* this would be null.
*
* TODO Implement reading and writing in Sun format, making Classpath IIOP
* interoperable with Sun's implementation. Current inmplementation reads and
* reproduces the exception class type only.
*
* @param input the input stream to read the context (orb and other settings
* are inherited from the main stream that received the message).
*
* @param contexts all service contexts that were present in the message.
*
* @return the Throwable, extracted from context, on null, if this has failed.
*/
public static Throwable read(BufferredCdrInput input, ServiceContext[] contexts)
{
input.mark(Integer.MAX_VALUE);
int h = input.read_long();
if (h == 0)
{
// This block reads exception info in the Sun specific format.
// (currently we read the exception name only).
try
{
// We may need to jump back if the value is read via value
// factory.
input.mark(512);
int value_tag = input.read_long();
checkTag(value_tag);
String codebase = null;
String[] ids = null;
String id = null;
// Check for the agreed null value.
if (value_tag == vt_NULL)
return null;
else if (value_tag == vt_INDIRECTION)
return (Throwable) readIndirection(input);
else
{
// Read the value.
if ((value_tag & vf_CODEBASE) != 0)
{
// The codebase is present. The codebase is a space
// separated list of URLs from where the implementing
// code can be downloaded.
codebase = read_string(input);
}
if ((value_tag & vf_MULTIPLE_IDS) != 0)
{
// Multiple supported repository ids are present.
ids = read_string_array(input);
}
else if ((value_tag & vf_ID) != 0)
{
// Single supported repository id is present.
id = read_string(input);
}
}
java.lang.Object ox = createInstance(id, ids, codebase);
return (Throwable) ox;
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
}
else
{
input.reset();
// Read as defined in OMG documentation.
return (Throwable) input.read_Value();
}
}
/**
* Load exception by name and create the instance. The reason why this is
* different from Vio is because some exceptions have no parameterless
* constructor, but have a constructor with the string parameter instead.
*/
static Object createInstance(String id, String[] ids, String codebase)
{
Object o = _createInstance(id, codebase);
if (ids != null)
for (int i = 0; i < ids.length && o == null; i++)
o = _createInstance(ids[i], codebase);
return o;
}
static Object _createInstance(String id, String codebase)
{
if (id == null)
return null;
if (id.equals(StringValueHelper.id()))
return "";
StringTokenizer st = new StringTokenizer(id, ":");
String prefix = st.nextToken();
if (prefix.equalsIgnoreCase("IDL"))
return ObjectCreator.Idl2Object(id);
else if (prefix.equalsIgnoreCase("RMI"))
{
String className = st.nextToken();
String hashCode = st.nextToken();
String sid = null;
if (st.hasMoreElements())
sid = st.nextToken();
try
{
Class objectClass = Util.loadClass(className, codebase,
Vio.class.getClassLoader());
String rid = ObjectCreator.getRepositoryId(objectClass);
if (!rid.equals(id))
{
// If direct string comparison fails, compare by meaning.
StringTokenizer st2 = new StringTokenizer(rid, ":");
if (!st2.nextToken().equals("RMI"))
throw new InternalError("RMI format expected: '" + rid + "'");
if (!st2.nextToken().equals(className))
throwIt("Class name mismatch", id, rid, null);
try
{
long h1 = Long.parseLong(hashCode, 16);
long h2 = Long.parseLong(st2.nextToken(), 16);
if (h1 != h2)
throwIt("Hashcode mismatch", id, rid, null);
if (sid != null && st2.hasMoreTokens())
{
long s1 = Long.parseLong(hashCode, 16);
long s2 = Long.parseLong(st2.nextToken(), 16);
if (s1 != s2)
throwIt("serialVersionUID mismatch", id, rid, null);
}
}
catch (NumberFormatException e)
{
throwIt("Invalid hashcode or svuid format: ", id, rid, e);
}
}
// Some RemoteExceptions have no public parameterless constructor,
// but they have constructor taking string as parameter.
try
{
return objectClass.newInstance();
}
catch (Exception ex)
{
// Try instantiate passing string as parameter.
Constructor c = objectClass.getConstructor(new Class[] { String.class });
return c.newInstance(new Object[] { "<message unavailable>" });
}
}
catch (MARSHAL m)
{
m.minor = Minor.Instantiation;
throw m;
}
catch (Exception ex)
{
MARSHAL m = new MARSHAL("Unable to instantiate " + id);
m.minor = Minor.Instantiation;
m.initCause(ex);
throw m;
}
}
else
throw new NO_IMPLEMENT("Unsupported prefix " + prefix + ":");
}
}
+101
View File
@@ -0,0 +1,101 @@
/* VMVio.java -- Native operations, required by value IO.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
/**
* This is a temporary replacement for the native call that would allocate
* objects without public constructors. The replacement only allocates
* objects with public parameterless constructor and objects with public
* constructor taking string (like some Throwables).
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*
* TODO FIXME replace by native call like in VMObjectInputStream.
* Required modification of Classpath the build system.
*/
package gnu.CORBA.CDR;
import java.lang.reflect.Constructor;
public class VMVio
{
/**
* Allocates a new Object of type clazz but without running the default
* constructor on it. It then calls the given constructor on it. The given
* constructor method comes from the constr_clazz which is a super class of
* the given clazz.
*/
public static Object allocateObject(Class clazz, Class constr_clazz,
Constructor constructor)
throws InstantiationException
{
try
{
Constructor c = clazz.getConstructor(new Class[0]);
c.setAccessible(true);
return c.newInstance(new Object[0]);
}
catch (Exception ex)
{
try
{
Constructor c = clazz.getConstructor(new Class[] { String.class });
return c.newInstance(new Object[] { "" });
}
catch (Exception ex2)
{
Constructor c[] = clazz.getConstructors();
for (int i = 0; i < c.length; i++)
{
try
{
c[i].setAccessible(true);
Class[] args = c[i].getParameterTypes();
return c[i].newInstance(new Object[args.length]);
}
catch (Exception ex3)
{
// Try another one.
}
}
}
throw new InstantiationException(clazz.getName());
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,336 @@
/* gnuRuntime.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA.CDR;
import gnu.CORBA.Minor;
import org.omg.CORBA.LocalObject;
import org.omg.CORBA.MARSHAL;
import java.io.Serializable;
import java.util.Comparator;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.TreeSet;
/**
* Our implementation of the sending context runtime.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuRuntime
extends LocalObject
implements org.omg.SendingContext.RunTime
{
/**
* The data entry about the object that was written.
*/
static class Entry
{
/**
* The stream position, where the object was written.
*/
int at;
/**
* The object that was written.
*/
Object object;
public String toString()
{
return object + "[" + at + "] "+object.getClass().getName();
}
}
/**
* The instruction that the actual object is stored at different location.
* Used when processing chunked data where positions shifts due removing the
* chunking tags.
*/
static class Redirection
extends Entry
{
public String toString()
{
return "->" + at;
}
}
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* The history of the written objects, maps object to records. The different
* objects must be treated as different regardless that .equals returns.
*/
private Map sh_objects = new IdentityHashMap();
/**
* The written repository Ids that can be shared.
*/
private Map sh_ids = new TreeMap(new Comparator()
{
public int compare(Object a, Object b)
{
if (a instanceof String && b instanceof String)
// Comparing string with string.
return ((String) a).compareTo((String) b);
else if (a instanceof String[] && b instanceof String[])
{
// Comparing array with array.
String[] sa = (String[]) a;
String[] sb = (String[]) b;
if (sa.length != sb.length)
return sa.length - sb.length;
else
{
int c;
for (int i = 0; i < sa.length; i++)
{
c = sa[i].compareTo(sb[i]);
if (c != 0)
return c;
}
return 0;
}
}
else
// Comparing string with array.
return a instanceof String ? 1 : -1;
}
});
/**
* The history of the written objects, maps positions to records. The
* different objects must be treated as different regardless that .equals
* returns.
*/
private Map positions = new HashMap();
/**
* The Codebase.
*/
private String codebase;
/**
* The pre-created instance of the object being written (avoid
* re-instantiation).
*/
public Serializable target;
/**
* Create Runtime.
*
* @param a_id a repository Id, if only one Id was specified in the stream.
* @param a_ids a repository Ids, if the multiple Ids were specified in te
* stream.
* @param a_codabase a codebase, if it was specified in the stream.
*/
public gnuRuntime(String a_codebase, Object a_target)
{
if (a_target instanceof Serializable)
target = (Serializable) a_target;
codebase = a_codebase;
}
/**
* Mark the given object as written at the given position.
*/
public void objectWritten(Object object, int at)
{
if (object == null || at < 0)
return; // No positional information provided.
if (sh_objects.containsKey(object))
throw new AssertionError("Repetetive writing of the same object "
+ object + " at " + at + dump());
Entry e = new Entry();
e.at = at;
e.object = object;
sh_objects.put(object, e);
positions.put(new Integer(at), e);
}
/**
* Check if the object is already written.
*
* @return the position, at that the object is allready written or -1 if it is
* not yet written.
*/
public int isWrittenAt(Object x)
{
Entry e = (Entry) sh_objects.get(x);
return e == null ? -1 : e.at;
}
/**
* Set redirection, indicating that the object, searched at the p_searched
* position can be actually found at the p_present position.
*/
public void redirect(int p_searched, int p_present)
{
Redirection redirection = new Redirection();
redirection.at = p_present;
positions.put(new Integer(p_searched), redirection);
}
/**
* Get the object, written at the given position. This returs both shared
* objects and repository Ids.
*
* @return the position, at that the object is allready written.
*
* @throws MARSHAL if there is no object written at that position.
*/
public Object isObjectWrittenAt(int x, int offset)
{
Entry e = (Entry) positions.get(new Integer(x));
if (e instanceof Redirection)
return isObjectWrittenAt(e.at, offset);
else if (e != null)
return e.object;
else
{
MARSHAL m = new MARSHAL("No object was written at " + x +
" (offset " + offset + ") r " + this + dump());
m.minor = Minor.Graph;
throw m;
}
}
/**
* Mark the given object as written at the given position.
*/
public void singleIdWritten(String id, int at)
{
if (sh_ids.containsKey(id))
throw new InternalError("Repetetive writing of the same string " +
id + dump());
Entry e = new Entry();
e.at = at;
e.object = id;
sh_ids.put(id, e);
positions.put(new Integer(at), e);
}
/**
* Mark the given object as written at the given position.
*/
public void multipleIdsWritten(String[] ids, int at)
{
if (sh_ids.containsKey(ids))
throw new InternalError("Repetetive writing of the same string " +
ids + dump());
Entry e = new Entry();
e.at = at;
e.object = ids;
sh_ids.put(ids, e);
positions.put(new Integer(at), e);
}
/**
* Check if the object is already written.
*
* @return the position, at that the object is allready written or -1 if it is
* not yet written.
*/
public int idWrittenAt(Object x)
{
Entry e = (Entry) sh_ids.get(x);
return e == null ? -1 : e.at;
}
/**
* Get the codebase.
*/
public String getCodeBase()
{
return codebase;
}
/**
* Set the codebase, preserving the old value if the passed parameter is null
* and forming the space delimited list if both new and old values are not
* null.
*/
public void addCodeBase(String base)
{
if (base != null)
{
if (codebase == null)
codebase = base;
else
codebase = codebase + " " + base;
}
}
/**
* Dump all objects that are currently stored.
*/
public String dump()
{
StringBuffer b = new StringBuffer(" Stream content: \n");
// Sort by position.
TreeSet t = new TreeSet(positions.keySet());
Iterator p = t.iterator();
while (p.hasNext())
{
Object k = p.next();
b.append(" " + k + ": " + ((Entry) positions.get(k)).toString()
+ "\n");
}
return b.toString();
}
}
@@ -0,0 +1,71 @@
/* gnuValueStream.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA.CDR;
/**
* A stream, implementing this interface, provides methods to get/set a position
* and get the RunTime.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public interface gnuValueStream
{
/**
* Get the current position in the buffer.
*
* @return The position in the buffer, taking offset into consideration.
*/
public int getPosition();
/**
* Jump to the given position, taking offset into consideration.
*/
public void seek(int position);
/**
* Get the RunTime information.
*/
public gnuRuntime getRunTime();
/**
* Replace the instance of RunTime.
*/
public void setRunTime(gnuRuntime a_runtime);
}
@@ -1,166 +0,0 @@
/* noHeaderInput.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA.CDR;
import org.omg.CORBA.CustomMarshal;
import org.omg.CORBA.DataInputStream;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.portable.BoxedValueHelper;
import org.omg.CORBA.portable.Streamable;
import org.omg.CORBA.portable.ValueFactory;
import java.io.Serializable;
/**
* Substitutes the main stream in factories when the header is already
* behind. Overrides methods that may be invoked from the factory,
* forcing not to read the header if called first time on this stream.
*
* This stream reverts to default behavior if one or more call are
* made (reading value types that are nested fields of the value type).
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
class noHeaderInput
extends cdrBufInput
implements DataInputStream
{
/**
* If true, this is not the first call.
*/
boolean notFirst;
/**
* Create an instance, reading from the given buffer.
*/
public noHeaderInput(byte[] buffer)
{
super(buffer);
}
/**
* Read when knowning the class instance.
*/
public Serializable read_value(Class clz)
{
if (notFirst)
return super.read_value(clz);
else
{
try
{
notFirst = true;
return read_value((Serializable) clz.newInstance());
}
catch (Exception ex)
{
MARSHAL m = new MARSHAL("Unable to create an instance");
m.initCause(ex);
throw m;
}
}
}
/**
* Tries to read using boxed value helper.
*/
public Serializable read_value(BoxedValueHelper helper)
{
if (notFirst)
return super.read_value(helper);
else
{
notFirst = true;
return helper.read_value(this);
}
}
/**
* Tries to locate a factory using repository id.
*/
public Serializable read_value(String repository_id)
{
if (notFirst)
return super.read_value(repository_id);
else
{
notFirst = true;
ValueFactory factory =
((org.omg.CORBA_2_3.ORB) orb()).lookup_value_factory(repository_id);
if (factory == null)
throw new MARSHAL("No factory");
return factory.read_value(this);
}
}
/**
* Try to read when having an unitialised value.
*/
public Serializable read_value(Serializable value)
{
if (notFirst)
return super.read_value(value);
else
{
notFirst = true;
// The user-defines io operations are implemented.
if (value instanceof CustomMarshal)
{
CustomMarshal marsh = (CustomMarshal) value;
try
{
marsh.unmarshal((DataInputStream) this);
}
catch (ClassCastException ex)
{
Vio.incorrect_plug_in(ex);
}
}
else
// The IDL-generated io operations are implemented.
if (value instanceof Streamable)
{
((Streamable) value)._read(this);
}
return value;
}
}
}
@@ -1,4 +1,4 @@
/* cdrEncapsCodec.java --
/* CdrEncapsCodecImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,9 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -57,19 +57,19 @@ import org.omg.IOP.CodecPackage.TypeMismatch;
/**
* The local {@link Codec} implementation for ENCODING_CDR_ENCAPS
* encoding. This is a local implementation; the remote side should
* have its own Codec of this kind.
* have its own Codec of this kind.
*
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class cdrEncapsCodec
public class CdrEncapsCodecImpl
extends LocalObject
implements Codec
{
/**
* The default version of encoding, used in parameterless constructor.
/**
* Use serialVersionUID for interoperability.
*/
private static final Version DEFAULT_VERSION = new Version(1, 2);
private static final long serialVersionUID = 1;
/**
* If set to true, no wide string or wide character is allowed (GIOP 1.0).
@@ -99,7 +99,7 @@ public class cdrEncapsCodec
/**
* Create an instance of this Codec, encoding following the given version.
*/
public cdrEncapsCodec(ORB _orb, Version _version)
public CdrEncapsCodecImpl(ORB _orb, Version _version)
{
orb = _orb;
version = _version;
@@ -125,8 +125,8 @@ public class cdrEncapsCodec
public Any decode(byte[] them)
throws FormatMismatch
{
cdrBufInput input = createInput(them);
cdrBufInput encapsulation = createEncapsulation(them, input);
BufferredCdrInput input = createInput(them);
BufferredCdrInput encapsulation = createEncapsulation(them, input);
TypeCode type = encapsulation.read_TypeCode();
@@ -142,9 +142,9 @@ public class cdrEncapsCodec
return readAny(type, encapsulation);
}
private cdrBufInput createEncapsulation(byte[] them, cdrBufInput input)
private BufferredCdrInput createEncapsulation(byte[] them, BufferredCdrInput input)
{
cdrBufInput encapsulation;
BufferredCdrInput encapsulation;
if ((them [ 0 ] | them [ 1 ] | them [ 2 ] | them [ 3 ]) == 0)
{
@@ -163,10 +163,10 @@ public class cdrEncapsCodec
{
checkTypePossibility("", that.type());
cdrBufOutput output = createOutput(that);
BufferedCdrOutput output = createOutput(that);
// cdrBufOutput has internal support for this encoding.
cdrOutput encapsulation = output.createEncapsulation();
// BufferedCdrOutput has internal support for this encoding.
AbstractCdrOutput encapsulation = output.createEncapsulation();
try
{
@@ -179,6 +179,7 @@ public class cdrEncapsCodec
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
m.minor = Minor.Encapsulation;
m.initCause(ex);
throw m;
}
@@ -206,8 +207,8 @@ public class cdrEncapsCodec
throw new TypeMismatch(ex.getMessage());
}
cdrBufInput input = createInput(them);
cdrBufInput encapsulation = createEncapsulation(them, input);
BufferredCdrInput input = createInput(them);
BufferredCdrInput encapsulation = createEncapsulation(them, input);
return readAny(type, encapsulation);
}
@@ -217,13 +218,13 @@ public class cdrEncapsCodec
* @param type a type of the Any to read.
* @param input the encapsulation stream.
*/
private Any readAny(TypeCode type, cdrBufInput encapsulation)
private Any readAny(TypeCode type, BufferredCdrInput encapsulation)
throws MARSHAL
{
gnuAny a = new gnuAny();
a.setOrb(orb);
// cdrBufInput has internal support for this encoding.
// BufferredCdrInput has internal support for this encoding.
a.read_value(encapsulation, type);
return a;
}
@@ -234,9 +235,9 @@ public class cdrEncapsCodec
{
checkTypePossibility("", that.type());
cdrBufOutput output = createOutput(that);
BufferedCdrOutput output = createOutput(that);
cdrOutput encapsulation = output.createEncapsulation();
AbstractCdrOutput encapsulation = output.createEncapsulation();
try
{
@@ -248,6 +249,7 @@ public class cdrEncapsCodec
catch (Exception ex)
{
MARSHAL m = new MARSHAL();
m.minor = Minor.Encapsulation;
m.initCause(ex);
throw m;
}
@@ -256,7 +258,7 @@ public class cdrEncapsCodec
/**
* Create the CDR output stream for writing the given Any.
* The cdrBufOutput has internal support for encapsulation encodings.
* The BufferedCdrOutput has internal support for encapsulation encodings.
*
* @param that the Any that will be written.
*
@@ -265,10 +267,10 @@ public class cdrEncapsCodec
* @throws InvalidTypeForEncoding if that Any cannot be written under the
* given version.
*/
private cdrBufOutput createOutput(Any that)
private BufferedCdrOutput createOutput(Any that)
throws InvalidTypeForEncoding
{
cdrBufOutput output = new cdrBufOutput();
BufferedCdrOutput output = new BufferedCdrOutput();
output.setOrb(orb);
output.setVersion(version);
return output;
@@ -325,9 +327,9 @@ public class cdrEncapsCodec
*
* @return the stream.
*/
private cdrBufInput createInput(byte[] them)
private BufferredCdrInput createInput(byte[] them)
{
cdrBufInput input = new cdrBufInput(them);
BufferredCdrInput input = new BufferredCdrInput(them);
input.setOrb(orb);
input.setVersion(version);
return input;
@@ -90,17 +90,6 @@ public class Connected_objects
* applicable.
*/
public final java.lang.Object identity;
public boolean equals(java.lang.Object other)
{
if (other instanceof cObject)
{
cObject o = (cObject) other;
return o.object.equals(object) && o.port == port;
}
else
return false;
}
}
/**
@@ -1,4 +1,4 @@
/* corbaArrayList.java --
/* CorbaList.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import org.omg.CORBA.Bounds;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class corbaArrayList
public class CorbaList
extends ArrayList
implements Serializable
{
@@ -64,7 +64,7 @@ public class corbaArrayList
/**
* Creates the list with the given initial size.
*/
public corbaArrayList(int initial_size)
public CorbaList(int initial_size)
{
super(initial_size);
}
@@ -72,7 +72,7 @@ public class corbaArrayList
/**
* Creates the list with the default size.
*/
public corbaArrayList()
public CorbaList()
{
}
@@ -0,0 +1,79 @@
/* DefaultSocketFactory.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.interfaces.SocketFactory;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
/**
* The default socket factory that forges "plain" server and client sockets. The
* class can be replaced by setting the gnu.CORBA.SocketFactory property.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class DefaultSocketFactory
implements SocketFactory
{
/**
* It is enough to have one instance of this class for all ORBs.
*/
public static final DefaultSocketFactory Singleton = new DefaultSocketFactory();
/**
* Create a client socket.
*/
public Socket createClientSocket(String host, int port)
throws IOException
{
return new Socket(host, port);
}
/**
* Create a server socket.
*/
public ServerSocket createServerSocket(int port)
throws IOException
{
return new ServerSocket(port);
}
}
@@ -1,4 +1,4 @@
/* abstractDynAny.java --
/* AbstractAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.typeNamer;
import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -54,7 +54,7 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class abstractDynAny
public abstract class AbstractAny
extends LocalObject
implements Serializable
{
@@ -108,12 +108,12 @@ public abstract class abstractDynAny
/**
* The change value listener.
*/
valueChangedListener listener;
ValueChangeListener listener;
/**
* Create the abstract dyn any.
*/
public abstractDynAny(TypeCode oType, TypeCode aType,
public AbstractAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -163,8 +163,8 @@ public abstract class abstractDynAny
*/
String typeMismatch(TypeCode expected, TypeCode actual)
{
return typeNamer.nameIt(expected) + " expected " +
typeNamer.nameIt(actual);
return TypeKindNamer.nameIt(expected) + " expected " +
TypeKindNamer.nameIt(actual);
}
/**
@@ -1,4 +1,4 @@
/* anyDivideable.java --
/* DivideableAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.typeNamer;
import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.CompletionStatus;
@@ -58,8 +58,8 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class anyDivideable
extends abstractDynAny
public abstract class DivideableAny
extends AbstractAny
implements Serializable
{
/**
@@ -78,7 +78,7 @@ public abstract class anyDivideable
*/
protected int pos = 0;
public anyDivideable(TypeCode oType, TypeCode aType,
public DivideableAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -486,9 +486,9 @@ public abstract class anyDivideable
{
if (!official_type.equal(other.type()))
return false;
else if (other instanceof anyDivideable)
else if (other instanceof DivideableAny)
{
anyDivideable x = (anyDivideable) other;
DivideableAny x = (DivideableAny) other;
if (x.array.length != array.length)
return false;
@@ -499,7 +499,7 @@ public abstract class anyDivideable
}
return true;
}
else if (other == null || other instanceof abstractDynAny)
else if (other == null || other instanceof AbstractAny)
return false;
else
return other.to_any().equal(to_any());
@@ -1,4 +1,4 @@
/* abstractRecord.java --
/* RecordAny.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
import gnu.CORBA.holderFactory;
import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -65,8 +65,8 @@ import java.lang.reflect.Field;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class abstractRecord
extends anyDivideable
public abstract class RecordAny
extends DivideableAny
implements DynAny, Serializable
{
/**
@@ -80,7 +80,7 @@ public abstract class abstractRecord
*
* @param fields The DynAny's, representing the fields of the structure.
*/
public abstractRecord(TypeCode oType, TypeCode aType,
public RecordAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -277,7 +277,7 @@ public abstract class abstractRecord
c [ i ] = array [ i ].copy();
}
abstractRecord d = newInstance(official_type, final_type, factory, orb);
RecordAny d = newInstance(official_type, final_type, factory, orb);
d.array = c;
return d;
}
@@ -285,7 +285,7 @@ public abstract class abstractRecord
/**
* Create a new instance when copying.
*/
protected abstract abstractRecord newInstance(TypeCode oType, TypeCode aType,
protected abstract RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory,
ORB anOrb
);
@@ -297,7 +297,7 @@ public abstract class abstractRecord
{
try
{
Streamable sHolder = holderFactory.createHolder(official_type);
Streamable sHolder = HolderLocator.createHolder(official_type);
Class sHolderClass = sHolder.getClass();
Field sHolderValue = sHolderClass.getField("value");
@@ -371,7 +371,7 @@ public abstract class abstractRecord
fField = structure.getClass().getField(fNames [ i ]);
field = fField.get(structure);
fType = array [ i ].type();
holder = holderFactory.createHolder(fType);
holder = HolderLocator.createHolder(fType);
member = createAny();
holder.getClass().getField("value").set(holder, field);
@@ -55,8 +55,8 @@ import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class anyUndivideable
extends abstractDynAny
public abstract class UndivideableAny
extends AbstractAny
implements Serializable
{
/**
@@ -67,7 +67,7 @@ public abstract class anyUndivideable
/**
* Create a new instance with the given typecode.
*/
public anyUndivideable(TypeCode oType, TypeCode aType,
public UndivideableAny(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb)
{
super(oType, aType, aFactory, anOrb);
@@ -1,4 +1,4 @@
/* valueChangedListener.java --
/* ValueChangeListener.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ package gnu.CORBA.DynAn;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public interface valueChangedListener
public interface ValueChangeListener
{
void changed();
}
@@ -38,14 +38,14 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.OctetHolder;
import gnu.CORBA.Unexpected;
import gnu.CORBA.WCharHolder;
import gnu.CORBA.WStringHolder;
import gnu.CORBA.holderFactory;
import gnu.CORBA.typeNamer;
import gnu.CORBA.universalHolder;
import gnu.CORBA.HolderLocator;
import gnu.CORBA.TypeKindNamer;
import gnu.CORBA.GeneralHolder;
import org.omg.CORBA.Any;
import org.omg.CORBA.AnyHolder;
@@ -84,7 +84,7 @@ import java.util.Arrays;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
public class gnuDynAny extends AbstractAny implements DynAny, Serializable
{
/**
* Use serialVersionUID for interoperability.
@@ -132,7 +132,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
{
if (holder != null)
{
cdrBufOutput buffer = new cdrBufOutput();
BufferedCdrOutput buffer = new BufferedCdrOutput();
holder._write(buffer);
gnuDynAny other;
@@ -165,7 +165,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
public DynAny current_component() throws TypeMismatch
{
throw new TypeMismatch("Not applicable for " +
typeNamer.nameIt(final_type)
TypeKindNamer.nameIt(final_type)
);
}
@@ -193,14 +193,14 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
{
throw new InvalidValue(ISNULL);
}
else if (a_holder instanceof universalHolder)
else if (a_holder instanceof GeneralHolder)
{
holder = holderFactory.createHolder(official_type);
holder = HolderLocator.createHolder(official_type);
if (holder == null)
holder = holderFactory.createHolder(final_type);
holder = HolderLocator.createHolder(final_type);
if (holder == null)
holder = ((universalHolder) a_holder).Clone();
holder = ((GeneralHolder) a_holder).Clone();
else
{
InputStream in = an_any.create_input_stream();
@@ -890,7 +890,7 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
*/
public boolean equal(DynAny other)
{
if (other instanceof abstractDynAny)
if (other instanceof AbstractAny)
{
if (other instanceof gnuDynAny)
{
@@ -899,10 +899,10 @@ public class gnuDynAny extends abstractDynAny implements DynAny, Serializable
if (!x.holder.getClass().equals(holder.getClass()))
return false;
cdrBufOutput b1 = new cdrBufOutput();
BufferedCdrOutput b1 = new BufferedCdrOutput();
x.holder._write(b1);
cdrBufOutput b2 = new cdrBufOutput(b1.buffer.size() + 10);
BufferedCdrOutput b2 = new BufferedCdrOutput(b1.buffer.size() + 10);
holder._write(b2);
return Arrays.equals(b1.buffer.toByteArray(),
@@ -40,8 +40,8 @@ package gnu.CORBA.DynAn;
import gnu.CORBA.Poa.ORB_1_4;
import gnu.CORBA.Unexpected;
import gnu.CORBA.holderFactory;
import gnu.CORBA.typeNamer;
import gnu.CORBA.HolderLocator;
import gnu.CORBA.TypeKindNamer;
import org.omg.CORBA.Any;
import org.omg.CORBA.LocalObject;
@@ -227,7 +227,7 @@ public class gnuDynAnyFactory
*/
public DynAny create_simple(TypeCode official, TypeCode type)
{
Streamable holder = holderFactory.createHolder(type);
Streamable holder = HolderLocator.createHolder(type);
return new gnuDynAny(holder, official, type, this, orb);
}
@@ -314,7 +314,7 @@ public class gnuDynAnyFactory
case TCKind._tk_Principal :
case TCKind._tk_abstract_interface :
throw new InconsistentTypeCode("Following API, the " +
typeNamer.nameIt(type) +
TypeKindNamer.nameIt(type) +
" must not be supported."
);
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
import gnu.CORBA.holderFactory;
import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
@@ -66,7 +66,7 @@ import java.lang.reflect.Field;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynArray
extends anyDivideable
extends DivideableAny
implements DynArray, Serializable
{
/**
@@ -238,10 +238,10 @@ public class gnuDynArray
try
{
Streamable memberHolder =
holderFactory.createHolder(official_components);
HolderLocator.createHolder(official_components);
if (memberHolder == null)
memberHolder = holderFactory.createHolder(final_components);
memberHolder = HolderLocator.createHolder(final_components);
Class memberHolderClass = memberHolder.getClass();
Class memberClass = memberHolderClass.getField("value").getType();
@@ -260,7 +260,7 @@ public class gnuDynArray
Array.set(members, i, member);
}
Streamable arrayHolder = holderFactory.createHolder(official_type);
Streamable arrayHolder = HolderLocator.createHolder(official_type);
arrayHolder.getClass().getField("value").set(arrayHolder, members);
Any g = createAny();
@@ -296,9 +296,9 @@ public class gnuDynArray
{
if (holderClass == null)
{
holder = holderFactory.createHolder(official_components);
holder = HolderLocator.createHolder(official_components);
if (holder == null)
holder = holderFactory.createHolder(final_components);
holder = HolderLocator.createHolder(final_components);
holderClass = holder.getClass();
}
else
@@ -60,7 +60,7 @@ import java.util.Arrays;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynEnum extends anyUndivideable implements DynEnum
public class gnuDynEnum extends UndivideableAny implements DynEnum
{
/**
* Use serialVersionUID for interoperability.
@@ -57,7 +57,7 @@ import java.math.BigDecimal;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynFixed extends anyUndivideable implements DynFixed
public class gnuDynFixed extends UndivideableAny implements DynFixed
{
/**
* Use serialVersionUID for interoperability.
@@ -54,7 +54,7 @@ import org.omg.DynamicAny.DynAny;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynStruct
extends abstractRecord
extends RecordAny
implements DynStruct, Serializable
{
/**
@@ -89,7 +89,7 @@ public class gnuDynStruct
}
/** @inheritDoc */
protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
protected RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb)
{
return new gnuDynStruct(oType, aType, aFactory, anOrb);
@@ -62,8 +62,8 @@ import java.io.Serializable;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynUnion
extends anyDivideable
implements DynUnion, Serializable, valueChangedListener
extends DivideableAny
implements DynUnion, Serializable, ValueChangeListener
{
/**
* Use serialVersionUID for interoperability.
@@ -96,7 +96,7 @@ public class gnuDynUnion
discriminator =
factory.create_dyn_any_from_type_code(final_type.discriminator_type());
((abstractDynAny) discriminator).listener = this;
((AbstractAny) discriminator).listener = this;
if (final_type.default_index() >= 0)
set_to_default_member();
@@ -114,7 +114,7 @@ public class gnuDynUnion
/*
* (non-Javadoc)
*
* @see gnu.CORBA.DynAn.anyDivideable#to_any()
* @see gnu.CORBA.DynAn.DivideableAny#to_any()
*/
public Any to_any()
{
@@ -171,7 +171,7 @@ public class gnuDynUnion
gnuDynUnion other =
new gnuDynUnion(official_type, final_type, factory, orb);
other.discriminator = discriminator.copy();
((abstractDynAny) other.discriminator).listener = other;
((AbstractAny) other.discriminator).listener = other;
if (array.length == 1)
{
other.array = new DynAny[] { other.discriminator };
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Minor;
import gnu.CORBA.Unexpected;
import org.omg.CORBA.Any;
@@ -66,7 +67,7 @@ import java.io.Serializable;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynValue extends abstractRecord implements DynValue,
public class gnuDynValue extends RecordAny implements DynValue,
Serializable
{
/**
@@ -243,7 +244,7 @@ public class gnuDynValue extends abstractRecord implements DynValue,
/**
* Create a new instance.
*/
protected abstractRecord newInstance(TypeCode oType, TypeCode aType,
protected RecordAny newInstance(TypeCode oType, TypeCode aType,
gnuDynAnyFactory aFactory, ORB anOrb
)
{
@@ -301,9 +302,12 @@ public class gnuDynValue extends abstractRecord implements DynValue,
ValueFactory factory =
((org.omg.CORBA_2_3.ORB) orb).lookup_value_factory(official_type.id());
if (factory == null)
throw new MARSHAL("Factory for " + official_type.id() +
" not registered."
);
{
MARSHAL m = new MARSHAL("Factory for " + official_type.id() +
" not registered.");
m.minor = Minor.Factory;
throw m;
}
OutputStream out = orb.create_output_stream();
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.CORBA.DynAn;
import gnu.CORBA.Unexpected;
import gnu.CORBA.holderFactory;
import gnu.CORBA.HolderLocator;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
@@ -65,7 +65,7 @@ import java.lang.reflect.Field;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class gnuDynValueBox
extends anyDivideable
extends DivideableAny
implements DynValueBox, Serializable
{
/**
@@ -208,7 +208,7 @@ public class gnuDynValueBox
{
try
{
Streamable holder = holderFactory.createHolder(content);
Streamable holder = HolderLocator.createHolder(content);
Field v = holder.getClass().getField("value");
v.set(holder, s);
@@ -125,6 +125,7 @@ public class EmptyExceptionHolder
catch (Exception ex)
{
BAD_OPERATION bad = new BAD_OPERATION();
bad.minor = Minor.CDR;
bad.initCause(ex);
throw bad;
}
@@ -1,245 +0,0 @@
/* ExceptionCreator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.CompletionStatusHelper;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.UserException;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
/**
* Creates the objects from the agreed IDL names.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ExceptionCreator
{
/**
* The standard OMG prefix.
*/
public static final String OMG_PREFIX = "omg.org/";
/**
* The standard java prefix.
*/
public static final String JAVA_PREFIX = "org.omg.";
/**
* Create the system exception with the given idl name.
*
* @param idl the exception IDL name, must match the syntax
* "IDL:<class/name>:1.0".
* @param minor the exception minor code.
* @param completed the exception completion status.
*
* @return the created exception.
*/
public static SystemException createSystemException(String idl, int minor,
CompletionStatus completed
)
{
try
{
String cl = toClassName(idl);
Class exClass = Class.forName(cl);
Constructor constructor =
exClass.getConstructor(new Class[]
{
String.class, int.class,
CompletionStatus.class
}
);
Object exception =
constructor.newInstance(new Object[]
{
" Remote exception " + idl + ", minor " +
minor + ", " + completed + ".",
new Integer(minor), completed
}
);
return (SystemException) exception;
}
catch (Exception ex)
{
ex.printStackTrace();
return new UNKNOWN("Unsupported system exception", minor, completed);
}
}
/**
* Read the system exception from the given stream.
* @param input the CDR stream to read from.
* @return the exception that has been stored in the stream
* (IDL name, minor code and completion status).
*/
public static SystemException readSystemException(InputStream input)
{
String idl = input.read_string();
int minor = input.read_ulong();
CompletionStatus status = CompletionStatusHelper.read(input);
SystemException exception =
ExceptionCreator.createSystemException(idl, minor, status);
return exception;
}
/**
* Reads the user exception, having the given Id, from the
* input stream. The id is expected to be in the form like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
*
* @param idl the exception idl name.
* @param input the stream to read from.
*
* @return the loaded exception.
* @return null if the helper class cannot be found.
*/
public static UserException readUserException(String idl, InputStream input)
{
try
{
String helper = toHelperName(idl);
Class helperClass = Class.forName(helper);
Method read =
helperClass.getMethod("read",
new Class[]
{
org.omg.CORBA.portable.InputStream.class
}
);
return (UserException) read.invoke(null, new Object[] { input });
}
catch (MARSHAL mex)
{
// This one is ok to throw
throw mex;
}
catch (Exception ex)
{
ex.printStackTrace();
return null;
}
}
/**
* Writes the system exception data to CDR output stream.
*
* @param output a stream to write data to.
* @param ex an exception to write.
*/
public static void writeSystemException(OutputStream output,
SystemException ex
)
{
String exIDL = toIDL(ex.getClass().getName());
output.write_string(exIDL);
output.write_ulong(ex.minor);
CompletionStatusHelper.write(output, ex.completed);
}
/**
* Converts teh given IDL name to class name.
*
* @param IDL the idl name.
*
*/
protected static String toClassName(String IDL)
{
String s = IDL;
int a = s.indexOf(':') + 1;
int b = s.lastIndexOf(':');
s = IDL.substring(a, b);
if (s.startsWith(OMG_PREFIX))
s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
return s.replace('/', '.');
}
/**
* Gets the helper class name from the string like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
*
* @param IDL the idl name.
*/
protected static String toHelperName(String IDL)
{
String s = IDL;
int a = s.indexOf(':') + 1;
int b = s.lastIndexOf(':');
s = IDL.substring(a, b);
if (s.startsWith(OMG_PREFIX))
s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
return s.replace('/', '.') + "Helper";
}
/**
* Convert the class name to IDL name.
*
* @param cn the class name.
*
* @return the idl name.
*/
protected static String toIDL(String cn)
{
if (cn.startsWith(JAVA_PREFIX))
cn = cn.substring(JAVA_PREFIX.length());
cn = cn.replace('.', '/');
return "IDL:" + OMG_PREFIX + cn + ":1.0";
}
}
@@ -81,6 +81,7 @@ public abstract class ForwardRequestHelper
catch (ClassCastException cex)
{
BAD_OPERATION bad = new BAD_OPERATION("ForwardRequest expected");
bad.minor = Minor.Any;
bad.initCause(cex);
throw bad;
}
@@ -47,7 +47,10 @@ import java.util.Set;
/**
* This class contains the codes, used to identify character sets
* in CORBA. These codes are defined in Open Software Foundation (OSF)
* code set registry
* code set registry.
*
* The name of this class specially sets "OSF" apart if somebody would start
* searching Open Software Foundation abbreviation.
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
@@ -38,15 +38,13 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
import gnu.CORBA.IOR;
import gnu.CORBA.Minor;
import org.omg.CORBA.MARSHAL;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
/**
* The explicit command to close the connection.
*
@@ -60,6 +58,11 @@ import java.net.Socket;
public class CloseMessage
extends MessageHeader
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* The singleton close message is typically enough, despite new
* instances may be instantiated if the specific version field
@@ -95,6 +98,7 @@ public class CloseMessage
catch (IOException ex)
{
MARSHAL m = new MARSHAL("Unable to flush the stream");
m.minor = Minor.Header;
m.initCause(ex);
throw m;
}
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.IOR;
import gnu.CORBA.IOR.CodeSets_profile;
@@ -51,7 +51,7 @@ import java.io.IOException;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class cxCodeSet
public class CodeSetServiceContext
extends ServiceContext
{
/**
@@ -62,7 +62,7 @@ public class cxCodeSet
/**
* The standard component to include in the messages.
*/
public static final cxCodeSet STANDARD = new cxCodeSet();
public static final CodeSetServiceContext STANDARD = new CodeSetServiceContext();
/**
* The encoding, used to transfer the narrow (1 byte) character data.
@@ -84,13 +84,13 @@ public class cxCodeSet
*
* @param contexts the array of contexts, can be null.
*/
public static cxCodeSet find(ServiceContext[] contexts)
public static CodeSetServiceContext find(ServiceContext[] contexts)
{
if (contexts != null)
for (int i = 0; i < contexts.length; i++)
{
if (contexts [ i ] instanceof cxCodeSet)
return (cxCodeSet) contexts [ i ];
if (contexts [ i ] instanceof CodeSetServiceContext)
return (CodeSetServiceContext) contexts [ i ];
}
return STANDARD;
}
@@ -102,12 +102,12 @@ public class cxCodeSet
* If you take this task, scan 'TODO character encoding' for
* relevant places.
*/
public static cxCodeSet negotiate(IOR.CodeSets_profile profile)
public static CodeSetServiceContext negotiate(IOR.CodeSets_profile profile)
{
if (profile.negotiated != null)
return profile.negotiated;
cxCodeSet use = new cxCodeSet();
CodeSetServiceContext use = new CodeSetServiceContext();
use.char_data =
negotiate(profile.narrow, STANDARD.char_data, CharSets_OSF.ISO8859_1);
@@ -124,9 +124,9 @@ public class cxCodeSet
* Read the context from the given stream. Does not read the
* code sets id.
*/
public void readContext(cdrInput input)
public void readContext(AbstractCdrInput input)
{
cdrInput encap = input.read_encapsulation();
AbstractCdrInput encap = input.read_encapsulation();
char_data = encap.read_ulong();
wide_char_data = encap.read_ulong();
@@ -145,11 +145,11 @@ public class cxCodeSet
* Write the context to the given stream, including the code
* sets id.
*/
public void write(cdrOutput output)
public void write(AbstractCdrOutput output)
{
output.write_ulong(ID);
cdrOutput enout = output.createEncapsulation();
AbstractCdrOutput enout = output.createEncapsulation();
enout.write_long(char_data);
enout.write_ulong(wide_char_data);
@@ -1,4 +1,4 @@
/* contextSupportingHeader.java --
/* ContextHandler.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import org.omg.CORBA.BAD_INV_ORDER;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class contextSupportingHeader
public abstract class ContextHandler
{
/**
@@ -38,7 +38,9 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.Minor;
import java.io.IOException;
import java.io.OutputStream;
@@ -46,6 +48,7 @@ import java.io.OutputStream;
import java.net.Socket;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.ORB;
/**
* The error message is sent in response to the message, encoded
@@ -59,6 +62,11 @@ import org.omg.CORBA.MARSHAL;
public class ErrorMessage
extends MessageHeader
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* Create a new error message, setting the message field
* to the {@link MESSAGE_ERROR} and the version number to
@@ -73,14 +81,22 @@ public class ErrorMessage
/**
* Send the error message to the given IOR address.
*
* @param to the IOR address (host and port, other fields
* @param ior the IOR address (host and port, other fields
* are not used).
*
* @param orb the ORB, sending the error message.
*/
public void send(IOR ior)
public void send(IOR ior, ORB orb)
{
try
{
Socket socket = new Socket(ior.Internet.host, ior.Internet.port);
Socket socket;
if (orb instanceof OrbFunctional)
socket = ((OrbFunctional) orb).socketFactory.createClientSocket(
ior.Internet.host, ior.Internet.port);
else
socket = new Socket(ior.Internet.host, ior.Internet.port);
OutputStream socketOutput = socket.getOutputStream();
write(socketOutput);
@@ -90,6 +106,7 @@ public class ErrorMessage
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
@@ -1,4 +1,4 @@
/* MessageHeader.java -- GIOP 1.0 message header.
/* MessageHeader.java -- GIOP message header.
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,32 +38,38 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
import gnu.CORBA.Minor;
import gnu.CORBA.Version;
import gnu.CORBA.CDR.BigEndianInputStream;
import gnu.CORBA.CDR.BigEndianOutputStream;
import gnu.CORBA.CDR.LittleEndianInputStream;
import gnu.CORBA.CDR.LittleEndianOutputStream;
import gnu.CORBA.CDR.abstractDataOutputStream;
import gnu.CORBA.Version;
import gnu.CORBA.CDR.AbstractDataInput;
import gnu.CORBA.CDR.AbstractDataOutput;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.portable.IDLEntity;
import java.io.DataInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import gnu.CORBA.CDR.BigEndianInputStream;
import gnu.CORBA.CDR.abstractDataInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Arrays;
/**
* The GIOP message header.
*
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class MessageHeader
implements IDLEntity
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* Request message.
*/
@@ -80,16 +86,15 @@ public class MessageHeader
public static final byte CANCEL_REQUEST = 2;
/**
* Locate request message, used to check the server ability to
* process requests for the object reference.
* This message is also used to get the
* Locate request message, used to check the server ability to process
* requests for the object reference. This message is also used to get the
* address where the object reference should be sent.
*/
public static final byte LOCATE_REQUEST = 3;
/**
* Locate reply message, sent in response to the
* {@link #LocateRequest} message.
* Locate reply message, sent in response to the {@link #LocateRequest}
* message.
*/
public static final byte LOCATE_REPLY = 4;
@@ -104,8 +109,8 @@ public class MessageHeader
public static final byte MESSAGE_ERROR = 6;
/**
* The fragment messge, following the previous message that
* has more fragments flag set. Added in GIOP 1.1
* The fragment messge, following the previous message that has more fragments
* flag set. Added in GIOP 1.1
*/
public static final byte FRAGMENT = 7;
@@ -117,12 +122,9 @@ public class MessageHeader
/**
* The message type names.
*/
protected static String[] types =
new String[]
{
"Request", "Reply", "Cancel", "Locate request", "Locate reply",
"Close connection", "Error", "Fragment"
};
protected static String[] types = new String[] { "Request", "Reply",
"Cancel", "Locate request", "Locate reply", "Close connection", "Error",
"Fragment" };
/**
* The GIOP version. Initialised to 1.0 .
@@ -154,7 +156,7 @@ public class MessageHeader
/**
* Create an empty message header, corresponding the given version.
*
*
* @param major the major message header version.
* @param minor the minot message header version.
*/
@@ -164,19 +166,27 @@ public class MessageHeader
}
/**
* Checks if the message is encoded in the Big Endian, most significant
* byte first.
* Checks if the message is encoded in the Big Endian, most significant byte
* first.
*/
public boolean isBigEndian()
{
return (flags & 0x1) == 0;
}
/**
* Checks if the message is partial, and more subsequent fragments follow.
*/
public boolean moreFragmentsFollow()
{
return (flags & 0x2) != 0;
}
/**
* Set the encoding to use.
*
* @param use_big_endian if true (default), the Big Endian
* encoding is used. If false, the Little Endian encoding is used.
*
* @param use_big_endian if true (default), the Big Endian encoding is used.
* If false, the Little Endian encoding is used.
*/
public void setBigEndian(boolean use_big_endian)
{
@@ -196,16 +206,16 @@ public class MessageHeader
/**
* Get the message type as string.
*
*
* @param type the message type as int (the field {@link message_type}).
*
*
* @return the message type as string.
*/
public String getTypeString(int type)
{
try
{
return types [ type ];
return types[type];
}
catch (ArrayIndexOutOfBoundsException ex)
{
@@ -215,10 +225,10 @@ public class MessageHeader
/**
* Creates reply header, matching the message header version number.
*
*
* @return one of {@link gnu.CORBA.GIOP.v1_0.ReplyHeader},
* {@link gnu.CORBA.GIOP.v1_2.ReplyHeader}, etc - depending on
* the version number in this header.
* {@link gnu.CORBA.GIOP.v1_2.ReplyHeader}, etc - depending on the version
* number in this header.
*/
public ReplyHeader create_reply_header()
{
@@ -230,10 +240,10 @@ public class MessageHeader
/**
* Creates request header, matching the message header version number.
*
*
* @return one of {@link gnu.CORBA.GIOP.v1_0.RequestHeader},
* {@link gnu.CORBA.GIOP.v1_2.RequestHeader}, etc - depending on
* the version number in this header.
* {@link gnu.CORBA.GIOP.v1_2.RequestHeader}, etc - depending on the version
* number in this header.
*/
public RequestHeader create_request_header()
{
@@ -261,24 +271,28 @@ public class MessageHeader
/**
* Read the header from the stream.
*
*
* @param istream a stream to read from.
*
*
* @throws MARSHAL if this is not a GIOP 1.0 header.
*/
public void read(java.io.InputStream istream)
throws MARSHAL
throws MARSHAL
{
try
{
byte[] xMagic = new byte[ MAGIC.length ];
byte[] xMagic = new byte[MAGIC.length];
istream.read(xMagic);
if (!Arrays.equals(xMagic, MAGIC))
throw new MARSHAL("Not a GIOP message");
{
MARSHAL m = new MARSHAL("Not a GIOP message");
m.minor = Minor.Giop;
throw m;
}
version = Version.read_version(istream);
abstractDataInputStream din;
AbstractDataInput din;
flags = (byte) istream.read();
@@ -295,6 +309,7 @@ public class MessageHeader
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
@@ -302,26 +317,26 @@ public class MessageHeader
/**
* Get the short string summary of the message.
*
*
* @return a short message summary.
*/
public String toString()
{
return "GIOP " + version + ", " + (isBigEndian() ? "Big" : "Little") +
" endian, " + getTypeString(message_type) + ", " + message_size +
" bytes. ";
return "GIOP " + version + ", " + (isBigEndian() ? "Big" : "Little")
+ " endian, " + getTypeString(message_type) + ", " + message_size
+ " bytes. ";
}
/**
* Write the header to stream.
*
*
* @param out a stream to write into.
*/
public void write(java.io.OutputStream out)
{
try
{
abstractDataOutputStream dout;
AbstractDataOutput dout;
if (isBigEndian())
dout = new BigEndianOutputStream(out);
@@ -333,18 +348,99 @@ public class MessageHeader
// Write version number.
version.write((OutputStream) dout);
dout.write(flags);
dout.write(message_type);
dout.writeInt(message_size);
}
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
}
/**
* Read data, followed by the message header. Handle fragmented messages.
*
* @param source the data source to read from.
* @param service the socket on that the time outs are set. Can be null (no
* timeouts are set).
* @param to_read the timeout while reading the message.
* @param to_pause the timeout for pauses between the message parts.
*/
public byte[] readMessage(InputStream source, Socket service, int to_read,
int to_pause)
{
try
{
byte[] r = new byte[message_size];
int n = 0;
if (service != null)
service.setSoTimeout(to_read);
reading: while (n < r.length)
{
n += source.read(r, n, r.length - n);
}
if (service != null)
service.setSoTimeout(to_pause);
// Read the message remainder if the message is fragmented.
if (moreFragmentsFollow())
{
ByteArrayOutputStream buffer = new ByteArrayOutputStream(
2 * r.length);
buffer.write(r);
if (r.length < 10)
// Increase the buffer size if the default value (size of the
// previous message) is really too small.
r = new byte[1024];
MessageHeader h2 = new MessageHeader();
do
{
h2.read(source);
int dn;
n = 0;
reading: while (n < h2.message_size)
{
dn = source.read(r, 0, h2.message_size - n);
if (n == 0 && service != null)
service.setSoTimeout(to_read);
if (n == 0 && version.since_inclusive(1, 2))
{
// Skip the four byte request id.
buffer.write(r, 4, dn - 4);
}
else
buffer.write(r, 0, dn);
n = +dn;
}
if (service != null)
service.setSoTimeout(to_pause);
}
while (h2.moreFragmentsFollow());
return buffer.toByteArray();
}
else
return r;
}
catch (IOException ioex)
{
MARSHAL m = new MARSHAL("Unable to read the message continuation.");
m.minor = Minor.Header;
m.initCause(ioex);
throw m;
}
}
}
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
/**
* The header of the standard reply.
@@ -47,7 +47,7 @@ import gnu.CORBA.CDR.cdrOutput;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class ReplyHeader
extends contextSupportingHeader
extends ContextHandler
{
/**
* Reply status, if no exception occured.
@@ -121,7 +121,7 @@ public abstract class ReplyHeader
*
* @param in a stream to read from.
*/
public abstract void read(cdrInput in);
public abstract void read(AbstractCdrInput in);
/**
* Returns a short string representation.
@@ -141,5 +141,5 @@ public abstract class ReplyHeader
*
* @param out a stream to write into.
*/
public abstract void write(cdrOutput out);
public abstract void write(AbstractCdrOutput out);
}
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.portable.IDLEntity;
@@ -49,7 +49,7 @@ import org.omg.CORBA.portable.IDLEntity;
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public abstract class RequestHeader
extends contextSupportingHeader
extends ContextHandler
implements IDLEntity
{
/**
@@ -137,7 +137,7 @@ public abstract class RequestHeader
*
* @param in a stream to read from.
*/
public abstract void read(cdrInput in);
public abstract void read(AbstractCdrInput in);
/**
* Return a string representation.
@@ -149,6 +149,6 @@ public abstract class RequestHeader
*
* @param out a stream to write into.
*/
public abstract void write(cdrOutput out);
public abstract void write(AbstractCdrOutput out);
}
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA.GIOP;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
@@ -48,7 +48,7 @@ import org.omg.CORBA.portable.IDLEntity;
/**
* Contains the ORB service data being passed.
*
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ServiceContext
@@ -59,6 +59,50 @@ public class ServiceContext
*/
private static final long serialVersionUID = 1;
/* Standard values for the context_id. */
public static final int TransactionService = 0;
/**
* Defines code sets, used to encode wide and narrow characters. Required for
* messages with data structures, involving wide characters.
*/
public static final int CodeSets = 1;
public static final int ChainBypassCheck = 2;
public static final int ChainBypassInfo = 3;
public static final int LogicalThreadId = 4;
public static final int BI_DIR_IIOP = 5;
public static final int SendingContextRunTime = 6;
public static final int INVOCATION_POLICIES = 7;
public static final int FORWARDED_IDENTITY = 8;
/**
* Contains exception details if exception being transferred is other than
* System or User exception. javax.rmi uses this context to transfer arbitrary
* java exceptions as CORBA value types.
*/
public static final int UnknownExceptionInfo = 9;
public static final int RTCorbaPriority = 10;
public static final int RTCorbaPriorityRange = 11;
public static final int FT_GROUP_VERSION = 12;
public static final int FT_REQUEST = 13;
public static final int ExceptionDetailMessage = 14;
public static final int SecurityAttributeService = 15;
public static final int ActivityService = 16;
/**
* The context id (for instance, 0x1 for code sets context). At the moment of
* writing, the OMG defines 16 standard values and provides rules to register
@@ -90,18 +134,18 @@ public class ServiceContext
/**
* Read the context values from the stream.
*
*
* @param istream a stream to read from.
*/
public static ServiceContext read(cdrInput istream)
public static ServiceContext read(AbstractCdrInput istream)
{
int id = istream.read_ulong();
switch (id)
{
case cxCodeSet.ID:
case CodeSetServiceContext.ID:
cxCodeSet codeset = new cxCodeSet();
CodeSetServiceContext codeset = new CodeSetServiceContext();
codeset.readContext(istream);
return codeset;
@@ -117,7 +161,7 @@ public class ServiceContext
/**
* Read a sequence of contexts from the input stream.
*/
public static ServiceContext[] readSequence(cdrInput istream)
public static ServiceContext[] readSequence(AbstractCdrInput istream)
{
int size = istream.read_long();
ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[size];
@@ -128,10 +172,10 @@ public class ServiceContext
/**
* Write the context values into the stream.
*
*
* @param ostream a stream to write the data to.
*/
public void write(cdrOutput ostream)
public void write(AbstractCdrOutput ostream)
{
ostream.write_ulong(context_id);
ostream.write_sequence(context_data);
@@ -140,7 +184,7 @@ public class ServiceContext
/**
* Write the sequence of contexts into the input stream.
*/
public static void writeSequence(cdrOutput ostream, ServiceContext[] value)
public static void writeSequence(AbstractCdrOutput ostream, ServiceContext[] value)
{
ostream.write_long(value.length);
for (int i = 0; i < value.length; i++)
@@ -172,8 +216,7 @@ public class ServiceContext
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
+ service_context.context_id, 15,
CompletionStatus.COMPLETED_NO);
+ service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
else
cx[exists] = service_context;
}
@@ -205,15 +248,13 @@ public class ServiceContext
// Replace context.
if (!replace)
throw new BAD_INV_ORDER("Repetetive setting of the context "
+ service_context.context_id, 15,
CompletionStatus.COMPLETED_NO);
+ service_context.context_id, 15, CompletionStatus.COMPLETED_NO);
else
cx[exists] = new ServiceContext(service_context);
return cx;
}
}
/**
* Find context with the given name in the context array.
*/
@@ -227,8 +268,8 @@ public class ServiceContext
}
/**
* Find context with the given name in the context array,
* converting into org.omg.IOP.ServiceContext.
* Find context with the given name in the context array, converting into
* org.omg.IOP.ServiceContext.
*/
public static org.omg.IOP.ServiceContext findContext(int ctx_name,
ServiceContext[] cx)
@@ -239,6 +280,17 @@ public class ServiceContext
throw new BAD_PARAM("No context with id " + ctx_name);
}
/**
* Find context with the given name in the context array without conversions.
*/
public static ServiceContext find(int ctx_name, ServiceContext[] cx)
{
for (int i = 0; i < cx.length; i++)
if (cx[i].context_id == ctx_name)
return cx[i];
return null;
}
/**
* Return a string representation.
*/
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_0;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
import gnu.CORBA.GIOP.cxCodeSet;
import gnu.CORBA.GIOP.CodeSetServiceContext;
/**
* The header of the standard reply.
@@ -98,13 +98,13 @@ public class ReplyHeader
* @param in a stream to read from.
*/
public void read(cdrInput in)
public void read(AbstractCdrInput in)
{
service_context = ServiceContext.readSequence(in);
request_id = in.read_ulong();
reply_status = in.read_ulong();
in.setCodeSet(cxCodeSet.find(service_context));
in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -128,12 +128,12 @@ public class ReplyHeader
*
* @param out a stream to write into.
*/
public void write(cdrOutput out)
public void write(AbstractCdrOutput out)
{
ServiceContext.writeSequence(out, service_context);
out.write_ulong(request_id);
out.write_ulong(reply_status);
out.setCodeSet(cxCodeSet.find(service_context));
out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_0;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
import gnu.CORBA.GIOP.cxCodeSet;
import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.portable.IDLEntity;
@@ -112,7 +112,7 @@ public class RequestHeader
*
* @param in a stream to read from.
*/
public void read(cdrInput in)
public void read(AbstractCdrInput in)
{
service_context = ServiceContext.readSequence(in);
request_id = in.read_ulong();
@@ -121,7 +121,7 @@ public class RequestHeader
operation = in.read_string();
requesting_principal = in.read_sequence();
in.setCodeSet(cxCodeSet.find(service_context));
in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -143,7 +143,7 @@ public class RequestHeader
*
* @param out a stream to write into.
*/
public void write(cdrOutput out)
public void write(AbstractCdrOutput out)
{
ServiceContext.writeSequence(out, service_context);
out.write_ulong(request_id);
@@ -152,6 +152,6 @@ public class RequestHeader
out.write_string(operation);
out.write_sequence(requesting_principal);
out.setCodeSet(cxCodeSet.find(service_context));
out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
@@ -38,10 +38,10 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_2;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
import gnu.CORBA.GIOP.cxCodeSet;
import gnu.CORBA.GIOP.CodeSetServiceContext;
/**
* GIOP 1.2 reply header.
@@ -56,7 +56,7 @@ public class ReplyHeader
*/
public ReplyHeader()
{
service_context = new ServiceContext[] { cxCodeSet.STANDARD };
service_context = new ServiceContext[] { CodeSetServiceContext.STANDARD };
}
/**
@@ -89,13 +89,13 @@ public class ReplyHeader
*
* @param in a stream to read from.
*/
public void read(cdrInput in)
public void read(AbstractCdrInput in)
{
request_id = in.read_ulong();
reply_status = in.read_ulong();
service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
in.setCodeSet(cxCodeSet.find(service_context));
in.setCodeSet(CodeSetServiceContext.find(service_context));
}
/**
@@ -107,12 +107,12 @@ public class ReplyHeader
*
* @param out a stream to write into.
*/
public void write(cdrOutput out)
public void write(AbstractCdrOutput out)
{
out.write_ulong(request_id);
out.write_ulong(reply_status);
gnu.CORBA.GIOP.ServiceContext.writeSequence(out, service_context);
out.setCodeSet(cxCodeSet.find(service_context));
out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
@@ -38,10 +38,11 @@ exception statement from your version. */
package gnu.CORBA.GIOP.v1_2;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.Minor;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.ServiceContext;
import gnu.CORBA.GIOP.cxCodeSet;
import gnu.CORBA.GIOP.CodeSetServiceContext;
import java.io.IOException;
@@ -58,6 +59,11 @@ import org.omg.CORBA.NO_IMPLEMENT;
public class RequestHeader
extends gnu.CORBA.GIOP.v1_0.RequestHeader
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* Indicates that the object is addressed by the object key.
*/
@@ -89,7 +95,7 @@ public class RequestHeader
*/
public RequestHeader()
{
service_context = new ServiceContext[] { cxCodeSet.STANDARD };
service_context = new ServiceContext[] { CodeSetServiceContext.STANDARD };
}
/**
@@ -123,7 +129,7 @@ public class RequestHeader
*
* @param in a stream to read from.
*/
public void read(cdrInput in)
public void read(AbstractCdrInput in)
{
try
{
@@ -150,20 +156,23 @@ public class RequestHeader
throw new NO_IMPLEMENT("Object addressing by by IOR addressing info");
default :
throw new MARSHAL("Unknow addressing method in request, " +
MARSHAL m = new MARSHAL("Unknow addressing method in request, " +
AddressingDisposition
);
m.minor = Minor.UnsupportedAddressing;
throw m;
}
operation = in.read_string();
service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in);
// No requesting principal in this new format.
in.setCodeSet(cxCodeSet.find(service_context));
in.setCodeSet(CodeSetServiceContext.find(service_context));
}
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.Header;
t.initCause(ex);
throw t;
}
@@ -186,7 +195,7 @@ public class RequestHeader
*
* @param out a stream to write into.
*/
public void write(cdrOutput out)
public void write(AbstractCdrOutput out)
{
out.write_ulong(request_id);
@@ -208,6 +217,6 @@ public class RequestHeader
ServiceContext.writeSequence(out, service_context);
// No requesting principal in this new format.
out.setCodeSet(cxCodeSet.find(service_context));
out.setCodeSet(CodeSetServiceContext.find(service_context));
}
}
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.MARSHAL;
@@ -60,18 +60,18 @@ import java.io.IOException;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class universalHolder
public class GeneralHolder
implements Streamable
{
/**
* The binary data, stored inside this holder.
*/
private cdrBufOutput value = new cdrBufOutput();
private BufferedCdrOutput value = new BufferedCdrOutput();
/**
* Create the universal holder that uses the given buffer to store the data.
*/
public universalHolder(cdrBufOutput buffer)
public GeneralHolder(BufferedCdrOutput buffer)
{
value = buffer;
}
@@ -89,9 +89,9 @@ public class universalHolder
{
try
{
if (input instanceof cdrBufInput)
if (input instanceof BufferredCdrInput)
{
cdrBufInput b = (cdrBufInput) input;
BufferredCdrInput b = (BufferredCdrInput) input;
value.write(b.buffer.getBuffer());
}
else
@@ -110,6 +110,7 @@ public class universalHolder
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.Any;
t.initCause(ex);
throw t;
}
@@ -122,7 +123,9 @@ public class universalHolder
*/
public TypeCode _type()
{
throw new BAD_OPERATION();
BAD_OPERATION bad = new BAD_OPERATION();
bad.minor = Minor.Inappropriate;
throw bad;
}
/**
@@ -142,6 +145,7 @@ public class universalHolder
catch (IOException ex)
{
MARSHAL t = new MARSHAL();
t.minor = Minor.Any;
t.initCause(ex);
throw t;
}
@@ -158,13 +162,13 @@ public class universalHolder
/**
* Clone.
*/
public universalHolder Clone()
public GeneralHolder Clone()
{
try
{
cdrBufOutput nb = new cdrBufOutput(value.buffer.size());
BufferedCdrOutput nb = new BufferedCdrOutput(value.buffer.size());
value.buffer.writeTo(nb);
return new universalHolder(nb);
return new GeneralHolder(nb);
}
catch (IOException ex)
{
@@ -1,4 +1,4 @@
/* holderFactory.java --
/* HolderLocator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -75,7 +75,7 @@ import org.omg.CORBA.ObjectHolder;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class holderFactory
public class HolderLocator
{
/**
* The array, sufficiently large to use any {@link TCKind}._tk* constant as
+73 -23
View File
@@ -38,12 +38,12 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.cdrInput;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.GIOP.CharSets_OSF;
import gnu.CORBA.GIOP.cxCodeSet;
import gnu.CORBA.GIOP.CodeSetServiceContext;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
@@ -59,6 +59,8 @@ import org.omg.IOP.TaggedProfileHelper;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.zip.Adler32;
/**
* The implementaton of the Interoperable Object Reference (IOR). IOR can be
@@ -174,16 +176,16 @@ public class IOR
* The negotiated coding result for this IOR. Saves time, requred for
* negotiation computations.
*/
public cxCodeSet negotiated;
public CodeSetServiceContext negotiated;
/**
* Read the code set profile information from the given input stream.
*
* @param profile a stream to read from.
*/
public void read(cdrInput profile)
public void read(AbstractCdrInput profile)
{
cdrBufInput encapsulation = profile.read_encapsulation();
BufferredCdrInput encapsulation = profile.read_encapsulation();
narrow.read(encapsulation);
wide.read(encapsulation);
}
@@ -201,9 +203,9 @@ public class IOR
*
* @param profile a stream to write into.
*/
public void write(cdrOutput profile)
public void write(AbstractCdrOutput profile)
{
cdrOutput encapsulation = profile.createEncapsulation();
AbstractCdrOutput encapsulation = profile.createEncapsulation();
narrow.write(encapsulation);
wide.write(encapsulation);
try
@@ -274,13 +276,13 @@ public class IOR
/**
* Write the internet profile (except the heading tag.
*/
public void write(cdrOutput out)
public void write(AbstractCdrOutput out)
{
try
{
// Need to write the Internet profile into the separate
// stream as we must know the size in advance.
cdrOutput b = out.createEncapsulation();
AbstractCdrOutput b = out.createEncapsulation();
version.write(b);
b.write_string(host);
@@ -310,6 +312,7 @@ public class IOR
catch (Exception e)
{
MARSHAL m = new MARSHAL("Unable to write Internet profile.");
m.minor = Minor.IOR;
m.initCause(e);
throw m;
}
@@ -392,7 +395,7 @@ public class IOR
buf.write(cx);
}
cdrBufInput cdr = new cdrBufInput(buf.toByteArray());
BufferredCdrInput cdr = new BufferredCdrInput(buf.toByteArray());
r._read(cdr);
return r;
@@ -411,7 +414,7 @@ public class IOR
* @param c a stream to read from.
* @throws IOException if the stream throws it.
*/
public void _read(cdrInput c)
public void _read(AbstractCdrInput c)
throws IOException, BAD_PARAM
{
int endian;
@@ -433,13 +436,13 @@ public class IOR
* If the stream contains a null value, the Id and Internet fields become
* equal to null. Otherwise Id contains some string (possibly empty).
*
* Id is checked for null in cdrInput that then returns null instead of
* Id is checked for null in AbstractCdrInput that then returns null instead of
* object.
*
* @param c a stream to read from.
* @throws IOException if the stream throws it.
*/
public void _read_no_endian(cdrInput c)
public void _read_no_endian(AbstractCdrInput c)
throws IOException, BAD_PARAM
{
Id = c.read_string();
@@ -456,7 +459,7 @@ public class IOR
for (int i = 0; i < n_profiles; i++)
{
int tag = c.read_long();
cdrBufInput profile = c.read_encapsulation();
BufferredCdrInput profile = c.read_encapsulation();
if (tag == Internet_profile.TAG_INTERNET_IOP)
{
@@ -515,7 +518,7 @@ public class IOR
* Write this IOR record to the provided CDR stream. This procedure writes the
* zero (Big Endian) marker first.
*/
public void _write(cdrOutput out)
public void _write(AbstractCdrOutput out)
{
// Always use Big Endian.
out.write(0);
@@ -528,7 +531,7 @@ public class IOR
* The null value is written as defined in OMG specification (zero length
* string, followed by an empty set of profiles).
*/
public static void write_null(cdrOutput out)
public static void write_null(AbstractCdrOutput out)
{
// Empty Id string.
out.write_string("");
@@ -541,7 +544,7 @@ public class IOR
* Write this IOR record to the provided CDR stream. The procedure writed data
* in Big Endian, but does NOT add any endian marker to the beginning.
*/
public void _write_no_endian(cdrOutput out)
public void _write_no_endian(AbstractCdrOutput out)
{
// Write repository id.
out.write_string(Id);
@@ -595,7 +598,7 @@ public class IOR
*/
public String toStringifiedReference()
{
cdrBufOutput out = new cdrBufOutput();
BufferedCdrOutput out = new BufferedCdrOutput();
_write(out);
@@ -675,7 +678,7 @@ public class IOR
TaggedComponent[] present;
if (profile.profile_data.length > 0)
{
cdrBufInput in = new cdrBufInput(profile.profile_data);
BufferredCdrInput in = new BufferredCdrInput(profile.profile_data);
present = new TaggedComponent[in.read_long()];
@@ -687,7 +690,7 @@ public class IOR
else
present = new TaggedComponent[0];
cdrBufOutput out = new cdrBufOutput(profile.profile_data.length
BufferedCdrOutput out = new BufferedCdrOutput(profile.profile_data.length
+ component.component_data.length
+ 8);
@@ -715,4 +718,51 @@ public class IOR
// The future supported tagged profiles should be added here.
throw new BAD_PARAM("Unsupported profile type " + profile.tag);
}
/**
* Checks for equality.
*/
public boolean equals(Object x)
{
if (x instanceof IOR)
{
boolean keys;
boolean hosts = true;
IOR other = (IOR) x;
if (Internet==null || other.Internet==null)
return Internet == other.Internet;
if (key != null && other.key != null)
keys = Arrays.equals(key, other.key);
else
keys = key == other.key;
if (Internet != null && Internet.host != null)
if (other.Internet != null && other.Internet.host != null)
hosts = other.Internet.host.equals(Internet.host);
return keys & hosts && Internet.port==other.Internet.port;
}
else
return false;
}
/**
* Get the hashcode of this IOR.
*/
public int hashCode()
{
Adler32 adler = new Adler32();
if (key != null)
adler.update(key);
if (Internet != null)
{
if (Internet.host != null)
adler.update(Internet.host.getBytes());
adler.update(Internet.port);
}
return (int) adler.getValue();
}
}
@@ -38,16 +38,20 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
import org.omg.CORBA.OBJ_ADAPTER;
import org.omg.CORBA.OMGVMCID;
import org.omg.PortableInterceptor.IORInfo;
import org.omg.PortableInterceptor.IORInterceptor;
import org.omg.PortableInterceptor.IORInterceptorOperations;
import org.omg.PortableInterceptor.IORInterceptor_3_0Operations;
import org.omg.PortableInterceptor.ObjectReferenceTemplate;
/**
* A block of the all registered IOR interceptors.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class IORInterceptors implements IORInterceptorOperations
public class IORInterceptors implements IORInterceptor_3_0Operations
{
/**
* The array of all registered IOR interceptors.
@@ -106,4 +110,81 @@ public class IORInterceptors implements IORInterceptorOperations
{
return getClass().getName();
}
/**
* Call this method for all registered CORBA 3.0 interceptors.
*/
public void adapter_manager_state_changed(int adapterManagerId, short adapterState)
{
for (int i = 0; i < interceptors.length; i++)
{
try
{
if (interceptors[i] instanceof IORInterceptor_3_0Operations)
{
((IORInterceptor_3_0Operations) interceptors[i]).
adapter_manager_state_changed(adapterManagerId, adapterState);
}
}
catch (Exception exc)
{
OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed");
oa.initCause(exc);
oa.minor = 6 | OMGVMCID.value;
throw oa;
}
}
}
/**
* Call this method for all registered CORBA 3.0 interceptors.
*/
public void adapter_state_changed(ObjectReferenceTemplate[] adapters, short adaptersState)
{
for (int i = 0; i < interceptors.length; i++)
{
try
{
if (interceptors[i] instanceof IORInterceptor_3_0Operations)
{
((IORInterceptor_3_0Operations) interceptors[i]).
adapter_state_changed(adapters, adaptersState);
}
}
catch (Exception exc)
{
OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed");
oa.initCause(exc);
oa.minor = 6 | OMGVMCID.value;
throw oa;
}
}
}
/**
* Call this method for all registered CORBA 3.0 interceptors.
*
* @throws OBJ_ADAPTER minor 6 on any failure (as defined by OMG specs).
*/
public void components_established(IORInfo info)
{
for (int i = 0; i < interceptors.length; i++)
{
try
{
if (interceptors[i] instanceof IORInterceptor_3_0Operations)
{
((IORInterceptor_3_0Operations) interceptors[i]).
components_established(info);
}
}
catch (Exception exc)
{
OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed");
oa.initCause(exc);
oa.minor = 6 | OMGVMCID.value;
throw oa;
}
}
}
}
@@ -39,6 +39,7 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
import gnu.CORBA.Poa.ORB_1_4;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.gnuCodecFactory;
import org.omg.CORBA.BAD_INV_ORDER;
@@ -87,7 +88,7 @@ public class Registrator extends LocalObject implements ORBInitInfo
/**
* The agreed properties prefix.
*/
public final static String m_prefix =
public static final String m_prefix =
"org.omg.PortableInterceptor.ORBInitializerClass.";
/**
@@ -182,7 +183,8 @@ public class Registrator extends LocalObject implements ORBInitInfo
try
{
String cn = sk.substring(m_prefix.length());
Class iClass = Class.forName(cn);
Class iClass = ObjectCreator.forName(cn);
ORBInitializer initializer =
(ORBInitializer) iClass.newInstance();
m_initializers.add(initializer);
@@ -467,4 +469,4 @@ public class Registrator extends LocalObject implements ORBInitInfo
{
return m_ior.size() > 0;
}
}
}
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.Interceptor;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.Poa.ORB_1_4;
import org.omg.CORBA.Any;
@@ -198,7 +198,7 @@ public class gnuIcCurrent extends ObjectImpl implements Current
Any[] r = get_slots();
Any[] copy = new Any[ r.length ];
cdrBufOutput buf = new cdrBufOutput();
BufferedCdrOutput buf = new BufferedCdrOutput();
buf.setOrb(orb);
for (int i = 0; i < copy.length; i++)
@@ -40,12 +40,14 @@ package gnu.CORBA.Interceptor;
import gnu.CORBA.IOR;
import gnu.CORBA.Poa.ORB_1_4;
import gnu.CORBA.Poa.gnuPOA;
import org.omg.CORBA.LocalObject;
import org.omg.CORBA.Policy;
import org.omg.IOP.TaggedComponent;
import org.omg.PortableInterceptor.IORInfo;
import org.omg.PortableServer.POA;
import org.omg.PortableInterceptor.ObjectReferenceFactory;
import org.omg.PortableInterceptor.ObjectReferenceTemplate;
/**
* Implements IORInfo.
@@ -67,7 +69,7 @@ public class gnuIorInfo extends LocalObject implements IORInfo
/**
* The POA, to that IOR is related.
*/
public final POA poa;
public final gnuPOA poa;
/**
* The IOR itself.
@@ -77,7 +79,7 @@ public class gnuIorInfo extends LocalObject implements IORInfo
/**
* Create an instance.
*/
public gnuIorInfo(ORB_1_4 an_orb, POA a_poa, IOR an_ior)
public gnuIorInfo(ORB_1_4 an_orb, gnuPOA a_poa, IOR an_ior)
{
orb = an_orb;
poa = a_poa;
@@ -113,8 +115,42 @@ public class gnuIorInfo extends LocalObject implements IORInfo
/**
* Return the state of the object POA.
*/
short state()
public short state()
{
return (short) poa.the_POAManager().get_state().value();
}
/**
* Get the adapter template, associated with this poa.
*/
public ObjectReferenceTemplate adapter_template()
{
return poa.getReferenceTemplate();
}
/**
* Get the object factory of the current POA.
*/
public ObjectReferenceFactory current_factory()
{
return poa.getReferenceFactory();
}
/**
* Set the object factory of the current POA.
*/
public void current_factory(ObjectReferenceFactory factory)
{
poa.setReferenceFactory(factory);
}
/**
* The method currently uses system identity hashcode that should be
* different for each object.
*/
public int manager_id()
{
// The System.identityHashCode is also called in gnuPoaManager.
return System.identityHashCode(poa.the_POAManager());
}
}
@@ -42,6 +42,7 @@ import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.GIOP.RequestHeader;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Poa.gnuServantObject;
import gnu.CORBA.OrbFunctional;
import gnu.CORBA.Unexpected;
import gnu.CORBA.gnuRequest;
@@ -453,4 +454,23 @@ public class gnuServerRequestInfo extends LocalObject
}
return p;
}
/** @inheritDoc */
public String[] adapter_name()
{
return m_object.poa.getReferenceTemplate().adapter_name();
}
/** @inheritDoc */
public String orb_id()
{
return m_object.orb.orb_id;
}
/** @inheritDoc */
public String server_id()
{
return OrbFunctional.server_id;
}
}
@@ -38,9 +38,8 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.Poa.activeObjectMap;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.Context;
@@ -70,23 +69,12 @@ import java.net.Socket;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class IOR_Delegate extends Simple_delegate
public class IorDelegate extends SimpleDelegate
{
/**
* True if the current IOR does not map into the local servant. If false, the
* IOR is either local or should be checked.
*/
boolean remote_ior;
/**
* If not null, this field contains data about the local servant.
*/
activeObjectMap.Obj local_ior;
/**
* Contructs an instance of object using the given IOR.
*/
public IOR_Delegate(ORB an_orb, IOR an_ior)
public IorDelegate(ORB an_orb, IOR an_ior)
{
super(an_orb, an_ior);
}
@@ -168,37 +156,36 @@ public class IOR_Delegate extends Simple_delegate
* request to the new direction. The ReplyHeader.LOCATION_FORWARD_PERM will
* cause additionally to remember the new location by this delegate, so
* subsequent calls will be immediately delivered to the new target.
*
*
* @param target the target object.
* @param output the output stream, previously returned by
* {@link #request(org.omg.CORBA.Object, String, boolean)}.
*
*
* @return the input stream, to read the response from or null for a one-way
* request.
*
*
* @throws SystemException if the SystemException has been thrown on the
* remote side (the exact type and the minor code matches the data of the
* remote exception that has been thrown).
*
*
* @throws org.omg.CORBA.portable.ApplicationException as specified.
* @throws org.omg.CORBA.portable.RemarshalException as specified.
*/
public InputStream invoke(org.omg.CORBA.Object target, OutputStream output)
throws ApplicationException, RemarshalException
{
streamRequest request = (streamRequest) output;
Forwardings:
while (true)
StreamBasedRequest request = (StreamBasedRequest) output;
Forwardings: while (true)
{
try
{
if (request.response_expected)
{
binaryReply response = request.request.submit();
RawReply response = request.request.submit();
// Read reply header.
ReplyHeader rh = response.header.create_reply_header();
cdrBufInput input = response.getStream();
BufferredCdrInput input = response.getStream();
input.setOrb(orb);
rh.read(input);
request.request.m_rph = rh;
@@ -207,34 +194,33 @@ public class IOR_Delegate extends Simple_delegate
switch (rh.reply_status)
{
case ReplyHeader.NO_EXCEPTION :
case ReplyHeader.NO_EXCEPTION:
if (request.request.m_interceptor != null)
request.request.m_interceptor.
receive_reply(request.request.m_info);
request.request.m_interceptor.receive_reply(request.request.m_info);
if (response.header.version.since_inclusive(1, 2))
input.align(8);
return input;
case ReplyHeader.SYSTEM_EXCEPTION :
case ReplyHeader.SYSTEM_EXCEPTION:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
throw ObjectCreator.readSystemException(input);
throw ObjectCreator.readSystemException(input,
rh.service_context);
case ReplyHeader.USER_EXCEPTION :
case ReplyHeader.USER_EXCEPTION:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
showException(request, input);
throw new ApplicationException(request.
request.m_exception_id, input
);
throw new ApplicationException(
request.request.m_exception_id, input);
case ReplyHeader.LOCATION_FORWARD_PERM :
case ReplyHeader.LOCATION_FORWARD_PERM:
moved_permanently = true;
case ReplyHeader.LOCATION_FORWARD :
case ReplyHeader.LOCATION_FORWARD:
if (response.header.version.since_inclusive(1, 2))
input.align(8);
@@ -245,10 +231,8 @@ public class IOR_Delegate extends Simple_delegate
}
catch (IOException ex)
{
MARSHAL t =
new MARSHAL("Cant read forwarding info", 5102,
CompletionStatus.COMPLETED_NO
);
MARSHAL t = new MARSHAL("Cant read forwarding info",
5102, CompletionStatus.COMPLETED_NO);
t.initCause(ex);
throw t;
}
@@ -277,8 +261,8 @@ public class IOR_Delegate extends Simple_delegate
r.setIor(forwarded);
IOR_contructed_object it =
new IOR_contructed_object(orb, forwarded);
IorObject it = new IorObject(orb,
forwarded);
r.m_target = it;
@@ -298,11 +282,10 @@ public class IOR_Delegate extends Simple_delegate
setIor(prev_ior);
}
default :
throw new MARSHAL("Unknow reply status: " +
rh.reply_status, 8000 + rh.reply_status,
CompletionStatus.COMPLETED_NO
);
default:
throw new MARSHAL("Unknow reply status: "
+ rh.reply_status, 8000 + rh.reply_status,
CompletionStatus.COMPLETED_NO);
}
}
else
@@ -314,8 +297,7 @@ public class IOR_Delegate extends Simple_delegate
catch (ForwardRequest forwarded)
{
ForwardRequest fw = forwarded;
Forwarding2:
while (true)
Forwarding2: while (true)
{
try
{
@@ -356,7 +338,7 @@ public class IOR_Delegate extends Simple_delegate
/**
* Show exception to interceptor.
*/
void showException(streamRequest request, cdrBufInput input)
void showException(StreamBasedRequest request, BufferredCdrInput input)
throws ForwardRequest
{
input.mark(2048);
@@ -408,9 +390,10 @@ public class IOR_Delegate extends Simple_delegate
request.set_target(target);
request.setOperation(operation);
streamRequest out = request.getParameterStream();
StreamBasedRequest out = request.getParameterStream();
out.response_expected = response_expected;
request.setORB(orb);
out.setOrb(orb);
return out;
}
@@ -447,8 +430,6 @@ public class IOR_Delegate extends Simple_delegate
public void setIor(IOR an_ior)
{
super.setIor(an_ior);
remote_ior = false;
local_ior = null;
}
/**
@@ -456,11 +437,6 @@ public class IOR_Delegate extends Simple_delegate
*/
public boolean is_local(org.omg.CORBA.Object self)
{
if (remote_ior)
return false;
else if (local_ior != null)
return true;
else
return super.is_local(self);
return false;
}
}
@@ -1,4 +1,4 @@
/* IOR_contructed_object.java --
/* IorObject.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,8 +46,9 @@ import org.omg.CORBA.portable.ObjectImpl;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class IOR_contructed_object
public class IorObject
extends ObjectImpl
implements IorProvider
{
/**
* The IOR, from which the object was constructed.
@@ -64,10 +65,10 @@ public class IOR_contructed_object
*
* @param an_ior the IOR.
*/
public IOR_contructed_object(ORB orb, IOR an_ior)
public IorObject(ORB orb, IOR an_ior)
{
ior = an_ior;
_set_delegate(new IOR_Delegate(orb, ior));
_set_delegate(new IorDelegate(orb, ior));
id = new String[] { ior.Id };
}
@@ -76,12 +77,20 @@ public class IOR_contructed_object
*
* @param an_ior the IOR in the string form.
*/
public IOR_contructed_object(Functional_ORB orb, String an_ior)
public IorObject(OrbFunctional orb, String an_ior)
{
ior = IOR.parse(an_ior);
_set_delegate(new IOR_Delegate(orb, ior));
_set_delegate(new IorDelegate(orb, ior));
id = new String[] { ior.Id };
}
/**
* Get the IOR of this object.
*/
public IOR getIor()
{
return ior;
}
public String[] _ids()
{
@@ -0,0 +1,52 @@
/* IorProvider.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA;
/**
* Marks the possibility of the implementing object to return the associated
* IOR.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public interface IorProvider
{
/**
* Get the IOR of the associated object.
*/
IOR getIor();
}
+282
View File
@@ -0,0 +1,282 @@
/* Minor.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA;
/**
* Provides information and operations, related to about the 20 bit vendor minor
* code Id. This code is included into all CORBA system exceptions and is also
* transferred to remote side.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public interface Minor
{
// Note: MARSHAL done.
/* MARSHAL */
/**
* The GNU Classpath VMCID. The last 12 bits can be used to mark up to 4096
* possible exceptions.
*/
int vendor = 0x47430000;
/*
* Minor codes form MARSHAL exception.
*/
/**
* The message being received is not a GIOP message. It does not start from
* the expected magic sequence byte[] { 'G', 'I', 'O', 'P' }.
*/
int Giop = 1 | vendor;
/**
* The unexpected IOException while reading or writing the GIOP message header
* or the subsequent request or response header
*/
int Header = 2 | vendor;
/**
* The data stream ended before reading all expected values from it. This
* usually means that the CORBA message is corrupted, but may also indicate
* that the server expects the remote method being invoked to have more or
* different parameters.
*/
int EOF = 3 | vendor;
/**
* The unexpected IOException while reading or writing the data via Commond
* Data Representation stream.
*/
int CDR = 5 | vendor;
/**
* The unexpected IOException while reading or writing the Value type.
*/
int Value = 6 | vendor;
/**
* The unexpected IOException while handling request forwarding.
*/
int Forwarding = 7 | vendor;
/**
* The unexpected IOException while handling data encapsulation, tagged
* components, tagged profiles, etc.
*/
int Encapsulation = 8 | vendor;
/**
* The unexpected IOException while inserting or extracting data to/from the
* Any or DynamicAny.
*/
int Any = 9 | vendor;
/**
* The unexpected UserException in the context where it cannot be handled and
* must be converted to the SystemException.
*/
int UserException = 10 | vendor;
/**
* While the operation could formally be applied to the target, the OMG
* standard states that it is actually not applicable. For example, some CORBA
* objects like POA are always local and should not be passed to or returned
* from the remote side.
*/
int Inappropriate = 11 | vendor;
/**
* When reading data, it was discovered that size of the data structure like
* string, sequence or character is written as the negative number.
*/
int Negative = 12 | vendor;
/**
* Reference to non-existing node in the data grapth while reading the value
* types.
*/
int Graph = 14 | vendor;
/**
* Unexpected exception was thrown from the IDL type helper while handling the
* object of this type as a boxed value.
*/
int Boxed = 15 | vendor;
/**
* Unable to instantiate an value type object while reading it from the
* stream.
*/
int Instantiation = 16 | vendor;
/**
* The header tag of the value type being read from the CDR stream contains an
* unexpected value outside 0x7fffff00 .. 0x7fffffff and also not null and not
* an indirection.
*/
int ValueHeaderTag = 17 | vendor;
/**
* The header tag flags of the value type being read from the CDR stream make
* the invalid combination (for instance, 0x7fffff04).
*/
int ValueHeaderFlags = 18 | vendor;
/**
* The value type class, written on the wire, is not compatible with the
* expected class, passed as a parameter to the InputStream.read_value.
*/
int ClassCast = 19 | vendor;
/**
* Positive or otherwise invalid indirection offset when reading the data
* graph of the value type.
*/
int Offset = 20 | vendor;
/**
* Errors while reading the chunked value type.
*/
int Chunks = 21 | vendor;
/**
* No means are provided to write this value type.
*/
int UnsupportedValue = 22 | vendor;
/**
* The value factory, required for the operation being invoked, is not
* registered with this ORB.
*/
int Factory = 23 | vendor;
/**
* Unsupported object addressing method in GIOP request header.
*/
int UnsupportedAddressing = 24 | vendor;
/**
* Invalid stringified object reference (IOR).
*/
int IOR = 25 | vendor;
/**
* Problems with converting between stubs, ties, interfaces and
* implementations.
*/
int TargetConversion = 26 | vendor;
/**
* Problems with reading or writing the fields of the value type object.
*/
int ValueFields = 27 | vendor;
/**
* The instance of the value type is not serializable.
*/
int NonSerializable = 28 | vendor;
/* BAD_OPERATION */
/**
* The remote side requested to invoke the method that is not available on
* that target (client and server probably disagree in the object definition).
*/
int Method = 0 | vendor;
/**
* Failed to activate the inactive object.
*/
int Activation = 10 | vendor;
/*
* Any - Attempt to extract from the Any value of the different type that was
* stored into that Any.
*/
/* ClassCast - Unable to narrow the object into stub. */
/**
* The policies, applying to ORB or POA prevent the requested operation.
*/
int Policy = 11 | vendor;
/**
* Socket related errors like failure to open socket on the expected port,
* failure to get a free port when required and so on.
*/
int Socket = 12 | vendor;
/**
* The passed value for enumeration is outside the valid range for that
* enumeration.
*/
int Enumeration = 14 | vendor;
/**
* The passed policy code is outside the valid range of the possible policies
* for the given policy type.
*/
int PolicyType = 15 | vendor;
/* NO_RESOURCES */
/**
* Unable to get a free port for a new socket. Proably too many objects under
* unsuitable POA policy.
*/
int Ports = 20 | vendor;
/**
* Too many parallel calls (too many parallel threads). The thread control
* prevents malicios client from knocking the server out by suddenly
* submitting large number of requests.
*/
int Threads = 21 | vendor;
/**
* The IOR starts with file://, http:// or ftp://, but this local or remote
* resource is not accessible.
*/
int Missing_IOR = 22 | vendor;
}
@@ -73,7 +73,7 @@ public class Ext
* The converter class converts between string and array form of the
* name.
*/
private snConverter converter = new snConverter();
private NameTransformer converter = new NameTransformer();
/**
* Create the extensions for the given instance of the context.
@@ -1,4 +1,4 @@
/* cmpNameComponent.java --
/* NameComponentComparator.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -49,18 +49,18 @@ import java.util.Comparator;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public final class cmpNameComponent
public final class NameComponentComparator
implements Comparator
{
/**
* The singleton instance of the name comparator.
*/
public static final cmpNameComponent singleton = new cmpNameComponent();
public static final NameComponentComparator singleton = new NameComponentComparator();
/**
* It is enough to have a singleton.
*/
private cmpNameComponent()
private NameComponentComparator()
{
}
@@ -93,6 +93,6 @@ public final class cmpNameComponent
*/
public boolean equals(Object x)
{
return x instanceof cmpNameComponent;
return x instanceof NameComponentComparator;
}
}
@@ -1,44 +1,45 @@
/* NameParser.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.NamingService;
import gnu.CORBA.Functional_ORB;
import gnu.CORBA.Minor;
import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.Unexpected;
import gnu.CORBA.Version;
@@ -51,11 +52,15 @@ import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CosNaming.NamingContext;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.CosNaming.NamingContextHelper;
import org.omg.CosNaming._NamingContextStub;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.StringTokenizer;
@@ -74,7 +79,7 @@ import java.util.StringTokenizer;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class NameParser
extends snConverter
extends NameTransformer
{
/**
* The corbaloc prefix.
@@ -90,6 +95,21 @@ public class NameParser
* The IOR prefix.
*/
public static final String pxIOR = "ior";
/**
* The file:// prefix.
*/
public static final String pxFILE = "file://";
/**
* The ftp:// prefix.
*/
public static final String pxFTP = "ftp://";
/**
* The http:// prefix.
*/
public static final String pxHTTP = "http://";
/**
* Marks iiop protocol.
@@ -114,7 +134,7 @@ public class NameParser
/**
* The string to name converter, initialized on demand.
*/
static snConverter converter;
static NameTransformer converter;
/**
* The current position.
@@ -134,6 +154,9 @@ public class NameParser
* 2. corbaloc:rir:[/key] <br>
* 3. corbaname:[iiop][version.subversion@]:host[:port]/key <br>
* 4. corbaname:rir:[/key] <br>
* 5. file://[file name]<br>
* 6. http://[url]<br>
* 7. ftp://[url]<br>
*
* Protocol defaults to IOP, the object key defaults to the NameService.
*
@@ -143,9 +166,31 @@ public class NameParser
* @return the resolved object.
*/
public synchronized org.omg.CORBA.Object corbaloc(String corbaloc,
Functional_ORB orb)
OrbFunctional orb)
throws BAD_PARAM
{
return corbaloc(corbaloc, orb, 0);
}
/**
* Parse controlling against the infinite recursion loop.
*/
private org.omg.CORBA.Object corbaloc(String corbaloc,
OrbFunctional orb, int recursion)
{
// The used CORBA specification does not state how many times we should to
//redirect, but the infinite loop may be used to knock out the system.
// by malicious attempt.
if (recursion > 10)
throw new DATA_CONVERSION("More than 10 redirections");
if (corbaloc.startsWith(pxFILE))
return corbaloc(readFile(corbaloc.substring(pxFILE.length())), orb, recursion+1);
else if (corbaloc.startsWith(pxHTTP))
return corbaloc(readUrl(corbaloc), orb, recursion+1);
else if (corbaloc.startsWith(pxFTP))
return corbaloc(readUrl(corbaloc), orb, recursion+1);
boolean corbaname;
// The alternative addresses, if given.
@@ -304,6 +349,70 @@ public class NameParser
else
throw new DATA_CONVERSION("Unsupported protocol '" + t[p] + "'");
}
/**
* Read IOR from the file in the local file system.
*/
String readFile(String file)
{
File f = new File(file);
if (!f.exists())
{
DATA_CONVERSION err = new DATA_CONVERSION(f.getAbsolutePath()
+ " does not exist.");
err.minor = Minor.Missing_IOR;
}
try
{
char[] c = new char[(int) f.length()];
FileReader fr = new FileReader(f);
fr.read(c);
fr.close();
return new String(c).trim();
}
catch (IOException ex)
{
DATA_CONVERSION d = new DATA_CONVERSION();
d.initCause(ex);
d.minor = Minor.Missing_IOR;
throw (d);
}
}
/**
* Read IOR from the remote URL.
*/
String readUrl(String url)
{
URL u;
try
{
u = new URL(url);
}
catch (MalformedURLException mex)
{
throw new BAD_PARAM("Malformed URL: '" + url + "'");
}
try
{
InputStreamReader r = new InputStreamReader(u.openStream());
StringBuffer b = new StringBuffer();
int c;
while ((c = r.read()) > 0)
b.append((char) c);
return b.toString().trim();
}
catch (Exception exc)
{
DATA_CONVERSION d = new DATA_CONVERSION("Reading " + url + " failed.");
d.minor = Minor.Missing_IOR;
throw d;
}
}
private org.omg.CORBA.Object resolve(org.omg.CORBA.Object object)
{
@@ -329,7 +438,7 @@ public class NameParser
}
if (converter == null)
converter = new snConverter();
converter = new NameTransformer();
try
{
@@ -380,7 +489,7 @@ public class NameParser
static NameParser n = new NameParser();
static void corbalocT(String ior, Functional_ORB orb)
static void corbalocT(String ior, OrbFunctional orb)
{
System.out.println(ior);
System.out.println(n.corbaloc(ior, orb));
@@ -391,7 +500,7 @@ public class NameParser
{
try
{
Functional_ORB orb = (Functional_ORB) ORB.init(args, null);
OrbFunctional orb = (OrbFunctional) ORB.init(args, null);
corbalocT("corbaloc:iiop:1.3@155axyz.com/Prod/aTradingService", orb);
corbalocT("corbaloc:iiop:2.7@255bxyz.com/Prod/bTradingService", orb);
corbalocT("corbaloc:iiop:355cxyz.com/Prod/cTradingService", orb);
@@ -1,4 +1,4 @@
/* snConverter.java --
/* NameTransformer.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,7 +51,7 @@ import java.util.StringTokenizer;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class snConverter
public class NameTransformer
{
/**
* A string, indicating the escape character.
@@ -301,7 +301,7 @@ public class snConverter
NameComponent b = new NameComponent("b/z", "b.k");
NameComponent c = new NameComponent("c", "");
snConverter sn = new snConverter();
NameTransformer sn = new NameTransformer();
try
{
@@ -66,7 +66,7 @@ public class NamingMap
*/
public NamingMap()
{
map = new TreeMap(cmpNameComponent.singleton);
map = new TreeMap(NameComponentComparator.singleton);
}
/**
@@ -1,4 +1,4 @@
/* Server.java --
/* NamingServiceTransient.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.NamingService;
import gnu.CORBA.Functional_ORB;
import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import org.omg.CosNaming.NamingContextExt;
@@ -102,7 +102,7 @@ public class NamingServiceTransient
try
{
// Create and initialize the ORB
final Functional_ORB orb = new Functional_ORB();
final OrbFunctional orb = new OrbFunctional();
if (args.length > 1)
for (int i = 0; i < args.length - 1; i++)
@@ -114,7 +114,7 @@ public class NamingServiceTransient
iorf = args[i + 1];
}
Functional_ORB.setPort(port);
OrbFunctional.setPort(port);
// Create the servant and register it with the ORB
NamingContextExt namer = new Ext(new TransientContext());
@@ -159,6 +159,6 @@ public class NamingServiceTransient
// Restore the default value for allocating ports for the subsequent
// objects.
Functional_ORB.setPort(Functional_ORB.DEFAULT_INITIAL_PORT);
OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
}
}
+270 -127
View File
@@ -38,27 +38,37 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.UnknownExceptionCtxHandler;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.CDR.AbstractCdrInput;
import gnu.CORBA.GIOP.ServiceContext;
import gnu.CORBA.typecodes.RecordTypeCode;
import gnu.classpath.VMStackWalker;
import org.omg.CORBA.Any;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.CompletionStatusHelper;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.UserException;
import org.omg.CORBA.portable.IDLEntity;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ValueBase;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.WeakHashMap;
import javax.rmi.CORBA.Util;
/**
* Creates java objects from the agreed IDL names for the simple case when the
* CORBA object is directly mapped into the locally defined java class.
*
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class ObjectCreator
@@ -78,92 +88,138 @@ public class ObjectCreator
*/
public static final String CLASSPATH_PREFIX = "gnu.CORBA.";
/**
* Maps classes to they IDL or RMI names. Computing RMI name is an expensive
* operations, so frequently used RMI keys are reused. The map must be weak to
* ensure that the class can be unloaded, when applicable.
*/
public static Map m_names = new WeakHashMap();
/**
* Maps IDL strings into known classes. The map must be weak to ensure that
* the class can be unloaded, when applicable.
*/
public static Map m_classes = new WeakHashMap();
/**
* Maps IDL types to they helpers.
*/
public static Map m_helpers = new WeakHashMap();
/**
* Try to instantiate an object with the given IDL name. The object must be
* mapped to the local java class. The omg.org domain must be mapped into the
* object in either org/omg or gnu/CORBA namespace.
*
*
* @param IDL name
* @return instantiated object instance or null if no such available.
*/
public static java.lang.Object createObject(String idl, String suffix)
{
try
synchronized (m_classes)
{
return Class.forName(toClassName(JAVA_PREFIX, idl) + suffix)
.newInstance();
}
catch (Exception ex)
{
try
Class known = (Class) (suffix == null ? m_classes.get(idl)
: m_classes.get(idl + 0xff + suffix));
Object object;
if (known != null)
{
return Class.forName(toClassName(CLASSPATH_PREFIX, idl) + suffix)
.newInstance();
try
{
return known.newInstance();
}
catch (Exception ex)
{
RuntimeException rex = new RuntimeException(idl + " suffix "
+ suffix, ex);
throw rex;
}
}
catch (Exception exex)
else
{
return null;
if (suffix == null)
suffix = "";
try
{
known = forName(toClassName(JAVA_PREFIX, idl) + suffix);
object = known.newInstance();
}
catch (Exception ex)
{
try
{
known = forName(toClassName(CLASSPATH_PREFIX, idl)
+ suffix);
object = known.newInstance();
}
catch (Exception exex)
{
return null;
}
}
m_classes.put(idl + 0xff + suffix, known);
return object;
}
}
}
/**
* Create the system exception with the given idl name.
*
* @param idl the exception IDL name, must match the syntax "IDL:<class/name>:1.0".
* @param minor the exception minor code.
* @param completed the exception completion status.
*
* @return the created exception.
*/
public static SystemException createSystemException(String idl, int minor,
CompletionStatus completed
)
{
try
{
String cl = toClassName(JAVA_PREFIX, idl);
Class exClass = Class.forName(cl);
Constructor constructor =
exClass.getConstructor(new Class[]
{
String.class, int.class, CompletionStatus.class
}
);
Object exception =
constructor.newInstance(new Object[]
{
" Remote exception " + idl + ", minor " + minor + ", " +
completed + ".", new Integer(minor), completed
}
);
return (SystemException) exception;
}
catch (Exception ex)
{
ex.printStackTrace();
return new UNKNOWN("Unsupported system exception", minor, completed);
}
}
/**
* Read the system exception from the given stream.
*
*
* @param input the CDR stream to read from.
* @param contexts the service contexts in request/reply header/
*
* @return the exception that has been stored in the stream (IDL name, minor
* code and completion status).
*/
public static SystemException readSystemException(InputStream input)
public static SystemException readSystemException(InputStream input,
ServiceContext[] contexts)
{
SystemException exception;
String idl = input.read_string();
int minor = input.read_ulong();
CompletionStatus status = CompletionStatusHelper.read(input);
CompletionStatus completed = CompletionStatusHelper.read(input);
SystemException exception =
ObjectCreator.createSystemException(idl, minor, status);
try
{
exception = (SystemException) createObject(idl, null);
exception.minor = minor;
exception.completed = completed;
}
catch (Exception ex)
{
UNKNOWN u = new UNKNOWN("Unsupported system exception " + idl, minor,
completed);
u.initCause(ex);
throw u;
}
try
{
// If UnknownExceptionInfo is present in the contexts, read it and
// set as a cause of this exception.
ServiceContext uEx = ServiceContext.find(
ServiceContext.UnknownExceptionInfo, contexts);
if (uEx != null)
{
BufferredCdrInput in = new BufferredCdrInput(uEx.context_data);
in.setOrb(in.orb());
if (input instanceof AbstractCdrInput)
{
((AbstractCdrInput) input).cloneSettings(in);
}
Throwable t = UnknownExceptionCtxHandler.read(in, contexts);
exception.initCause(t);
}
}
catch (Exception ex)
{
// Unsupported context format. Do not terminate as the user program may
// not need it.
}
return exception;
}
@@ -172,10 +228,10 @@ public class ObjectCreator
* Reads the user exception, having the given Id, from the input stream. The
* id is expected to be in the form like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
*
*
* @param idl the exception idl name.
* @param input the stream to read from.
*
*
* @return the loaded exception.
* @return null if the helper class cannot be found.
*/
@@ -183,13 +239,10 @@ public class ObjectCreator
{
try
{
String helper = toHelperName(idl);
Class helperClass = Class.forName(helper);
Class helperClass = findHelper(idl);
Method read =
helperClass.getMethod("read",
new Class[] { org.omg.CORBA.portable.InputStream.class }
);
Method read = helperClass.getMethod("read",
new Class[] { org.omg.CORBA.portable.InputStream.class });
return (UserException) read.invoke(null, new Object[] { input });
}
@@ -208,7 +261,7 @@ public class ObjectCreator
/**
* Gets the helper class name from the string like
* 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0'
*
*
* @param IDL the idl name.
*/
public static String toHelperName(String IDL)
@@ -227,15 +280,14 @@ public class ObjectCreator
/**
* Writes the system exception data to CDR output stream.
*
*
* @param output a stream to write data to.
* @param ex an exception to write.
*/
public static void writeSystemException(OutputStream output,
SystemException ex
)
SystemException ex)
{
String exIDL = toIDL(ex.getClass().getName());
String exIDL = getRepositoryId(ex.getClass());
output.write_string(exIDL);
output.write_ulong(ex.minor);
CompletionStatusHelper.write(output, ex.completed);
@@ -243,9 +295,9 @@ public class ObjectCreator
/**
* Converts the given IDL name to class name.
*
*
* @param IDL the idl name.
*
*
*/
protected static String toClassName(String prefix, String IDL)
{
@@ -265,34 +317,43 @@ public class ObjectCreator
* Converts the given IDL name to class name and tries to load the matching
* class. The OMG prefix (omg.org) is replaced by the java prefix org.omg. No
* other prefixes are added.
*
*
* @param IDL the idl name.
*
* TODO Cache the returned classes, avoiding these string manipulations each
* time the conversion is required.
*
*
* @return the matching class or null if no such is available.
*/
public static Class Idl2class(String IDL)
{
String s = IDL;
int a = s.indexOf(':') + 1;
int b = s.lastIndexOf(':');
s = IDL.substring(a, b);
if (s.startsWith(OMG_PREFIX))
s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
String cn = s.replace('/', '.');
try
synchronized (m_classes)
{
return Class.forName(cn);
}
catch (ClassNotFoundException ex)
{
return null;
Class c = (Class) m_classes.get(IDL);
if (c != null)
return c;
else
{
String s = IDL;
int a = s.indexOf(':') + 1;
int b = s.lastIndexOf(':');
s = IDL.substring(a, b);
if (s.startsWith(OMG_PREFIX))
s = JAVA_PREFIX + s.substring(OMG_PREFIX.length());
String cn = s.replace('/', '.');
try
{
c = forName(cn);
m_classes.put(IDL, c);
return c;
}
catch (ClassNotFoundException ex)
{
return null;
}
}
}
}
@@ -301,9 +362,9 @@ public class ObjectCreator
* and create an object instance with parameterless constructor. The OMG
* prefix (omg.org) is replaced by the java prefix org.omg. No other prefixes
* are added.
*
*
* @param IDL the idl name.
*
*
* @return instantiated object instance or null if such attempt was not
* successful.
*/
@@ -325,34 +386,53 @@ public class ObjectCreator
}
/**
* Convert the class name to IDL name.
*
* @param cn the class name.
*
* @return the idl name.
* Convert the class name to IDL or RMI name (repository id). If the class
* inherits from IDLEntity, ValueBase or SystemException, returns repository
* Id in the IDL:(..) form. If it does not, returns repository Id in the
* RMI:(..) form.
*
* @param cx the class for that the name must be computed.
*
* @return the idl or rmi name.
*/
public static String toIDL(String cn)
public static synchronized String getRepositoryId(Class cx)
{
if (cn.startsWith(JAVA_PREFIX))
cn = OMG_PREFIX + cn.substring(JAVA_PREFIX.length()).replace('.', '/');
else if (cn.startsWith(CLASSPATH_PREFIX))
cn =
OMG_PREFIX +
cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
String name = (String) m_names.get(cx);
if (name != null)
return name;
return "IDL:" + cn + ":1.0";
String cn = cx.getName();
if (!(IDLEntity.class.isAssignableFrom(cx)
|| ValueBase.class.isAssignableFrom(cx) || SystemException.class.isAssignableFrom(cx)))
{
// Not an IDL entity.
name = Util.createValueHandler().getRMIRepositoryID(cx);
}
else
{
if (cn.startsWith(JAVA_PREFIX))
cn = OMG_PREFIX
+ cn.substring(JAVA_PREFIX.length()).replace('.', '/');
else if (cn.startsWith(CLASSPATH_PREFIX))
cn = OMG_PREFIX
+ cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/');
name = "IDL:" + cn + ":1.0";
}
m_names.put(cx, name);
return name;
}
/**
* Insert the passed parameter into the given Any, assuming that the helper
* class is available. The helper class must have the "Helper" suffix and be
* in the same package as the class of the object being inserted.
*
*
* @param into the target to insert.
*
*
* @param object the object to insert. It can be any object as far as the
* corresponding helper is provided.
*
*
* @return true on success, false otherwise.
*/
public static boolean insertWithHelper(Any into, Object object)
@@ -360,12 +440,10 @@ public class ObjectCreator
try
{
String helperClassName = object.getClass().getName() + "Helper";
Class helperClass = Class.forName(helperClassName);
Class helperClass = forName(helperClassName);
Method insert =
helperClass.getMethod("insert",
new Class[] { Any.class, object.getClass() }
);
Method insert = helperClass.getMethod("insert", new Class[] {
Any.class, object.getClass() });
insert.invoke(null, new Object[] { into, object });
@@ -385,20 +463,20 @@ public class ObjectCreator
{
try
{
cdrBufOutput output = new cdrBufOutput();
BufferedCdrOutput output = new BufferedCdrOutput();
String m_exception_id = toIDL(exception.getClass().getName());
String m_exception_id = getRepositoryId(exception.getClass());
output.write_string(m_exception_id);
output.write_ulong(exception.minor);
CompletionStatusHelper.write(output, exception.completed);
String name = getDefaultName(m_exception_id);
universalHolder h = new universalHolder(output);
GeneralHolder h = new GeneralHolder(output);
into.insert_Streamable(h);
recordTypeCode r = new recordTypeCode(TCKind.tk_except);
RecordTypeCode r = new RecordTypeCode(TCKind.tk_except);
r.setId(m_exception_id);
r.setName(name);
into.type(r);
@@ -444,4 +522,69 @@ public class ObjectCreator
if (!ok)
throw new InternalError("Exception wrapping broken");
}
/**
* Find helper for the class with the given name.
*/
public static Class findHelper(String idl)
{
synchronized (m_helpers)
{
Class c = (Class) m_helpers.get(idl);
if (c != null)
return c;
try
{
String helper = toHelperName(idl);
c = forName(helper);
m_helpers.put(idl, c);
return c;
}
catch (Exception ex)
{
return null;
}
}
}
/**
* Load the class with the given name. This method tries to use the context
* class loader first. If this fails, it searches for the suitable class
* loader in the caller stack trace. This method is a central point where all
* requests to find a class by name are delegated.
*/
public static Class forName(String className) throws ClassNotFoundException
{
try
{
return Class.forName(className, true,
Thread.currentThread().getContextClassLoader());
}
catch (ClassNotFoundException nex)
{
/**
* Returns the first user defined class loader on the call stack, or
* null when no non-null class loader was found.
*/
Class[] ctx = VMStackWalker.getClassContext();
for (int i = 0; i < ctx.length; i++)
{
// Since we live in a class loaded by the bootstrap
// class loader, getClassLoader is safe to call without
// needing to be wrapped in a privileged action.
ClassLoader cl = ctx[i].getClassLoader();
try
{
if (cl != null)
return Class.forName(className, true, cl);
}
catch (ClassNotFoundException nex2)
{
// Try next.
}
}
}
throw new ClassNotFoundException(className);
}
}
+2 -2
View File
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.primitiveTypeCode;
import gnu.CORBA.typecodes.PrimitiveTypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -64,7 +64,7 @@ public final class OctetHolder
* The default type code for this holder.
*/
private static final TypeCode t_octet =
new primitiveTypeCode(TCKind.tk_octet);
new PrimitiveTypeCode(TCKind.tk_octet);
/**
* The <code>long</code> (CORBA <code>octet</code>) value,
+375
View File
@@ -0,0 +1,375 @@
/* OrbFocused.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.Poa.ORB_1_4;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.NO_RESOURCES;
import org.omg.CORBA.portable.InvokeHandler;
import java.applet.Applet;
import java.net.ServerSocket;
import java.util.Iterator;
import java.util.Properties;
import java.util.Random;
import java.util.StringTokenizer;
/**
* This class implements the ORB that uses a single port or the restricted port
* range for all its objects. It is required to for use together with various
* firewalls that does not allow opening multiple randomly selected ports, as
* the defauld CORBA implementation used to do. The firewal must be configured
* to allow CORBA to work on one fixed port or (for better performance) on a
* small fixed range of ports. This does not restrict the maximal number of the
* connected objects as the objects can share the same port.
*
* The used port or the used port range can be specified via property
* gnu.CORBA.ListenerPort. The value of this property is a single port or range
* of ports, boundary values (inclusive) being separeted by dash (for instance,
* "1245-1250").
*
* It is possible to instantiate multiple instances of the focused ORBs and
* combine them with the ordinary ORBs. If you instantiate several instances of
* the focused ORBs on the same host, they used port sets should not overlap.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class OrbFocused
extends ORB_1_4
{
/**
* The name of the fixed port range property. The presence of this property
* indicates that the default focused ORB must be used.
*/
public static final String LISTENER_PORT = "gnu.CORBA.ListenerPort";
/**
* The start of the range of the available ports, inclusive.
*/
int m_ports_from = -1;
/**
* The end of the range of the available ports, inclusive.
*/
int m_ports_to = -1;
/**
* The requests to port are served in parallel threads.
*/
static final int PARALLEL = 0;
/**
* The requests to port are served in the same thread.
*/
static final int SEQUENTIAL = 1;
/**
* The random number generator to get a random port in the valid range.
*/
Random m_random = new Random();
/**
* Parse the "gnu.CORBA.ListenerPort" property and initialize the valid port
* set range.
*/
public void setPortRange(String property)
{
int from, to;
try
{
StringTokenizer st = new StringTokenizer(property, " -");
if (st.countTokens() == 1)
from = to = Integer.parseInt(st.nextToken());
else
{
from = Integer.parseInt(st.nextToken());
to = Integer.parseInt(st.nextToken());
m_random = new Random();
}
setPortRange(from, to);
}
catch (Exception ex)
{
throw new BAD_PARAM("Unable to parse port range '" + property + "'");
}
}
/**
* Set the port range.
*
* @param from - start of the port range, inclusive.
* @param to - end of the port range, inclusive.
*/
public void setPortRange(int from, int to)
{
if (from < 0 || to < 0 || to < from)
throw new BAD_PARAM("Invalid range");
m_ports_from = from;
m_ports_to = to;
}
/**
* Get the port from the previously specified usage range.
*/
int getPortFromRange(int attempt)
{
if (m_ports_from == m_ports_to)
return m_ports_from;
else if (m_ports_to - m_ports_from < RANDOM_PORT_ATTEMPTS)
return m_ports_from + (attempt % (m_ports_to - m_ports_from + 1));
else
return m_random.nextInt(m_ports_to - m_ports_from + 1) + m_ports_from;
}
/**
* Get the shared port server where the new object can be added. This may
* result reusing the existing server or instantiating a new server. If the
* new server is instantiated and the ORB is already running, the server is
* started.
*/
protected portServer getPortServer(int type)
{
portServer p;
int n;
if (m_ports_from < m_ports_to)
n = RANDOM_PORT_ATTEMPTS;
else
n = 1;
Ports: for (int a = 0; a < n; a++)
{
int port = getPortFromRange(a);
for (int i = 0; i < portServers.size(); i++)
{
p = (portServer) portServers.get(i);
if (p.s_port == port)
{
return (portServer) p;
}
}
// The server is not yet instantiated. Instantiate.
try
{
// Check if the port is ok:
ServerSocket s = socketFactory.createServerSocket(port);
s.close();
portServer shared;
switch (type)
{
case PARALLEL:
shared = new portServer(port);
break;
case SEQUENTIAL:
shared = new sharedPortServer(port);
break;
default:
throw new InternalError("Invalid server type " + type);
}
portServers.add(shared);
if (running)
shared.start();
return shared;
}
catch (Exception ex)
{
// Port is taken or probably other problems.
continue Ports;
}
}
throw new NO_RESOURCES("No free port available at " + m_ports_from + "-"
+ m_ports_to, Minor.Ports, CompletionStatus.COMPLETED_NO);
}
/**
* Start the ORBs main working cycle (receive invocation - invoke on the local
* object - send response - wait for another invocation).
*
* The method only returns after calling {@link #shutdown(boolean)}.
*/
public void run()
{
if (m_ports_from < 0 || m_ports_to < 0)
throw new BAD_INV_ORDER("For " + getClass().getName() + " "
+ LISTENER_PORT + " property must be set");
running = true;
// Start all port servers. In the current subclass, the portServers
// collection must be already filled in.
Iterator iter = portServers.iterator();
while (iter.hasNext())
{
portServer subserver = (portServer) iter.next();
if (!subserver.isAlive())
{
// Reuse the current thread for the last portServer.
if (!iter.hasNext())
{
// Discard the iterator.
iter = null;
subserver.run();
return;
}
else
subserver.start();
}
}
}
/**
* Get free port from the allowed range. This method instantiates the port
* server for the returned port.
*/
public int getFreePort()
throws BAD_OPERATION
{
portServer s = getPortServer(PARALLEL);
return s.s_port;
}
/**
* Connect the given CORBA object to this ORB, explicitly specifying the
* object key and the identity of the thread (and port), where the object must
* be served. The identity is normally the POA.
*
* The new port server will be started only if there is no one already running
* for the same identity. Otherwise, the task of the existing port server will
* be widened, including duty to serve the given object. All objects,
* connected to a single identity by this method, will process they requests
* subsequently in the same thread. The method is used when the expected
* number of the objects is too large to have a single port and thread per
* object. This method is used by POAs, having a single thread policy.
*
* @param object the object, must implement the {@link InvokeHandler})
* interface.
* @param key the object key, usually used to identify the object from remote
* side.
* @param port the port, where the object must be connected.
*
* @throws BAD_PARAM if the object does not implement the
* {@link InvokeHandler}).
*/
public void connect_1_thread(org.omg.CORBA.Object object, byte[] key,
java.lang.Object identity)
{
sharedPortServer shared = (sharedPortServer) identities.get(identity);
if (shared == null)
{
shared = (sharedPortServer) getPortServer(SEQUENTIAL);
identities.put(identity, shared);
if (running)
{
shared.start();
}
}
Connected_objects.cObject ref = connected_objects.add(key, object,
shared.s_port, identity);
IOR ior = createIOR(ref);
prepareObject(object, ior);
}
/**
* In this type of ORB, the service is started by {@link #getPortServer}. The
* method below is not in use and should return without action.
*/
public void startService(IOR ior)
{
}
/**
* Set parameters (additionally search for the port range property).
*/
protected void set_parameters(Applet applet, Properties props)
{
super.set_parameters(applet, props);
String lp = applet.getParameter(LISTENER_PORT);
if (lp != null)
setPortRange(lp);
}
/**
* Set parameters (additionally search for the port range property).
*/
protected void set_parameters(String[] args, Properties props)
{
super.set_parameters(args, props);
String lp = null;
String lpKey = "-" + LISTENER_PORT;
if (args != null)
if (args.length >= 2)
{
for (int i = 0; i < args.length - 1; i++)
if (args[i].equals(lpKey))
lp = args[i + 1];
}
if (lp != null)
setPortRange(lp);
}
/**
* Additionally set the port range property, when applicable.
*/
protected void useProperties(Properties props)
{
super.useProperties(props);
String lp = props.getProperty(LISTENER_PORT);
if (lp != null)
setPortRange(lp);
}
}
@@ -1,4 +1,4 @@
/* Functional_ORB.java --
/* OrbFunctional.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,8 +38,9 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.UnknownExceptionCtxHandler;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.CloseMessage;
import gnu.CORBA.GIOP.ErrorMessage;
import gnu.CORBA.GIOP.MessageHeader;
@@ -48,38 +49,35 @@ import gnu.CORBA.GIOP.RequestHeader;
import gnu.CORBA.NamingService.NameParser;
import gnu.CORBA.NamingService.NamingServiceTransient;
import gnu.CORBA.Poa.gnuForwardRequest;
import gnu.CORBA.interfaces.SocketFactory;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.DATA_CONVERSION;
import org.omg.CORBA.MARSHAL;
import org.omg.CORBA.NO_RESOURCES;
import org.omg.CORBA.OBJECT_NOT_EXIST;
import org.omg.CORBA.Object;
import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.Request;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.UNKNOWN;
import org.omg.CORBA.WrongTransaction;
import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InvokeHandler;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.CORBA.portable.UnknownException;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import java.applet.Applet;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -87,6 +85,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
@@ -98,14 +97,15 @@ import java.util.TreeMap;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class Functional_ORB extends Restricted_ORB
public class OrbFunctional extends OrbRestricted
{
/**
* A server, responsible for listening on requests on some local port. The ORB
* may listen on multiple ports and process the requests in separate threads.
* Normally the server takes one port per object being served.
*/
class portServer extends Thread
protected class portServer
extends Thread
{
/**
* The number of the currently running parallel threads.
@@ -133,26 +133,27 @@ public class Functional_ORB extends Restricted_ORB
portServer(int _port)
{
s_port = _port;
setDaemon(true);
try
{
service = socketFactory.createServerSocket(s_port);
}
catch (IOException ex)
{
BAD_OPERATION bad = new BAD_OPERATION(
"Unable to open the server socket at " + s_port);
bad.minor = Minor.Socket;
bad.initCause(ex);
throw bad;
}
}
/**
* Enter the serving loop (get request/process it). All portServer normally
* terminate thy threads when the Functional_ORB.running is set to false.
* terminate thy threads when the OrbFunctional.running is set to false.
*/
public void run()
{
try
{
service = new ServerSocket(s_port);
}
catch (IOException ex)
{
BAD_OPERATION bad =
new BAD_OPERATION("Unable to open the server socket.");
bad.initCause(ex);
throw bad;
}
while (running)
{
try
@@ -168,11 +169,11 @@ public class Functional_ORB extends Restricted_ORB
}
catch (Exception iex)
{
// Wait 5 seconds. Do not terminate the
// Wait. Do not terminate the
// service due potentially transient error.
try
{
Thread.sleep(5000);
Thread.sleep(TWAIT_SERVER_ERROR_PAUSE);
}
catch (InterruptedException ex)
{
@@ -183,10 +184,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* Perform a single serving step.
*
*
* @throws java.lang.Exception
*/
void tick() throws Exception
void tick()
throws Exception
{
serve(this, service);
}
@@ -222,7 +224,7 @@ public class Functional_ORB extends Restricted_ORB
* serving multiple requests (probably to the different objects) on the same
* thread.
*/
class sharedPortServer extends portServer
protected class sharedPortServer extends portServer
{
/**
* Create a new portServer, serving on specific port.
@@ -249,6 +251,23 @@ public class Functional_ORB extends Restricted_ORB
* for a free port.
*/
public static int DEFAULT_INITIAL_PORT = 1126;
/**
* When trying to open the socket on a random port, start of the interval to
* try.
*/
public static int RANDOM_PORT_FROM = 1024;
/**
* When trying to open the socket on a random port, end of the interval to
* try.
*/
public static int RANDOM_PORT_TO = 4024;
/**
* The number of attempts to try when opening random port.
*/
public static int RANDOM_PORT_ATTEMPTS = 64;
/**
* The property of port, on that this ORB is listening for requests from
@@ -277,7 +296,18 @@ public class Functional_ORB extends Restricted_ORB
* The string, defining the naming service initial reference.
*/
public static final String NAME_SERVICE = "NameService";
/**
* Defines the ORB ID that is accessible by IOR interceptors.
*/
public static final String ORB_ID = "org.omg.CORBA.ORBid";
/**
* Defines the SERVER ID that is accessible by IOR interceptors.
*/
public static final String SERVER_ID = "org.omg.CORBA.ServerId";
/**
* The if the client has once opened a socket, it should start sending the
* message header in a given time. Otherwise the server will close the socket.
@@ -301,6 +331,13 @@ public class Functional_ORB extends Restricted_ORB
*/
public static String AFTER_RECEIVING =
"gnu.classpath.CORBA.TOUT_AFTER_RECEIVING";
/**
* The server waits for this duration after the potentially transient error
* during its servicing cycle.
*/
public static String SERVER_ERROR_PAUSE =
"gnu.classpath.CORBA.SERVER_ERROR_PAUSE";
/**
* The address of the local host.
@@ -313,7 +350,7 @@ public class Functional_ORB extends Restricted_ORB
* This prevents server hang when the client opens the socket, but does not
* send any message, usually due crash on the client side.
*/
private int TOUT_START_READING_MESSAGE = 20 * 1000;
public int TOUT_START_READING_MESSAGE = 20 * 1000;
// (Here and below, we use * to make the meaning of the constant clearler).
@@ -321,14 +358,20 @@ public class Functional_ORB extends Restricted_ORB
* If the client has started to send the request message, the socket time out
* changes to the specified value.
*/
private int TOUT_WHILE_READING = 2 * 60 * 1000;
public int TOUT_WHILE_READING = 2 * 60 * 1000;
/**
* If the message body is received, the time out changes to the specifice
* value. This must be longer, as includes time, required to process the
* received task. We make it 40 minutes.
*/
private int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
public int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
/**
* The server waits for this duration after the potentially transient error
* during its servicing cycle.
*/
public int TWAIT_SERVER_ERROR_PAUSE = 5000;
/**
* Some clients tend to submit multiple requests over the same socket. The
@@ -338,6 +381,17 @@ public class Functional_ORB extends Restricted_ORB
* seven seconds.
*/
public static int TANDEM_REQUESTS = 7000;
/**
* The Id of this ORB.
*/
public String orb_id = "orb_"+hashCode();
/**
* The Id of this Server. This field is defined static to ensure it has
* the same value over all ORB's in this machine.
*/
public static String server_id = "server_"+OrbFunctional.class.hashCode();
/**
* The map of the already conncted objects.
@@ -365,7 +419,7 @@ public class Functional_ORB extends Restricted_ORB
/**
* The currently active portServers.
*/
private ArrayList portServers = new ArrayList();
protected ArrayList portServers = new ArrayList();
/**
* The host, on that the name service is expected to be running.
@@ -414,11 +468,16 @@ public class Functional_ORB extends Restricted_ORB
* exceeding this limit, the NO_RESOURCES is thrown back to the client.
*/
private int MAX_RUNNING_THREADS = 256;
/**
* The producer of the client and server sockets for this ORB.
*/
public SocketFactory socketFactory = DefaultSocketFactory.Singleton;
/**
* Create the instance of the Functional ORB.
*/
public Functional_ORB()
public OrbFunctional()
{
try
{
@@ -457,13 +516,14 @@ public class Functional_ORB extends Restricted_ORB
/**
* Get the currently free port, starting from the initially set port and going
* up max 20 steps, then trying to bind into any free address.
*
*
* @return the currently available free port.
*
*
* @throws NO_RESOURCES if the server socked cannot be opened on the local
* host.
*/
public int getFreePort() throws BAD_OPERATION
public int getFreePort()
throws BAD_OPERATION
{
ServerSocket s;
int a_port;
@@ -475,7 +535,7 @@ public class Functional_ORB extends Restricted_ORB
{
Integer free = (Integer) freed_ports.getLast();
freed_ports.removeLast();
s = new ServerSocket(free.intValue());
s = socketFactory.createServerSocket(free.intValue());
s.close();
return free.intValue();
}
@@ -491,7 +551,7 @@ public class Functional_ORB extends Restricted_ORB
{
try
{
s = new ServerSocket(a_port);
s = socketFactory.createServerSocket(a_port);
s.close();
Port = a_port + 1;
return a_port;
@@ -502,21 +562,31 @@ public class Functional_ORB extends Restricted_ORB
}
}
try
Random rand = new Random();
// Try any random port in the interval RANDOM_PORT_FROM.RANDOM_PORT_TO.
int range = RANDOM_PORT_TO - RANDOM_PORT_FROM;
IOException ioex = null;
for (int i = 0; i < RANDOM_PORT_ATTEMPTS; i++)
{
// Try any port.
s = new ServerSocket();
a_port = s.getLocalPort();
s.close();
return a_port;
}
catch (IOException ex)
{
NO_RESOURCES bad =
new NO_RESOURCES("Unable to open the server socket.");
bad.initCause(ex);
throw bad;
try
{
a_port = RANDOM_PORT_FROM + rand.nextInt(range);
s = socketFactory.createServerSocket(a_port);
s.close();
return a_port;
}
catch (IOException ex)
{
// Repeat the loop if this exception has been thrown.
ioex = ex;
}
}
NO_RESOURCES bad = new NO_RESOURCES("Unable to open the server socket.");
bad.minor = Minor.Ports;
if (ioex != null)
bad.initCause(ioex);
throw bad;
}
/**
@@ -525,7 +595,7 @@ public class Functional_ORB extends Restricted_ORB
* on this port first. It the port is busy, or if more objects are connected,
* the subsequent object will receive a larger port values, skipping
* unavailable ports, if required. The change applies globally.
*
*
* @param a_Port a port, on that the server is listening for requests.
*/
public static void setPort(int a_Port)
@@ -677,9 +747,9 @@ public class Functional_ORB extends Restricted_ORB
if (object instanceof ObjectImpl)
{
Delegate delegate = ((ObjectImpl) object)._get_delegate();
if (delegate instanceof Simple_delegate)
if (delegate instanceof SimpleDelegate)
{
byte[] key = ((Simple_delegate) delegate).getIor().key;
byte[] key = ((SimpleDelegate) delegate).getIor().key;
rmKey = connected_objects.get(key);
}
}
@@ -756,11 +826,7 @@ public class Functional_ORB extends Restricted_ORB
if (!ior.Internet.host.equals(LOCAL_HOST))
return null;
// Must be the same port.
if (ior.Internet.port != Port)
return null;
return find_connected_object(ior.key);
return find_connected_object(ior.key, ior.Internet.port);
}
/**
@@ -806,8 +872,8 @@ public class Functional_ORB extends Restricted_ORB
if (forObject instanceof ObjectImpl)
{
Delegate delegate = ((ObjectImpl) forObject)._get_delegate();
if (delegate instanceof Simple_delegate)
return ((Simple_delegate) delegate).getIor().toStringifiedReference();
if (delegate instanceof SimpleDelegate)
return ((SimpleDelegate) delegate).getIor().toStringifiedReference();
}
// Handle the case when the object is local.
@@ -899,7 +965,7 @@ public class Functional_ORB extends Restricted_ORB
}
else
subserver = (portServer) identities.get(obj.identity);
if (!subserver.isAlive())
{
// Reuse the current thread for the last portServer.
@@ -915,6 +981,30 @@ public class Functional_ORB extends Restricted_ORB
}
}
}
/**
* Start the server in a new thread, if not already running. This method is
* used to ensure that the objects being transfered will be served from the
* remote side, if required. If the ORB is started using this method, it
* starts as a daemon thread.
*/
public void ensureRunning()
{
final OrbFunctional THIS = this;
if (!running)
{
Thread t = new Thread()
{
public void run()
{
THIS.run();
}
};
t.setDaemon(true);
t.start();
}
}
/**
* Shutdown the ORB server.
@@ -961,21 +1051,22 @@ public class Functional_ORB extends Restricted_ORB
org.omg.CORBA.Object object = find_local_object(ior);
if (object == null)
{
ObjectImpl impl = stubFinder.search(this, ior);
ObjectImpl impl = StubLocator.search(this, ior);
try
{
if (impl._get_delegate() == null)
impl._set_delegate(new IOR_Delegate(this, ior));
impl._set_delegate(new IorDelegate(this, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception
// in response to the attempt to get the unset delegate.
impl._set_delegate(new IOR_Delegate(this, ior));
impl._set_delegate(new IorDelegate(this, ior));
}
object = impl;
connected_objects.add(ior.key, impl, ior.Internet.port, null);
// TODO remove commented out code below.
// connected_objects.add(ior.key, impl, ior.Internet.port, null);
}
return object;
}
@@ -995,7 +1086,7 @@ public class Functional_ORB extends Restricted_ORB
ior.Internet.port = ns_port;
ior.key = NamingServiceTransient.getDefaultKey();
IOR_contructed_object iorc = new IOR_contructed_object(this, ior);
IorObject iorc = new IorObject(this, ior);
NamingContextExt namer = NamingContextExtHelper.narrow(iorc);
initial_references.put(NAME_SERVICE, namer);
return namer;
@@ -1004,23 +1095,29 @@ public class Functional_ORB extends Restricted_ORB
/**
* Find and return the object, that must be previously connected to this ORB.
* Return null if no such object is available.
*
*
* @param key the object key.
*
* @param port the port where the object is connected.
*
* @return the connected object, null if none.
*/
protected org.omg.CORBA.Object find_connected_object(byte[] key)
protected org.omg.CORBA.Object find_connected_object(byte[] key, int port)
{
Connected_objects.cObject ref = connected_objects.get(key);
return ref == null ? null : ref.object;
if (ref == null)
return null;
if (port >= 0 && ref.port != port)
return null;
else
return ref.object;
}
/**
* Set the ORB parameters. This method is normally called from
* {@link #init(Applet, Properties)}.
*
*
* @param app the current applet.
*
*
* @param props application specific properties, passed as the second
* parameter in {@link #init(Applet, Properties)}. Can be <code>null</code>.
*/
@@ -1033,37 +1130,39 @@ public class Functional_ORB extends Restricted_ORB
{
for (int i = 0; i < para.length; i++)
{
if (para [ i ] [ 0 ].equals(LISTEN_ON))
Port = Integer.parseInt(para [ i ] [ 1 ]);
if (para [ i ] [ 0 ].equals(REFERENCE))
if (para[i][0].equals(LISTEN_ON))
Port = Integer.parseInt(para[i][1]);
if (para[i][0].equals(REFERENCE))
{
StringTokenizer st =
new StringTokenizer(para [ i ] [ 1 ], "=");
StringTokenizer st = new StringTokenizer(para[i][1], "=");
initial_references.put(st.nextToken(),
string_to_object(st.nextToken())
);
string_to_object(st.nextToken()));
}
if (para [ i ] [ 0 ].equals(NS_HOST))
ns_host = para [ i ] [ 1 ];
if (para [ i ] [ 0 ].equals(START_READING_MESSAGE))
TOUT_START_READING_MESSAGE = Integer.parseInt(para [ i ] [ 1 ]);
if (para [ i ] [ 0 ].equals(WHILE_READING))
TOUT_WHILE_READING = Integer.parseInt(para [ i ] [ 1 ]);
if (para [ i ] [ 0 ].equals(AFTER_RECEIVING))
TOUT_AFTER_RECEIVING = Integer.parseInt(para [ i ] [ 1 ]);
if (para[i][0].equals(ORB_ID))
orb_id = para[i][1];
if (para[i][0].equals(SERVER_ID))
server_id = para[i][1];
if (para[i][0].equals(NS_HOST))
ns_host = para[i][1];
if (para[i][0].equals(START_READING_MESSAGE))
TOUT_START_READING_MESSAGE = Integer.parseInt(para[i][1]);
if (para[i][0].equals(WHILE_READING))
TOUT_WHILE_READING = Integer.parseInt(para[i][1]);
if (para[i][0].equals(AFTER_RECEIVING))
TOUT_AFTER_RECEIVING = Integer.parseInt(para[i][1]);
try
{
if (para [ i ] [ 0 ].equals(NS_PORT))
ns_port = Integer.parseInt(para [ i ] [ 1 ]);
if (para[i][0].equals(NS_PORT))
ns_port = Integer.parseInt(para[i][1]);
}
catch (NumberFormatException ex)
{
BAD_PARAM bad =
new BAD_PARAM("Invalid " + NS_PORT +
"property, unable to parse '" +
props.getProperty(NS_PORT) + "'"
);
BAD_PARAM bad = new BAD_PARAM("Invalid " + NS_PORT
+ "property, unable to parse '" + props.getProperty(NS_PORT)
+ "'");
bad.initCause(ex);
throw bad;
}
@@ -1074,11 +1173,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* Set the ORB parameters. This method is normally called from
* {@link #init(String[], Properties)}.
*
*
* @param para the parameters, that were passed as the parameters to the
* <code>main(String[] args)</code> method of the current standalone
* application.
*
*
* @param props application specific properties that were passed as a second
* parameter in {@link init(String[], Properties)}). Can be <code>null</code>.
*/
@@ -1088,29 +1187,33 @@ public class Functional_ORB extends Restricted_ORB
{
for (int i = 0; i < para.length - 1; i++)
{
if (para [ i ].endsWith("ListenOn"))
Port = Integer.parseInt(para [ i + 1 ]);
if (para [ i ].endsWith("ORBInitRef"))
if (para[i].endsWith("ListenOn"))
Port = Integer.parseInt(para[i + 1]);
if (para[i].endsWith("ORBInitRef"))
{
StringTokenizer st = new StringTokenizer(para [ i + 1 ], "=");
StringTokenizer st = new StringTokenizer(para[i + 1], "=");
initial_references.put(st.nextToken(),
string_to_object(st.nextToken())
);
string_to_object(st.nextToken()));
}
if (para [ i ].endsWith("ORBInitialHost"))
ns_host = para [ i + 1 ];
if (para[i].endsWith("ORBInitialHost"))
ns_host = para[i + 1];
if (para[i].endsWith("ServerId"))
server_id = para[i++];
else if (para[i].endsWith("ORBid"))
orb_id = para[i++];
try
{
if (para [ i ].endsWith("ORBInitialPort"))
ns_port = Integer.parseInt(para [ i + 1 ]);
if (para[i].endsWith("ORBInitialPort"))
ns_port = Integer.parseInt(para[i + 1]);
}
catch (NumberFormatException ex)
{
throw new BAD_PARAM("Invalid " + para [ i ] +
"parameter, unable to parse '" +
props.getProperty(para [ i + 1 ]) + "'"
);
throw new BAD_PARAM("Invalid " + para[i]
+ "parameter, unable to parse '"
+ props.getProperty(para[i + 1]) + "'");
}
}
}
@@ -1156,7 +1259,7 @@ public class Functional_ORB extends Restricted_ORB
* @throws BAD_PARAM if the object does not implement the
* {@link InvokeHandler}).
*/
private void prepareObject(org.omg.CORBA.Object object, IOR ior)
protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
throws BAD_PARAM
{
/*
@@ -1172,12 +1275,12 @@ public class Functional_ORB extends Restricted_ORB
try
{
if (impl._get_delegate() == null)
impl._set_delegate(new Simple_delegate(this, ior));
impl._set_delegate(new SimpleDelegate(this, ior));
}
catch (BAD_OPERATION ex)
{
// Some colaborants may throw this exception.
impl._set_delegate(new Simple_delegate(this, ior));
impl._set_delegate(new SimpleDelegate(this, ior));
}
}
}
@@ -1197,7 +1300,7 @@ public class Functional_ORB extends Restricted_ORB
*/
private void respond_to_client(OutputStream net_out,
MessageHeader msh_request, RequestHeader rh_request,
bufferedResponseHandler handler, SystemException sysEx
ResponseHandlerImpl handler, SystemException sysEx
) throws IOException
{
// Set the reply header properties.
@@ -1211,8 +1314,8 @@ public class Functional_ORB extends Restricted_ORB
reply.reply_status = ReplyHeader.NO_EXCEPTION;
reply.request_id = rh_request.request_id;
cdrBufOutput out =
new cdrBufOutput(50 + handler.getBuffer().buffer.size());
BufferedCdrOutput out =
new BufferedCdrOutput(50 + handler.getBuffer().buffer.size());
out.setOrb(this);
out.setOffset(msh_request.getHeaderSize());
@@ -1256,7 +1359,7 @@ public class Functional_ORB extends Restricted_ORB
rh_forward.request_id = rh_request.request_id;
// The forwarding code is either LOCATION_FORWARD or LOCATION_FORWARD_PERM.
cdrBufOutput out = new cdrBufOutput();
BufferedCdrOutput out = new BufferedCdrOutput();
out.setOrb(this);
out.setOffset(msh_forward.getHeaderSize());
@@ -1324,11 +1427,11 @@ public class Functional_ORB extends Restricted_ORB
/**
* A single servicing step, when the client socket is alrady open.
*
*
* Normally, each task matches a single remote invocation. However under
* frequent tandem submissions the same task may span over several
* invocations.
*
*
* @param service the opened client socket.
* @param no_resources if true, the "NO RESOURCES" exception is thrown to the
* client.
@@ -1337,8 +1440,7 @@ public class Functional_ORB extends Restricted_ORB
{
try
{
Serving:
while (true)
Serving: while (true)
{
InputStream in = service.getInputStream();
service.setSoTimeout(TOUT_START_READING_MESSAGE);
@@ -1358,9 +1460,7 @@ public class Functional_ORB extends Restricted_ORB
if (max_version != null)
{
if (!msh_request.version.until_inclusive(max_version.major,
max_version.minor
)
)
max_version.minor))
{
OutputStream out = service.getOutputStream();
new ErrorMessage(max_version).write(out);
@@ -1368,25 +1468,14 @@ public class Functional_ORB extends Restricted_ORB
}
}
byte[] r = new byte[ msh_request.message_size ];
int n = 0;
service.setSoTimeout(TOUT_WHILE_READING);
reading:
while (n < r.length)
{
n += in.read(r, n, r.length - n);
}
service.setSoTimeout(TOUT_AFTER_RECEIVING);
byte[] r = msh_request.readMessage(in, service, TOUT_WHILE_READING,
TOUT_AFTER_RECEIVING);
if (msh_request.message_type == MessageHeader.REQUEST)
{
RequestHeader rh_request;
cdrBufInput cin = new cdrBufInput(r);
BufferredCdrInput cin = new BufferredCdrInput(r);
cin.setOrb(this);
cin.setVersion(msh_request.version);
cin.setOffset(msh_request.getHeaderSize());
@@ -1406,8 +1495,8 @@ public class Functional_ORB extends Restricted_ORB
// find the target object.
}
InvokeHandler target =
(InvokeHandler) find_connected_object(rh_request.object_key);
InvokeHandler target = (InvokeHandler) find_connected_object(
rh_request.object_key, -1);
// Prepare the reply header. This must be done in advance,
// as the size must be known for handler to set alignments
@@ -1415,17 +1504,19 @@ public class Functional_ORB extends Restricted_ORB
ReplyHeader rh_reply = msh_request.create_reply_header();
// TODO log errors about not existing objects and methods.
bufferedResponseHandler handler =
new bufferedResponseHandler(this, msh_request, rh_reply,
rh_request
);
ResponseHandlerImpl handler = new ResponseHandlerImpl(
this, msh_request, rh_reply, rh_request);
SystemException sysEx = null;
try
{
if (no_resources)
throw new NO_RESOURCES();
{
NO_RESOURCES no = new NO_RESOURCES("Too many parallel calls");
no.minor = Minor.Threads;
throw no;
}
if (target == null)
throw new OBJECT_NOT_EXIST();
target._invoke(rh_request.operation, cin, handler);
@@ -1442,24 +1533,45 @@ public class Functional_ORB extends Restricted_ORB
continue Serving;
}
}
catch (UnknownException uex)
{
sysEx = new UNKNOWN("Unknown", 2,
CompletionStatus.COMPLETED_MAYBE);
sysEx.initCause(uex.originalEx);
org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
rh_reply.service_context, uex.originalEx, ech);
ObjectCreator.writeSystemException(ech, sysEx);
}
catch (SystemException ex)
{
sysEx = ex;
org.omg.CORBA.portable.OutputStream ech =
handler.createExceptionReply();
org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
rh_reply.service_context, ex, ech);
ObjectCreator.writeSystemException(ech, ex);
}
catch (Exception except)
{
// This should never happen under normal operation and
// can only indicate errors in user object implementation.
// We inform the user.
except.printStackTrace();
sysEx =
new UNKNOWN("Unknown", 2,
CompletionStatus.COMPLETED_MAYBE
);
org.omg.CORBA.portable.OutputStream ech =
handler.createExceptionReply();
sysEx = new UNKNOWN("Unknown", 2,
CompletionStatus.COMPLETED_MAYBE);
sysEx.initCause(except);
org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply();
rh_reply.service_context = UnknownExceptionCtxHandler.addExceptionContext(
rh_reply.service_context, except, ech);
ObjectCreator.writeSystemException(ech, sysEx);
}
@@ -1469,21 +1581,17 @@ public class Functional_ORB extends Restricted_ORB
{
OutputStream sou = service.getOutputStream();
respond_to_client(sou, msh_request, rh_request, handler,
sysEx
);
sysEx);
}
}
else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION ||
msh_request.message_type == MessageHeader.MESSAGE_ERROR
)
else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION
|| msh_request.message_type == MessageHeader.MESSAGE_ERROR)
{
CloseMessage.close(service.getOutputStream());
service.close();
return;
}
;
// TODO log error: "Not a request message."
if (service != null && !service.isClosed())
// Wait for the subsequent invocations on the
@@ -1505,8 +1613,12 @@ public class Functional_ORB extends Restricted_ORB
return;
}
}
private void useProperties(Properties props)
/**
* Set the ORB parameters from the properties that were accumulated
* from several locations.
*/
protected void useProperties(Properties props)
{
if (props != null)
{
@@ -1527,6 +1639,9 @@ public class Functional_ORB extends Restricted_ORB
if (props.containsKey(AFTER_RECEIVING))
TOUT_AFTER_RECEIVING =
Integer.parseInt(props.getProperty(AFTER_RECEIVING));
if (props.containsKey(SERVER_ERROR_PAUSE))
TWAIT_SERVER_ERROR_PAUSE =
Integer.parseInt(props.getProperty(SERVER_ERROR_PAUSE));
}
catch (NumberFormatException ex)
{
@@ -1535,7 +1650,31 @@ public class Functional_ORB extends Restricted_ORB
"'"
);
}
if (props.containsKey(SocketFactory.PROPERTY))
{
String factory = null;
try
{
factory = props.getProperty(SocketFactory.PROPERTY);
if (factory!=null)
socketFactory = (SocketFactory)
ObjectCreator.forName(factory).newInstance();
}
catch (Exception ex)
{
BAD_PARAM p = new BAD_PARAM("Bad socket factory "+factory);
p.initCause(ex);
throw p;
}
}
if (props.containsKey(ORB_ID))
orb_id = props.getProperty(ORB_ID);
if (props.containsKey(SERVER_ID))
server_id = props.getProperty(SERVER_ID);
Enumeration en = props.elements();
while (en.hasMoreElements())
{
@@ -38,7 +38,11 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.typecodes.AliasTypeCode;
import gnu.CORBA.typecodes.ArrayTypeCode;
import gnu.CORBA.typecodes.RecordTypeCode;
import gnu.CORBA.typecodes.StringTypeCode;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
@@ -60,6 +64,7 @@ import org.omg.CORBA.portable.OutputStream;
import org.omg.CORBA.portable.ValueFactory;
import org.omg.PortableInterceptor.ClientRequestInterceptorOperations;
import org.omg.PortableInterceptor.IORInterceptorOperations;
import org.omg.PortableInterceptor.IORInterceptor_3_0Operations;
import org.omg.PortableInterceptor.ServerRequestInterceptorOperations;
import java.applet.Applet;
@@ -82,18 +87,18 @@ import java.util.Properties;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
public class OrbRestricted extends org.omg.CORBA_2_3.ORB
{
/**
* The singleton instance of this ORB.
*/
public static final ORB Singleton = new Restricted_ORB();
public static final ORB Singleton = new OrbRestricted();
/**
* The cumulated listener for all IOR interceptors. Interceptors are used by
* {@link gnu.CORBA.Poa.ORB_1_4}.
*/
public IORInterceptorOperations iIor;
public IORInterceptor_3_0Operations iIor;
/**
* The cumulated listener for all server request interceptors. Interceptors
@@ -126,14 +131,14 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
* Create a new instance of the RestrictedORB. This is used in derived classes
* only.
*/
protected Restricted_ORB()
protected OrbRestricted()
{
}
/** {@inheritDoc} */
public TypeCode create_alias_tc(String id, String name, TypeCode typecode)
{
return new aliasTypeCode(typecode, id, name);
return new AliasTypeCode(typecode, id, name);
}
/** {@inheritDoc} */
@@ -147,8 +152,8 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_array_tc(int length, TypeCode element_type)
{
primitiveArrayTypeCode p =
new primitiveArrayTypeCode(TCKind.tk_array, element_type);
ArrayTypeCode p =
new ArrayTypeCode(TCKind.tk_array, element_type);
p.setLength(length);
return p;
}
@@ -162,7 +167,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_enum_tc(String id, String name, String[] values)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_enum);
RecordTypeCode r = new RecordTypeCode(TCKind.tk_enum);
for (int i = 0; i < values.length; i++)
{
r.field().name = values [ i ];
@@ -191,7 +196,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
StructMember[] members
)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_except);
RecordTypeCode r = new RecordTypeCode(TCKind.tk_except);
r.setId(id);
r.setName(name);
@@ -229,7 +234,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public OutputStream create_output_stream()
{
cdrBufOutput stream = new cdrBufOutput();
BufferedCdrOutput stream = new BufferedCdrOutput();
stream.setOrb(this);
return stream;
}
@@ -237,8 +242,8 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_sequence_tc(int bound, TypeCode element_type)
{
primitiveArrayTypeCode p =
new primitiveArrayTypeCode(TCKind.tk_sequence, element_type);
ArrayTypeCode p =
new ArrayTypeCode(TCKind.tk_sequence, element_type);
p.setLength(bound);
return p;
}
@@ -246,7 +251,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_string_tc(int bound)
{
stringTypeCode p = new stringTypeCode(TCKind.tk_string);
StringTypeCode p = new StringTypeCode(TCKind.tk_string);
p.setLength(bound);
return p;
}
@@ -256,7 +261,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
StructMember[] members
)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_struct);
RecordTypeCode r = new RecordTypeCode(TCKind.tk_struct);
r.setId(id);
r.setName(name);
@@ -273,7 +278,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
TypeCode discriminator_type, UnionMember[] members
)
{
recordTypeCode r = new recordTypeCode(TCKind.tk_union);
RecordTypeCode r = new RecordTypeCode(TCKind.tk_union);
r.setId(id);
r.setName(name);
r.setDiscriminator_type(discriminator_type);
@@ -290,7 +295,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
/** {@inheritDoc} */
public TypeCode create_wstring_tc(int bound)
{
stringTypeCode p = new stringTypeCode(TCKind.tk_wstring);
StringTypeCode p = new StringTypeCode(TCKind.tk_wstring);
p.setLength(bound);
return p;
}
@@ -300,7 +305,7 @@ public class Restricted_ORB extends org.omg.CORBA_2_3.ORB
{
try
{
return typeNamer.getPrimitveTC(tcKind);
return TypeKindNamer.getPrimitveTC(tcKind);
}
catch (BadKind ex)
{
@@ -1,4 +1,4 @@
/* activeObjectMap.java --
/* AOM.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,7 +40,6 @@ package gnu.CORBA.Poa;
import gnu.CORBA.ByteArrayComparator;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;
import java.util.Iterator;
@@ -57,7 +56,7 @@ import java.util.TreeMap;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class activeObjectMap
public class AOM
{
/**
* The reference data about the object, placed on the AOM.
@@ -67,7 +66,7 @@ public class activeObjectMap
/**
* Create an initialised instance.
*/
Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, POA _poa)
Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, gnuPOA _poa)
{
object = _object;
key = _key;
@@ -96,7 +95,7 @@ public class activeObjectMap
/**
* The POA, where the object is connected.
*/
public final POA poa;
public final gnuPOA poa;
/**
* The object key.
@@ -142,17 +141,6 @@ public class activeObjectMap
{
deactivated = state;
}
public boolean equals(java.lang.Object other)
{
if (other instanceof Obj)
{
Obj o = (Obj) other;
return o.object.equals(object);
}
else
return false;
}
}
/**
@@ -269,7 +257,7 @@ public class activeObjectMap
*
* @return the newly created object record.
*/
public Obj add(org.omg.CORBA.Object object, Servant servant, POA poa)
public Obj add(org.omg.CORBA.Object object, Servant servant, gnuPOA poa)
{
return add(generateObjectKey(object), object, servant, poa);
}
@@ -283,7 +271,7 @@ public class activeObjectMap
* @param poa the POA, where the object is connected.
*/
public Obj add(byte[] key, org.omg.CORBA.Object object, Servant servant,
POA poa
gnuPOA poa
)
{
Obj rec = new Obj(object, key, servant, poa);
@@ -298,7 +286,7 @@ public class activeObjectMap
* and object.
* @param port the port that this object would take.
*/
public Obj add(servantDelegate delegate)
public Obj add(ServantDelegateImpl delegate)
{
Obj rec =
new Obj(delegate.object, delegate.servant_id, delegate.servant,
@@ -1,4 +1,4 @@
/* vPolicy.java --
/* AccessiblePolicy.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import org.omg.CORBA.Policy;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public interface vPolicy
public interface AccessiblePolicy
extends Policy
{
/**
@@ -1,4 +1,4 @@
/* dynImpHandler.java --
/* DynamicImpHandler.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -53,7 +53,7 @@ import org.omg.PortableServer.DynamicImplementation;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class dynImpHandler
public class DynamicImpHandler
implements InvokeHandler
{
/**
@@ -66,7 +66,7 @@ public class dynImpHandler
* Create a new instance, wrapping some dyn implementation.
* @param _servant
*/
public dynImpHandler(DynamicImplementation _servant)
public DynamicImpHandler(DynamicImplementation _servant)
{
servant = _servant;
}
@@ -39,8 +39,9 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.IOR;
import gnu.CORBA.IOR_Delegate;
import gnu.CORBA.IOR_contructed_object;
import gnu.CORBA.IorDelegate;
import gnu.CORBA.IorObject;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
@@ -101,9 +102,9 @@ public class ForwardedServant
ObjectImpl fto = (ObjectImpl) a_ref;
// Check maybe the remote side forwarded back to our local object.
if (fto instanceof IOR_contructed_object)
if (fto instanceof IorObject)
{
IOR_contructed_object iref = (IOR_contructed_object) fto;
IorObject iref = (IorObject) fto;
// Check maybe the IOR is local.
ORB t_orb = iref._orb();
@@ -111,13 +112,13 @@ public class ForwardedServant
{
ORB_1_4 orb = (ORB_1_4) t_orb;
Delegate d = iref._get_delegate();
if (d instanceof IOR_Delegate)
if (d instanceof IorDelegate)
{
IOR_Delegate ird = (IOR_Delegate) iref._get_delegate();
IorDelegate ird = (IorDelegate) iref._get_delegate();
IOR ior = ird.getIor();
if (orb.LOCAL_HOST.equalsIgnoreCase(ior.Internet.host))
{
activeObjectMap.Obj rx = orb.rootPOA.findIorKey(ior.key);
AOM.Obj rx = orb.rootPOA.findIorKey(ior.key);
if (rx != null)
{
if (rx.object == fto ||
@@ -175,6 +176,7 @@ public class ForwardedServant
catch (IOException io_ex)
{
MARSHAL m = new MARSHAL();
m.minor = Minor.Forwarding;
m.initCause(io_ex);
throw m;
}
@@ -38,8 +38,10 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.CDR.cdrOutput;
import gnu.CORBA.streamRequest;
import gnu.CORBA.CDR.AbstractCdrOutput;
import gnu.CORBA.IOR;
import gnu.CORBA.IorProvider;
import gnu.CORBA.StreamBasedRequest;
import org.omg.CORBA.ARG_INOUT;
import org.omg.CORBA.Bounds;
@@ -68,17 +70,22 @@ import java.util.Arrays;
* A local delegate, transferring all object requests to the locally available
* servant. This class is involved in handling the method invocations on the
* local object, obtained by POA.create_reference_with_id.
*
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
public class LocalDelegate
extends org.omg.CORBA_2_3.portable.Delegate
implements IorProvider
{
/**
* The same servant as an invocation handler.
*/
gnuServantObject object;
String operation;
final gnuPOA poa;
public final gnuPOA poa;
final byte[] Id;
/**
@@ -91,6 +98,14 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
poa = a_poa;
Id = an_id;
}
/**
* Get the IOR of the connected object.
*/
public IOR getIor()
{
return object.getIor();
}
public Request request(org.omg.CORBA.Object target, String method)
{
@@ -107,8 +122,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
}
public boolean is_equivalent(org.omg.CORBA.Object target,
org.omg.CORBA.Object other
)
org.omg.CORBA.Object other)
{
if (target == other)
return true;
@@ -157,9 +171,9 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Check if this object could be named by the given repository id.
*
*
* @param idl_id the repository id to check.
*
*
* @return true if it is one of the possible repository ids of this object.
*/
public boolean is_a(org.omg.CORBA.Object a_servant, String idl_id)
@@ -167,7 +181,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
String[] maybe = object._ids();
for (int i = 0; i < maybe.length; i++)
{
if (maybe [ i ].equals(idl_id))
if (maybe[i].equals(idl_id))
return true;
}
return false;
@@ -186,8 +200,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String method, NVList parameters, NamedValue returns,
ExceptionList exceptions, ContextList ctx_list
)
ExceptionList exceptions, ContextList ctx_list)
{
operation = method;
@@ -204,8 +217,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
* Create request for using with DII.
*/
public Request create_request(org.omg.CORBA.Object target, Context context,
String method, NVList parameters, NamedValue returns
)
String method, NVList parameters, NamedValue returns)
{
operation = method;
@@ -226,23 +238,20 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Create a request to invoke the method of this CORBA object.
*
*
* @param operation the name of the method to invoke.
* @param response_expected specifies if this is one way message or the
* response to the message is expected.
*
*
* @return the stream where the method arguments should be written.
*/
public org.omg.CORBA.portable.OutputStream request(
org.omg.CORBA.Object target,
String method,
boolean response_expected
)
org.omg.CORBA.Object target, String method, boolean response_expected)
{
operation = method;
// Check if the object is not explicitly deactivated.
activeObjectMap.Obj e = poa.aom.get(Id);
AOM.Obj e = poa.aom.get(Id);
if (e != null && e.isDeactiveted())
{
if (poa.servant_activator != null || poa.servant_locator != null)
@@ -280,7 +289,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
/**
* Make an invocation.
*
*
* @param target not in use.
* @param output the stream request that should be returned by
* {@link #m_request} in this method.
@@ -292,31 +301,29 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
{
try
{
streamRequest sr = (streamRequest) output;
StreamBasedRequest sr = (StreamBasedRequest) output;
LocalRequest lr = (LocalRequest) sr.request;
InvokeHandler handler =
lr.object.getHandler(lr.operation(), lr.cookie, false);
InvokeHandler handler = lr.object.getHandler(lr.operation(), lr.cookie,
false);
if (handler instanceof dynImpHandler)
if (handler instanceof DynamicImpHandler)
{
// The local request known how to handle it, but the different
// method must be called.
lr.invoke();
// The encapsulation will inherit orb, endian, charsets, etc.
cdrOutput buf = sr.createEncapsulation();
AbstractCdrOutput buf = sr.createEncapsulation();
// Write all request parameters to the buffer stream.
if (lr.env().exception() != null)
{
try
{
UnknownUserException uex =
(UnknownUserException) lr.env().exception();
UnknownUserException uex = (UnknownUserException) lr.env().exception();
throw new ApplicationException(uex.except.type().id(),
uex.except.create_input_stream()
);
uex.except.create_input_stream());
}
catch (BadKind ex)
{
@@ -334,9 +341,8 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
for (int i = 0; i < lr.arguments().count(); i++)
{
a = lr.arguments().item(i);
if (a.flags() == ARG_INOUT.value ||
a.flags() == ARG_INOUT.value
)
if (a.flags() == ARG_INOUT.value
|| a.flags() == ARG_INOUT.value)
{
a.value().write_value(buf);
}
@@ -362,10 +368,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate
try
{
return ((ObjectImpl) f.forward_reference)._invoke(f.forward_reference._request(
operation,
true
)
);
operation, true));
}
catch (RemarshalException e)
{
@@ -38,19 +38,19 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.CDR.BufferedCdrOutput;
import gnu.CORBA.GIOP.MessageHeader;
import gnu.CORBA.GIOP.v1_2.ReplyHeader;
import gnu.CORBA.GIOP.v1_2.RequestHeader;
import gnu.CORBA.Interceptor.gnuClientRequestInfo;
import gnu.CORBA.Interceptor.gnuServerRequestInfo;
import gnu.CORBA.typecodes.RecordTypeCode;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Unexpected;
import gnu.CORBA.gnuAny;
import gnu.CORBA.gnuRequest;
import gnu.CORBA.recordTypeCode;
import gnu.CORBA.streamReadyHolder;
import gnu.CORBA.streamRequest;
import gnu.CORBA.StreamHolder;
import gnu.CORBA.StreamBasedRequest;
import org.omg.CORBA.ARG_OUT;
import org.omg.CORBA.Any;
@@ -115,7 +115,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
/**
* The buffer to write into.
*/
cdrBufOutput buffer;
BufferedCdrOutput buffer;
/**
* The responsible POA.
@@ -252,7 +252,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
handler = object.getHandler(operation(), cookie, false);
}
cdrBufOutput request_part = new cdrBufOutput();
BufferedCdrOutput request_part = new BufferedCdrOutput();
request_part.setOrb(orb());
@@ -288,7 +288,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
request_part.create_input_stream();
// Ensure the servant (handler) has a delegate set.
servantDelegate sd = null;
ServantDelegateImpl sd = null;
Delegate d = null;
@@ -300,19 +300,19 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
// In some cases exception is thrown if the delegate is not set.
}
if (d instanceof servantDelegate)
if (d instanceof ServantDelegateImpl)
{
// If the delegate is already set, try to reuse the existing
// instance.
sd = (servantDelegate) d;
sd = (ServantDelegateImpl) d;
if (sd.object != object)
{
sd = new servantDelegate(servant, poa, Id);
sd = new ServantDelegateImpl(servant, poa, Id);
}
}
else
{
sd = new servantDelegate(servant, poa, Id);
sd = new ServantDelegateImpl(servant, poa, Id);
}
servant._set_delegate(sd);
@@ -368,13 +368,13 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
// Failed due any reason, insert without
// helper.
a.insert_Streamable(new streamReadyHolder(
a.insert_Streamable(new StreamHolder(
buf.create_input_stream()
)
);
recordTypeCode r =
new recordTypeCode(TCKind.tk_except);
RecordTypeCode r =
new RecordTypeCode(TCKind.tk_except);
r.setId(uex_idl);
r.setName(ObjectCreator.getDefaultName(uex_idl));
}
@@ -531,9 +531,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
{
InvokeHandler handler = object.getHandler(operation(), cookie, false);
if (handler instanceof dynImpHandler)
if (handler instanceof DynamicImpHandler)
{
DynamicImplementation dyn = ((dynImpHandler) handler).servant;
DynamicImplementation dyn = ((DynamicImpHandler) handler).servant;
if (serverRequest == null)
{
serverRequest = new LocalServerRequest(this);
@@ -589,7 +589,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
// Prepare an Any that will hold the exception.
gnuAny exc = new gnuAny();
exc.insert_Streamable(new streamReadyHolder(input));
exc.insert_Streamable(new StreamHolder(input));
UnknownUserException unuex = new UnknownUserException(exc);
m_environment.exception(unuex);
@@ -637,7 +637,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
*
* @return the CDR output stream, containing the written output.
*/
cdrBufOutput getBuffer()
BufferedCdrOutput getBuffer()
{
return buffer;
}
@@ -656,7 +656,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
*/
private void prepareStream()
{
buffer = new cdrBufOutput();
buffer = new BufferedCdrOutput();
buffer.setOrb(orb());
}
@@ -664,9 +664,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler,
* Get the parameter stream, where the invocation arguments should be written
* if they are written into the stream directly.
*/
public streamRequest getParameterStream()
public StreamBasedRequest getParameterStream()
{
m_parameter_buffer = new streamRequest();
m_parameter_buffer = new StreamBasedRequest();
m_parameter_buffer.request = this;
m_parameter_buffer.setOrb(poa.orb());
return m_parameter_buffer;
+44 -7
View File
@@ -38,7 +38,7 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.Functional_ORB;
import gnu.CORBA.OrbFunctional;
import gnu.CORBA.IOR;
import gnu.CORBA.Connected_objects.cObject;
import gnu.CORBA.DynAn.gnuDynAnyFactory;
@@ -53,11 +53,13 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.OBJECT_NOT_EXIST;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Policy;
import org.omg.CORBA.PolicyError;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.PortableInterceptor.PolicyFactory;
import org.omg.PortableServer.POA;
import org.omg.PortableServer.Servant;
import org.omg.PortableServer.POAManagerPackage.State;
import org.omg.PortableServer.POAPackage.InvalidPolicy;
import java.applet.Applet;
@@ -69,7 +71,7 @@ import java.util.Properties;
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class ORB_1_4
extends Functional_ORB
extends OrbFunctional
{
/**
* The root POA.
@@ -100,7 +102,7 @@ public class ORB_1_4
super();
try
{
rootPOA = new gnuPOA(null, "RootPOA", null, policySets.rootPoa(), this);
rootPOA = new gnuPOA(null, "RootPOA", null, StandardPolicies.rootPoa(), this);
}
catch (InvalidPolicy ex)
{
@@ -130,7 +132,7 @@ public class ORB_1_4
{
try
{
activeObjectMap.Obj exists = rootPOA.findObject(forObject);
AOM.Obj exists = rootPOA.findObject(forObject);
if (exists == null)
throw new OBJECT_NOT_EXIST(forObject == null ? "null"
: forObject.toString());
@@ -201,9 +203,9 @@ public class ORB_1_4
IOR ior = super.createIOR(ref);
if (iIor != null)
{
activeObjectMap.Obj obj = rootPOA.findIorKey(ior.key);
AOM.Obj obj = rootPOA.findIorKey(ior.key);
POA poa;
gnuPOA poa;
// Null means that the object was connected to the ORB directly.
if (obj == null)
@@ -215,6 +217,7 @@ public class ORB_1_4
// This may modify the ior.
iIor.establish_components(info);
iIor.components_established(info);
}
return ior;
}
@@ -252,5 +255,39 @@ public class ORB_1_4
super.set_parameters(para, props);
registerInterceptors(props, para);
}
/**
* This method is called by RMI-IIOP {@link javax.rmi.Tie#orb(ORB)}, passing
* <code>this</code> as parameter. The ORB will try to connect that tie as
* one of its objects, if it is not already connected. If the wrapper is an
* instance of Servant this method also activates the root poa (if not already
* active).
*/
public void set_delegate(java.lang.Object wrapper)
{
if (wrapper instanceof org.omg.CORBA.Object)
{
org.omg.CORBA.Object object = (org.omg.CORBA.Object) wrapper;
if (connected_objects.getKey(object) == null)
connect(object);
}
else if (wrapper instanceof Servant)
{
Servant s = (Servant) wrapper;
if (rootPOA.findServant(s) == null)
try
{
rootPOA.servant_to_reference(s);
if (rootPOA.the_POAManager().get_state().value() == State._HOLDING)
rootPOA.the_POAManager().activate();
}
catch (Exception e)
{
BAD_OPERATION bad = new BAD_OPERATION("Unable to connect "
+ wrapper + " to " + this);
throw bad;
}
}
}
}
@@ -1,4 +1,4 @@
/* servantDelegate.java --
/* ServantDelegateImpl.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ import org.omg.PortableServer.portable.Delegate;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class servantDelegate
public class ServantDelegateImpl
implements Delegate
{
/**
@@ -93,7 +93,7 @@ public class servantDelegate
* @param a_servant the servant.
* @param a_servant_id the servant id.
*/
public servantDelegate(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id)
public ServantDelegateImpl(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id)
{
poa = a_poa;
servant = a_servant;
@@ -1,4 +1,4 @@
/* policySets.java --
/* StandardPolicies.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -56,14 +56,14 @@ import java.util.ArrayList;
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public class policySets
public class StandardPolicies
{
/**
* The default policy set, as defined in OMG specs. This is also
* the policy set for the root POA.
*/
private static final vPolicy[] rootPOASet =
new vPolicy[]
private static final AccessiblePolicy[] rootPOASet =
new AccessiblePolicy[]
{
new gnuThreadPolicy(ThreadPolicyValue.ORB_CTRL_MODEL),
new gnuLifespanPolicy(LifespanPolicyValue.TRANSIENT),
@@ -69,7 +69,7 @@ public class gnuAdapterActivator
{
try
{
POA n = parent.create_POA(child_name, null, policySets.rootPoa());
POA n = parent.create_POA(child_name, null, StandardPolicies.rootPoa());
n.the_POAManager().activate();
}
catch (Exception ex)
@@ -51,7 +51,7 @@ import org.omg.PortableServer.IdAssignmentPolicyValue;
*/
public class gnuIdAssignmentPolicy
extends _PolicyImplBase
implements IdAssignmentPolicy, vPolicy
implements IdAssignmentPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
@@ -51,7 +51,7 @@ import org.omg.PortableServer.IdUniquenessPolicyValue;
*/
public class gnuIdUniquenessPolicy
extends _PolicyImplBase
implements IdUniquenessPolicy, vPolicy
implements IdUniquenessPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ImplicitActivationPolicyValue;
*/
public class gnuImplicitActivationPolicy
extends _PolicyImplBase
implements ImplicitActivationPolicy, vPolicy
implements ImplicitActivationPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
@@ -51,7 +51,7 @@ import org.omg.PortableServer.LifespanPolicyValue;
*/
public class gnuLifespanPolicy
extends _PolicyImplBase
implements LifespanPolicy, vPolicy
implements LifespanPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
+331 -140
View File
@@ -49,10 +49,15 @@ import org.omg.CORBA.LocalObject;
import org.omg.CORBA.NO_IMPLEMENT;
import org.omg.CORBA.OBJ_ADAPTER;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
import org.omg.CORBA.Policy;
import org.omg.CORBA.SetOverrideType;
import org.omg.CORBA.TRANSIENT;
import org.omg.CORBA.portable.ObjectImpl;
import org.omg.PortableInterceptor.NON_EXISTENT;
import org.omg.PortableInterceptor.ObjectReferenceFactory;
import org.omg.PortableInterceptor.ObjectReferenceTemplate;
import org.omg.PortableInterceptor.ObjectReferenceTemplateHelper;
import org.omg.PortableServer.AdapterActivator;
import org.omg.PortableServer.ForwardRequest;
import org.omg.PortableServer.IdAssignmentPolicy;
@@ -87,8 +92,10 @@ import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
import org.omg.PortableServer.POAPackage.ServantNotActive;
import org.omg.PortableServer.POAPackage.WrongAdapter;
import org.omg.PortableServer.POAPackage.WrongPolicy;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.cdrBufOutput;
import gnu.CORBA.OrbFunctional;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.CDR.BufferedCdrOutput;
/**
* Our POA implementation.
@@ -97,12 +104,108 @@ import gnu.CORBA.CDR.cdrBufOutput;
*/
public class gnuPOA
extends LocalObject
implements POA
implements POA, ObjectReferenceFactory
{
/**
* The object reference template, associated with this POA.
*
* @since 1.5
*/
class RefTemplate implements ObjectReferenceTemplate
{
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
RefTemplate()
{
// The adapter name is computed once.
ArrayList names = new ArrayList();
names.add(the_name());
POA poa = the_parent();
while (poa != null)
{
names.add(poa.the_name());
poa = poa.the_parent();
}
// Fill in the string array in reverse (more natural) order,
// root POA first.
m_adapter_name = new String[names.size()];
for (int i = 0; i < m_adapter_name.length; i++)
m_adapter_name[i] = (String) names.get(m_adapter_name.length - i - 1);
}
/**
* The adapter name
*/
final String[] m_adapter_name;
/**
* Get the name of this POA.
*/
public String[] adapter_name()
{
return (String[]) m_adapter_name.clone();
}
/**
* Get the ORB id.
*/
public String orb_id()
{
return m_orb.orb_id;
}
/**
* Get the server id.
*/
public String server_id()
{
return OrbFunctional.server_id;
}
/**
* Create the object.
*/
public Object make_object(String repositoryId, byte[] objectId)
{
return create_reference_with_id(objectId, repositoryId);
}
/**
* Get the array of truncatible repository ids.
*/
public String[] _truncatable_ids()
{
return ref_template_ids;
}
}
/**
* Use serialVersionUID for interoperability.
*/
private static final long serialVersionUID = 1;
/**
* The adapter reference template.
*/
ObjectReferenceTemplate refTemplate;
/**
* The reference template repository ids. Defined outside the class as it
* cannot have static members.
*/
final static String[] ref_template_ids =
new String[] { ObjectReferenceTemplateHelper.id() };
/**
* The active object map, mapping between object keys, objects and servants.
*/
public final activeObjectMap aom = new activeObjectMap();
public final AOM aom = new AOM();
/**
* The children of this POA.
@@ -182,6 +285,12 @@ public class gnuPOA
* necessity of the frequent checks.
*/
public final boolean retain_servant;
/**
* The object reference factory, used to create the new object
* references.
*/
ObjectReferenceFactory m_object_factory = this;
/**
* Create a new abstract POA.
@@ -199,7 +308,7 @@ public class gnuPOA
throws InvalidPolicy
{
// Add default policies.
Policy[] all_policies = policySets.withDefault(a_policies);
Policy[] all_policies = StandardPolicies.withDefault(a_policies);
name = a_name;
parent = a_parent;
@@ -222,12 +331,14 @@ public class gnuPOA
for (int i = 0; i < s_policies.length; i++)
{
s_policies [ i ] = all_policies [ i ].copy();
m_policies.add(((vPolicy) s_policies [ i ]).getValue());
m_policies.add(((AccessiblePolicy) s_policies [ i ]).getValue());
}
retain_servant = applies(ServantRetentionPolicyValue.RETAIN);
validatePolicies(a_policies);
refTemplate = new RefTemplate();
}
/**
@@ -281,7 +392,7 @@ public class gnuPOA
keys.addAll(aom.keySet());
byte[] key;
activeObjectMap.Obj obj;
AOM.Obj obj;
boolean last;
for (int i = 0; i < keys.size(); i++)
{
@@ -422,30 +533,30 @@ public class gnuPOA
}
/**
* Generate the Object Id for the given servant and add the servant to
* the Active Object Map using this Id a a key. If the servant
* activator is set, its incarnate method will be called.
*
* @param a_servant a servant that would serve the object with the
* returned Object Id. If null is passed, under apporoprate policies the
* servant activator is invoked.
*
* Generate the Object Id for the given servant and add the servant to the
* Active Object Map using this Id a a key. If the servant activator is set,
* its incarnate method will be called.
*
* @param a_servant a servant that would serve the object with the returned
* Object Id. If null is passed, under apporoprate policies the servant
* activator is invoked.
*
* @return the generated objert Id for the given servant.
*
* @throws ServantAlreadyActive if this servant is already in the
* Active Object Map and the UNIQUE_ID policy applies.
*
* @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN
* do not apply to this POA.
*
* @throws ServantAlreadyActive if this servant is already in the Active
* Object Map and the UNIQUE_ID policy applies.
*
* @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN do not
* apply to this POA.
*/
public byte[] activate_object(Servant a_servant)
throws ServantAlreadyActive, WrongPolicy
throws ServantAlreadyActive, WrongPolicy
{
checkDiscarding();
required(ServantRetentionPolicyValue.RETAIN);
required(IdAssignmentPolicyValue.SYSTEM_ID);
activeObjectMap.Obj exists = aom.findServant(a_servant);
AOM.Obj exists = aom.findServant(a_servant);
if (exists != null)
{
@@ -464,28 +575,30 @@ public class gnuPOA
// activations.
}
byte[] object_key = activeObjectMap.getFreeId();
servantDelegate delegate = new servantDelegate(a_servant, this, object_key);
connectDelegate(object_key, delegate);
byte[] object_key = AOM.getFreeId();
ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,
object_key);
create_and_connect(object_key,
a_servant._all_interfaces(this, object_key)[0], delegate);
return object_key;
}
/**
* Add the given servant to the Active Object Map as a servant for the
* object with the provided Object Id. If the servant activator is
* set, its incarnate method will be called.
*
* Add the given servant to the Active Object Map as a servant for the object
* with the provided Object Id. If the servant activator is set, its incarnate
* method will be called.
*
* @param an_Object_Id an object id for the given object.
* @param a_servant a servant that will serve the object with the given
* Object Id. If null is passed, under apporoprate policies the
* servant activator is invoked.
*
* @throws ObjectAlreadyActive if the given object id is already in the
* Active Object Map.
* @throws ServantAlreadyActive if the UNIQUE_ID policy applies and
* this servant is already in use.
* @throws WrongPolicy if the required RETAIN policy does not apply to
* this POA.
* @param a_servant a servant that will serve the object with the given Object
* Id. If null is passed, under apporoprate policies the servant activator is
* invoked.
*
* @throws ObjectAlreadyActive if the given object id is already in the Active
* Object Map.
* @throws ServantAlreadyActive if the UNIQUE_ID policy applies and this
* servant is already in use.
* @throws WrongPolicy if the required RETAIN policy does not apply to this
* POA.
* @throws BAD_PARAM if the passed object id is invalid due any reason.
*/
public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant)
@@ -496,16 +609,14 @@ public class gnuPOA
}
/**
* Same as activate_object_with_id, but permits gnuForwardRequest
* forwarding exception. This is used when the activation is called
* from the remote invocation context and we have possibility
* to return the forwarding message.
* Same as activate_object_with_id, but permits gnuForwardRequest forwarding
* exception. This is used when the activation is called from the remote
* invocation context and we have possibility to return the forwarding
* message.
*/
public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant,
boolean use_forwarding
)
throws ServantAlreadyActive, ObjectAlreadyActive,
WrongPolicy
boolean use_forwarding)
throws ServantAlreadyActive, ObjectAlreadyActive, WrongPolicy
{
checkDiscarding();
required(ServantRetentionPolicyValue.RETAIN);
@@ -514,12 +625,12 @@ public class gnuPOA
// already active.
if (applies(IdUniquenessPolicyValue.UNIQUE_ID))
{
activeObjectMap.Obj sx = aom.findServant(a_servant, false);
AOM.Obj sx = aom.findServant(a_servant, false);
if (sx != null)
throw new ServantAlreadyActive();
}
activeObjectMap.Obj exists = aom.get(an_Object_Id);
AOM.Obj exists = aom.get(an_Object_Id);
if (exists != null)
{
if (exists.servant == null)
@@ -537,26 +648,27 @@ public class gnuPOA
}
else
{
servantDelegate delegate =
new servantDelegate(a_servant, this, an_Object_Id);
connectDelegate(an_Object_Id, delegate);
ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this,
an_Object_Id);
create_and_connect(an_Object_Id, a_servant._all_interfaces(this,
an_Object_Id)[0], delegate);
}
}
/**
* Locate the servant for this object Id and connect it to ORB.
*
*
* @param an_Object_Id the object id.
* @param a_servant the servant (may be null).
* @param exists an existing active object map entry.
* @param use_forwarding allow to throw the gnuForwardRequest
* if the activator throws ForwardRequest.
*
* @throws OBJ_ADAPTER minor 4 if the servant cannot be located
* (the required servant manager may be missing).
* @param use_forwarding allow to throw the gnuForwardRequest if the activator
* throws ForwardRequest.
*
* @throws OBJ_ADAPTER minor 4 if the servant cannot be located (the required
* servant manager may be missing).
*/
private void locateServant(byte[] an_Object_Id, Servant a_servant,
activeObjectMap.Obj exists, boolean use_forwarding
AOM.Obj exists, boolean use_forwarding
)
throws InternalError
{
@@ -582,8 +694,8 @@ public class gnuPOA
throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO);
}
servantDelegate delegate =
new servantDelegate(exists.servant, this, an_Object_Id);
ServantDelegateImpl delegate =
new ServantDelegateImpl(exists.servant, this, an_Object_Id);
exists.servant._set_delegate(delegate);
object.setServant(exists.servant);
connect_to_orb(an_Object_Id, delegate.object);
@@ -605,7 +717,7 @@ public class gnuPOA
{
required(ServantRetentionPolicyValue.RETAIN);
activeObjectMap.Obj exists = aom.get(the_Object_Id);
AOM.Obj exists = aom.get(the_Object_Id);
if (exists == null || exists.isDeactiveted())
throw new ObjectNotActive();
@@ -615,7 +727,7 @@ public class gnuPOA
// Check if this servant is serving something else.
aom.remove(the_Object_Id);
activeObjectMap.Obj other = aom.findServant(exists.servant, false);
AOM.Obj other = aom.findServant(exists.servant, false);
boolean remaining = other != null;
@@ -643,7 +755,7 @@ public class gnuPOA
throws WrongPolicy
{
required(IdAssignmentPolicyValue.SYSTEM_ID);
return create_reference_with_id(activeObjectMap.getFreeId(), a_repository_id);
return create_reference_with_id(AOM.getFreeId(), a_repository_id);
}
/**
@@ -662,8 +774,8 @@ public class gnuPOA
* servant.
*/
public org.omg.CORBA.Object create_reference_with_id(byte[] an_object_id,
String a_repository_id
)
String a_repository_id
)
{
String[] ids;
if (a_repository_id == null)
@@ -672,7 +784,7 @@ public class gnuPOA
ids = new String[] { a_repository_id };
// Check maybe such object is already activated.
activeObjectMap.Obj e = aom.get(an_object_id);
AOM.Obj e = aom.get(an_object_id);
Servant servant;
if (e == null)
@@ -847,7 +959,7 @@ public class gnuPOA
return m_poa_id;
else
{
cdrBufOutput buffer = new cdrBufOutput();
BufferedCdrOutput buffer = new BufferedCdrOutput();
POA p = this;
while (p != null)
{
@@ -874,7 +986,7 @@ public class gnuPOA
{
required(ServantRetentionPolicyValue.RETAIN);
activeObjectMap.Obj ref = aom.get(the_Object_Id);
AOM.Obj ref = aom.get(the_Object_Id);
if (ref == null)
throw new ObjectNotActive();
else
@@ -897,7 +1009,7 @@ public class gnuPOA
{
if (applies(ServantRetentionPolicyValue.RETAIN))
{
activeObjectMap.Obj ref = aom.get(the_Object_Id);
AOM.Obj ref = aom.get(the_Object_Id);
if (ref == null || ref.isDeactiveted())
{
if (default_servant != null)
@@ -932,7 +1044,7 @@ public class gnuPOA
public byte[] reference_to_id(org.omg.CORBA.Object the_Object)
throws WrongAdapter, WrongPolicy
{
activeObjectMap.Obj ref = aom.findObject(the_Object);
AOM.Obj ref = aom.findObject(the_Object);
if (ref == null)
throw new WrongAdapter();
return ref.key;
@@ -958,7 +1070,7 @@ public class gnuPOA
{
if (applies(ServantRetentionPolicyValue.RETAIN))
{
activeObjectMap.Obj ref = aom.findObject(the_Object);
AOM.Obj ref = aom.findObject(the_Object);
if (ref == null)
throw new WrongAdapter();
else if (ref.isDeactiveted() || ref.servant == null)
@@ -1017,7 +1129,7 @@ public class gnuPOA
)
)
{
activeObjectMap.Obj ref = null;
AOM.Obj ref = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
ref = aom.findServant(the_Servant);
if (ref == null &&
@@ -1047,31 +1159,31 @@ public class gnuPOA
}
/**
* <p>Converts the given servant to the object reference.
* The servant will serve all methods, invoked on the returned object.
* The returned object reference can be passed to the remote client,
* enabling remote invocations.
* </p><p>
* If the specified servant is active, it is returned. Otherwise,
* if the POA has the IMPLICIT_ACTIVATION policy the method activates
* the servant. In this case, if the servant activator is set,
* the {@link ServantActivatorOperations#incarnate} method will be called.
* <p>
* Converts the given servant to the object reference. The servant will serve
* all methods, invoked on the returned object. The returned object reference
* can be passed to the remote client, enabling remote invocations.
* </p>
*
* <p>
* If the specified servant is active, it is returned. Otherwise, if the POA
* has the IMPLICIT_ACTIVATION policy the method activates the servant. In
* this case, if the servant activator is set, the
* {@link ServantActivatorOperations#incarnate} method will be called.
* </p>
*
* @throws ServantNotActive if the servant is inactive and no
* IMPLICIT_ACTIVATION policy applies.
* @throws WrongPolicy This method needs the RETAIN policy and either the
* UNIQUE_ID or IMPLICIT_ACTIVATION policies.
*
*
* @return the object, exposing the given servant in the context of this POA.
*/
public org.omg.CORBA.Object servant_to_reference(Servant the_Servant)
throws ServantNotActive,
WrongPolicy
throws ServantNotActive, WrongPolicy
{
required(ServantRetentionPolicyValue.RETAIN);
activeObjectMap.Obj exists = null;
AOM.Obj exists = null;
if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID))
exists = aom.findServant(the_Servant);
@@ -1092,17 +1204,17 @@ public class gnuPOA
else
return exists.object;
}
if (exists == null &&
applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)
)
if (exists == null
&& applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION))
{
checkDiscarding();
byte[] object_key = activeObjectMap.getFreeId();
byte[] object_key = AOM.getFreeId();
servantDelegate delegate =
new servantDelegate(the_Servant, this, object_key);
connectDelegate(object_key, delegate);
ServantDelegateImpl delegate = new ServantDelegateImpl(the_Servant,
this, object_key);
create_and_connect(object_key, the_Servant._all_interfaces(this,
object_key)[0], delegate);
return delegate.object;
}
@@ -1111,22 +1223,22 @@ public class gnuPOA
}
/**
* Incarnate in cases when request forwarding is not expected
* because the servant must be provided by the servant activator.
*
* @param x the aom entry, where the object is replaced by
* value, returned by servant activator (if not null).
*
* Incarnate in cases when request forwarding is not expected because the
* servant must be provided by the servant activator.
*
* @param x the aom entry, where the object is replaced by value, returned by
* servant activator (if not null).
*
* @param key the object key.
*
*
* @param a_servant the servant that was passed as a parameter in the
* activation method.
*
* @param use_forwarding if true, the gnuForwardRequest is throw
* under the forwarding exception (for remote client). Otherwise, the
* request is internally redirected (for local invocation).
*
* @param use_forwarding if true, the gnuForwardRequest is throw under the
* forwarding exception (for remote client). Otherwise, the request is
* internally redirected (for local invocation).
*/
private Servant incarnate(activeObjectMap.Obj x, byte[] object_key,
private Servant incarnate(AOM.Obj x, byte[] object_key,
Servant a_servant, boolean use_forwarding
)
{
@@ -1281,34 +1393,46 @@ public class gnuPOA
}
/**
* <p> Destroy this POA and all descendant POAs. The destroyed POAs can be
* later re-created via {@link AdapterActivator} or by invoking
* {@link #create_POA}.
* This differs from {@link PoaManagerOperations#deactivate} that does
* not allow recreation of the deactivated POAs. After deactivation,
* recreation is only possible if the POAs were later destroyed.
* </p><p>
* The remote invocation on the target, belonging to the POA that is
* currently destroyed return the remote exception ({@link TRANSIENT},
* minor code 4).
* <p>
* Destroy this POA and all descendant POAs. The destroyed POAs can be later
* re-created via {@link AdapterActivator} or by invoking {@link #create_POA}.
* This differs from {@link PoaManagerOperations#deactivate} that does not
* allow recreation of the deactivated POAs. After deactivation, recreation is
* only possible if the POAs were later destroyed.
* </p>
* <p>
* The remote invocation on the target, belonging to the POA that is currently
* destroyed return the remote exception ({@link TRANSIENT}, minor code 4).
* </p>
*
* @param etherealize_objects if true, and POA has RETAIN policy, and the
* servant manager is available, the servant manager method
* {@link ServantActivatorOperations#etherealize} is called for each
* <i>active</i> object in the Active Object Map. This method should not
* try to access POA being destroyed. If <code>destroy</code> is called
* multiple times before the destruction completes,
* the etherialization should be invoked only once.
*
* {@link ServantActivatorOperations#etherealize} is called for each <i>active</i>
* object in the Active Object Map. This method should not try to access POA
* being destroyed. If <code>destroy</code> is called multiple times before
* the destruction completes, the etherialization should be invoked only once.
*
* @param wait_for_completion if true, the method waits till the POA being
* destroyed completes all current requests and etherialization. If false,
* the method returns immediately.
* destroyed completes all current requests and etherialization. If false, the
* method returns immediately.
*/
public void destroy(boolean etherealize_objects, boolean wait_for_completion)
{
// Notify the IOR interceptors about that the POA is destroyed.
if (m_orb.iIor != null)
m_orb.iIor.adapter_state_changed(
new ObjectReferenceTemplate[] { getReferenceTemplate() },
NON_EXISTENT.value);
if (wait_for_completion)
waitWhileRunning();
// Nofify the IOR interceptors that the POA is destroyed.
if (m_manager instanceof gnuPOAManager)
{
((gnuPOAManager) m_manager).poaDestroyed(this);
}
// Put the brake instead of manager, preventing the subsequent
// requests.
gnuPOAManager g = new gnuPOAManager();
@@ -1328,7 +1452,7 @@ public class gnuPOA
keys.addAll(aom.keySet());
byte[] key;
activeObjectMap.Obj obj;
AOM.Obj obj;
for (int i = 0; i < keys.size(); i++)
{
key = (byte[]) keys.get(i);
@@ -1348,7 +1472,7 @@ public class gnuPOA
POA[] ch = the_children();
for (int i = 0; i < ch.length; i++)
{
ch [ i ].destroy(etherealize_objects, wait_for_completion);
ch[i].destroy(etherealize_objects, wait_for_completion);
}
}
@@ -1430,13 +1554,14 @@ public class gnuPOA
}
/**
* Connect the given delegate under the given key, also calling
* incarnate.
* Connect the given delegate under the given key, also calling incarnate.
*/
private void connectDelegate(byte[] object_key, servantDelegate delegate)
private void create_and_connect(byte[] object_key, String repository_id,
ServantDelegateImpl delegate)
{
aom.add(delegate);
connect_to_orb(object_key, delegate.object);
connect_to_orb(object_key, getReferenceFactory().make_object(repository_id,
object_key));
if (servant_activator != null)
incarnate(null, object_key, delegate.servant, false);
}
@@ -1517,9 +1642,9 @@ public class gnuPOA
/**
* Recursively searches for the given object in the POA tree.
*/
public activeObjectMap.Obj findObject(org.omg.CORBA.Object object)
public AOM.Obj findObject(org.omg.CORBA.Object object)
{
activeObjectMap.Obj h = aom.findObject(object);
AOM.Obj h = aom.findObject(object);
if (h != null)
return h;
else
@@ -1533,16 +1658,16 @@ public class gnuPOA
}
return h;
}
/**
* Recursively searches for the given key in the POA tree.
* @param ior_key the key, ecapsulating both object
* and poa ids.
* @return
*/
public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id)
public AOM.Obj findKey(byte[] object_id, byte[] poa_id)
{
activeObjectMap.Obj h = null;
AOM.Obj h = null;
if (Arrays.equals(poa_id, id()))
h = aom.get(object_id);
if (h != null)
@@ -1563,9 +1688,9 @@ public class gnuPOA
* Parses the given key, extracts poa and object id and searches
* for such reference.
*/
public activeObjectMap.Obj findIorKey(byte[] ior_key)
public AOM.Obj findIorKey(byte[] ior_key)
{
cdrBufInput in = new cdrBufInput(ior_key);
BufferredCdrInput in = new BufferredCdrInput(ior_key);
int signature = in.read_long();
if (signature != SIGNATURE)
return null;
@@ -1582,7 +1707,7 @@ public class gnuPOA
*/
public byte[] toIORKey(byte[] object_id)
{
cdrBufOutput buffer = new cdrBufOutput();
BufferedCdrOutput buffer = new BufferedCdrOutput();
buffer.write_long(SIGNATURE);
buffer.write_sequence(object_id);
buffer.write_sequence(id());
@@ -1600,7 +1725,7 @@ public class gnuPOA
*/
public byte[] idFormIor(byte[] ior_key)
{
cdrBufInput in = new cdrBufInput(ior_key);
BufferredCdrInput in = new BufferredCdrInput(ior_key);
int signature = in.read_long();
if (signature != SIGNATURE)
return null;
@@ -1612,4 +1737,70 @@ public class gnuPOA
else
return null;
}
/**
* Recursively searches for the given servant in the POA tree.
*/
public AOM.Obj findServant(Servant servant)
{
AOM.Obj h = aom.findServant(servant);
if (h != null)
return h;
else
{
for (int i = 0; i < children.size(); i++)
{
h = ((gnuPOA) children.get(i)).findServant(servant);
if (h != null)
return h;
}
}
return h;
}
/**
* Get the object reference template of this POA.
* Instantiate a singleton instance, if required.
*/
public ObjectReferenceTemplate getReferenceTemplate()
{
if (refTemplate == null)
refTemplate = new RefTemplate();
return refTemplate;
}
public ObjectReferenceFactory getReferenceFactory()
{
return m_object_factory;
}
public void setReferenceFactory(ObjectReferenceFactory factory)
{
m_object_factory = factory;
}
/**
* Create the object (needed by the factory interface).
*/
public Object make_object(String a_repository_id, byte[] an_object_id)
{
AOM.Obj existing = aom.get(an_object_id);
// The object may already exist. In this case, it is just returned.
if (existing != null && existing.object != null)
return existing.object;
else
{
return new gnuServantObject(new String[] { a_repository_id },
an_object_id, this, m_orb);
}
}
/**
* Required by object reference factory ops.
*/
public String[] _truncatable_ids()
{
return ref_template_ids;
}
}
@@ -40,6 +40,8 @@ package gnu.CORBA.Poa;
import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.LocalObject;
import org.omg.PortableInterceptor.NON_EXISTENT;
import org.omg.PortableInterceptor.ObjectReferenceTemplate;
import org.omg.PortableServer.POAManager;
import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
import org.omg.PortableServer.POAManagerPackage.State;
@@ -59,18 +61,22 @@ public class gnuPOAManager
extends LocalObject
implements POAManager
{
/**
* The POAs, controlled by this manager. The members must be instances of
* the gnuAbstractPOA.
/**
* Use serialVersionUID for interoperability.
*/
HashSet POAs = new HashSet();
private static final long serialVersionUID = 1;
/**
* The POAs, controlled by this manager.
*/
private HashSet POAs = new HashSet();
/**
* The state of the manager. The newly created manager is always
* in the holding state.
*/
State state = State.HOLDING;
/**
* Get the state of the POA manager.
*/
@@ -94,6 +100,8 @@ public class gnuPOAManager
state = State.ACTIVE;
else
throw new AdapterInactive();
notifyInterceptors(state.value());
}
/**
@@ -113,6 +121,9 @@ public class gnuPOAManager
state = State.HOLDING;
else
throw new AdapterInactive();
notifyInterceptors(state.value());
if (wait_for_completion)
waitForIdle();
}
@@ -144,6 +155,9 @@ public class gnuPOAManager
if (state == State.INACTIVE)
throw new AdapterInactive("Repetetive inactivation");
state = State.INACTIVE;
notifyInterceptors(state.value());
if (wait_for_completion)
waitForIdle();
@@ -178,6 +192,9 @@ public class gnuPOAManager
state = State.DISCARDING;
else
throw new AdapterInactive();
notifyInterceptors(state.value());
if (wait_for_completion)
waitForIdle();
}
@@ -193,11 +210,13 @@ public class gnuPOAManager
{
if (state == State.ACTIVE)
throw new BAD_INV_ORDER("The state is active");
gnuPOA poa;
Iterator iter = POAs.iterator();
while (iter.hasNext())
{
gnuPOA poa = (gnuPOA) iter.next();
poa = (gnuPOA) iter.next();
poa.waitWhileRunning();
}
}
@@ -222,4 +241,33 @@ public class gnuPOAManager
{
POAs.remove(poa);
}
/**
* This method is called when POA is destryed. The interceptors are
* notified.
*/
public void poaDestroyed(gnuPOA poa)
{
notifyInterceptors(NON_EXISTENT.value);
}
/**
* Notify CORBA 3.0 interceptors about the status change.
*/
public synchronized void notifyInterceptors(int new_state)
{
gnuPOA poa;
Iterator iter = POAs.iterator();
// The System.identityHashCode is also called in gnuIorInfo.
while (iter.hasNext())
{
poa = (gnuPOA) iter.next();
if (poa.m_orb.iIor != null)
{
poa.m_orb.iIor.adapter_manager_state_changed(
System.identityHashCode(this), (short) new_state);
}
}
}
}
@@ -51,7 +51,7 @@ import org.omg.PortableServer.RequestProcessingPolicyValue;
*/
public class gnuRequestProcessingPolicy
extends _PolicyImplBase
implements RequestProcessingPolicy, vPolicy
implements RequestProcessingPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
@@ -39,14 +39,17 @@ exception statement from your version. */
package gnu.CORBA.Poa;
import gnu.CORBA.GIOP.ReplyHeader;
import gnu.CORBA.IOR_Delegate;
import gnu.CORBA.IOR_contructed_object;
import gnu.CORBA.IorDelegate;
import gnu.CORBA.IorObject;
import gnu.CORBA.Interceptor.gnuServerRequestInfo;
import gnu.CORBA.typecodes.RecordTypeCode;
import gnu.CORBA.IOR;
import gnu.CORBA.IorProvider;
import gnu.CORBA.Minor;
import gnu.CORBA.ObjectCreator;
import gnu.CORBA.Unexpected;
import gnu.CORBA.bufferedResponseHandler;
import gnu.CORBA.recordTypeCode;
import gnu.CORBA.streamReadyHolder;
import gnu.CORBA.ResponseHandlerImpl;
import gnu.CORBA.StreamHolder;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
@@ -90,7 +93,8 @@ import java.util.Arrays;
public class gnuServantObject extends ObjectImpl
implements org.omg.CORBA.Object,
InvokeHandler,
CurrentOperations
CurrentOperations,
IorProvider
{
/**
* The associated servant that must also implement the {@link InvokeHandler}
@@ -144,6 +148,14 @@ public class gnuServantObject extends ObjectImpl
poa = a_poa;
orb = an_orb;
}
/**
* Get the IOR as it would be for this object.
*/
public IOR getIor()
{
return orb.getLocalIor(this);
}
/**
* Create a servant object, associated with the passed servant.
@@ -257,10 +269,8 @@ public class gnuServantObject extends ObjectImpl
}
catch (Exception ex)
{
ex.printStackTrace();
BAD_OPERATION bad =
new BAD_OPERATION("Unable to activate", 0x5004,
new BAD_OPERATION("Unable to activate", Minor.Activation,
CompletionStatus.COMPLETED_NO
);
bad.initCause(ex);
@@ -276,7 +286,7 @@ public class gnuServantObject extends ObjectImpl
// No servant and no servant manager - throw exception.
else
{
throw new BAD_OPERATION("Unable to activate", 0x5002,
throw new BAD_OPERATION("Unable to activate", Minor.Activation,
CompletionStatus.COMPLETED_NO
);
}
@@ -294,7 +304,7 @@ public class gnuServantObject extends ObjectImpl
}
else if (a_servant instanceof DynamicImplementation)
{
return new dynImpHandler((DynamicImplementation) a_servant);
return new DynamicImpHandler((DynamicImplementation) a_servant);
}
else
{
@@ -402,17 +412,17 @@ public class gnuServantObject extends ObjectImpl
boolean intercept = false;
ServerRequestInterceptorOperations interceptor = null;
gnuServerRequestInfo info = null;
bufferedResponseHandler i_handler = null;
ResponseHandlerImpl i_handler = null;
try
{
if (orb.iServer != null &&
r_handler instanceof bufferedResponseHandler
r_handler instanceof ResponseHandlerImpl
)
{
interceptor = orb.iServer;
i_handler = (bufferedResponseHandler) r_handler;
i_handler = (ResponseHandlerImpl) r_handler;
info =
new gnuServerRequestInfo(this, i_handler.request_header,
@@ -426,7 +436,7 @@ public class gnuServantObject extends ObjectImpl
try
{
CookieHolder cookie = null;
activeObjectMap.Obj self = poa.aom.get(Id);
AOM.Obj self = poa.aom.get(Id);
if (poa.servant_locator != null)
{
@@ -467,18 +477,18 @@ public class gnuServantObject extends ObjectImpl
{
// In some cases exception is thrown if the delegate is not set.
}
if (d instanceof servantDelegate)
if (d instanceof ServantDelegateImpl)
{
// If the delegate is already set, check maybe we can
// reuse the existing instance.
if (((servantDelegate) d).object != this)
if (((ServantDelegateImpl) d).object != this)
{
servant._set_delegate(new servantDelegate(servant, poa, Id));
servant._set_delegate(new ServantDelegateImpl(servant, poa, Id));
}
}
else
{
servant._set_delegate(new servantDelegate(servant, poa, Id));
servant._set_delegate(new ServantDelegateImpl(servant, poa, Id));
}
try
@@ -536,13 +546,13 @@ public class gnuServantObject extends ObjectImpl
{
// Failed due any reason, insert without
// helper.
a.insert_Streamable(new streamReadyHolder(
a.insert_Streamable(new StreamHolder(
buf.create_input_stream()
)
);
recordTypeCode r =
new recordTypeCode(TCKind.tk_except);
RecordTypeCode r =
new RecordTypeCode(TCKind.tk_except);
r.setId(uex_idl);
r.setName(ObjectCreator.getDefaultName(
uex_idl
@@ -774,12 +784,12 @@ public class gnuServantObject extends ObjectImpl
gnuServantObject g = (gnuServantObject) other;
return orb == g.orb && poa == g.poa && Arrays.equals(Id, g.Id);
}
else if (other instanceof IOR_contructed_object)
else if (other instanceof IorObject)
{
IOR_contructed_object ir = ((IOR_contructed_object) other);
IorObject ir = ((IorObject) other);
try
{
IOR_Delegate ird = (IOR_Delegate) ir._get_delegate();
IorDelegate ird = (IorDelegate) ir._get_delegate();
byte[] ior_id = poa.idFormIor(ird.getIor().key);
if (ior_id != null && Arrays.equals(ior_id, Id))
{
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ServantRetentionPolicyValue;
*/
public class gnuServantRetentionPolicy
extends _PolicyImplBase
implements ServantRetentionPolicy, vPolicy
implements ServantRetentionPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
@@ -51,7 +51,7 @@ import org.omg.PortableServer.ThreadPolicyValue;
*/
public class gnuThreadPolicy
extends _PolicyImplBase
implements ThreadPolicy, vPolicy
implements ThreadPolicy, AccessiblePolicy
{
/**
* Use serialVersionUID for interoperability.
@@ -1,4 +1,4 @@
/* binaryReply.java --
/* RawReply.java --
Copyright (C) 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -37,7 +37,7 @@ exception statement from your version. */
package gnu.CORBA;
import gnu.CORBA.CDR.cdrBufInput;
import gnu.CORBA.CDR.BufferredCdrInput;
import gnu.CORBA.GIOP.MessageHeader;
import org.omg.CORBA.ORB;
@@ -48,7 +48,7 @@ import org.omg.CORBA.ORB;
*
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
class binaryReply
class RawReply
{
/**
* The message header.
@@ -71,7 +71,7 @@ class binaryReply
* @param an_header the message header
* @param a_data the message data.
*/
binaryReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
RawReply(ORB an_orb, MessageHeader an_header, byte[] a_data)
{
orb = an_orb;
header = an_header;
@@ -83,9 +83,9 @@ class binaryReply
*
* @return the CDR stream to read the message data.
*/
cdrBufInput getStream()
BufferredCdrInput getStream()
{
cdrBufInput in = new cdrBufInput(data);
BufferredCdrInput in = new BufferredCdrInput(data);
in.setOffset(header.getHeaderSize());
in.setVersion(header.version);
in.setOrb(orb);

Some files were not shown because too many files have changed in this diff Show More