diff options
96 files changed, 8662 insertions, 2068 deletions
@@ -1,3 +1,93 @@ +2005-08-28 <AudriusA@Bioinformatics.org> + + * gnu/CORBA/Interceptor/ForwardRequestHolder.java,
gnu/CORBA/Interceptor/gnuClientRequestInfo.java,
gnu/CORBA/Interceptor/gnuIcCurrent.java,
gnu/CORBA/Interceptor/gnuIorInfo.java,
gnu/CORBA/Interceptor/gnuServerRequestInfo.java,
gnu/CORBA/Interceptor/IORInterceptors.java,
gnu/CORBA/Interceptor/ClientRequestInterceptors.java,
gnu/CORBA/Interceptor/Registrator.java,
gnu/CORBA/Interceptor/ServerRequestInterceptors.java,
gnu/CORBA/GIOP/contextSupportingHeader.java, + org/omg/PortableInterceptor/ClientRequestInfo.java, + org/omg/PortableInterceptor/ClientRequestInfoOperations.java, + org/omg/PortableInterceptor/ClientRequestInterceptor.java, + org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java, + org/omg/PortableInterceptor/Current.java, + org/omg/PortableInterceptor/CurrentHelper.java, + org/omg/PortableInterceptor/CurrentOperations.java, + org/omg/PortableInterceptor/ForwardRequest.java, + org/omg/PortableInterceptor/ForwardRequestHelper.java, + org/omg/PortableInterceptor/InvalidSlot.java, + org/omg/PortableInterceptor/InvalidSlotHelper.java, + org/omg/PortableInterceptor/ORBInitInfo.java, + org/omg/PortableInterceptor/ORBInitInfoOperations.java, + org/omg/PortableInterceptor/ORBInitializer.java, + org/omg/PortableInterceptor/ORBInitializerOperations.java, + org/omg/PortableInterceptor/PolicyFactory.java, + org/omg/PortableInterceptor/PolicyFactoryOperations.java, + org/omg/PortableInterceptor/RequestInfo.java, + org/omg/PortableInterceptor/RequestInfoOperations.java, + org/omg/PortableInterceptor/ServerRequestInfo.java, + org/omg/PortableInterceptor/ServerRequestInfoOperations.java, + org/omg/PortableInterceptor/ServerRequestInterceptor.java, + org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java, + org/omg/PortableInterceptor/package.html: New files. + * gnu/CORBA/ExceptionCreator.java, + gnu/CORBA/Functional_ORB.java, + gnu/CORBA/IOR.java, + gnu/CORBA/IOR_Delegate.java, + gnu/CORBA/ObjectCreator.java, + gnu/CORBA/Restricted_ORB.java, + gnu/CORBA/bufferedResponseHandler.java, + gnu/CORBA/gnuCodecFactory.java, + gnu/CORBA/gnuRequest.java, + gnu/CORBA/primitiveArrayTypeCode.java, + gnu/CORBA/primitiveTypeCode.java, + gnu/CORBA/CDR/Vio.java, + gnu/CORBA/CDR/cdrOutput.java, + gnu/CORBA/DynAn/gnuDynAny.java, + gnu/CORBA/DynAn/gnuDynEnum.java, + gnu/CORBA/DynAn/gnuDynFixed.java, + gnu/CORBA/DynAn/gnuDynValue.java, + gnu/CORBA/GIOP/ReplyHeader.java, + gnu/CORBA/GIOP/RequestHeader.java, + gnu/CORBA/GIOP/ServiceContext.java, + gnu/CORBA/GIOP/v1_0/RequestHeader.java, + gnu/CORBA/Poa/LocalDelegate.java, + gnu/CORBA/Poa/LocalRequest.java, + gnu/CORBA/Poa/ORB_1_4.java, + gnu/CORBA/Poa/gnuServantObject.java, + gnu/CORBA/Poa/servantDelegate.java, + org/omg/CORBA/ServiceDetailHelper.java, + org/omg/CORBA/DynAnyPackage/Invalid.java, + org/omg/CORBA/DynAnyPackage/InvalidSeq.java, + org/omg/CORBA/DynAnyPackage/InvalidValue.java, + org/omg/CORBA/DynAnyPackage/TypeMismatch.java, + org/omg/DynamicAny/NameDynAnyPairSeqHelper.java, + org/omg/DynamicAny/_DynAnyFactoryStub.java, + org/omg/DynamicAny/_DynAnyStub.java, + org/omg/DynamicAny/_DynArrayStub.java, + org/omg/DynamicAny/_DynEnumStub.java, + org/omg/DynamicAny/_DynFixedStub.java, + org/omg/DynamicAny/_DynSequenceStub.java, + org/omg/DynamicAny/_DynStructStub.java, + org/omg/DynamicAny/_DynUnionStub.java, + org/omg/DynamicAny/_DynValueStub.java, + org/omg/IOP/ServiceContext.java, + org/omg/IOP/TaggedComponentHelper.java, + org/omg/IOP/TaggedProfileHelper.java, + org/omg/PortableInterceptor/IORInfo.java, + org/omg/PortableInterceptor/IORInfoOperations.java, + org/omg/PortableInterceptor/IORInterceptor.java, + org/omg/PortableInterceptor/IORInterceptorOperations.java, + org/omg/PortableInterceptor/Interceptor.java, + org/omg/PortableInterceptor/LOCATION_FORWARD.java, + org/omg/PortableInterceptor/SUCCESSFUL.java, + org/omg/PortableInterceptor/SYSTEM_EXCEPTION.java, + org/omg/PortableInterceptor/TRANSPORT_RETRY.java, + org/omg/PortableInterceptor/USER_EXCEPTION.java, + org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateName.java, + org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java, + org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidName.java, + org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java, + org/omg/PortableInterceptor/ORBInitInfoPackage/ObjectIdHelper.java: Rewritten. + * org/omg/CORBA/ORB.java, + org/omg/CORBA/package.html, + NEWS: Documentation update. + 2005-08-28 Chris Burdess <dog@gnu.org> * gnu/xml/xpath/ArithmeticExpr.java: Fix div and mod by zero to @@ -1,5 +1,11 @@ New in release 0.18 (not yet released) +* The PortableInterceptor and related functionality in other packages + is now implemented: + + The sever and client interceptors work as required since jdk 1.4. + The IOR interceptor works as needed for jdk 1.5. + * The DynamicAny package is completed and passes the prepared tests. * The Portable Object Adapter should now support the output of the recent IDL to java compilers. These compilers now generate servants and diff --git a/gnu/CORBA/CDR/Vio.java b/gnu/CORBA/CDR/Vio.java index d7a749dd6..0a37132b2 100644 --- a/gnu/CORBA/CDR/Vio.java +++ b/gnu/CORBA/CDR/Vio.java @@ -46,7 +46,7 @@ import org.omg.CORBA.DataOutputStream; import org.omg.CORBA.MARSHAL; import org.omg.CORBA.NO_IMPLEMENT; import org.omg.CORBA.StringSeqHelper; -import org.omg.CORBA.portable.*; +import org.omg.CORBA.portable.BoxedValueHelper; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.Streamable; @@ -317,8 +317,8 @@ public abstract class Vio * @throws MARSHAL if the reading has failed due any reason. */ public static Object read(InputStream input, Object value_instance, - Object helper - ) + Object helper + ) { try { @@ -399,8 +399,8 @@ public abstract class Vio * @return the value that was read. */ private static Object read_instance(InputStream input, Object value, - int value_tag, Object helper - ) + int value_tag, Object helper + ) { try { @@ -507,8 +507,8 @@ public abstract class Vio // Stating the interfaces that the USER should use. throw new MARSHAL("The " + value.getClass().getName() + - " must implement either StreamableValue or CustomValue." - ); + " must implement either StreamableValue or CustomValue." + ); // The negative end of state marker is expected from OMG standard. // If the chunking is used, this marker is already extracted. @@ -562,8 +562,8 @@ public abstract class Vio * @throws MARSHAL if the writing failed due any reason. */ public static void write(OutputStream output, Serializable value, - Class substitute - ) + Class substitute + ) { // Write null if this is a null value. if (value == null) @@ -598,8 +598,8 @@ public abstract class Vio * not null. */ public static void write(OutputStream output, Serializable value, - Object helper - ) + Object helper + ) { if (value == null) output.write_long(vt_NULL); @@ -627,8 +627,8 @@ public abstract class Vio * if the value should be written unsing other methods. */ private static void write_instance(OutputStream output, Serializable value, - String id, Object helper - ) + String id, Object helper + ) { // This implementation always writes a single repository id. // It never writes multiple repository ids and currently does not use @@ -684,12 +684,11 @@ public abstract class Vio // for the global boxed value type itself. Method write = helperClass.getMethod("write", - new Class[] - { - org.omg.CORBA.portable.OutputStream.class, - value.getClass() - } - ); + new Class[] + { + org.omg.CORBA.portable.OutputStream.class, value.getClass() + } + ); write.invoke(null, new Object[] { outObj, value }); ok = true; } @@ -701,9 +700,8 @@ public abstract class Vio // Stating the interfaces that the USER should use. if (!ok) throw new MARSHAL("The " + value.getClass().getName() + - " must implement either StreamableValue" + - " or CustomValue." - ); + " must implement either StreamableValue" + " or CustomValue." + ); } if (USE_CHUNKING) @@ -731,8 +729,7 @@ public abstract class Vio * * @throws NO_IMPLEMENT, always. */ - static void incorrect_plug_in(Throwable ex) - throws NO_IMPLEMENT + static void incorrect_plug_in(Throwable ex) throws NO_IMPLEMENT { NO_IMPLEMENT no = new NO_IMPLEMENT("Incorrect CORBA plug-in"); no.initCause(ex); @@ -749,10 +746,11 @@ public abstract class Vio private static final void checkTag(int value_tag) { if ((value_tag < 0x7fffff00 || value_tag > 0x7fffffff) && - value_tag != vt_NULL && value_tag != vt_INDIRECTION - ) + value_tag != vt_NULL && + value_tag != vt_INDIRECTION + ) throw new MARSHAL("Invalid value record, unsupported header tag: " + - value_tag - ); + value_tag + ); } }
\ No newline at end of file diff --git a/gnu/CORBA/CDR/cdrOutput.java b/gnu/CORBA/CDR/cdrOutput.java index 36a00e132..85f341c91 100644 --- a/gnu/CORBA/CDR/cdrOutput.java +++ b/gnu/CORBA/CDR/cdrOutput.java @@ -41,6 +41,7 @@ package gnu.CORBA.CDR; import gnu.CORBA.BigDecimalHelper; import gnu.CORBA.GIOP.CharSets_OSF; import gnu.CORBA.GIOP.cxCodeSet; +import gnu.CORBA.Poa.gnuServantObject; import gnu.CORBA.IOR; import gnu.CORBA.Simple_delegate; import gnu.CORBA.TypeCodeHelper; @@ -327,6 +328,15 @@ public abstract class cdrOutput IOR.write_null(this); return; } + else if (x instanceof gnuServantObject) + { + // The ORB may be different if several ORBs coexist + // in the same machine. + gnuServantObject g = (gnuServantObject) x; + IOR ior = g.orb.getLocalIor(x); + ior._write_no_endian(this); + return; + } else if (x instanceof ObjectImpl) { Delegate d = ((ObjectImpl) x)._get_delegate(); diff --git a/gnu/CORBA/DynAn/gnuDynAny.java b/gnu/CORBA/DynAn/gnuDynAny.java index a12706176..015628ebf 100644 --- a/gnu/CORBA/DynAn/gnuDynAny.java +++ b/gnu/CORBA/DynAn/gnuDynAny.java @@ -1,4 +1,4 @@ -/* primitiveDynAny.java -- +/* gnuDynAny.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,13 +38,14 @@ exception statement from your version. */ package gnu.CORBA.DynAn; -import gnu.CORBA.*; import gnu.CORBA.CDR.cdrBufOutput; 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 org.omg.CORBA.Any; import org.omg.CORBA.AnyHolder; @@ -65,7 +66,8 @@ import org.omg.CORBA.TypeCode; import org.omg.CORBA.TypeCodeHolder; import org.omg.CORBA.TypeCodePackage.BadKind; import org.omg.CORBA.ValueBaseHolder; -import org.omg.CORBA.portable.*; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.Streamable; import org.omg.DynamicAny.DynAny; import org.omg.DynamicAny.DynAnyPackage.InvalidValue; @@ -82,9 +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 abstractDynAny implements DynAny, Serializable { /** * Use serialVersionUID for interoperability. @@ -102,8 +102,8 @@ public class gnuDynAny * @param a_holder */ public gnuDynAny(Streamable aHolder, TypeCode oType, TypeCode aType, - gnuDynAnyFactory aFactory, ORB anOrb - ) + gnuDynAnyFactory aFactory, ORB anOrb + ) { super(oType, aType, aFactory, anOrb); holder = aHolder; @@ -114,8 +114,7 @@ public class gnuDynAny * * @param from the source to assign from. */ - public void assign(DynAny from) - throws TypeMismatch + public void assign(DynAny from) throws TypeMismatch { checkType(official_type, from.type()); @@ -141,8 +140,8 @@ public class gnuDynAny { other = new gnuDynAny((Streamable) (holder.getClass().newInstance()), - official_type, final_type, factory, orb - ); + official_type, final_type, factory, orb + ); } catch (Exception e) { @@ -163,12 +162,11 @@ public class gnuDynAny * * @return <code>null</code>, always. */ - public DynAny current_component() - throws TypeMismatch + public DynAny current_component() throws TypeMismatch { throw new TypeMismatch("Not applicable for " + - typeNamer.nameIt(final_type) - ); + typeNamer.nameIt(final_type) + ); } /** @@ -186,8 +184,7 @@ public class gnuDynAny * @throws TypeMismatch if the final_type of the passed Any is not the same as * the final_type, currently stored in this Any. */ - public void from_any(Any an_any) - throws TypeMismatch, InvalidValue + public void from_any(Any an_any) throws TypeMismatch, InvalidValue { checkType(official_type, an_any.type()); @@ -240,8 +237,7 @@ public class gnuDynAny /** * Return the second (enclosed any) that is stored in the wrapped Any. */ - public Any get_any() - throws TypeMismatch + public Any get_any() throws TypeMismatch { try { @@ -256,8 +252,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public boolean get_boolean() - throws TypeMismatch + public boolean get_boolean() throws TypeMismatch { try { @@ -272,8 +267,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public char get_char() - throws TypeMismatch + public char get_char() throws TypeMismatch { try { @@ -288,8 +282,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public double get_double() - throws TypeMismatch + public double get_double() throws TypeMismatch { try { @@ -304,8 +297,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public float get_float() - throws TypeMismatch + public float get_float() throws TypeMismatch { try { @@ -320,8 +312,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public int get_long() - throws TypeMismatch + public int get_long() throws TypeMismatch { try { @@ -336,8 +327,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public long get_longlong() - throws TypeMismatch + public long get_longlong() throws TypeMismatch { try { @@ -352,8 +342,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public byte get_octet() - throws TypeMismatch + public byte get_octet() throws TypeMismatch { try { @@ -368,8 +357,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public Object get_reference() - throws TypeMismatch + public Object get_reference() throws TypeMismatch { try { @@ -384,8 +372,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public short get_short() - throws TypeMismatch + public short get_short() throws TypeMismatch { try { @@ -400,8 +387,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public String get_string() - throws TypeMismatch + public String get_string() throws TypeMismatch { try { @@ -416,8 +402,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public TypeCode get_typecode() - throws TypeMismatch + public TypeCode get_typecode() throws TypeMismatch { try { @@ -432,32 +417,28 @@ public class gnuDynAny } /** {@inheritDoc} */ - public int get_ulong() - throws TypeMismatch + public int get_ulong() throws TypeMismatch { check(TCKind.tk_ulong); return get_long(); } /** {@inheritDoc} */ - public long get_ulonglong() - throws TypeMismatch + public long get_ulonglong() throws TypeMismatch { check(TCKind.tk_ulonglong); return get_longlong(); } /** {@inheritDoc} */ - public short get_ushort() - throws TypeMismatch + public short get_ushort() throws TypeMismatch { check(TCKind.tk_ushort); return get_short(); } /** {@inheritDoc} */ - public Serializable get_val() - throws TypeMismatch + public Serializable get_val() throws TypeMismatch { try { @@ -472,8 +453,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public char get_wchar() - throws TypeMismatch + public char get_wchar() throws TypeMismatch { try { @@ -488,8 +468,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public String get_wstring() - throws TypeMismatch + public String get_wstring() throws TypeMismatch { try { @@ -504,8 +483,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_any(Any a_x) - throws TypeMismatch, InvalidValue + public void insert_any(Any a_x) throws TypeMismatch, InvalidValue { try { @@ -539,8 +517,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_boolean(boolean a_x) - throws InvalidValue, TypeMismatch + public void insert_boolean(boolean a_x) throws InvalidValue, TypeMismatch { try { @@ -556,8 +533,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_char(char a_x) - throws InvalidValue, TypeMismatch + public void insert_char(char a_x) throws InvalidValue, TypeMismatch { try { @@ -573,8 +549,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_double(double a_x) - throws InvalidValue, TypeMismatch + public void insert_double(double a_x) throws InvalidValue, TypeMismatch { try { @@ -590,8 +565,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_float(float a_x) - throws InvalidValue, TypeMismatch + public void insert_float(float a_x) throws InvalidValue, TypeMismatch { try { @@ -607,8 +581,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_long(int a_x) - throws InvalidValue, TypeMismatch + public void insert_long(int a_x) throws InvalidValue, TypeMismatch { try { @@ -624,8 +597,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_longlong(long a_x) - throws InvalidValue, TypeMismatch + public void insert_longlong(long a_x) throws InvalidValue, TypeMismatch { try { @@ -641,8 +613,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_octet(byte a_x) - throws InvalidValue, TypeMismatch + public void insert_octet(byte a_x) throws InvalidValue, TypeMismatch { try { @@ -658,8 +629,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_reference(Object a_x) - throws InvalidValue, TypeMismatch + public void insert_reference(Object a_x) throws InvalidValue, TypeMismatch { try { @@ -675,8 +645,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_short(short a_x) - throws InvalidValue, TypeMismatch + public void insert_short(short a_x) throws InvalidValue, TypeMismatch { try { @@ -692,17 +661,17 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_string(String a_x) - throws InvalidValue, TypeMismatch + public void insert_string(String a_x) throws InvalidValue, TypeMismatch { try { - if (a_x != null && final_type.length() > 0 && - a_x.length() > final_type.length() - ) + if (a_x != null && + final_type.length() > 0 && + a_x.length() > final_type.length() + ) throw new InvalidValue(a_x.length() + " exceeds bound, " + - final_type.length() - ); + final_type.length() + ); ((StringHolder) holder).value = a_x; valueChanged(); } @@ -721,8 +690,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_typecode(TypeCode a_x) - throws InvalidValue, TypeMismatch + public void insert_typecode(TypeCode a_x) throws InvalidValue, TypeMismatch { try { @@ -738,8 +706,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_ulong(int a_x) - throws InvalidValue, TypeMismatch + public void insert_ulong(int a_x) throws InvalidValue, TypeMismatch { try { @@ -755,8 +722,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_ulonglong(long a_x) - throws InvalidValue, TypeMismatch + public void insert_ulonglong(long a_x) throws InvalidValue, TypeMismatch { try { @@ -772,8 +738,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_ushort(short a_x) - throws InvalidValue, TypeMismatch + public void insert_ushort(short a_x) throws InvalidValue, TypeMismatch { try { @@ -789,8 +754,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_val(Serializable a_x) - throws InvalidValue, TypeMismatch + public void insert_val(Serializable a_x) throws InvalidValue, TypeMismatch { try { @@ -806,8 +770,7 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_wchar(char a_x) - throws InvalidValue, TypeMismatch + public void insert_wchar(char a_x) throws InvalidValue, TypeMismatch { try { @@ -823,17 +786,17 @@ public class gnuDynAny } /** {@inheritDoc} */ - public void insert_wstring(String a_x) - throws InvalidValue, TypeMismatch + public void insert_wstring(String a_x) throws InvalidValue, TypeMismatch { try { - if (a_x != null && final_type.length() > 0 && - a_x.length() > type().length() - ) + if (a_x != null && + final_type.length() > 0 && + a_x.length() > type().length() + ) throw new InvalidValue(a_x.length() + " exceeds bound, " + - final_type.length() - ); + final_type.length() + ); ((WStringHolder) holder).value = a_x; valueChanged(); } @@ -913,8 +876,7 @@ public class gnuDynAny * Inserts Any, contained in the parameter, into Any, contained in this * DynAny. */ - public void insert_dyn_any(DynAny d) - throws TypeMismatch, InvalidValue + public void insert_dyn_any(DynAny d) throws TypeMismatch, InvalidValue { check(d.type().kind()); @@ -944,8 +906,8 @@ public class gnuDynAny holder._write(b2); return Arrays.equals(b1.buffer.toByteArray(), - b2.buffer.toByteArray() - ); + b2.buffer.toByteArray() + ); } else return false; @@ -953,8 +915,8 @@ public class gnuDynAny if (other == null) return false; else if (other.component_count() != component_count() || - !official_type.equal(other.type()) - ) + !official_type.equal(other.type()) + ) return false; else return other.to_any().equal(to_any()); @@ -970,14 +932,12 @@ public class gnuDynAny return 0; } - public DynAny get_dyn_any() - throws TypeMismatch, InvalidValue + public DynAny get_dyn_any() throws TypeMismatch, InvalidValue { return new gnuDynAny(holder, official_type, final_type, factory, orb); } - private void check(TCKind t) - throws TypeMismatch + private void check(TCKind t) throws TypeMismatch { if (t.value() != final_type.kind().value()) throw new TypeMismatch(t.value() + "!=" + final_type.kind().value()); diff --git a/gnu/CORBA/DynAn/gnuDynEnum.java b/gnu/CORBA/DynAn/gnuDynEnum.java index 148d99375..2fccc85c5 100644 --- a/gnu/CORBA/DynAn/gnuDynEnum.java +++ b/gnu/CORBA/DynAn/gnuDynEnum.java @@ -51,7 +51,7 @@ import org.omg.DynamicAny.DynAnyPackage.InvalidValue; import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; import org.omg.DynamicAny.DynEnum; -import java.io.*; +import java.io.IOException; import java.util.Arrays; @@ -60,9 +60,7 @@ import java.util.Arrays; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuDynEnum - extends anyUndivideable - implements DynEnum +public class gnuDynEnum extends anyUndivideable implements DynEnum { /** * Use serialVersionUID for interoperability. @@ -85,8 +83,8 @@ public class gnuDynEnum * Create a new dyn enum from the given typecode. */ public gnuDynEnum(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, - ORB anOrb - ) + ORB anOrb + ) { super(oType, aType, aFactory, anOrb); try @@ -117,8 +115,7 @@ public class gnuDynEnum * Assign the Enum from the passed value. The passed DynAny must hold the * enumeration of exactly the same final_type. */ - public void assign(DynAny from) - throws TypeMismatch + public void assign(DynAny from) throws TypeMismatch { checkType(official_type, from.type()); if (!(from instanceof DynEnum)) @@ -154,7 +151,7 @@ public class gnuDynEnum { gnuDynEnum oe = (gnuDynEnum) other; return current == oe.current && - (oe.values == values || Arrays.equals(values, oe.values)); + (oe.values == values || Arrays.equals(values, oe.values)); } else if (other instanceof DynEnum) { @@ -168,8 +165,7 @@ public class gnuDynEnum /** * Set value from any that must contain enumeration. */ - public void from_any(Any an_any) - throws TypeMismatch, InvalidValue + public void from_any(Any an_any) throws TypeMismatch, InvalidValue { checkType(official_type, an_any.type()); try @@ -207,8 +203,7 @@ public class gnuDynEnum /** * Set the value of this enumeration as string. */ - public void set_as_string(String value) - throws InvalidValue + public void set_as_string(String value) throws InvalidValue { for (int i = 0; i < values.length; i++) { @@ -225,8 +220,7 @@ public class gnuDynEnum /** * Set the value of this enumeration as int. */ - public void set_as_ulong(int value) - throws InvalidValue + public void set_as_ulong(int value) throws InvalidValue { if (value < 0 || value >= values.length) throw new InvalidValue(value + " not in [0.." + values.length); diff --git a/gnu/CORBA/DynAn/gnuDynFixed.java b/gnu/CORBA/DynAn/gnuDynFixed.java index 13ec24e6c..39b002262 100644 --- a/gnu/CORBA/DynAn/gnuDynFixed.java +++ b/gnu/CORBA/DynAn/gnuDynFixed.java @@ -43,7 +43,6 @@ import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.ORB; import org.omg.CORBA.TypeCode; -import org.omg.CORBA.TypeCodePackage.*; import org.omg.DynamicAny.DynAny; import org.omg.DynamicAny.DynAnyPackage.InvalidValue; import org.omg.DynamicAny.DynAnyPackage.TypeMismatch; @@ -58,9 +57,7 @@ import java.math.BigDecimal; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuDynFixed - extends anyUndivideable - implements DynFixed +public class gnuDynFixed extends anyUndivideable implements DynFixed { /** * Use serialVersionUID for interoperability. @@ -90,9 +87,9 @@ public class gnuDynFixed /** * Create a new instance of the dyn fixed. */ - public gnuDynFixed(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, - ORB anOrb - ) + public gnuDynFixed(TypeCode oType, TypeCode aType, + gnuDynAnyFactory aFactory, ORB anOrb + ) { super(oType, aType, aFactory, anOrb); try @@ -130,7 +127,7 @@ public class gnuDynFixed * Set the value. */ public boolean set_value(String fixed_value) - throws TypeMismatch, InvalidValue + throws TypeMismatch, InvalidValue { // Count the digits till decimal point. int digs = 0; @@ -152,8 +149,8 @@ public class gnuDynFixed } if (digs > (digits - scale)) throw new InvalidValue("Too many digits: " + digs + " for " + digits + - "." + scale - ); + "." + scale + ); try { @@ -177,8 +174,7 @@ public class gnuDynFixed /** * Assign the value from another BigDecimal. */ - public void assign(DynAny from) - throws TypeMismatch + public void assign(DynAny from) throws TypeMismatch { checkType(official_type, from.type()); @@ -227,8 +223,7 @@ public class gnuDynFixed * Set the value from Any (must hold <code>fixed</code> with the matching * typecode.). */ - public void from_any(Any an_any) - throws TypeMismatch, InvalidValue + public void from_any(Any an_any) throws TypeMismatch, InvalidValue { try { diff --git a/gnu/CORBA/DynAn/gnuDynValue.java b/gnu/CORBA/DynAn/gnuDynValue.java index db37be016..c2db94797 100644 --- a/gnu/CORBA/DynAn/gnuDynValue.java +++ b/gnu/CORBA/DynAn/gnuDynValue.java @@ -42,13 +42,10 @@ import gnu.CORBA.Unexpected; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_PARAM; -import org.omg.CORBA.CompletionStatus; 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.*; import org.omg.CORBA.VM_TRUNCATABLE; import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.ValueFactory; @@ -69,9 +66,8 @@ import java.io.Serializable; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuDynValue - extends abstractRecord - implements DynValue, Serializable +public class gnuDynValue extends abstractRecord implements DynValue, + Serializable { /** * Use serialVersionUID for interoperability. @@ -86,9 +82,9 @@ public class gnuDynValue /** * Create an instance. */ - public gnuDynValue(TypeCode oType, TypeCode aType, gnuDynAnyFactory aFactory, - ORB anOrb - ) + public gnuDynValue(TypeCode oType, TypeCode aType, + gnuDynAnyFactory aFactory, ORB anOrb + ) { super(oType, aType, aFactory, anOrb); @@ -116,6 +112,7 @@ public class gnuDynValue // Add members of ancestor in front of the curren members. DynValue anc = (DynValue) ancestor; anc.set_to_value(); + NameDynAnyPair[] aar = anc.get_members_as_dyn_any(); inheritFields(aar); } @@ -128,9 +125,8 @@ public class gnuDynValue } else throw new BAD_PARAM("The parent of " + final_type.id() + ", " + - parent.id() + - ", is not structure nor value." - ); + parent.id() + ", is not structure nor value." + ); } } catch (Exception e) @@ -168,8 +164,7 @@ public class gnuDynValue } /** @inheritDoc */ - public TCKind current_member_kind() - throws TypeMismatch, InvalidValue + public TCKind current_member_kind() throws TypeMismatch, InvalidValue { if (isNull) throw new TypeMismatch(ISNULL); @@ -179,8 +174,7 @@ public class gnuDynValue ; /** @inheritDoc */ - public String current_member_name() - throws TypeMismatch, InvalidValue + public String current_member_name() throws TypeMismatch, InvalidValue { if (isNull) throw new TypeMismatch(ISNULL); @@ -190,8 +184,7 @@ public class gnuDynValue ; /** @inheritDoc */ - public NameDynAnyPair[] get_members_as_dyn_any() - throws InvalidValue + public NameDynAnyPair[] get_members_as_dyn_any() throws InvalidValue { if (isNull) throw new InvalidValue(ISNULL); @@ -200,8 +193,7 @@ public class gnuDynValue ; /** @inheritDoc */ - public NameValuePair[] get_members() - throws InvalidValue + public NameValuePair[] get_members() throws InvalidValue { if (isNull) throw new InvalidValue(ISNULL); @@ -212,7 +204,7 @@ public class gnuDynValue /** @inheritDoc */ public void set_members_as_dyn_any(NameDynAnyPair[] value) - throws TypeMismatch, InvalidValue + throws TypeMismatch, InvalidValue { super.set_members_as_dyn_any(value); isNull = false; @@ -221,7 +213,7 @@ public class gnuDynValue /** @inheritDoc */ public void set_members(NameValuePair[] value) - throws TypeMismatch, InvalidValue + throws TypeMismatch, InvalidValue { super.set_members(value); isNull = false; @@ -252,8 +244,8 @@ public class gnuDynValue * Create a new instance. */ protected abstractRecord newInstance(TypeCode oType, TypeCode aType, - gnuDynAnyFactory aFactory, ORB anOrb - ) + gnuDynAnyFactory aFactory, ORB anOrb + ) { gnuDynValue v = new gnuDynValue(oType, aType, aFactory, anOrb); if (isNull) @@ -283,8 +275,7 @@ public class gnuDynValue /** * Get the focused component, throwing exception if the current value is null. */ - protected DynAny focused() - throws InvalidValue, TypeMismatch + protected DynAny focused() throws InvalidValue, TypeMismatch { if (isNull) throw new TypeMismatch(ISNULL); @@ -311,8 +302,8 @@ public class gnuDynValue ((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." - ); + " not registered." + ); OutputStream out = orb.create_output_stream(); @@ -337,8 +328,7 @@ public class gnuDynValue } /** @inheritDoc */ - public void assign(DynAny from) - throws TypeMismatch + public void assign(DynAny from) throws TypeMismatch { checkType(official_type, from.type()); @@ -376,16 +366,13 @@ public class gnuDynValue } /** {@inheritDoc} */ - public Serializable get_val() - throws TypeMismatch, InvalidValue + public Serializable get_val() throws TypeMismatch, InvalidValue { return to_any().extract_Value(); } - /** {@inheritDoc} */ - public void insert_val(Serializable a_x) - throws InvalidValue, TypeMismatch + public void insert_val(Serializable a_x) throws InvalidValue, TypeMismatch { Any a = to_any(); a.insert_Value(a_x); diff --git a/gnu/CORBA/ExceptionCreator.java b/gnu/CORBA/ExceptionCreator.java index 536053cef..8b7520505 100644 --- a/gnu/CORBA/ExceptionCreator.java +++ b/gnu/CORBA/ExceptionCreator.java @@ -145,14 +145,11 @@ public class ExceptionCreator { try { - String holder = toHelperName(idl); - - System.out.println("Helper " + holder); - - Class holderClass = Class.forName(holder); + String helper = toHelperName(idl); + Class helperClass = Class.forName(helper); Method read = - holderClass.getMethod("read", + helperClass.getMethod("read", new Class[] { org.omg.CORBA.portable.InputStream.class diff --git a/gnu/CORBA/Functional_ORB.java b/gnu/CORBA/Functional_ORB.java index c8d6a4c93..bf6497953 100644 --- a/gnu/CORBA/Functional_ORB.java +++ b/gnu/CORBA/Functional_ORB.java @@ -1,4 +1,4 @@ -/* FunctionalORB.java -- +/* Functional_ORB.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -58,6 +58,7 @@ 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.portable.Delegate; import org.omg.CORBA.portable.InvokeHandler; import org.omg.CORBA.portable.ObjectImpl; @@ -88,28 +89,25 @@ import java.util.TreeMap; /** * The ORB implementation, capable to handle remote invocations on the - * registered object. This class implements all features, required till - * the jdk 1.3 inclusive, but does not support the POA that appears since - * 1.4. The POA is supported by {@link gnu.CORBA.Poa.ORB_1_4}. + * registered object. This class implements all features, required till the jdk + * 1.3 inclusive, but does not support the POA that appears since 1.4. The POA + * is supported by {@link gnu.CORBA.Poa.ORB_1_4}. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ -public class Functional_ORB - extends Restricted_ORB +public class Functional_ORB extends Restricted_ORB { /** - * 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. + * 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 + class portServer extends Thread { /** * The number of the currently running parallel threads. */ - private int running_threads; + int running_threads; /** * The port on that this portServer is listening for requests. @@ -122,8 +120,7 @@ public class Functional_ORB ServerSocket service; /** - * True if the serving node must shutdown due - * call of the close_now(). + * True if the serving node must shutdown due call of the close_now(). */ boolean terminated; @@ -136,9 +133,8 @@ public class Functional_ORB } /** - * Enter the serving loop (get request/process it). - * All portServer normally terminate thy threads when - * the Functional_ORB.running is set to false. + * Enter the serving loop (get request/process it). All portServer normally + * terminate thy threads when the Functional_ORB.running is set to false. */ public void run() { @@ -184,10 +180,10 @@ public class Functional_ORB /** * Perform a single serving step. + * * @throws java.lang.Exception */ - void tick() - throws Exception + void tick() throws Exception { serve(this, service); } @@ -219,12 +215,11 @@ public class Functional_ORB } /** - * A server, responsible for listening on requests on some - * local port and serving multiple requests (probably to the - * different objects) on the same thread. + * A server, responsible for listening on requests on some local port and + * serving multiple requests (probably to the different objects) on the same + * thread. */ - class sharedPortServer - extends portServer + class sharedPortServer extends portServer { /** * Create a new portServer, serving on specific port. @@ -236,10 +231,10 @@ public class Functional_ORB /** * Perform a single serving step. + * * @throws java.lang.Exception */ - void tick() - throws Exception + void tick() throws Exception { Socket request = service.accept(); serveStep(request, false); @@ -247,14 +242,14 @@ public class Functional_ORB } /** - * The default value where the first instance of this ORB will start - * looking for a free port. + * The default value where the first instance of this ORB will start looking + * for a free port. */ public static int DEFAULT_INITIAL_PORT = 1126; /** - * The property of port, on that this ORB is listening for requests from clients. - * This class supports one port per ORB only. + * The property of port, on that this ORB is listening for requests from + * clients. This class supports one port per ORB only. */ public static final String LISTEN_ON = "gnu.classpath.CORBA.ListenOn"; @@ -264,12 +259,14 @@ public class Functional_ORB public static final String REFERENCE = "org.omg.CORBA.ORBInitRef"; /** - * The property, defining the port on that the default name service is running. + * The property, defining the port on that the default name service is + * running. */ public static final String NS_PORT = "org.omg.CORBA.ORBInitialPort"; /** - * The property, defining the host on that the default name service is running. + * The property, defining the host on that the default name service is + * running. */ public static final String NS_HOST = "org.omg.CORBA.ORBInitialHost"; @@ -279,24 +276,25 @@ public class Functional_ORB public static final String NAME_SERVICE = "NameService"; /** - * 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. This prevents server hang when the client opens the socket, - * but does not send any message, usually due crash on the client side. + * 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. + * This prevents server hang when the client opens the socket, but does not + * send any message, usually due crash on the client side. */ public static String START_READING_MESSAGE = "gnu.classpath.CORBA.TOUT_START_READING_MESSAGE"; /** - * If the client has started to send the request message, the socket time - * out changes to the specified value. + * If the client has started to send the request message, the socket time out + * changes to the specified value. */ - public static String WHILE_READING = "gnu.classpath.CORBA.TOUT_WHILE_READING"; + public static String WHILE_READING = + "gnu.classpath.CORBA.TOUT_WHILE_READING"; /** - * 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. + * 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. */ public static String AFTER_RECEIVING = "gnu.classpath.CORBA.TOUT_AFTER_RECEIVING"; @@ -307,53 +305,52 @@ public class Functional_ORB public final String LOCAL_HOST; /** - * 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. This prevents server hang when the client opens the socket, - * but does not send any message, usually due crash on the client side. + * 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. + * 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; // (Here and below, we use * to make the meaning of the constant clearler). /** - * If the client has started to send the request message, the socket time - * out changes to the specified value. + * 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; /** - * 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. + * 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; /** - * Some clients tend to submit multiple requests over the - * same socket. The server waits for the next request on - * the same socket for the duration, specified - * below. In additions, the request of this implementation also - * waits for the same duration before closing the socket. - * The default time is seven seconds. + * Some clients tend to submit multiple requests over the same socket. The + * server waits for the next request on the same socket for the duration, + * specified below. In additions, the request of this implementation also + * waits for the same duration before closing the socket. The default time is + * seven seconds. */ public static int TANDEM_REQUESTS = 7000; /** * The map of the already conncted objects. */ - protected final Connected_objects connected_objects = new Connected_objects(); + protected final Connected_objects connected_objects = + new Connected_objects(); /** - * The maximal CORBA version, supported by this ORB. The default value - * 0 means that the ORB will not check the request version while trying - * to respond. + * The maximal CORBA version, supported by this ORB. The default value 0 means + * that the ORB will not check the request version while trying to respond. */ protected Version max_version; /** - * Setting this value to false causes the ORB to shutdown after the - * latest serving operation is complete. + * Setting this value to false causes the ORB to shutdown after the latest + * serving operation is complete. */ protected boolean running; @@ -373,12 +370,12 @@ public class Functional_ORB private String ns_host; /** - * Probably free port, under that the ORB will try listening for - * remote requests first. When the new object is connected, this - * port is used first, then it is incremented by 1, etc. If the given - * port is not available, up to 20 subsequent values are tried and then - * the parameterless server socket contructor is called. The constant is - * shared between multiple instances of this ORB. + * Probably free port, under that the ORB will try listening for remote + * requests first. When the new object is connected, this port is used first, + * then it is incremented by 1, etc. If the given port is not available, up to + * 20 subsequent values are tried and then the parameterless server socket + * contructor is called. The constant is shared between multiple instances of + * this ORB. */ private static int Port = DEFAULT_INITIAL_PORT; @@ -404,10 +401,9 @@ public class Functional_ORB protected Hashtable identities = new Hashtable(); /** - * The maximal allowed number of the currently running parallel - * threads per object. For security reasons, this is made private and - * unchangeable. After exceeding this limit, the NO_RESOURCES - * is thrown back to the client. + * The maximal allowed number of the currently running parallel threads per + * object. For security reasons, this is made private and unchangeable. After + * exceeding this limit, the NO_RESOURCES is thrown back to the client. */ private int MAX_RUNNING_THREADS = 256; @@ -431,20 +427,19 @@ public class Functional_ORB } /** - * If the max version is assigned, the orb replies with the error - * message if the request version is above the supported 1.2 version. - * This behavior is recommended by OMG, but not all implementations - * respond that error message by re-sending the request, encoded in the older - * version. - */ + * If the max version is assigned, the orb replies with the error message if + * the request version is above the supported 1.2 version. This behavior is + * recommended by OMG, but not all implementations respond that error message + * by re-sending the request, encoded in the older version. + */ public void setMaxVersion(Version max_supported) { max_version = max_supported; } /** - * Get the maximal supported GIOP version or null if the version is - * not checked. + * Get the maximal supported GIOP version or null if the version is not + * checked. */ public Version getMaxVersion() { @@ -452,17 +447,15 @@ public class Functional_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. + * 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. + * @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; @@ -519,12 +512,11 @@ public class Functional_ORB } /** - * Set the port, on that the server is listening for the client requests. - * If only one object is connected to the orb, the server will be - * try listening 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. + * Set the port, on that the server is listening for the client requests. If + * only one object is connected to the orb, the server will be try listening + * 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. */ @@ -534,14 +526,13 @@ public class Functional_ORB } /** - * Connect the given CORBA object to this ORB. After the object is - * connected, it starts receiving remote invocations via this ORB. + * Connect the given CORBA object to this ORB. After the object is connected, + * it starts receiving remote invocations via this ORB. * - * The ORB tries to connect the object to the port, that has been - * previously set by {@link setPort(int)}. On failure, it tries - * 20 subsequent larger values and then calls the parameterless - * server socked constructor to get any free local port. - * If this fails, the {@link NO_RESOURCES} is thrown. + * The ORB tries to connect the object to the port, that has been previously + * set by {@link setPort(int)}. On failure, it tries 20 subsequent larger + * values and then calls the parameterless server socked constructor to get + * any free local port. If this fails, the {@link NO_RESOURCES} is thrown. * * @param object the object, must implement the {@link InvokeHandler}) * interface. @@ -561,19 +552,18 @@ public class Functional_ORB } /** - * Connect the given CORBA object to this ORB, explicitly specifying - * the object key. + * Connect the given CORBA object to this ORB, explicitly specifying the + * object key. * - * The ORB tries to connect the object to the port, that has been - * previously set by {@link setPort(int)}. On failure, it tries - * 20 subsequent larger values and then calls the parameterless - * server socked constructor to get any free local port. - * If this fails, the {@link NO_RESOURCES} is thrown. + * The ORB tries to connect the object to the port, that has been previously + * set by {@link setPort(int)}. On failure, it tries 20 subsequent larger + * values and then calls the parameterless server socked constructor to get + * any free local port. If this fails, the {@link NO_RESOURCES} is thrown. * * @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 key the object key, usually used to identify the object from remote + * side. * * @throws BAD_PARAM if the object does not implement the * {@link InvokeHandler}). @@ -591,31 +581,30 @@ public class Functional_ORB } /** - * 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. + * 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. + * 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 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 - ) + java.lang.Object identity + ) { sharedPortServer shared = (sharedPortServer) identities.get(identity); if (shared == null) @@ -653,23 +642,22 @@ public class Functional_ORB */ public void destroy() { - super.destroy(); - portServer p; for (int i = 0; i < portServers.size(); i++) { p = (portServer) portServers.get(i); p.close_now(); } + super.destroy(); } /** - * Disconnect the given CORBA object from this ORB. The object will be - * no longer receiving the remote invocations. In response to the - * remote invocation on this object, the ORB will send the - * exception {@link OBJECT_NOT_EXIST}. The object, however, is not - * destroyed and can receive the local invocations. - + * Disconnect the given CORBA object from this ORB. The object will be no + * longer receiving the remote invocations. In response to the remote + * invocation on this object, the ORB will send the exception + * {@link OBJECT_NOT_EXIST}. The object, however, is not destroyed and can + * receive the local invocations. + * * @param object the object to disconnect. */ public void disconnect(org.omg.CORBA.Object object) @@ -692,8 +680,6 @@ public class Functional_ORB // object implementation. if (rmKey == null) rmKey = connected_objects.getKey(object); - - // Disconnect the object on any success. if (rmKey != null) { // Find and stop the corresponding portServer. @@ -714,10 +700,10 @@ public class Functional_ORB } /** - * Notifies ORB that the shared service indentity (usually POA) - * is destroyed. The matching shared port server is terminated - * and the identity table entry is deleted. If this identity - * is not known for this ORB, the method returns without action. + * Notifies ORB that the shared service indentity (usually POA) is destroyed. + * The matching shared port server is terminated and the identity table entry + * is deleted. If this identity is not known for this ORB, the method returns + * without action. * * @param identity the identity that has been destroyed. */ @@ -728,24 +714,24 @@ public class Functional_ORB sharedPortServer ise = (sharedPortServer) identities.get(identity); if (ise != null) - synchronized (connected_objects) - { - ise.close_now(); - identities.remove(identity); + { + synchronized (connected_objects) + { + ise.close_now(); + identities.remove(identity); - Connected_objects.cObject obj; - Map.Entry m; - Iterator iter = connected_objects.entrySet().iterator(); - while (iter.hasNext()) - { - m = (Map.Entry) iter.next(); - obj = (Connected_objects.cObject) m.getValue(); - if (obj.identity == identity) - { + Connected_objects.cObject obj; + Map.Entry m; + Iterator iter = connected_objects.entrySet().iterator(); + while (iter.hasNext()) + { + m = (Map.Entry) iter.next(); + obj = (Connected_objects.cObject) m.getValue(); + if (obj.identity == identity) iter.remove(); - } - } - } + } + } + } } /** @@ -753,8 +739,8 @@ public class Functional_ORB * * @param ior the ior of the potentially local object. * - * @return the local object, represented by the given IOR, - * or null if this is not a local connected object. + * @return the local object, represented by the given IOR, or null if this is + * not a local connected object. */ public org.omg.CORBA.Object find_local_object(IOR ior) { @@ -783,26 +769,26 @@ public class Functional_ORB Iterator iter = initial_references.keySet().iterator(); while (iter.hasNext()) - refs [ p++ ] = (String) iter.next(); - + { + refs [ p++ ] = (String) iter.next(); + } return refs; } /** - * Get the IOR reference string for the given object. - * The string embeds information about the object - * repository Id, its access key and the server internet - * address and port. With this information, the object - * can be found by another ORB, possibly located on remote - * computer. + * Get the IOR reference string for the given object. The string embeds + * information about the object repository Id, its access key and the server + * internet address and port. With this information, the object can be found + * by another ORB, possibly located on remote computer. * * @param the CORBA object * @return the object IOR representation. * - * @throws BAD_PARAM if the object has not been previously - * connected to this ORB. - * @throws BAD_OPERATION in the unlikely case if the local host - * address cannot be resolved. + * @throws BAD_PARAM if the object has not been previously connected to this + * ORB. + * + * @throws BAD_OPERATION in the unlikely case if the local host address cannot + * be resolved. * * @see string_to_object(String) */ @@ -821,8 +807,8 @@ public class Functional_ORB if (rec == null) throw new BAD_PARAM("The object " + forObject + - " has not been previously connected to this ORB" - ); + " has not been previously connected to this ORB" + ); IOR ior = createIOR(rec); @@ -830,17 +816,28 @@ public class Functional_ORB } /** - * Find and return the easily accessible CORBA object, addressed - * by name. + * Get the local IOR for the given object, null if the object is not local. + */ + public IOR getLocalIor(org.omg.CORBA.Object forObject) + { + Connected_objects.cObject rec = connected_objects.getKey(forObject); + if (rec == null) + return null; + else + return createIOR(rec); + } + + /** + * Find and return the easily accessible CORBA object, addressed by name. * * @param name the object name. * @return the object * - * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name - * is not associated with the known object. + * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name is not + * associated with the known object. */ public org.omg.CORBA.Object resolve_initial_references(String name) - throws InvalidName + throws InvalidName { org.omg.CORBA.Object object = null; try @@ -866,9 +863,8 @@ public class Functional_ORB } /** - * Start the ORBs main working cycle - * (receive invocation - invoke on the local object - send response - - * wait for another invocation). + * 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)}. */ @@ -894,9 +890,7 @@ public class Functional_ORB portServers.add(subserver); } else - { - subserver = (portServer) identities.get(obj.identity); - } + subserver = (portServer) identities.get(obj.identity); if (!subserver.isAlive()) { @@ -917,8 +911,8 @@ public class Functional_ORB /** * Shutdown the ORB server. * - * @param wait_for_completion if true, the current thread is - * suspended until the shutdown process is complete. + * @param wait_for_completion if true, the current thread is suspended until + * the shutdown process is complete. */ public void shutdown(boolean wait_for_completion) { @@ -936,10 +930,10 @@ public class Functional_ORB } /** - * Find and return the CORBA object, addressed by the given - * IOR string representation. The object can (an usually is) - * located on a remote computer, possibly running a different - * (not necessary java) CORBA implementation. + * Find and return the CORBA object, addressed by the given IOR string + * representation. The object can (an usually is) located on a remote + * computer, possibly running a different (not necessary java) CORBA + * implementation. * * @param ior the object IOR representation string. * @@ -956,9 +950,7 @@ public class Functional_ORB try { if (impl._get_delegate() == null) - { - impl._set_delegate(new IOR_Delegate(this, ior)); - } + impl._set_delegate(new IOR_Delegate(this, ior)); } catch (BAD_OPERATION ex) { @@ -974,15 +966,13 @@ public class Functional_ORB } /** - * Get the default naming service for the case when there no - * NameService entries. + * Get the default naming service for the case when there no NameService + * entries. */ protected org.omg.CORBA.Object getDefaultNameService() { if (initial_references.containsKey(NAME_SERVICE)) - { - return (org.omg.CORBA.Object) initial_references.get(NAME_SERVICE); - } + return (org.omg.CORBA.Object) initial_references.get(NAME_SERVICE); IOR ior = new IOR(); ior.Id = NamingContextExtHelper.id(); @@ -997,8 +987,8 @@ public class Functional_ORB } /** - * Find and return the object, that must be previously connected - * to this ORB. Return null if no such object is available. + * 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. * @@ -1017,8 +1007,7 @@ public class Functional_ORB * @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>. + * parameter in {@link #init(Applet, Properties)}. Can be <code>null</code>. */ protected void set_parameters(Applet app, Properties props) { @@ -1031,27 +1020,23 @@ public class Functional_ORB { 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 ]); - try { if (para [ i ] [ 0 ].equals(NS_PORT)) @@ -1061,9 +1046,9 @@ public class Functional_ORB { BAD_PARAM bad = new BAD_PARAM("Invalid " + NS_PORT + - "property, unable to parse '" + - props.getProperty(NS_PORT) + "'" - ); + "property, unable to parse '" + + props.getProperty(NS_PORT) + "'" + ); bad.initCause(ex); throw bad; } @@ -1075,52 +1060,54 @@ public class Functional_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 + * @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>. + * @param props application specific properties that were passed as a second + * parameter in {@link init(String[], Properties)}). Can be <code>null</code>. */ protected void set_parameters(String[] para, Properties props) { if (para.length > 1) - 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")) - { - StringTokenizer st = new StringTokenizer(para [ i + 1 ], "="); - initial_references.put(st.nextToken(), - string_to_object(st.nextToken()) - ); - } - - if (para [ i ].endsWith("ORBInitialHost")) - ns_host = para [ i + 1 ]; + { + 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")) + { + StringTokenizer st = new StringTokenizer(para [ i + 1 ], "="); + initial_references.put(st.nextToken(), + string_to_object(st.nextToken()) + ); + } - try - { - 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 ]) + "'" - ); - } - } + if (para [ i ].endsWith("ORBInitialHost")) + ns_host = para [ i + 1 ]; + try + { + 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 ]) + "'" + ); + } + } + } useProperties(props); } - private IOR createIOR(Connected_objects.cObject ref) - throws BAD_OPERATION + /** + * Create IOR for the given object references. + */ + protected IOR createIOR(Connected_objects.cObject ref) + throws BAD_OPERATION { IOR ior = new IOR(); ior.key = ref.key; @@ -1134,7 +1121,6 @@ public class Functional_ORB } if (ior.Id == null) ior.Id = ref.object.getClass().getName(); - try { ior.Internet.host = InetAddress.getLocalHost().getHostAddress(); @@ -1156,13 +1142,12 @@ public class Functional_ORB * {@link InvokeHandler}). */ private void prepareObject(org.omg.CORBA.Object object, IOR ior) - throws BAD_PARAM + throws BAD_PARAM { /* - if (!(object instanceof InvokeHandler)) - throw new BAD_PARAM(object.getClass().getName() + - " does not implement InvokeHandler. " - ); + * if (!(object instanceof InvokeHandler)) throw new + * BAD_PARAM(object.getClass().getName() + " does not implement + * InvokeHandler. " ); */ // If no delegate is set, set the default delegate. @@ -1172,9 +1157,7 @@ public class Functional_ORB try { if (impl._get_delegate() == null) - { - impl._set_delegate(new Simple_delegate(this, ior)); - } + impl._set_delegate(new Simple_delegate(this, ior)); } catch (BAD_OPERATION ex) { @@ -1190,20 +1173,17 @@ public class Functional_ORB * @param net_out the stream to write response into * @param msh_request the request message header * @param rh_request the request header - * @param handler the invocation handler that has been used to - * invoke the operation - * @param sysEx the system exception, thrown during the invocation, - * null if none. + * @param handler the invocation handler that has been used to invoke the + * operation + * @param sysEx the system exception, thrown during the invocation, null if + * none. * * @throws IOException */ private void respond_to_client(OutputStream net_out, - MessageHeader msh_request, - RequestHeader rh_request, - bufferedResponseHandler handler, - SystemException sysEx - ) - throws IOException + MessageHeader msh_request, RequestHeader rh_request, + bufferedResponseHandler handler, SystemException sysEx + ) throws IOException { // Set the reply header properties. ReplyHeader reply = handler.reply_header; @@ -1214,17 +1194,23 @@ public class Functional_ORB reply.reply_status = ReplyHeader.USER_EXCEPTION; else reply.reply_status = ReplyHeader.NO_EXCEPTION; - reply.request_id = rh_request.request_id; - cdrBufOutput out = new cdrBufOutput(50 + handler.getBuffer().buffer.size()); + cdrBufOutput out = + new cdrBufOutput(50 + handler.getBuffer().buffer.size()); out.setOrb(this); out.setOffset(msh_request.getHeaderSize()); reply.write(out); - // Write the reply data from the handler. + if (msh_request.version.since_inclusive(1, 2)) + { + out.align(8); + + // Write the reply data from the handler. The handler data already + // include the necessary heading zeroes for alignment. + } handler.getBuffer().buffer.writeTo(out); MessageHeader msh_reply = new MessageHeader(); @@ -1240,13 +1226,11 @@ public class Functional_ORB } /** - * Forward request to another target, as indicated by the passed - * exception. + * Forward request to another target, as indicated by the passed exception. */ - private void forward_request(OutputStream net_out, MessageHeader msh_request, - RequestHeader rh_request, gnuForwardRequest info - ) - throws IOException + private void forward_request(OutputStream net_out, + MessageHeader msh_request, RequestHeader rh_request, gnuForwardRequest info + ) throws IOException { MessageHeader msh_forward = new MessageHeader(); msh_forward.version = msh_request.version; @@ -1265,7 +1249,6 @@ public class Functional_ORB if (msh_forward.version.since_inclusive(1, 2)) out.align(8); - out.write_Object(info.forward_reference); msh_forward.message_size = out.buffer.size(); @@ -1279,17 +1262,17 @@ public class Functional_ORB /** * Contains a single servicing task. * - * Normally, each task matches a single remote invocation. - * However under frequent tandem submissions the same - * task may span over several invocations. + * Normally, each task matches a single remote invocation. However under + * frequent tandem submissions the same task may span over several + * invocations. * * @param serverSocket the ORB server socket. * * @throws MARSHAL * @throws IOException */ - private void serve(final portServer p, ServerSocket serverSocket) - throws MARSHAL, IOException + void serve(final portServer p, ServerSocket serverSocket) + throws MARSHAL, IOException { final Socket service; service = serverSocket.accept(); @@ -1327,15 +1310,15 @@ public class Functional_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. + * 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. + * @param no_resources if true, the "NO RESOURCES" exception is thrown to the + * client. */ - private void serveStep(Socket service, boolean no_resources) + void serveStep(Socket service, boolean no_resources) { try { @@ -1358,15 +1341,17 @@ public class Functional_ORB } if (max_version != null) - if (!msh_request.version.until_inclusive(max_version.major, - max_version.minor - ) - ) - { - OutputStream out = service.getOutputStream(); - new ErrorMessage(max_version).write(out); - return; - } + { + if (!msh_request.version.until_inclusive(max_version.major, + max_version.minor + ) + ) + { + OutputStream out = service.getOutputStream(); + new ErrorMessage(max_version).write(out); + return; + } + } byte[] r = new byte[ msh_request.message_size ]; @@ -1400,9 +1385,12 @@ public class Functional_ORB // in 1.2 and higher, align the current position at // 8 octet boundary. if (msh_request.version.since_inclusive(1, 2)) - cin.align(8); + { + cin.align(8); + + // find the target object. + } - // find the target object. InvokeHandler target = (InvokeHandler) find_connected_object(rh_request.object_key); @@ -1413,7 +1401,9 @@ public class Functional_ORB // TODO log errors about not existing objects and methods. bufferedResponseHandler handler = - new bufferedResponseHandler(this, msh_request, rh_reply); + new bufferedResponseHandler(this, msh_request, rh_reply, + rh_request + ); SystemException sysEx = null; @@ -1449,7 +1439,9 @@ public class Functional_ORB { except.printStackTrace(); sysEx = - new UNKNOWN("Unknown", 2, CompletionStatus.COMPLETED_MAYBE); + new UNKNOWN("Unknown", 2, + CompletionStatus.COMPLETED_MAYBE + ); org.omg.CORBA.portable.OutputStream ech = handler.createExceptionReply(); @@ -1462,13 +1454,13 @@ public class Functional_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 - ) + msh_request.message_type == MessageHeader.MESSAGE_ERROR + ) { CloseMessage.close(service.getOutputStream()); service.close(); @@ -1478,11 +1470,10 @@ public class Functional_ORB // TODO log error: "Not a request message." if (service != null && !service.isClosed()) - { - // Wait for the subsequent invocations on the - // same socket for the TANDEM_REQUEST duration. - service.setSoTimeout(TANDEM_REQUESTS); - } + + // Wait for the subsequent invocations on the + // same socket for the TANDEM_REQUEST duration. + service.setSoTimeout(TANDEM_REQUESTS); else return; } @@ -1506,23 +1497,18 @@ public class Functional_ORB { if (props.containsKey(LISTEN_ON)) Port = Integer.parseInt(props.getProperty(LISTEN_ON)); - if (props.containsKey(NS_HOST)) ns_host = props.getProperty(NS_HOST); - try { if (props.containsKey(NS_PORT)) ns_port = Integer.parseInt(props.getProperty(NS_PORT)); - if (props.containsKey(START_READING_MESSAGE)) TOUT_START_READING_MESSAGE = Integer.parseInt(props.getProperty(START_READING_MESSAGE)); - if (props.containsKey(WHILE_READING)) TOUT_WHILE_READING = Integer.parseInt(props.getProperty(WHILE_READING)); - if (props.containsKey(AFTER_RECEIVING)) TOUT_AFTER_RECEIVING = Integer.parseInt(props.getProperty(AFTER_RECEIVING)); @@ -1530,9 +1516,9 @@ public class Functional_ORB catch (NumberFormatException ex) { throw new BAD_PARAM("Invalid " + NS_PORT + - "property, unable to parse '" + - props.getProperty(NS_PORT) + "'" - ); + "property, unable to parse '" + props.getProperty(NS_PORT) + + "'" + ); } Enumeration en = props.elements(); @@ -1541,33 +1527,31 @@ public class Functional_ORB String item = (String) en.nextElement(); if (item.equals(REFERENCE)) initial_references.put(item, - string_to_object(props.getProperty(item)) - ); + string_to_object(props.getProperty(item)) + ); } } } /** - * Get the next instance with a response being received. If all currently - * sent responses not yet processed, this method pauses till at least one of - * them is complete. If there are no requests currently sent, the method - * pauses till some request is submitted and the response is received. - * This strategy is identical to the one accepted by Suns 1.4 ORB - * implementation. + * Get the next instance with a response being received. If all currently sent + * responses not yet processed, this method pauses till at least one of them + * is complete. If there are no requests currently sent, the method pauses + * till some request is submitted and the response is received. This strategy + * is identical to the one accepted by Suns 1.4 ORB implementation. * - * The returned response is removed from the list of the currently - * submitted responses and is never returned again. + * The returned response is removed from the list of the currently submitted + * responses and is never returned again. * * @return the previously sent request that now contains the received * response. * * @throws WrongTransaction If the method was called from the transaction - * scope different than the one, used to send the request. The exception - * can be raised only if the request is implicitly associated with some - * particular transaction. + * scope different than the one, used to send the request. The exception can + * be raised only if the request is implicitly associated with some particular + * transaction. */ - public Request get_next_response() - throws org.omg.CORBA.WrongTransaction + public Request get_next_response() throws org.omg.CORBA.WrongTransaction { return asynchron.get_next_response(); } @@ -1576,8 +1560,8 @@ public class Functional_ORB * Find if any of the requests that have been previously sent with * {@link #send_multiple_requests_deferred}, have a response yet. * - * @return true if there is at least one response to the previously - * sent request, false otherwise. + * @return true if there is at least one response to the previously sent + * request, false otherwise. */ public boolean poll_next_response() { @@ -1585,12 +1569,12 @@ public class Functional_ORB } /** - * Send multiple prepared requests expecting to get a reply. All requests - * are send in parallel, each in its own separate thread. When the - * reply arrives, it is stored in the agreed fields of the corresponing - * request data structure. If this method is called repeatedly, - * the new requests are added to the set of the currently sent requests, - * but the old set is not discarded. + * Send multiple prepared requests expecting to get a reply. All requests are + * send in parallel, each in its own separate thread. When the reply arrives, + * it is stored in the agreed fields of the corresponing request data + * structure. If this method is called repeatedly, the new requests are added + * to the set of the currently sent requests, but the old set is not + * discarded. * * @param requests the prepared array of requests. * @@ -1605,8 +1589,8 @@ public class Functional_ORB /** * Send multiple prepared requests one way, do not caring about the answer. - * The messages, containing requests, will be marked, indicating that - * the sender is not expecting to get a reply. + * The messages, containing requests, will be marked, indicating that the + * sender is not expecting to get a reply. * * @param requests the prepared array of requests. * @@ -1620,8 +1604,7 @@ public class Functional_ORB /** * Set the flag, forcing all server threads to terminate. */ - protected void finalize() - throws java.lang.Throwable + protected void finalize() throws java.lang.Throwable { running = false; super.finalize(); diff --git a/gnu/CORBA/GIOP/ReplyHeader.java b/gnu/CORBA/GIOP/ReplyHeader.java index 1e0e154f8..f0f409394 100644 --- a/gnu/CORBA/GIOP/ReplyHeader.java +++ b/gnu/CORBA/GIOP/ReplyHeader.java @@ -41,13 +41,13 @@ package gnu.CORBA.GIOP; import gnu.CORBA.CDR.cdrInput; import gnu.CORBA.CDR.cdrOutput; - /** * The header of the standard reply. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public abstract class ReplyHeader + extends contextSupportingHeader { /** * Reply status, if no exception occured. @@ -65,9 +65,8 @@ public abstract class ReplyHeader public static final int SYSTEM_EXCEPTION = 2; /** - * Reply status, if the client ORB must re - send - * the request to another destination. The body - * contains IOR. + * Reply status, if the client ORB must re - send the request to another + * destination. The body contains IOR. */ public static final int LOCATION_FORWARD = 3; @@ -84,16 +83,6 @@ public abstract class ReplyHeader public static final int NEEDS_ADDRESSING_MODE = 5; /** - * Empty array, indicating that no service context is available. - */ - protected static final ServiceContext[] NO_CONTEXT = new ServiceContext[ 0 ]; - - /** - * The ORB service data. - */ - public ServiceContext[] service_context = NO_CONTEXT; - - /** * The status of this reply, holds one of the reply status constants. */ public int reply_status; @@ -110,19 +99,19 @@ public abstract class ReplyHeader { switch (reply_status) { - case NO_EXCEPTION : + case NO_EXCEPTION: return "ok"; - case USER_EXCEPTION : + case USER_EXCEPTION: return "user exception"; - case SYSTEM_EXCEPTION : + case SYSTEM_EXCEPTION: return "system exception"; - case LOCATION_FORWARD : + case LOCATION_FORWARD: return "moved"; - default : + default: return null; } } diff --git a/gnu/CORBA/GIOP/RequestHeader.java b/gnu/CORBA/GIOP/RequestHeader.java index f2de4e271..17cccb883 100644 --- a/gnu/CORBA/GIOP/RequestHeader.java +++ b/gnu/CORBA/GIOP/RequestHeader.java @@ -41,7 +41,6 @@ package gnu.CORBA.GIOP; import gnu.CORBA.CDR.cdrInput; import gnu.CORBA.CDR.cdrOutput; - import org.omg.CORBA.portable.IDLEntity; /** @@ -50,13 +49,13 @@ import org.omg.CORBA.portable.IDLEntity; * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public abstract class RequestHeader + extends contextSupportingHeader implements IDLEntity { /** - * The currently free request id. This field is incremented - * each time the new request header is constructed. To facilitate - * error detection, the first free id is equal to 0x01234567 - * (19088743). + * The currently free request id. This field is incremented each time the new + * request header is constructed. To facilitate error detection, the first + * free id is equal to 0x01234567 (19088743). */ private static int freeId = 0x01234567; @@ -71,23 +70,17 @@ public abstract class RequestHeader public byte[] object_key; /** - * A value identifying the requesting principal. - * Initialised into a single zero byte. + * A value identifying the requesting principal. Initialised into a single + * zero byte. * * @deprecated by CORBA 2.2. */ public byte[] requesting_principal; /** - * Contains the ORB service data being passed. Initialised as the - * zero size array by default. - */ - public ServiceContext[] service_context = new ServiceContext[ 0 ]; - - /** - * This is used to associate the reply message with the - * previous request message. Initialised each time by the - * different value, increasing form 1 to Integer.MAX_VALUE. + * This is used to associate the reply message with the previous request + * message. Initialised each time by the different value, increasing form 1 to + * Integer.MAX_VALUE. */ public int request_id = getNextId(); @@ -97,10 +90,9 @@ public abstract class RequestHeader protected boolean response_expected = true; /** - * Get next free request id. The value of the free request - * id starts from 0x02345678, it is incremented each time this - * function is called and is reset to 1 after reaching - * Integer.MAX_VALUE. + * Get next free request id. The value of the free request id starts from + * 0x02345678, it is incremented each time this function is called and is + * reset to 1 after reaching Integer.MAX_VALUE. * * @return the next free request id. */ @@ -126,15 +118,15 @@ public abstract class RequestHeader public abstract boolean isResponseExpected(); /** - * Converts an byte array into hexadecimal string values. - * Used in various toString() methods. + * Converts an byte array into hexadecimal string values. Used in various + * toString() methods. */ public String bytes(byte[] array) { StringBuffer b = new StringBuffer(); for (int i = 0; i < array.length; i++) { - b.append(Integer.toHexString(array [ i ] & 0xFF)); + b.append(Integer.toHexString(array[i] & 0xFF)); b.append(" "); } return b.toString(); @@ -158,4 +150,5 @@ public abstract class RequestHeader * @param out a stream to write into. */ public abstract void write(cdrOutput out); + } diff --git a/gnu/CORBA/GIOP/ServiceContext.java b/gnu/CORBA/GIOP/ServiceContext.java index 7e44bdcea..29a8ea8ac 100644 --- a/gnu/CORBA/GIOP/ServiceContext.java +++ b/gnu/CORBA/GIOP/ServiceContext.java @@ -41,7 +41,9 @@ package gnu.CORBA.GIOP; import gnu.CORBA.CDR.cdrInput; import gnu.CORBA.CDR.cdrOutput; - +import org.omg.CORBA.BAD_INV_ORDER; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.portable.IDLEntity; /** @@ -53,16 +55,40 @@ public class ServiceContext implements IDLEntity { /** - * The context data. + * Use serialVersionUID for interoperability. */ - public byte[] context_data; + private static final long serialVersionUID = 1; /** - * The context id. + * The context id (for instance, 0x1 for code sets context). At the moment of + * writing, the OMG defines 16 standard values and provides rules to register + * the vendor specific context ids. The range 0-4095 is reserved for the + * future standard OMG contexts. */ public int context_id; /** + * The context_data. + */ + public byte[] context_data; + + /** + * Crete unitialised instance. + */ + public ServiceContext() + { + } + + /** + * Create from omg context. + */ + public ServiceContext(org.omg.IOP.ServiceContext from) + { + context_id = from.context_id; + context_data = from.context_data; + } + + /** * Read the context values from the stream. * * @param istream a stream to read from. @@ -73,13 +99,13 @@ public class ServiceContext switch (id) { - case cxCodeSet.ID : + case cxCodeSet.ID: cxCodeSet codeset = new cxCodeSet(); codeset.readContext(istream); return codeset; - default : + default: ServiceContext ctx = new ServiceContext(); ctx.context_id = id; @@ -94,9 +120,9 @@ public class ServiceContext public static ServiceContext[] readSequence(cdrInput istream) { int size = istream.read_long(); - ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[ size ]; + ServiceContext[] value = new gnu.CORBA.GIOP.ServiceContext[size]; for (int i = 0; i < value.length; i++) - value [ i ] = read(istream); + value[i] = read(istream); return value; } @@ -118,7 +144,99 @@ public class ServiceContext { ostream.write_long(value.length); for (int i = 0; i < value.length; i++) - value [ i ].write(ostream); + value[i].write(ostream); + } + + /** + * Add context to the given array of contexts. + */ + public static void add(org.omg.IOP.ServiceContext[] cx, + org.omg.IOP.ServiceContext service_context, boolean replace) + { + int exists = -1; + + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == service_context.context_id) + exists = i; + + if (exists < 0) + { + // Add context. + org.omg.IOP.ServiceContext[] n = new org.omg.IOP.ServiceContext[cx.length + 1]; + for (int i = 0; i < cx.length; i++) + n[i] = cx[i]; + n[cx.length] = service_context; + } + else + { + // Replace context. + if (!replace) + throw new BAD_INV_ORDER("Repetetive setting of the context " + + service_context.context_id, 15, + CompletionStatus.COMPLETED_NO); + else + cx[exists] = service_context; + } + } + + /** + * Add context to the given array of contexts. + */ + public static ServiceContext[] add(ServiceContext[] cx, + org.omg.IOP.ServiceContext service_context, boolean replace) + { + int exists = -1; + + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == service_context.context_id) + exists = i; + + if (exists < 0) + { + // Add context. + ServiceContext[] n = new ServiceContext[cx.length + 1]; + for (int i = 0; i < cx.length; i++) + n[i] = cx[i]; + n[cx.length] = new ServiceContext(service_context); + return n; + } + else + { + // Replace context. + if (!replace) + throw new BAD_INV_ORDER("Repetetive setting of the context " + + service_context.context_id, 15, + CompletionStatus.COMPLETED_NO); + else + cx[exists] = new ServiceContext(service_context); + return cx; + } + } + + + /** + * Find context with the given name in the context array. + */ + public static org.omg.IOP.ServiceContext findContext(int ctx_name, + org.omg.IOP.ServiceContext[] cx) + { + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == ctx_name) + return cx[i]; + throw new BAD_PARAM("No context with id " + ctx_name); + } + + /** + * Find context with the given name in the context array, + * converting into org.omg.IOP.ServiceContext. + */ + public static org.omg.IOP.ServiceContext findContext(int ctx_name, + ServiceContext[] cx) + { + for (int i = 0; i < cx.length; i++) + if (cx[i].context_id == ctx_name) + return new org.omg.IOP.ServiceContext(ctx_name, cx[i].context_data); + throw new BAD_PARAM("No context with id " + ctx_name); } /** @@ -126,6 +244,6 @@ public class ServiceContext */ public String toString() { - return "ctx "+context_id+", size "+context_data.length; + return "ctx " + context_id + ", size " + context_data.length; } } diff --git a/gnu/CORBA/GIOP/contextSupportingHeader.java b/gnu/CORBA/GIOP/contextSupportingHeader.java new file mode 100644 index 000000000..ba6c1f88d --- /dev/null +++ b/gnu/CORBA/GIOP/contextSupportingHeader.java @@ -0,0 +1,76 @@ +/* contextSupportingHeader.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.GIOP; + +import org.omg.CORBA.BAD_INV_ORDER; + +/** + * A header, supporting the service contexts. Such header has a context field + * and methods for adding the new contexts. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class contextSupportingHeader +{ + + /** + * Empty array, indicating that no service context is available. + */ + protected static final ServiceContext[] NO_CONTEXT = new ServiceContext[0]; + + /** + * The context data. + */ + public ServiceContext[] service_context = NO_CONTEXT; + + /** + * Add service context to this header. + * + * @param context_to_add context to add. + * @param replace if true, the existing context with this ID is replaced. + * Otherwise, BAD_INV_ORDER is throwsn. + */ + public void addContext(org.omg.IOP.ServiceContext context_to_add, + boolean replace) + throws BAD_INV_ORDER + { + service_context = ServiceContext.add(service_context, context_to_add, + replace); + } +} diff --git a/gnu/CORBA/GIOP/v1_0/RequestHeader.java b/gnu/CORBA/GIOP/v1_0/RequestHeader.java index ffa45c37b..7ede4e5b9 100644 --- a/gnu/CORBA/GIOP/v1_0/RequestHeader.java +++ b/gnu/CORBA/GIOP/v1_0/RequestHeader.java @@ -40,11 +40,11 @@ package gnu.CORBA.GIOP.v1_0; import gnu.CORBA.CDR.cdrInput; import gnu.CORBA.CDR.cdrOutput; - -import org.omg.CORBA.portable.IDLEntity; import gnu.CORBA.GIOP.ServiceContext; import gnu.CORBA.GIOP.cxCodeSet; +import org.omg.CORBA.portable.IDLEntity; + /** * The GIOP 1.0 request message. * diff --git a/gnu/CORBA/IOR.java b/gnu/CORBA/IOR.java index cedbce461..02e94aa64 100644 --- a/gnu/CORBA/IOR.java +++ b/gnu/CORBA/IOR.java @@ -47,22 +47,29 @@ import gnu.CORBA.GIOP.cxCodeSet; import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.CompletionStatus; +import org.omg.CORBA.MARSHAL; import org.omg.CORBA.ULongSeqHelper; +import org.omg.IOP.TAG_INTERNET_IOP; +import org.omg.IOP.TAG_MULTIPLE_COMPONENTS; +import org.omg.IOP.TaggedComponent; +import org.omg.IOP.TaggedComponentHelper; +import org.omg.IOP.TaggedProfile; +import org.omg.IOP.TaggedProfileHelper; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.util.ArrayList; /** - * The implementaton of the Interoperable Object Reference (IOR). - * IOR can be compared with the Internet address for a web page, - * it provides means to locate the CORBA service on the web. - * IOR contains the host address, port number, the object identifier - * (key) inside the server, the communication protocol version, - * supported charsets and so on. + * The implementaton of the Interoperable Object Reference (IOR). IOR can be + * compared with the Internet address for a web page, it provides means to + * locate the CORBA service on the web. IOR contains the host address, port + * number, the object identifier (key) inside the server, the communication + * protocol version, supported charsets and so on. * - * Ths class provides method for encoding and - * decoding the IOR information from/to the stringified references, - * usually returned by {@link org.omg.CORBA.ORB#String object_to_string()}. + * Ths class provides method for encoding and decoding the IOR information + * from/to the stringified references, usually returned by + * {@link org.omg.CORBA.ORB#String object_to_string()}. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) * @@ -72,10 +79,22 @@ import java.io.IOException; public class IOR { /** - * The code sets profile. + * The code sets tagged component, normally part of the Internet profile. This + * compone consists of the two componenets itself. */ public static class CodeSets_profile { + public CodeSets_profile() + { + int[] supported = CharSets_OSF.getSupportedCharSets(); + + narrow.native_set = CharSets_OSF.NATIVE_CHARACTER; + narrow.conversion = supported; + + wide.native_set = CharSets_OSF.NATIVE_WIDE_CHARACTER; + wide.conversion = supported; + } + /** * The code set component. */ @@ -112,7 +131,7 @@ public class IOR b.append(" conversion "); for (int i = 0; i < conversion.length; i++) { - b.append(name(conversion [ i ])); + b.append(name(conversion[i])); b.append(' '); } } @@ -131,8 +150,8 @@ public class IOR private String name(int set) { - return "0x" + Integer.toHexString(set) + " (" + - CharSets_OSF.getName(set) + ") "; + return "0x" + Integer.toHexString(set) + " (" + + CharSets_OSF.getName(set) + ") "; } } @@ -201,7 +220,7 @@ public class IOR /** * The internet profile. */ - public static class Internet_profile + public class Internet_profile { /** * The agreed tag for the Internet profile. @@ -224,6 +243,18 @@ public class IOR public int port; /** + * The code sets component in the internet profile of this IOR. This is not + * a separate profile. + */ + public CodeSets_profile CodeSets = new CodeSets_profile(); + + /** + * Reserved for all components of this profile, this array holds the + * components other than code set components. + */ + ArrayList components = new ArrayList(); + + /** * Return the human readable representation. */ public String toString() @@ -235,22 +266,63 @@ public class IOR b.append(" (v"); b.append(version); b.append(")"); + if (components.size() > 0) + b.append(" " + components.size() + " extra components."); return b.toString(); } + + /** + * Write the internet profile (except the heading tag. + */ + public void write(cdrOutput out) + { + try + { + // Need to write the Internet profile into the separate + // stream as we must know the size in advance. + cdrOutput b = out.createEncapsulation(); + + version.write(b); + b.write_string(host); + + b.write_ushort((short) (port & 0xFFFF)); + + // Write the object key. + b.write_long(key.length); + b.write(key); + + // Number of the tagged components. + b.write_long(1 + components.size()); + + b.write_long(CodeSets_profile.TAG_CODE_SETS); + CodeSets.write(b); + + TaggedComponent t; + + for (int i = 0; i < components.size(); i++) + { + t = (TaggedComponent) components.get(i); + TaggedComponentHelper.write(b, t); + } + + b.close(); + } + catch (Exception e) + { + MARSHAL m = new MARSHAL("Unable to write Internet profile."); + m.initCause(e); + throw m; + } + } } /** - * The standard minor code, indicating that the string to object - * converstio has failed due non specific reasons. + * The standard minor code, indicating that the string to object converstio + * has failed due non specific reasons. */ public static final int FAILED = 10; /** - * The code sets profile of this IOR. - */ - public CodeSets_profile CodeSets = new CodeSets_profile(); - - /** * The internet profile of this IOR. */ public Internet_profile Internet = new Internet_profile(); @@ -261,45 +333,35 @@ public class IOR public String Id; /** - * The additional tagged components, encapsulated in - * the byte arrays. They are only supported by the - * later versions, than currently implemented. + * The object key. */ - public byte[][] extra; + public byte[] key; /** - * The object key. + * All tagged profiles of this IOR, except the separately defined Internet + * profile. */ - public byte[] key; + ArrayList profiles = new ArrayList(); /** - * True if the profile was encoded using the Big Endian or - * the encoding is not known. + * True if the profile was encoded using the Big Endian or the encoding is not + * known. * * false if it was encoded using the Little Endian. */ public boolean Big_Endian = true; /** - * Create an empty instance, initialising the code sets to default - * values. + * Create an empty instance, initialising the code sets to default values. */ public IOR() { - int[] supported = CharSets_OSF.getSupportedCharSets(); - - CodeSets.narrow.native_set = CharSets_OSF.NATIVE_CHARACTER; - CodeSets.narrow.conversion = supported; - - CodeSets.wide.native_set = CharSets_OSF.NATIVE_WIDE_CHARACTER; - CodeSets.wide.conversion = supported; } /** * Parse the provided stringifed reference. * - * @param stringified_reference, in the form of - * IOR:nnnnnn..... + * @param stringified_reference, in the form of IOR:nnnnnn..... * * @return the parsed IOR * @@ -308,14 +370,13 @@ public class IOR * TODO corballoc and other alternative formats. */ public static IOR parse(String stringified_reference) - throws BAD_PARAM + throws BAD_PARAM { try { if (!stringified_reference.startsWith("IOR:")) throw new BAD_PARAM("The string refernce must start with IOR:", - FAILED, CompletionStatus.COMPLETED_NO - ); + FAILED, CompletionStatus.COMPLETED_NO); IOR r = new IOR(); @@ -340,8 +401,7 @@ public class IOR { ex.printStackTrace(); throw new BAD_PARAM(ex + " while parsing " + stringified_reference, - FAILED, CompletionStatus.COMPLETED_NO - ); + FAILED, CompletionStatus.COMPLETED_NO); } } @@ -352,7 +412,7 @@ public class IOR * @throws IOException if the stream throws it. */ public void _read(cdrInput c) - throws IOException, BAD_PARAM + throws IOException, BAD_PARAM { int endian; @@ -366,23 +426,21 @@ public class IOR } /** - * Read the IOR from the provided input stream, not reading - * the endian data at the beginning of the stream. The IOR is - * thansferred in this form in + * Read the IOR from the provided input stream, not reading the endian data at + * the beginning of the stream. The IOR is thansferred in this form in * {@link write_Object(org.omg.CORBA.Object)}. * * If the stream contains a null value, the Id and Internet fields become - * equal to null. Otherwise Id contains some string (possibly - * empty). + * equal to null. Otherwise Id contains some string (possibly empty). * - * Id is checked for null in cdrInput that then returns - * null instead of object. + * Id is checked for null in cdrInput that then returns null instead of + * object. * * @param c a stream to read from. * @throws IOException if the stream throws it. */ public void _read_no_endian(cdrInput c) - throws IOException, BAD_PARAM + throws IOException, BAD_PARAM { Id = c.read_string(); @@ -407,9 +465,7 @@ public class IOR Internet.host = profile.read_string(); Internet.port = profile.gnu_read_ushort(); - int lk = profile.read_long(); - key = new byte[ lk ]; - profile.read(key); + key = profile.read_sequence(); // Read tagged components. int n_components = 0; @@ -425,7 +481,16 @@ public class IOR if (ctag == CodeSets_profile.TAG_CODE_SETS) { - CodeSets.read(profile); + Internet.CodeSets.read(profile); + } + else + { + // Construct a generic component for codesets + // profile. + TaggedComponent pc = new TaggedComponent(); + pc.tag = ctag; + pc.component_data = profile.read_sequence(); + Internet.components.add(pc); } } } @@ -434,12 +499,21 @@ public class IOR ex.printStackTrace(); } } + else + { + // Construct a generic profile. + TaggedProfile p = new TaggedProfile(); + p.tag = tag; + p.profile_data = profile.buffer.getBuffer(); + + profiles.add(p); + } } } /** - * Write this IOR record to the provided CDR stream. - * This procedure writes the zero (Big Endian) marker first. + * Write this IOR record to the provided CDR stream. This procedure writes the + * zero (Big Endian) marker first. */ public void _write(cdrOutput out) { @@ -451,8 +525,8 @@ public class IOR /** * Write a null value to the CDR output stream. * - * The null value is written as defined in OMG specification - * (zero length string, followed by an empty set of profiles). + * The null value is written as defined in OMG specification (zero length + * string, followed by an empty set of profiles). */ public static void write_null(cdrOutput out) { @@ -464,47 +538,27 @@ public class IOR } /** - * Write this IOR record to the provided CDR stream. The procedure - * writed data in Big Endian, but does NOT add any endian marker - * to the beginning. + * Write this IOR record to the provided CDR stream. The procedure writed data + * in Big Endian, but does NOT add any endian marker to the beginning. */ public void _write_no_endian(cdrOutput out) { - try - { - // Write repository id. - out.write_string(Id); - - // Always one profile. - out.write_long(1); - - // It is the Internet profile. - out.write_long(Internet_profile.TAG_INTERNET_IOP); + // Write repository id. + out.write_string(Id); - // Need to write the Internet profile into the separate - // stream as we must know the size in advance. - cdrOutput b = out.createEncapsulation(); + out.write_long(1 + profiles.size()); - Internet.version.write(b); - b.write_string(Internet.host); + // Write the Internet profile. + out.write_long(Internet_profile.TAG_INTERNET_IOP); + Internet.write(out); - b.write_ushort((short) (Internet.port & 0xFFFF)); + // Write other profiles. + TaggedProfile tp; - // Write the object key. - b.write_long(key.length); - b.write(key); - - // One tagged component. - b.write_long(1); - - b.write_long(CodeSets_profile.TAG_CODE_SETS); - CodeSets.write(b); - - b.close(); - } - catch (IOException ex) + for (int i = 0; i < profiles.size(); i++) { - Unexpected.error(ex); + tp = (TaggedProfile) profiles.get(i); + TaggedProfileHelper.write(out, tp); } } @@ -525,11 +579,11 @@ public class IOR for (int i = 0; i < key.length; i++) { - b.append(Integer.toHexString(key [ i ] & 0xFF)); + b.append(Integer.toHexString(key[i] & 0xFF)); } b.append(" "); - b.append(CodeSets); + b.append(Internet.CodeSets); return b.toString(); } @@ -552,7 +606,7 @@ public class IOR for (int i = 0; i < binary.length; i++) { - s = Integer.toHexString(binary [ i ] & 0xFF); + s = Integer.toHexString(binary[i] & 0xFF); if (s.length() == 1) b.append('0'); b.append(s); @@ -560,4 +614,105 @@ public class IOR return b.toString(); } + + /** + * Adds a service-specific component to the IOR profile. The specified + * component will be included in all profiles, present in the IOR. + * + * @param tagged_component a tagged component being added. + */ + public void add_ior_component(TaggedComponent tagged_component) + { + // Add to the Internet profile. + Internet.components.add(tagged_component); + + // Add to others. + for (int i = 0; i < profiles.size(); i++) + { + TaggedProfile profile = (TaggedProfile) profiles.get(i); + addComponentTo(profile, tagged_component); + } + } + + /** + * Adds a service-specific component to the IOR profile. + * + * @param tagged_component a tagged component being added. + * + * @param profile_id the IOR profile to that the component must be added. The + * 0 value ({@link org.omg.IOP.TAG_INTERNET_IOP#value}) adds to the Internet + * profile where host and port are stored by default. + */ + public void add_ior_component_to_profile(TaggedComponent tagged_component, + int profile_id) + { + if (profile_id == TAG_INTERNET_IOP.value) + // Add to the Internet profile + Internet.components.add(tagged_component); + else + { + // Add to others. + for (int i = 0; i < profiles.size(); i++) + { + TaggedProfile profile = (TaggedProfile) profiles.get(i); + if (profile.tag == profile_id) + addComponentTo(profile, tagged_component); + } + } + } + + /** + * Add given component to the given profile that is NOT an Internet profile. + * + * @param profile the profile, where the component should be added. + * @param component the component to add. + */ + private static void addComponentTo(TaggedProfile profile, + TaggedComponent component) + { + if (profile.tag == TAG_MULTIPLE_COMPONENTS.value) + { + TaggedComponent[] present; + if (profile.profile_data.length > 0) + { + cdrBufInput in = new cdrBufInput(profile.profile_data); + + present = new TaggedComponent[in.read_long()]; + + for (int i = 0; i < present.length; i++) + { + present[i] = TaggedComponentHelper.read(in); + } + } + else + present = new TaggedComponent[0]; + + cdrBufOutput out = new cdrBufOutput(profile.profile_data.length + + component.component_data.length + + 8); + + // Write new amount of components. + out.write_long(present.length + 1); + + // Write other components. + for (int i = 0; i < present.length; i++) + TaggedComponentHelper.write(out, present[i]); + + // Write the passed component. + TaggedComponentHelper.write(out, component); + + try + { + out.close(); + } + catch (IOException e) + { + throw new Unexpected(e); + } + profile.profile_data = out.buffer.toByteArray(); + } + else + // The future supported tagged profiles should be added here. + throw new BAD_PARAM("Unsupported profile type " + profile.tag); + } }
\ No newline at end of file diff --git a/gnu/CORBA/IOR_Delegate.java b/gnu/CORBA/IOR_Delegate.java index e3fde60ee..31591eb44 100644 --- a/gnu/CORBA/IOR_Delegate.java +++ b/gnu/CORBA/IOR_Delegate.java @@ -55,6 +55,7 @@ import org.omg.CORBA.portable.ApplicationException; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.RemarshalException; +import org.omg.PortableInterceptor.ForwardRequest; import java.io.IOException; @@ -69,12 +70,11 @@ import java.net.Socket; * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ -public class IOR_Delegate - extends Simple_delegate +public class IOR_Delegate extends Simple_delegate { /** - * True if the current IOR does not map into the local servant. - * If false, the IOR is either local or should be checked. + * 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; @@ -105,9 +105,8 @@ public class IOR_Delegate * @return the created request. */ public Request create_request(org.omg.CORBA.Object target, Context context, - String operation, NVList parameters, - NamedValue returns - ) + String operation, NVList parameters, NamedValue returns + ) { gnuRequest request = getRequestInstance(target); @@ -135,10 +134,9 @@ public class IOR_Delegate * @return the created request. */ public Request create_request(org.omg.CORBA.Object target, Context context, - String operation, NVList parameters, - NamedValue returns, ExceptionList exceptions, - ContextList ctx_list - ) + String operation, NVList parameters, NamedValue returns, + ExceptionList exceptions, ContextList ctx_list + ) { gnuRequest request = getRequestInstance(target); @@ -166,134 +164,207 @@ public class IOR_Delegate /** * Invoke operation on the given object, als handling temproray and permanent - * redirections. The ReplyHeader.LOCATION_FORWARD will cause to resend - * the request to the new direction. The ReplyHeader.LOCATION_FORWARD_PERM - * will cause additionally to remember the new location by this delegate, - * so subsequent calls will be immediately delivered to the new target. + * redirections. The ReplyHeader.LOCATION_FORWARD will cause to resend the + * request to the new direction. The ReplyHeader.LOCATION_FORWARD_PERM will + * cause additionally to remember the new location by this delegate, so + * subsequent calls will be immediately delivered to the new target. * * @param target the target object. * @param output the output stream, previously returned by * {@link #request(org.omg.CORBA.Object, String, boolean)}. * - * @return the input stream, to read the response from or null for a - * one-way request. + * @return the input stream, to read the response from or null for a one-way + * request. * * @throws SystemException if the SystemException has been thrown on the - * remote side (the exact type and the minor code matches the data of - * the remote exception that has been thrown). + * remote side (the exact type and the minor code matches the data of the + * remote exception that has been thrown). * * @throws org.omg.CORBA.portable.ApplicationException as specified. * @throws org.omg.CORBA.portable.RemarshalException as specified. */ public InputStream invoke(org.omg.CORBA.Object target, OutputStream output) - throws ApplicationException, RemarshalException + throws ApplicationException, RemarshalException { streamRequest request = (streamRequest) output; - if (request.response_expected) + Forwardings: + while (true) { - binaryReply response = request.request.submit(); - - // Read reply header. - ReplyHeader rh = response.header.create_reply_header(); - cdrBufInput input = response.getStream(); - input.setOrb(orb); - rh.read(input); - - boolean moved_permanently = false; - - switch (rh.reply_status) + try { - case ReplyHeader.NO_EXCEPTION : - if (response.header.version.since_inclusive(1, 2)) - input.align(8); - return input; - - case ReplyHeader.SYSTEM_EXCEPTION : - if (response.header.version.since_inclusive(1, 2)) - input.align(8); - throw ObjectCreator.readSystemException(input); - - case ReplyHeader.USER_EXCEPTION : - if (response.header.version.since_inclusive(1, 2)) - input.align(8); - input.mark(2000); - - String uxId = input.read_string(); - input.reset(); - - throw new ApplicationException(uxId, input); - - case ReplyHeader.LOCATION_FORWARD_PERM : - moved_permanently = true; - - case ReplyHeader.LOCATION_FORWARD : - if (response.header.version.since_inclusive(1, 2)) - input.align(8); - - IOR forwarded = new IOR(); - try - { - forwarded._read_no_endian(input); - } - catch (IOException ex) - { - MARSHAL t = - new MARSHAL("Cant read forwarding info", 5102, - CompletionStatus.COMPLETED_NO - ); - t.initCause(ex); - throw t; - } - - gnuRequest prev = request.request; - gnuRequest r = getRequestInstance(target); - - r.m_args = prev.m_args; - r.m_context = prev.m_context; - r.m_context_list = prev.m_context_list; - r.m_environment = prev.m_environment; - r.m_exceptions = prev.m_exceptions; - r.m_operation = prev.m_operation; - r.m_parameter_buffer = prev.m_parameter_buffer; - r.m_parameter_buffer.request = r; - r.m_result = prev.m_result; - r.m_target = prev.m_target; - r.oneWay = prev.oneWay; - r.setIor(forwarded); - - IOR_contructed_object it = - new IOR_contructed_object(orb, forwarded); - - r.m_target = it; - - request.request = r; - - IOR prev_ior = getIor(); - - setIor(forwarded); - - try - { - return invoke(it, request); - } - finally - { - if (!moved_permanently) - setIor(prev_ior); - } - - default : - throw new MARSHAL("Unknow reply status: " + rh.reply_status, - 8000 + rh.reply_status, - CompletionStatus.COMPLETED_NO - ); + if (request.response_expected) + { + binaryReply response = request.request.submit(); + + // Read reply header. + ReplyHeader rh = response.header.create_reply_header(); + cdrBufInput input = response.getStream(); + input.setOrb(orb); + rh.read(input); + request.request.m_rph = rh; + + boolean moved_permanently = false; + + switch (rh.reply_status) + { + case ReplyHeader.NO_EXCEPTION : + if (request.request.m_interceptor != null) + request.request.m_interceptor. + receive_reply(request.request.m_info); + if (response.header.version.since_inclusive(1, 2)) + input.align(8); + return input; + + case ReplyHeader.SYSTEM_EXCEPTION : + if (response.header.version.since_inclusive(1, 2)) + input.align(8); + showException(request, input); + + throw ObjectCreator.readSystemException(input); + + 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 + ); + + case ReplyHeader.LOCATION_FORWARD_PERM : + moved_permanently = true; + + case ReplyHeader.LOCATION_FORWARD : + if (response.header.version.since_inclusive(1, 2)) + input.align(8); + + IOR forwarded = new IOR(); + try + { + forwarded._read_no_endian(input); + } + catch (IOException ex) + { + MARSHAL t = + new MARSHAL("Cant read forwarding info", 5102, + CompletionStatus.COMPLETED_NO + ); + t.initCause(ex); + throw t; + } + + gnuRequest prev = request.request; + gnuRequest r = getRequestInstance(target); + + r.m_interceptor = prev.m_interceptor; + r.m_slots = prev.m_slots; + + r.m_args = prev.m_args; + r.m_context = prev.m_context; + r.m_context_list = prev.m_context_list; + r.m_environment = prev.m_environment; + r.m_exceptions = prev.m_exceptions; + r.m_operation = prev.m_operation; + r.m_parameter_buffer = prev.m_parameter_buffer; + r.m_parameter_buffer.request = r; + r.m_result = prev.m_result; + r.m_target = prev.m_target; + r.oneWay = prev.oneWay; + r.m_forward_ior = forwarded; + + if (r.m_interceptor != null) + r.m_interceptor.receive_other(r.m_info); + + r.setIor(forwarded); + + IOR_contructed_object it = + new IOR_contructed_object(orb, forwarded); + + r.m_target = it; + + request.request = r; + + IOR prev_ior = getIor(); + + setIor(forwarded); + + try + { + return invoke(it, request); + } + finally + { + if (!moved_permanently) + setIor(prev_ior); + } + + default : + throw new MARSHAL("Unknow reply status: " + + rh.reply_status, 8000 + rh.reply_status, + CompletionStatus.COMPLETED_NO + ); + } + } + else + { + request.request.send_oneway(); + return null; + } + } + catch (ForwardRequest forwarded) + { + ForwardRequest fw = forwarded; + Forwarding2: + while (true) + { + try + { + gnuRequest prev = request.request; + gnuRequest r = getRequestInstance(target); + + r.m_interceptor = prev.m_interceptor; + r.m_args = prev.m_args; + r.m_context = prev.m_context; + r.m_context_list = prev.m_context_list; + r.m_environment = prev.m_environment; + r.m_exceptions = prev.m_exceptions; + r.m_operation = prev.m_operation; + r.m_parameter_buffer = prev.m_parameter_buffer; + r.m_parameter_buffer.request = r; + r.m_result = prev.m_result; + r.m_target = prev.m_target; + r.oneWay = prev.oneWay; + + r.m_forwarding_target = fw.forward; + + if (r.m_interceptor != null) + r.m_interceptor.receive_other(r.m_info); + + r.m_target = fw.forward; + request.request = r; + break Forwarding2; + } + catch (ForwardRequest e) + { + forwarded = e; + } + } } } - else - { - request.request.send_oneway(); - return null; - } + } + + /** + * Show exception to interceptor. + */ + void showException(streamRequest request, cdrBufInput input) + throws ForwardRequest + { + input.mark(2048); + request.request.m_exception_id = input.read_string(); + input.reset(); + + if (request.request.m_interceptor != null) + request.request.m_interceptor.receive_exception(request.request.m_info); } /** @@ -328,8 +399,8 @@ public class IOR_Delegate * @return the stream where the method arguments should be written. */ public OutputStream request(org.omg.CORBA.Object target, String operation, - boolean response_expected - ) + boolean response_expected + ) { gnuRequest request = getRequestInstance(target); @@ -344,11 +415,11 @@ public class IOR_Delegate } /** - * If there is an opened cache socket to access this object, close - * that socket. + * If there is an opened cache socket to access this object, close that + * socket. * - * @param target The target is not used, this delegate requires a - * single instance per object. + * @param target The target is not used, this delegate requires a single + * instance per object. */ public void release(org.omg.CORBA.Object target) { @@ -369,8 +440,8 @@ public class IOR_Delegate } /** - * Reset the remote_ior flag, forcing to check if the object is local - * on the next getRequestInstance call. + * Reset the remote_ior flag, forcing to check if the object is local on the + * next getRequestInstance call. */ public void setIor(IOR an_ior) { diff --git a/gnu/CORBA/Interceptor/ClientRequestInterceptors.java b/gnu/CORBA/Interceptor/ClientRequestInterceptors.java new file mode 100644 index 000000000..cc830a01b --- /dev/null +++ b/gnu/CORBA/Interceptor/ClientRequestInterceptors.java @@ -0,0 +1,139 @@ +/* ClientRequestInterceptors.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.Interceptor; + +import org.omg.PortableInterceptor.ClientRequestInfo; +import org.omg.PortableInterceptor.ClientRequestInterceptor; +import org.omg.PortableInterceptor.ClientRequestInterceptorOperations; +import org.omg.PortableInterceptor.ForwardRequest; + +/** + * A block of the all registered ClientRequest interceptors. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class ClientRequestInterceptors + implements ClientRequestInterceptorOperations +{ + /** + * The array of all registered ClientRequest interceptors. + */ + private final ClientRequestInterceptor[] interceptors; + + /** + * Create the interceptor pack with the registerend interceptor array, + * obtained from the registrator. + */ + public ClientRequestInterceptors(Registrator registrator) + { + interceptors = registrator.getClientRequestInterceptors(); + } + + /** @inheritDoc */ + public void receive_exception(ClientRequestInfo info) + throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].receive_exception(info); + } + } + + /** @inheritDoc */ + public void receive_other(ClientRequestInfo info) throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].receive_other(info); + } + } + + /** @inheritDoc */ + public void receive_reply(ClientRequestInfo info) + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].receive_reply(info); + } + } + + /** @inheritDoc */ + public void send_poll(ClientRequestInfo info) throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].send_poll(info); + } + } + + /** @inheritDoc */ + public void send_request(ClientRequestInfo info) throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].send_request(info); + } + } + + /** + * Call destroy on all registered interceptors. + */ + public void destroy() + { + for (int i = 0; i < interceptors.length; i++) + { + try + { + interceptors [ i ].destroy(); + } + catch (Exception exc) + { + // OMG states we should ignore. + } + } + } + + /** + * Get the class name. + */ + public String name() + { + return getClass().getName(); + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/ForwardRequestHolder.java b/gnu/CORBA/Interceptor/ForwardRequestHolder.java new file mode 100644 index 000000000..d9ced03a3 --- /dev/null +++ b/gnu/CORBA/Interceptor/ForwardRequestHolder.java @@ -0,0 +1,106 @@ +/* ForwardRequestHolder.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.Interceptor; + +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.Streamable; +import org.omg.PortableInterceptor.ForwardRequest; +import org.omg.PortableInterceptor.ForwardRequestHelper; + +/** + * A holder for the exception {@link ForwardRequest}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class ForwardRequestHolder implements Streamable +{ + /** + * The stored ForwardRequest value. + */ + public ForwardRequest value; + + /** + * Create the unitialised instance, leaving the value field with default + * <code>null</code> value. + */ + public ForwardRequestHolder() + { + } + + /** + * Create the initialised instance. + * + * @param initialValue the value that will be assigned to the + * <code>value</code> field. + */ + public ForwardRequestHolder(ForwardRequest initialValue) + { + value = initialValue; + } + + /** + * Fill in the {@link value} by data from the CDR stream. + * + * @param input the org.omg.CORBA.portable stream to read. + */ + public void _read(InputStream input) + { + value = ForwardRequestHelper.read(input); + } + + /** + * Write the stored value into the CDR stream. + * + * @param output the org.omg.CORBA.portable stream to write. + */ + public void _write(OutputStream output) + { + ForwardRequestHelper.write(output, value); + } + + /** + * Get the typecode of the ForwardRequest. + */ + public TypeCode _type() + { + return ForwardRequestHelper.type(); + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/IORInterceptors.java b/gnu/CORBA/Interceptor/IORInterceptors.java new file mode 100644 index 000000000..88756988c --- /dev/null +++ b/gnu/CORBA/Interceptor/IORInterceptors.java @@ -0,0 +1,109 @@ +/* IORInterceptors.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.Interceptor; + +import org.omg.PortableInterceptor.IORInfo; +import org.omg.PortableInterceptor.IORInterceptor; +import org.omg.PortableInterceptor.IORInterceptorOperations; + +/** + * A block of the all registered IOR interceptors. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class IORInterceptors implements IORInterceptorOperations +{ + /** + * The array of all registered IOR interceptors. + */ + private final IORInterceptor[] interceptors; + + /** + * Create the interceptor pack with the registerend interceptor array, + * obtained from the registrator. + */ + public IORInterceptors(Registrator registrator) + { + interceptors = registrator.getIORInterceptors(); + } + + /** + * Call this method for all registered interceptors. + */ + public void establish_components(IORInfo info) + { + for (int i = 0; i < interceptors.length; i++) + { + try + { + interceptors [ i ].establish_components(info); + } + catch (Exception exc) + { + // OMG states we should ignore. + } + } + } + + /** + * Call destroy on all registered interceptors. + */ + public void destroy() + { + for (int i = 0; i < interceptors.length; i++) + { + try + { + interceptors [ i ].destroy(); + } + catch (Exception exc) + { + // OMG states we should ignore. + } + } + } + + /** + * Get the class name. + */ + public String name() + { + return getClass().getName(); + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/Registrator.java b/gnu/CORBA/Interceptor/Registrator.java new file mode 100644 index 000000000..e871aaa6b --- /dev/null +++ b/gnu/CORBA/Interceptor/Registrator.java @@ -0,0 +1,470 @@ +/* Registrator.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.Interceptor; + +import gnu.CORBA.Poa.ORB_1_4; +import gnu.CORBA.gnuCodecFactory; + +import org.omg.CORBA.BAD_INV_ORDER; +import org.omg.CORBA.CompletionStatus; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.Object; +import org.omg.IOP.CodecFactory; +import org.omg.PortableInterceptor.ClientRequestInterceptor; +import org.omg.PortableInterceptor.IORInterceptor; +import org.omg.PortableInterceptor.Interceptor; +import org.omg.PortableInterceptor.ORBInitInfo; +import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; +import org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName; +import org.omg.PortableInterceptor.ORBInitializer; +import org.omg.PortableInterceptor.ORBInitializerOperations; +import org.omg.PortableInterceptor.PolicyFactory; +import org.omg.PortableInterceptor.ServerRequestInterceptor; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.TreeMap; + +/** + * Collects interceptors, references and factories into arrays during + * registration. As the class is security sensitive, the most of the fields are + * private. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class Registrator extends LocalObject implements ORBInitInfo +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * The agreed properties prefix. + */ + public final String m_prefix = + "org.omg.PortableInterceptor.ORBInitializerClass."; + + /** + * The initialization - time server request interceptors. + */ + private ArrayList m_server = new ArrayList(); + + /** + * The initialization - time client request interceptors. + */ + private ArrayList m_client = new ArrayList(); + + /** + * The initialization - time ior interceptors. + */ + private ArrayList m_ior = new ArrayList(); + + /** + * The policy factories. + */ + public Hashtable m_policyFactories = new Hashtable(); + + /** + * The registered references. To avoid exposing the ORB's references map, the + * are added by ORB from inside the ORB code. The ORB is responsible for + * taking them from this field between pre_init and post_init. + */ + public TreeMap m_references = new TreeMap(); + + /** + * The initializers. + */ + public ArrayList m_initializers = new ArrayList(); + + /** + * The ORB being intialised. + */ + final ORB_1_4 orb; + + /** + * The argument string array, passed to ORB.init. + */ + final String[] m_args; + + /** + * The codec factory. + */ + final gnuCodecFactory m_codecFactory; + + /** + * Create the interceptor collection from the given properties, using the + * agreed naming convention. + * + * @param orb the ORB being initialised. + * @param props the cumulated set of properties where the orb initializer + * pattern is searched. + * @param an_args the argument string array, passed to ORB.init. + */ + public Registrator(ORB_1_4 an_orb, Properties props, String[] an_args) + { + orb = an_orb; + m_args = an_args; + m_codecFactory = new gnuCodecFactory(orb); + checkProperties(props); + checkProperties(System.getProperties()); + checkFile("user.home", null); + checkFile("java.home", "lib"); + } + + /** + * Scan the given properties for the possible interceptors. + */ + private void checkProperties(Properties props) + { + if (props == null) + { + return; + } + + Enumeration names = props.propertyNames(); + java.lang.Object key; + String sk; + + while (names.hasMoreElements()) + { + key = names.nextElement(); + if (key != null) + { + sk = key.toString(); + if (sk.startsWith(m_prefix)) + { + try + { + String cn = sk.substring(m_prefix.length()); + Class iClass = Class.forName(cn); + ORBInitializer initializer = + (ORBInitializer) iClass.newInstance(); + m_initializers.add(initializer); + } + catch (Exception exc) + { + // OMG states we should not throw an exception, but + // this will help the user to detect his error + // in initialiser properties. Should never print during + // normal run. + System.err.println(sk + " failed"); + } + } + } + } + } + + /** + * Check if the property is defined in the existsting file orb.properties. + */ + private void checkFile(String dir, String subdir) + { + try + { + File f = new File(dir); + if (!f.exists()) + { + return; + } + + if (subdir != null) + { + f = new File(f, subdir); + } + f = new File(f, "orb.properties"); + + if (!f.exists()) + { + return; + } + + Properties p = new Properties(); + p.load(new BufferedInputStream(new FileInputStream(f))); + + checkProperties(p); + } + catch (IOException ex) + { + } + } + + /** + * Called by ORB as a pre_init for all initializers. + */ + public void pre_init() + { + Iterator iter = m_initializers.iterator(); + while (iter.hasNext()) + { + ORBInitializerOperations initializer = + (ORBInitializerOperations) iter.next(); + initializer.pre_init(this); + } + } + + /** + * Get the map of the registered references. The ORB calls this method to + * import the references into its references map. + */ + public Map getRegisteredReferences() + { + return m_references; + } + + /** + * Called by ORB as a post-init for all initializers. After this call, the + * interceptor sets are fixed and redundant information is discarded. + */ + public void post_init() + { + Iterator iter = m_initializers.iterator(); + while (iter.hasNext()) + { + ORBInitializerOperations initializer = + (ORBInitializerOperations) iter.next(); + initializer.post_init(this); + } + } + + public ServerRequestInterceptor[] getServerRequestInterceptors() + { + ServerRequestInterceptor[] iServer = + new ServerRequestInterceptor[ m_server.size() ]; + for (int i = 0; i < iServer.length; i++) + { + iServer [ i ] = (ServerRequestInterceptor) m_server.get(i); + } + return iServer; + } + + public ClientRequestInterceptor[] getClientRequestInterceptors() + { + ClientRequestInterceptor[] iClient = + new ClientRequestInterceptor[ m_client.size() ]; + for (int i = 0; i < iClient.length; i++) + { + iClient [ i ] = (ClientRequestInterceptor) m_client.get(i); + } + return iClient; + } + + public IORInterceptor[] getIORInterceptors() + { + IORInterceptor[] iIor = new IORInterceptor[ m_ior.size() ]; + for (int i = 0; i < iIor.length; i++) + { + iIor [ i ] = (IORInterceptor) m_ior.get(i); + } + return iIor; + } + + public void add_client_request_interceptor( + ClientRequestInterceptor interceptor + ) throws DuplicateName + { + add(m_client, interceptor); + } + + public void add_ior_interceptor(IORInterceptor interceptor) + throws DuplicateName + { + add(m_ior, interceptor); + } + + public void add_server_request_interceptor( + ServerRequestInterceptor interceptor + ) throws DuplicateName + { + add(m_server, interceptor); + } + + /** + * Allocate a new slot for request - specific records. + */ + public int allocate_slot_id() + { + return orb.icSlotSize++; + } + + /** + * Add the interceptor to the given collection. + * + * @param list the collection to add. + * @param interceptor the interceptor to add. + */ + private void add(ArrayList list, Interceptor interceptor) + throws DuplicateName + { + if (interceptor.name().length() > 0) + { + Iterator iter = list.iterator(); + Interceptor ic; + + while (iter.hasNext()) + { + ic = (Interceptor) iter.next(); + if (ic.name().equals(interceptor.name())) + { + throw new DuplicateName(interceptor.name()); + } + } + } + list.add(interceptor); + } + + /** + * Get string array, passed to ORB.init. + */ + public String[] arguments() + { + return m_args; + } + + /** + * Get the codec factory. + */ + public CodecFactory codec_factory() + { + return m_codecFactory; + } + + /** + * Get the ORB's id, currently using .toString. + */ + public String orb_id() + { + return "orb_" + orb; + } + + /** + * Register reference. + */ + public void register_initial_reference(String object_name, Object object) + throws InvalidName + { + if (object_name == null) + { + throw new InvalidName("null"); + } + else if (object_name.length() == 0) + { + throw new InvalidName("Empty string"); + } + else if (m_references.containsKey(object_name)) + { + throw new InvalidName(object_name); + } + else + { + m_references.put(object_name, object); + } + } + + /** + * Accumulates the policy factory map. + */ + public void register_policy_factory(int policy_type, + PolicyFactory policy_factory + ) + { + Integer it = new Integer(policy_type); + if (m_policyFactories.containsKey(it)) + { + throw new BAD_INV_ORDER( + "Repetetive registration of the policy factory for type " + + policy_type, + 16, + CompletionStatus.COMPLETED_NO + ); + } + m_policyFactories.put(it, policy_factory); + } + + /** + * Delegates to ORB. + */ + public org.omg.CORBA.Object resolve_initial_references(String object_name) + throws InvalidName + { + try + { + return orb.resolve_initial_references(object_name); + } + catch (org.omg.CORBA.ORBPackage.InvalidName e) + { + InvalidName in = new InvalidName(e.getMessage()); + in.initCause(e); + throw in; + } + } + + /** + * Check if any interceptors of this type were registered. + */ + public boolean hasClientRequestInterceptors() + { + return m_client.size() > 0; + } + + /** + * Check if any interceptors of this type were registered. + */ + public boolean hasServerRequestInterceptors() + { + return m_server.size() > 0; + } + + /** + * Check if any interceptors of this type were registered. + */ + public boolean hasIorInterceptors() + { + return m_ior.size() > 0; + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/ServerRequestInterceptors.java b/gnu/CORBA/Interceptor/ServerRequestInterceptors.java new file mode 100644 index 000000000..4b9bede98 --- /dev/null +++ b/gnu/CORBA/Interceptor/ServerRequestInterceptors.java @@ -0,0 +1,139 @@ +/* ServerRequestInterceptors.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.Interceptor; + +import org.omg.PortableInterceptor.ForwardRequest; +import org.omg.PortableInterceptor.ServerRequestInfo; +import org.omg.PortableInterceptor.ServerRequestInterceptor; +import org.omg.PortableInterceptor.ServerRequestInterceptorOperations; + +/** + * A block of the all registered ServerRequest interceptors. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class ServerRequestInterceptors + implements ServerRequestInterceptorOperations +{ + /** + * The array of all registered ServerRequest interceptors. + */ + private final ServerRequestInterceptor[] interceptors; + + /** + * Create the interceptor pack with the registerend interceptor array, + * obtained from the registrator. + */ + public ServerRequestInterceptors(Registrator registrator) + { + interceptors = registrator.getServerRequestInterceptors(); + } + + /** @inheritDoc */ + public void receive_request_service_contexts(ServerRequestInfo info) + throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].receive_request_service_contexts(info); + } + } + + /** @inheritDoc */ + public void receive_request(ServerRequestInfo info) throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].receive_request(info); + } + } + + /** @inheritDoc */ + public void send_exception(ServerRequestInfo info) throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].send_exception(info); + } + } + + /** @inheritDoc */ + public void send_other(ServerRequestInfo info) throws ForwardRequest + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].send_other(info); + } + } + + /** @inheritDoc */ + public void send_reply(ServerRequestInfo info) + { + for (int i = 0; i < interceptors.length; i++) + { + interceptors [ i ].send_reply(info); + } + } + + /** + * Call destroy on all registered interceptors. + */ + public void destroy() + { + for (int i = 0; i < interceptors.length; i++) + { + try + { + interceptors [ i ].destroy(); + } + catch (Exception exc) + { + // OMG states we should ignore. + } + } + } + + /** + * Get the class name. + */ + public String name() + { + return getClass().getName(); + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/gnuClientRequestInfo.java b/gnu/CORBA/Interceptor/gnuClientRequestInfo.java new file mode 100644 index 000000000..beb81c81f --- /dev/null +++ b/gnu/CORBA/Interceptor/gnuClientRequestInfo.java @@ -0,0 +1,337 @@ +/* gnuClientRequestInfo.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.Interceptor; + +import gnu.CORBA.Unexpected; +import gnu.CORBA.gnuRequest; + +import org.omg.CORBA.ARG_IN; +import org.omg.CORBA.ARG_INOUT; +import org.omg.CORBA.ARG_OUT; +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.Bounds; +import org.omg.CORBA.ExceptionList; +import org.omg.CORBA.INV_POLICY; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.NVList; +import org.omg.CORBA.ORB; +import org.omg.CORBA.ParameterMode; +import org.omg.CORBA.Policy; +import org.omg.CORBA.TCKind; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.TypeCodePackage.BadKind; +import org.omg.Dynamic.Parameter; +import org.omg.IOP.ServiceContext; +import org.omg.IOP.TaggedComponent; +import org.omg.IOP.TaggedProfile; +import org.omg.PortableInterceptor.ClientRequestInfo; +import org.omg.PortableInterceptor.InvalidSlot; + +/** + * Client request info. All requests on the client side in Classpath + * implementations are handled via gnuRequest class. This class holds the + * instance of the gnuRequest, accessing the request info this way. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class gnuClientRequestInfo extends LocalObject + implements ClientRequestInfo +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * The request structure, from that some methods take the needed information + * directly. The same request structure cannot be reused in parallel threads, + * the submission methods are synchronized. + */ + private final gnuRequest request; + + /** + * Provides possibility to set the wrapped thrown exception explicitly, where + * applicable. + */ + public Any m_wrapped_exception; + + /** + * Create the info on the given request. + */ + public gnuClientRequestInfo(gnuRequest a_request) + { + request = a_request; + } + + /** @inheritDoc */ + public void add_request_service_context(ServiceContext service_context, + boolean replace + ) + { + request.add_request_service_context(service_context, replace); + } + + /** @inheritDoc */ + public TaggedProfile effective_profile() + { + return request.effective_profile(); + } + + /** @inheritDoc */ + public org.omg.CORBA.Object effective_target() + { + return request.effective_target(); + } + + /** @inheritDoc */ + public TaggedComponent get_effective_component(int id) + throws BAD_PARAM + { + return request.get_effective_component(id); + } + + /** @inheritDoc */ + public TaggedComponent[] get_effective_components(int id) + throws BAD_PARAM + { + return request.get_effective_components(id); + } + + /** @inheritDoc */ + public Policy get_request_policy(int type) throws INV_POLICY + { + return request.get_request_policy(type); + } + + /** @inheritDoc */ + public String received_exception_id() + { + try + { + if (m_wrapped_exception != null) + { + return m_wrapped_exception.type().id(); + } + else + { + return request.received_exception_id(); + } + } + catch (BadKind e) + { + throw new Unexpected(e); + } + } + + /** @inheritDoc */ + public Any received_exception() + { + if (m_wrapped_exception != null) + { + return m_wrapped_exception; + } + else + { + return request.received_exception(); + } + } + + /** @inheritDoc */ + public org.omg.CORBA.Object target() + { + return request.target(); + } + + /** @inheritDoc */ + public Parameter[] arguments() + { + request.checkDii(); + + NVList args = request.arguments(); + Parameter[] p = new Parameter[ args.count() ]; + try + { + for (int i = 0; i < p.length; i++) + { + ParameterMode mode; + + switch (args.item(i).flags()) + { + case ARG_IN.value : + mode = ParameterMode.PARAM_IN; + break; + + case ARG_OUT.value : + mode = ParameterMode.PARAM_OUT; + break; + + case ARG_INOUT.value : + mode = ParameterMode.PARAM_INOUT; + break; + + default : + throw new Unexpected(); + } + + p [ i ] = new Parameter(args.item(i).value(), mode); + } + } + catch (Bounds e) + { + throw new Unexpected(e); + } + return p; + } + + /** @inheritDoc */ + public Any result() + { + request.checkDii(); + + Any rt = request.return_value(); + + if (rt == null) + { + ORB orb = request.orb(); + rt = orb.create_any(); + rt.type(orb.get_primitive_tc(TCKind.tk_void)); + return rt; + } + + return request.return_value(); + } + + /** @inheritDoc */ + public String[] contexts() + { + return request.ice_contexts(); + } + + /** @inheritDoc */ + public TypeCode[] exceptions() + { + request.checkDii(); + + ExceptionList ex = request.exceptions(); + TypeCode[] et = new TypeCode[ ex.count() ]; + try + { + for (int i = 0; i < et.length; i++) + { + et [ i ] = ex.item(i); + } + } + catch (Bounds e) + { + throw new Unexpected(e); + } + return et; + } + + /** @inheritDoc */ + public org.omg.CORBA.Object forward_reference() + { + return request.forward_reference(); + } + + /** @inheritDoc */ + public String[] operation_context() + { + return request.operation_context(); + } + + /** @inheritDoc */ + public Any get_slot(int id) throws InvalidSlot + { + return request.get_slot(id); + } + + /** @inheritDoc */ + public String operation() + { + return request.operation(); + } + + /** @inheritDoc */ + public short reply_status() + { + return request.reply_status(); + } + + /** @inheritDoc */ + public int request_id() + { + return request.request_id(); + } + + /** @inheritDoc */ + public boolean response_expected() + { + return request.response_expected(); + } + + /** + * Determines how far the request shall progress before control is returned to + * the client. However up till JDK 1.5 inclusive this method always returns + * SYNC_WITH_TRANSPORT. + * + * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always. + * + * @specnote as defined in the Suns 1.5 JDK API. + */ + public short sync_scope() + { + return request.sync_scope(); + } + + /** @inheritDoc */ + public ServiceContext get_reply_service_context(int ctx_name) + throws BAD_PARAM + { + return request.get_reply_service_context(ctx_name); + } + + /** @inheritDoc */ + public ServiceContext get_request_service_context(int ctx_name) + throws BAD_PARAM + { + return request.get_request_service_context(ctx_name); + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/gnuIcCurrent.java b/gnu/CORBA/Interceptor/gnuIcCurrent.java new file mode 100644 index 000000000..ee8af7fc0 --- /dev/null +++ b/gnu/CORBA/Interceptor/gnuIcCurrent.java @@ -0,0 +1,255 @@ +/* gnuIcCurrent.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.Interceptor; + +import gnu.CORBA.CDR.cdrBufOutput; +import gnu.CORBA.Poa.ORB_1_4; + +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_INV_ORDER; +import org.omg.CORBA.TCKind; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.ObjectImpl; +import org.omg.PortableInterceptor.Current; +import org.omg.PortableInterceptor.CurrentHelper; +import org.omg.PortableInterceptor.InvalidSlot; + +import java.util.Hashtable; +import java.util.Iterator; +import java.util.Map; + +/** + * Supports the "Interceptor current" concept, providing the slot value + * information for the current thread. When making the invocation, this + * information is copied to the Current, returned by ClientRequestInfo. + * + * There is only one instance of this class per ORB. It maintains a thread to + * information map. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class gnuIcCurrent extends ObjectImpl implements Current +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * The ORB, controllin this Current. It provides data about the required size + * of the slot array. + */ + final ORB_1_4 orb; + + /** + * The table, mapping threads to records. + */ + private Hashtable threads = new Hashtable(); + + /** + * An empty array when no slots are defined, computed once. + */ + static final Any[] NO_SLOTS = new Any[ 0 ]; + + /** + * Create the IC current. + */ + public gnuIcCurrent(ORB_1_4 an_orb) + { + orb = an_orb; + } + + /** + * Get the array of POA current repository ids. + * + * @return a single member array, containing value, returned by the + * {@link CurrentHelper#id}, normally + * "IDL:omg.org/PortableInterceptor/Current:1.0". + */ + public String[] _ids() + { + return new String[] { CurrentHelper.id() }; + } + + /** + * Add the entry to the map. + */ + public void put(Thread t, Any[] record) + { + synchronized (threads) + { + threads.put(t, record); + + // Remove non-running threads, avoiding memory leak. + if (threads.size() > 12) + { + Iterator it = threads.entrySet().iterator(); + while (it.hasNext()) + { + Map.Entry e = (Map.Entry) it.next(); + Thread tx = (Thread) e.getKey(); + if (!tx.isAlive()) + { + it.remove(); + } + } + } + } + } + + /** + * Check if this thread is registered. + */ + public boolean has(Thread t) + { + synchronized (threads) + { + return threads.containsKey(t); + } + } + + /** + * Remove the entry from the map. + */ + public void remove(Thread t) + { + synchronized (threads) + { + threads.remove(t); + } + } + + /** + * Get array of all slots, as it is applicable for the current thread. If the + * slots were not previously allocated, they are allocated during this call. + */ + Any[] get_slots() + { + Any[] r; + synchronized (threads) + { + r = (Any[]) threads.get(Thread.currentThread()); + if (r == null) + { + r = new Any[ orb.icSlotSize ]; + + for (int i = 0; i < r.length; i++) + { + Any a = orb.create_any(); + a.type(orb.get_primitive_tc(TCKind.tk_null)); + r [ i ] = a; + } + + put(Thread.currentThread(), r); + } + return r; + } + } + + /** + * Get copu array of all slots, as it is applicable for the current thread. If + * the slots were not previously allocated, they are allocated during this + * call. + */ + public Any[] clone_slots() + { + if (orb.icSlotSize == 0) + { + return NO_SLOTS; + } + else + { + Any[] r = get_slots(); + Any[] copy = new Any[ r.length ]; + + cdrBufOutput buf = new cdrBufOutput(); + buf.setOrb(orb); + + for (int i = 0; i < copy.length; i++) + { + r [ i ].write_value(buf); + } + + InputStream input = buf.create_input_stream(); + + for (int i = 0; i < copy.length; i++) + { + copy [ i ] = orb.create_any(); + copy [ i ].read_value(input, r [ i ].type()); + } + + return copy; + } + } + + /** + * Get value for the slot with the given id. If the array of Currents has not + * been yet allocated for the current thread, it is allocated during the + * invocation of this method. + */ + public Any get_slot(int slot_id) throws InvalidSlot, BAD_INV_ORDER + { + try + { + return get_slots() [ slot_id ]; + } + catch (ArrayIndexOutOfBoundsException e) + { + throw new InvalidSlot("Slot " + slot_id); + } + } + + /** + * Set value for the slot with the given id. If the array of Currents has not + * been yet allocated for the current thread, it is allocated during the + * invocation of this method. + */ + public void set_slot(int slot_id, Any data) + throws InvalidSlot, BAD_INV_ORDER + { + try + { + get_slots() [ slot_id ] = data; + } + catch (ArrayIndexOutOfBoundsException e) + { + throw new InvalidSlot("Slot " + slot_id); + } + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/gnuIorInfo.java b/gnu/CORBA/Interceptor/gnuIorInfo.java new file mode 100644 index 000000000..1c406cb5e --- /dev/null +++ b/gnu/CORBA/Interceptor/gnuIorInfo.java @@ -0,0 +1,120 @@ +/* gnuIorInfo.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.Interceptor; + +import gnu.CORBA.IOR; +import gnu.CORBA.Poa.ORB_1_4; + +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; + +/** + * Implements IORInfo. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class gnuIorInfo extends LocalObject implements IORInfo +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * The ORB, to that the IOR is related. + */ + public final ORB_1_4 orb; + + /** + * The POA, to that IOR is related. + */ + public final POA poa; + + /** + * The IOR itself. + */ + private final IOR ior; + + /** + * Create an instance. + */ + public gnuIorInfo(ORB_1_4 an_orb, POA a_poa, IOR an_ior) + { + orb = an_orb; + poa = a_poa; + ior = an_ior; + } + + /** + * Add component to tje specified profile of this IOR. + */ + public void add_ior_component_to_profile(TaggedComponent tagged_component, + int profile_id + ) + { + ior.add_ior_component_to_profile(tagged_component, profile_id); + } + + /** + * Add component to all found profiles in this IOR. + */ + public void add_ior_component(TaggedComponent tagged_component) + { + ior.add_ior_component(tagged_component); + } + + /** + * Get the POA policy. + */ + public Policy get_effective_policy(int policy_type) + { + return poa._get_policy(policy_type); + } + + /** + * Return the state of the object POA. + */ + short state() + { + return (short) poa.the_POAManager().get_state().value(); + } +}
\ No newline at end of file diff --git a/gnu/CORBA/Interceptor/gnuServerRequestInfo.java b/gnu/CORBA/Interceptor/gnuServerRequestInfo.java new file mode 100644 index 000000000..5f75f7687 --- /dev/null +++ b/gnu/CORBA/Interceptor/gnuServerRequestInfo.java @@ -0,0 +1,456 @@ +/* gnuServerRequestInfo.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.Interceptor; + +import gnu.CORBA.GIOP.ReplyHeader; +import gnu.CORBA.GIOP.RequestHeader; +import gnu.CORBA.ObjectCreator; +import gnu.CORBA.Poa.gnuServantObject; +import gnu.CORBA.Unexpected; +import gnu.CORBA.gnuRequest; + +import org.omg.CORBA.ARG_IN; +import org.omg.CORBA.ARG_INOUT; +import org.omg.CORBA.ARG_OUT; +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.Bounds; +import org.omg.CORBA.CompletionStatus; +import org.omg.CORBA.ExceptionList; +import org.omg.CORBA.INV_POLICY; +import org.omg.CORBA.LocalObject; +import org.omg.CORBA.NO_RESOURCES; +import org.omg.CORBA.NVList; +import org.omg.CORBA.Object; +import org.omg.CORBA.ParameterMode; +import org.omg.CORBA.Policy; +import org.omg.CORBA.TCKind; +import org.omg.CORBA.TypeCode; +import org.omg.Dynamic.Parameter; +import org.omg.IOP.ServiceContext; +import org.omg.Messaging.SYNC_WITH_TRANSPORT; +import org.omg.PortableInterceptor.InvalidSlot; +import org.omg.PortableInterceptor.ServerRequestInfo; + +/** + * Implementation of the ServerRequestInfo, associacted with gnuServantObject. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class gnuServerRequestInfo extends LocalObject + implements ServerRequestInfo +{ + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * A local object that will serve the invocation. + */ + final gnuServantObject m_object; + + /** + * A message that the given resource is not available using this metod of + * invocation. + */ + static final String not_available = + "The used invocation method provides" + "no access to this resource."; + + /** + * An array of slots. + */ + Any[] m_slots; + + /** + * The request header. + */ + public final RequestHeader m_request_header; + + /** + * The reply header. + */ + public final ReplyHeader m_reply_header; + + /** + * The forward reference, if applicable. + */ + public Object m_forward_reference; + + /** + * The thrown systen exception. + */ + public Exception m_sys_exception; + + /** + * The Any, containing the thrown user exception. + */ + public Any m_usr_exception; + + /** + * The associated request, if any. + */ + public gnuRequest m_request; + + /** + * Create a new instance at the time when it is known which object will serve + * the invocation. + * + * @param an_object a local object, connected to the local servant that will + * serve the invocation. + */ + public gnuServerRequestInfo(gnuServantObject an_object, + RequestHeader a_request_header, ReplyHeader a_reply_header + ) + { + m_object = an_object; + m_request_header = a_request_header; + m_reply_header = a_reply_header; + m_slots = new Any[ m_object.orb.icSlotSize ]; + reset(); + } + + /** + * Set the give slot. + */ + public void set_slot(int id, Any data) throws InvalidSlot + { + try + { + m_slots [ id ] = data; + } + catch (Exception e) + { + InvalidSlot ex = new InvalidSlot("Cannot set slot " + id); + ex.initCause(e); + throw ex; + } + } + + /** + * Get the given slot. + */ + public Any get_slot(int id) throws InvalidSlot + { + try + { + return m_slots [ id ]; + } + catch (Exception e) + { + InvalidSlot ex = new InvalidSlot("Cannot get slot " + id); + ex.initCause(e); + throw ex; + } + } + + /** + * Reset slot data. + */ + public void reset() + { + TypeCode tkNull = m_object.orb.get_primitive_tc(TCKind.tk_null); + for (int i = 0; i < m_slots.length; i++) + { + Any a = m_object.orb.create_any(); + a.type(tkNull); + m_slots [ i ] = a; + } + m_sys_exception = null; + m_usr_exception = null; + } + + /** + * Get the object id (not the object IOR key). + */ + public byte[] object_id() + { + return m_object.Id; + } + + /** + * Check if the target is an instance of the type, represented by the given + * repository Id. + */ + public boolean target_is_a(String id) + { + return m_object._is_a(id); + } + + /** + * Get the POA id. + */ + public byte[] adapter_id() + { + return m_object.poa.id(); + } + + /** + * Get the POA policy of the given type that applies to the object being + * served (request being handled). + */ + public Policy get_server_policy(int type) throws INV_POLICY + { + return m_object.poa._get_policy(type); + } + + /** + * Get the first member of the object repository id array. + */ + public String target_most_derived_interface() + { + return m_object._ids() [ 0 ]; + } + + /** + * Get the name of the operation being performed. + */ + public String operation() + { + if (m_request != null) + { + return m_request.operation(); + } + else + { + return m_request_header.operation; + } + } + + /** + * Not available. + */ + public TypeCode[] exceptions() + { + if (m_request == null) + { + throw new NO_RESOURCES(not_available, 1, + CompletionStatus.COMPLETED_MAYBE + ); + } + + m_request.checkDii(); + + ExceptionList ex = m_request.exceptions(); + TypeCode[] et = new TypeCode[ ex.count() ]; + try + { + for (int i = 0; i < et.length; i++) + { + et [ i ] = ex.item(i); + } + } + catch (Bounds e) + { + throw new Unexpected(e); + } + return et; + } + + /** + * Get reply status. + */ + public short reply_status() + { + return (short) m_reply_header.reply_status; + } + + /** + * Get request id. All local requests have request id = -1. + */ + public int request_id() + { + return m_request_header.request_id; + } + + /** + * Check if the client expected any response. + */ + public boolean response_expected() + { + return m_request_header.isResponseExpected(); + } + + /** @inheritDoc */ + public void add_reply_service_context(ServiceContext service_context, + boolean replace + ) + { + m_reply_header.addContext(service_context, replace); + } + + /** + * Get an exception, wrapped into Any. + */ + public Any sending_exception() + { + if (m_usr_exception != null) + { + return m_usr_exception; + } + else if (m_sys_exception != null) + { + Any a = m_object.orb.create_any(); + ObjectCreator.insertException(a, m_sys_exception); + return a; + } + else + { + return null; + } + } + + public org.omg.CORBA.Object forward_reference() + { + return m_forward_reference; + } + + /** @inheritDoc */ + public ServiceContext get_reply_service_context(int ctx_name) + throws BAD_PARAM + { + return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name, + m_reply_header.service_context + ); + } + + /** @inheritDoc */ + public ServiceContext get_request_service_context(int ctx_name) + throws BAD_PARAM + { + return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name, + m_request_header.service_context + ); + } + + /** + * Not available + */ + public String[] operation_context() + { + if (m_request == null) + { + throw new NO_RESOURCES(not_available); + } + else + { + return m_request.operation_context(); + } + } + + /** @inheritDoc */ + public Any result() + { + if (m_request == null) + { + throw new NO_RESOURCES(not_available); + } + else + { + return m_request.return_value(); + } + } + + /** @inheritDoc */ + public String[] contexts() + { + if (m_request == null) + { + throw new NO_RESOURCES(not_available); + } + else + { + return m_request.ice_contexts(); + } + } + + /** + * Always returns "with transport". + */ + public short sync_scope() + { + return SYNC_WITH_TRANSPORT.value; + } + + /** @inheritDoc */ + public Parameter[] arguments() + { + if (m_request == null) + { + throw new NO_RESOURCES(not_available); + } + + m_request.checkDii(); + + NVList args = m_request.arguments(); + Parameter[] p = new Parameter[ args.count() ]; + try + { + for (int i = 0; i < p.length; i++) + { + ParameterMode mode; + + switch (args.item(i).flags()) + { + case ARG_IN.value : + mode = ParameterMode.PARAM_IN; + break; + + case ARG_OUT.value : + mode = ParameterMode.PARAM_OUT; + break; + + case ARG_INOUT.value : + mode = ParameterMode.PARAM_INOUT; + break; + + default : + throw new Unexpected(); + } + + p [ i ] = new Parameter(args.item(i).value(), mode); + } + } + catch (Bounds e) + { + throw new Unexpected(e); + } + return p; + } +}
\ No newline at end of file diff --git a/gnu/CORBA/ObjectCreator.java b/gnu/CORBA/ObjectCreator.java index b99c46ba6..81c1d06e7 100644 --- a/gnu/CORBA/ObjectCreator.java +++ b/gnu/CORBA/ObjectCreator.java @@ -1,4 +1,4 @@ -/* ExceptionCreator.java -- +/* ObjectCreator.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,10 +38,15 @@ exception statement from your version. */ package gnu.CORBA; +import gnu.CORBA.CDR.cdrBufOutput; + +import org.omg.CORBA.Any; import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.CompletionStatusHelper; import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.StructMember; import org.omg.CORBA.SystemException; +import org.omg.CORBA.TCKind; import org.omg.CORBA.UNKNOWN; import org.omg.CORBA.UserException; import org.omg.CORBA.portable.InputStream; @@ -51,9 +56,8 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; /** - * Creates java objects from the agreed IDL names for the simple - * case when the CORBA object is directly mapped into the locally - * defined java class. + * Creates java objects from the agreed IDL names for the simple case when the + * CORBA object is directly mapped into the locally defined java class. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ @@ -70,20 +74,17 @@ public class ObjectCreator public static final String JAVA_PREFIX = "org.omg."; /** - * The prefix for classes that are placed instide the - * gnu.CORBA namespace. + * The prefix for classes that are placed instide the gnu.CORBA namespace. */ public static final String CLASSPATH_PREFIX = "gnu.CORBA."; /** - * Try to instantiate an object with the given IDL name. - * The object must be mapped to the local java class. - * The omg.org domain must be mapped into the object in either - * org/omg or gnu/CORBA namespace. + * Try to instantiate an object with the given IDL name. The object must be + * mapped to the local java class. The omg.org domain must be mapped into the + * object in either org/omg or gnu/CORBA namespace. * * @param IDL name - * @return instantiated object instance or null if no such - * available. + * @return instantiated object instance or null if no such available. */ public static java.lang.Object createObject(String idl, String suffix) { @@ -109,16 +110,15 @@ public class ObjectCreator /** * Create the system exception with the given idl name. * - * @param idl the exception IDL name, must match the syntax - * "IDL:<class/name>:1.0". + * @param idl the exception IDL name, must match the syntax "IDL:<class/name>:1.0". * @param minor the exception minor code. * @param completed the exception completion status. * * @return the created exception. */ public static SystemException createSystemException(String idl, int minor, - CompletionStatus completed - ) + CompletionStatus completed + ) { try { @@ -127,20 +127,18 @@ public class ObjectCreator Constructor constructor = exClass.getConstructor(new Class[] - { - String.class, int.class, - CompletionStatus.class - } - ); + { + String.class, int.class, CompletionStatus.class + } + ); Object exception = constructor.newInstance(new Object[] - { - " Remote exception " + idl + ", minor " + - minor + ", " + completed + ".", - new Integer(minor), completed - } - ); + { + " Remote exception " + idl + ", minor " + minor + ", " + + completed + ".", new Integer(minor), completed + } + ); return (SystemException) exception; } @@ -153,9 +151,10 @@ public class ObjectCreator /** * Read the system exception from the given stream. + * * @param input the CDR stream to read from. - * @return the exception that has been stored in the stream - * (IDL name, minor code and completion status). + * @return the exception that has been stored in the stream (IDL name, minor + * code and completion status). */ public static SystemException readSystemException(InputStream input) { @@ -170,8 +169,8 @@ public class ObjectCreator } /** - * Reads the user exception, having the given Id, from the - * input stream. The id is expected to be in the form like + * Reads the user exception, having the given Id, from the input stream. The + * id is expected to be in the form like * 'IDL:test/org/omg/CORBA/ORB/communication/ourUserException:1.0' * * @param idl the exception idl name. @@ -189,11 +188,8 @@ public class ObjectCreator Method read = helperClass.getMethod("read", - new Class[] - { - org.omg.CORBA.portable.InputStream.class - } - ); + new Class[] { org.omg.CORBA.portable.InputStream.class } + ); return (UserException) read.invoke(null, new Object[] { input }); } @@ -236,8 +232,8 @@ public class ObjectCreator * @param ex an exception to write. */ public static void writeSystemException(OutputStream output, - SystemException ex - ) + SystemException ex + ) { String exIDL = toIDL(ex.getClass().getName()); output.write_string(exIDL); @@ -266,14 +262,14 @@ public class ObjectCreator } /** - * Converts the given IDL name to class name and tries to load the - * matching class. The OMG prefix (omg.org) is replaced by - * the java prefix org.omg. No other prefixes are added. + * Converts the given IDL name to class name and tries to load the matching + * class. The OMG prefix (omg.org) is replaced by the java prefix org.omg. No + * other prefixes are added. * * @param IDL the idl name. * - * TODO Cache the returned classes, avoiding these string manipulations - * each time the conversion is required. + * TODO Cache the returned classes, avoiding these string manipulations each + * time the conversion is required. * * @return the matching class or null if no such is available. */ @@ -301,10 +297,10 @@ public class ObjectCreator } /** - * Converts the given IDL name to class name, tries to load the - * matching class and create an object instance with parameterless - * constructor. The OMG prefix (omg.org) is replaced by - * the java prefix org.omg. No other prefixes are added. + * Converts the given IDL name to class name, tries to load the matching class + * and create an object instance with parameterless constructor. The OMG + * prefix (omg.org) is replaced by the java prefix org.omg. No other prefixes + * are added. * * @param IDL the idl name. * @@ -341,8 +337,111 @@ public class ObjectCreator cn = OMG_PREFIX + cn.substring(JAVA_PREFIX.length()).replace('.', '/'); else if (cn.startsWith(CLASSPATH_PREFIX)) cn = - OMG_PREFIX + cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/'); + OMG_PREFIX + + cn.substring(CLASSPATH_PREFIX.length()).replace('.', '/'); return "IDL:" + cn + ":1.0"; } + + /** + * Insert the passed parameter into the given Any, assuming that the helper + * class is available. The helper class must have the "Helper" suffix and be + * in the same package as the class of the object being inserted. + * + * @param into the target to insert. + * + * @param object the object to insert. It can be any object as far as the + * corresponding helper is provided. + * + * @return true on success, false otherwise. + */ + public static boolean insertWithHelper(Any into, Object object) + { + try + { + String helperClassName = object.getClass().getName() + "Helper"; + Class helperClass = Class.forName(helperClassName); + + Method insert = + helperClass.getMethod("insert", + new Class[] { Any.class, object.getClass() } + ); + + insert.invoke(null, new Object[] { into, object }); + + return true; + } + catch (Exception exc) + { + // Failed due some reason. + return false; + } + } + + /** + * Insert the system exception into the given Any. + */ + public static boolean insertSysException(Any into, SystemException exception) + { + try + { + cdrBufOutput output = new cdrBufOutput(); + + String m_exception_id = toIDL(exception.getClass().getName()); + output.write_string(m_exception_id); + output.write_ulong(exception.minor); + CompletionStatusHelper.write(output, exception.completed); + + String name = getDefaultName(m_exception_id); + + universalHolder h = new universalHolder(output); + + into.insert_Streamable(h); + + recordTypeCode r = new recordTypeCode(TCKind.tk_except); + r.setId(m_exception_id); + r.setName(name); + into.type(r); + + return true; + } + catch (Exception ex) + { + ex.printStackTrace(); + return false; + } + } + + /** + * Get the type name from the IDL string. + */ + public static String getDefaultName(String idl) + { + int f1 = idl.lastIndexOf("/"); + int p1 = (f1 < 0) ? 0 : f1; + int p2 = idl.indexOf(":", p1); + if (p2 < 0) + p2 = idl.length(); + + String name = idl.substring(f1 + 1, p2); + return name; + } + + /** + * Insert this exception into the given Any. On failure, insert the UNKNOWN + * exception. + */ + public static void insertException(Any into, Throwable exception) + { + boolean ok = false; + if (exception instanceof SystemException) + ok = insertSysException(into, (SystemException) exception); + else if (exception instanceof UserException) + ok = insertWithHelper(into, exception); + + if (!ok) + ok = insertSysException(into, new UNKNOWN()); + if (!ok) + throw new InternalError("Exception wrapping broken"); + } }
\ No newline at end of file diff --git a/gnu/CORBA/Poa/LocalDelegate.java b/gnu/CORBA/Poa/LocalDelegate.java index 950e6e2ff..7af3369d2 100644 --- a/gnu/CORBA/Poa/LocalDelegate.java +++ b/gnu/CORBA/Poa/LocalDelegate.java @@ -59,21 +59,19 @@ import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.InvokeHandler; import org.omg.CORBA.portable.ObjectImpl; import org.omg.CORBA.portable.OutputStream; -import org.omg.CORBA_2_3.portable.Delegate; +import org.omg.CORBA.portable.RemarshalException; import org.omg.PortableServer.ServantLocatorPackage.CookieHolder; 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. + * 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 { /** * The same servant as an invocation handler. @@ -84,8 +82,8 @@ public class LocalDelegate final byte[] Id; /** - * Create a local delegate, forwarding requests to the - * servant that must also be an invocation handler. + * Create a local delegate, forwarding requests to the servant that must also + * be an invocation handler. */ public LocalDelegate(gnuServantObject an_object, gnuPOA a_poa, byte[] an_id) { @@ -109,8 +107,8 @@ public class LocalDelegate } public boolean is_equivalent(org.omg.CORBA.Object target, - org.omg.CORBA.Object other - ) + org.omg.CORBA.Object other + ) { if (target == other) return true; @@ -159,10 +157,10 @@ public class LocalDelegate /** * 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. + * @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) { @@ -187,10 +185,9 @@ public class LocalDelegate * Create request for using with DII. */ public Request create_request(org.omg.CORBA.Object target, Context context, - String method, NVList parameters, - NamedValue returns, ExceptionList exceptions, - ContextList ctx_list - ) + String method, NVList parameters, NamedValue returns, + ExceptionList exceptions, ContextList ctx_list + ) { operation = method; @@ -207,9 +204,8 @@ public class LocalDelegate * 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; @@ -237,10 +233,11 @@ public class LocalDelegate * * @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 - ) + public org.omg.CORBA.portable.OutputStream request( + org.omg.CORBA.Object target, + String method, + boolean response_expected + ) { operation = method; @@ -285,74 +282,97 @@ public class LocalDelegate * Make an invocation. * * @param target not in use. - * @param output the stream request that should be returned by {@link #request} - * in this method. - * @throws ApplicationException if the use exception is thrown by - * the servant method. + * @param output the stream request that should be returned by + * {@link #m_request} in this method. + * @throws ApplicationException if the use exception is thrown by the servant + * method. */ public InputStream invoke(org.omg.CORBA.Object target, OutputStream output) - throws ApplicationException + throws ApplicationException { - streamRequest sr = (streamRequest) output; - - LocalRequest lr = (LocalRequest) sr.request; - InvokeHandler handler = lr.object.getHandler(lr.operation(), lr.cookie, false); - - if (handler instanceof dynImpHandler) + try { - // The local request known how to handle it, but the different - // method must be called. - lr.invoke(); + streamRequest sr = (streamRequest) output; - // The encapsulation will inherit orb, endian, charsets, etc. - cdrOutput buf = sr.createEncapsulation(); + LocalRequest lr = (LocalRequest) sr.request; + InvokeHandler handler = + lr.object.getHandler(lr.operation(), lr.cookie, false); - // Write all request parameters to the buffer stream. - if (lr.env().exception() != null) + if (handler instanceof dynImpHandler) { + // 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(); + + // Write all request parameters to the buffer stream. + if (lr.env().exception() != null) + { + try + { + UnknownUserException uex = + (UnknownUserException) lr.env().exception(); + throw new ApplicationException(uex.except.type().id(), + uex.except.create_input_stream() + ); + } + catch (BadKind ex) + { + InternalError ierr = new InternalError(); + ierr.initCause(ex); + throw ierr; + } + } + if (lr.return_value() != null) + lr.return_value().write_value(buf); + + NamedValue a; try { - UnknownUserException uex = - (UnknownUserException) lr.env().exception(); - throw new ApplicationException(uex.except.type().id(), - uex.except.create_input_stream() - ); + 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 + ) + { + a.value().write_value(buf); + } + } } - catch (BadKind ex) + catch (Bounds ex) { InternalError ierr = new InternalError(); ierr.initCause(ex); throw ierr; } - } - if (lr.return_value() != null) - lr.return_value().write_value(buf); - NamedValue a; + return buf.create_input_stream(); + } + else + { + LocalRequest lrq = (LocalRequest) sr.request; + return lrq.s_invoke(handler); + } + } + catch (gnuForwardRequest f) + { try { - 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 - ) - { - a.value().write_value(buf); - } - } + return ((ObjectImpl) f.forward_reference)._invoke(f.forward_reference._request( + operation, + true + ) + ); } - catch (Bounds ex) + catch (RemarshalException e) { - InternalError ierr = new InternalError(); - ierr.initCause(ex); - throw ierr; + // Never thrown in this place by Classpath implementation. + throw new NO_IMPLEMENT(); } - - return buf.create_input_stream(); } - else - return ((LocalRequest) sr.request).s_invoke(handler); } public void releaseReply(org.omg.CORBA.Object target, InputStream input) diff --git a/gnu/CORBA/Poa/LocalRequest.java b/gnu/CORBA/Poa/LocalRequest.java index 3c2816d70..a727499fc 100644 --- a/gnu/CORBA/Poa/LocalRequest.java +++ b/gnu/CORBA/Poa/LocalRequest.java @@ -40,23 +40,38 @@ package gnu.CORBA.Poa; import gnu.CORBA.CDR.cdrBufOutput; 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.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 org.omg.CORBA.ARG_OUT; +import org.omg.CORBA.Any; import org.omg.CORBA.BAD_INV_ORDER; import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.Bounds; import org.omg.CORBA.NamedValue; import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.TCKind; import org.omg.CORBA.UnknownUserException; +import org.omg.CORBA.UserException; import org.omg.CORBA.portable.ApplicationException; +import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.InvokeHandler; +import org.omg.CORBA.portable.ObjectImpl; import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.ResponseHandler; +import org.omg.PortableInterceptor.ClientRequestInterceptorOperations; +import org.omg.PortableInterceptor.ForwardRequest; +import org.omg.PortableInterceptor.ServerRequestInterceptorOperations; import org.omg.PortableServer.CurrentOperations; import org.omg.PortableServer.CurrentPackage.NoContext; import org.omg.PortableServer.DynamicImplementation; @@ -68,15 +83,13 @@ import org.omg.PortableServer.portable.Delegate; import java.io.IOException; /** - * Directs the invocation to the locally available servant. - * The POA servant does not longer implement the CORBA object and - * cannot be substituted directly. + * Directs the invocation to the locally available servant. The POA servant does + * not longer implement the CORBA object and cannot be substituted directly. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class LocalRequest - extends gnuRequest - implements ResponseHandler, CurrentOperations +public class LocalRequest extends gnuRequest implements ResponseHandler, + CurrentOperations { /** * Used by servant locator, if involved. @@ -94,7 +107,7 @@ public class LocalRequest private static final MessageHeader header = new MessageHeader(); /** - * True if the stream was obtained by invoking {@link #createExceptionReply()}, + * True if the stream was obtained by invoking {@link #createExceptionReply()}, * false otherwise. */ boolean exceptionReply; @@ -129,17 +142,19 @@ public class LocalRequest // Instantiate the cookie holder only if required. if (poa.servant_locator != null) - cookie = new CookieHolder(); + { + cookie = new CookieHolder(); + } object = local_object; prepareStream(); } /** - * Make an invocation and return a stream from where the results - * can be read and throw ApplicationException, where applicable. + * Make an invocation and return a stream from where the results can be read + * and throw ApplicationException, where applicable. */ org.omg.CORBA.portable.InputStream s_invoke(InvokeHandler handler) - throws ApplicationException + throws ApplicationException { try { @@ -148,7 +163,9 @@ public class LocalRequest org.omg.CORBA.portable.InputStream input = v_invoke(handler); if (!exceptionReply) - return input; + { + return input; + } else { input.mark(500); @@ -174,100 +191,341 @@ public class LocalRequest } /** - * Make an invocation and return a stream from where the results - * can be read. + * Make an invocation and return a stream from where the results can be read. * * @param the invoke handler (can be null, then it is obtained self * dependently). */ public org.omg.CORBA.portable.InputStream v_invoke(InvokeHandler handler) { - if (handler == null) - handler = object.getHandler(operation(), cookie, false); - - cdrBufOutput request_part = new cdrBufOutput(); + // Local request must be intercepted both by server and request + // interceptors. + boolean s_intercept = false; + ServerRequestInterceptorOperations s_interceptor = null; + gnuServerRequestInfo s_info = null; - request_part.setOrb(orb()); + boolean c_intercept = false; + ClientRequestInterceptorOperations c_interceptor = null; + gnuClientRequestInfo c_info = null; - if (m_args != null && m_args.count() > 0) + try { - write_parameters(header, request_part); + if (poa.m_orb.iServer != null || poa.m_orb.iClient != null) + { + setORB(poa.m_orb); + + // These two are only needed with interceptors. + m_rqh = new RequestHeader(); + m_rqh.operation = m_operation; + m_rph = new ReplyHeader(); + + m_rqh.object_key = object.Id; + m_rph.request_id = m_rqh.request_id; + } + + if (poa.m_orb.iClient != null) + { + c_interceptor = poa.m_orb.iClient; + + c_info = new gnuClientRequestInfo(this); + c_intercept = true; + + c_interceptor.send_request(c_info); + + m_target = object; + } + + if (poa.m_orb.iServer != null) + { + s_interceptor = poa.m_orb.iServer; + + s_info = new gnuServerRequestInfo(object, m_rqh, m_rph); + s_info.m_request = this; + + s_intercept = true; + + s_interceptor.receive_request_service_contexts(s_info); + } + + if (handler == null) + { + handler = object.getHandler(operation(), cookie, false); + } + + cdrBufOutput request_part = new cdrBufOutput(); + + request_part.setOrb(orb()); + + if (m_args != null && m_args.count() > 0) + { + write_parameters(header, request_part); + + if (m_parameter_buffer != null) + { + throw new BAD_INV_ORDER("Please either add parameters or " + + "write them into stream, but not both " + "at once." + ); + } + } if (m_parameter_buffer != null) - throw new BAD_INV_ORDER("Please either add parameters or " + - "write them into stream, but not both " + - "at once." - ); - } + { + write_parameter_buffer(header, request_part); + } - if (m_parameter_buffer != null) - { - write_parameter_buffer(header, request_part); - } + Servant servant; + + if (handler instanceof Servant) + { + servant = (Servant) handler; + } + else + { + throw new BAD_OPERATION("Unexpected handler type " + handler); + } - Servant servant; + org.omg.CORBA.portable.InputStream input = + request_part.create_input_stream(); - if (handler instanceof Servant) - servant = (Servant) handler; - else - throw new BAD_OPERATION("Unexpected handler type " + handler); + // Ensure the servant (handler) has a delegate set. + servantDelegate sd = null; + + Delegate d = null; - org.omg.CORBA.portable.InputStream input = - request_part.create_input_stream(); + try + { + d = servant._get_delegate(); + } + catch (Exception ex) + { + // In some cases exception is thrown if the delegate is not set. + } + if (d instanceof servantDelegate) + { + // If the delegate is already set, try to reuse the existing + // instance. + sd = (servantDelegate) d; + if (sd.object != object) + { + sd = new servantDelegate(servant, poa, Id); + } + } + else + { + sd = new servantDelegate(servant, poa, Id); + } + servant._set_delegate(sd); - // Ensure the servant (handler) has a delegate set. - servantDelegate sd = null; + try + { + ORB o = orb(); + if (o instanceof ORB_1_4) + { + ((ORB_1_4) o).currents.put(Thread.currentThread(), this); + } - Delegate d = null; + try + { + if (s_intercept) + { + s_interceptor.receive_request(s_info); + } + handler._invoke(m_operation, input, this); + + // Handler is casted into i_handler. + if ((s_intercept || c_intercept) && isExceptionReply()) + { + s_info.m_reply_header.reply_status = + ReplyHeader.USER_EXCEPTION; + m_rph.reply_status = ReplyHeader.USER_EXCEPTION; + + // Make Any, holding the user exception. + Any a = new gnuAny(); + OutputStream buf = getBuffer(); + InputStream in = buf.create_input_stream(); + String uex_idl = "unknown"; + try + { + in.mark(Integer.MAX_VALUE); + uex_idl = in.read_string(); + m_exception_id = uex_idl; + in.reset(); + } + catch (IOException e) + { + throw new Unexpected(e); + } + + try + { + UserException exception = + ObjectCreator.readUserException(uex_idl, in); + + m_environment.exception(exception); + ObjectCreator.insertWithHelper(a, exception); + } + catch (Exception e) + { + // Failed due any reason, insert without + // helper. + a.insert_Streamable(new streamReadyHolder( + buf.create_input_stream() + ) + ); + + recordTypeCode r = + new recordTypeCode(TCKind.tk_except); + r.setId(uex_idl); + r.setName(ObjectCreator.getDefaultName(uex_idl)); + } + + s_info.m_usr_exception = a; + c_info.m_wrapped_exception = a; + s_interceptor.send_exception(s_info); + c_interceptor.receive_exception(c_info); + } + else + { + if (s_intercept) + { + s_info.m_reply_header.reply_status = + ReplyHeader.NO_EXCEPTION; + s_interceptor.send_reply(s_info); + } + if (c_intercept) + { + m_rph.reply_status = ReplyHeader.NO_EXCEPTION; + c_interceptor.receive_reply(c_info); + } + } + } + catch (SystemException sys_ex) + { + if (s_intercept) + { + s_info.m_reply_header.reply_status = + ReplyHeader.SYSTEM_EXCEPTION; + s_info.m_sys_exception = sys_ex; + s_interceptor.send_exception(s_info); + } + + if (c_intercept) + { + m_rph.reply_status = ReplyHeader.SYSTEM_EXCEPTION; + + Any a = new gnuAny(); + if (ObjectCreator.insertSysException(a, sys_ex)) + { + c_info.m_wrapped_exception = a; + } + c_interceptor.receive_exception(c_info); + } + + throw sys_ex; + } + } + finally + { + ORB o = orb(); + if (o instanceof ORB_1_4) + { + ((ORB_1_4) o).currents.remove(Thread.currentThread()); + } + } - try - { - d = servant._get_delegate(); - } - catch (Exception ex) - { - // In some cases exception is thrown if the delegate is not set. - } - if (d instanceof servantDelegate) - { - // If the delegate is already set, try to reuse the existing - // instance. - sd = (servantDelegate) d; - if (sd.object != object) - sd = new servantDelegate(servant, poa, Id); + if (poa.servant_locator != null) + { + poa.servant_locator.postinvoke(object.Id, poa, operation(), + cookie.value, object.getServant() + ); + } + return buffer.create_input_stream(); } - else - sd = new servantDelegate(servant, poa, Id); - servant._set_delegate(sd); - try + catch (ForwardRequest fex) { - ORB o = orb(); - if (o instanceof ORB_1_4) + // May be thrown by interceptor. + if (s_intercept) { - ((ORB_1_4) o).currents.put(Thread.currentThread(), this); + Forwarding: + while (true) + { + s_info.m_reply_header.reply_status = + ReplyHeader.LOCATION_FORWARD; + s_info.m_forward_reference = fex.forward; + try + { + s_interceptor.send_other(s_info); + break Forwarding; + } + catch (ForwardRequest fex2) + { + s_info.m_forward_reference = fex2.forward; + fex.forward = s_info.m_forward_reference; + } + } } - handler._invoke(m_operation, input, this); + if (c_intercept) + { + this.m_rph.reply_status = ReplyHeader.LOCATION_FORWARD; + this.m_forwarding_target = fex.forward; + try + { + c_interceptor.receive_other(c_info); + } + catch (ForwardRequest fex2) + { + fex.forward = fex2.forward; + } + } + throw new gnuForwardRequest(fex.forward); } - finally + catch (gnuForwardRequest fex) { - ORB o = orb(); - if (o instanceof ORB_1_4) - ((ORB_1_4) o).currents.remove(Thread.currentThread()); - } - - if (poa.servant_locator != null) - poa.servant_locator.postinvoke(object.Id, poa, operation(), cookie.value, - object.getServant() - ); + // May be thrown during activation. + // May be thrown during activation. + if (s_intercept) + { + Forwarding: + while (true) + { + s_info.m_reply_header.reply_status = + ReplyHeader.LOCATION_FORWARD; + s_info.m_forward_reference = fex.forward_reference; + try + { + s_interceptor.send_other(s_info); + break Forwarding; + } + catch (ForwardRequest fex2) + { + s_info.m_forward_reference = fex2.forward; + fex.forward_reference = (ObjectImpl) fex2.forward; + } + } + } - return buffer.create_input_stream(); + if (c_intercept) + { + this.m_rph.reply_status = ReplyHeader.LOCATION_FORWARD; + this.m_forwarding_target = fex.forward_reference; + try + { + c_interceptor.receive_other(c_info); + } + catch (ForwardRequest fex2) + { + fex.forward_reference = (ObjectImpl) fex2.forward; + } + } + throw fex; + } } /** - * Make an invocation and store the result in the fields of this - * Request. Used with DII only. + * Make an invocation and store the result in the fields of this Request. Used + * with DII only. */ public void invoke() { @@ -277,7 +535,9 @@ public class LocalRequest { DynamicImplementation dyn = ((dynImpHandler) handler).servant; if (serverRequest == null) - serverRequest = new LocalServerRequest(this); + { + serverRequest = new LocalServerRequest(this); + } try { poa.m_orb.currents.put(Thread.currentThread(), this); @@ -304,25 +564,27 @@ public class LocalRequest // Read returned parameters, if set. if (m_args != null) - for (int i = 0; i < m_args.count(); i++) - { - try - { - arg = m_args.item(i); - - // Both ARG_INOUT and ARG_OUT have this binary flag set. - if ((arg.flags() & ARG_OUT.value) != 0) - { - arg.value().read_value(input, arg.value().type()); - } - } - catch (Bounds ex) - { - Unexpected.error(ex); - } - } + { + for (int i = 0; i < m_args.count(); i++) + { + try + { + arg = m_args.item(i); + + // Both ARG_INOUT and ARG_OUT have this binary flag set. + if ((arg.flags() & ARG_OUT.value) != 0) + { + arg.value().read_value(input, arg.value().type()); + } + } + catch (Bounds ex) + { + Unexpected.error(ex); + } + } + } } - else // User exception reply + else// User exception reply { // Prepare an Any that will hold the exception. gnuAny exc = new gnuAny(); @@ -336,10 +598,9 @@ public class LocalRequest } /** - * Get an output stream for providing details about the exception. - * Before returning the stream, the handler automatically writes - * the message header and the reply about exception header, - * but not the message header. + * Get an output stream for providing details about the exception. Before + * returning the stream, the handler automatically writes the message header + * and the reply about exception header, but not the message header. * * @return the stream to write exception details into. */ @@ -353,8 +614,8 @@ public class LocalRequest /** * Get an output stream for writing a regular reply (not an exception). * - * Before returning the stream, the handler automatically writes - * the regular reply header, but not the message header. + * Before returning the stream, the handler automatically writes the regular + * reply header, but not the message header. * * @return the output stream for writing a regular reply. */ @@ -366,12 +627,12 @@ public class LocalRequest } /** - * Get the buffer, normally containing the written reply. - * The reply includes the reply header (or the exception header) - * but does not include the message header. + * Get the buffer, normally containing the written reply. The reply includes + * the reply header (or the exception header) but does not include the message + * header. * - * The stream buffer can also be empty if no data have been written - * into streams, returned by {@link #createReply()} or + * The stream buffer can also be empty if no data have been written into + * streams, returned by {@link #createReply()} or * {@link #createExceptionReply()}. * * @return the CDR output stream, containing the written output. @@ -382,9 +643,8 @@ public class LocalRequest } /** - * True if the stream was obtained by invoking - * {@link #createExceptionReply()}, false otherwise - * (usually no-exception reply). + * True if the stream was obtained by invoking {@link #createExceptionReply()}, + * false otherwise (usually no-exception reply). */ boolean isExceptionReply() { @@ -401,8 +661,8 @@ public class LocalRequest } /** - * Get the parameter stream, where the invocation arguments should - * be written if they are written into the stream directly. + * Get the parameter stream, where the invocation arguments should be written + * if they are written into the stream directly. */ public streamRequest getParameterStream() { @@ -412,14 +672,12 @@ public class LocalRequest return m_parameter_buffer; } - public byte[] get_object_id() - throws NoContext + public byte[] get_object_id() throws NoContext { return Id; } - public POA get_POA() - throws NoContext + public POA get_POA() throws NoContext { return poa; } diff --git a/gnu/CORBA/Poa/ORB_1_4.java b/gnu/CORBA/Poa/ORB_1_4.java index 00ca3bf76..d95bf2be8 100644 --- a/gnu/CORBA/Poa/ORB_1_4.java +++ b/gnu/CORBA/Poa/ORB_1_4.java @@ -1,4 +1,4 @@ -/* poaORB.java -- +/* ORB_1_4.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,13 +39,30 @@ exception statement from your version. */ package gnu.CORBA.Poa; import gnu.CORBA.Functional_ORB; +import gnu.CORBA.IOR; +import gnu.CORBA.Connected_objects.cObject; import gnu.CORBA.DynAn.gnuDynAnyFactory; +import gnu.CORBA.Interceptor.ClientRequestInterceptors; +import gnu.CORBA.Interceptor.IORInterceptors; +import gnu.CORBA.Interceptor.Registrator; +import gnu.CORBA.Interceptor.ServerRequestInterceptors; +import gnu.CORBA.Interceptor.gnuIcCurrent; +import gnu.CORBA.Interceptor.gnuIorInfo; +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.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.POAPackage.InvalidPolicy; +import java.applet.Applet; +import java.util.Properties; + /** * The ORB, supporting POAs that are the feature of jdk 1.4. * @@ -60,10 +77,15 @@ public class ORB_1_4 public final gnuPOA rootPOA; /** - * Maps the active threads to the invocation data ("Current's"). + * Maps the active threads to the invocation data ("POA Current's"). */ public gnuPoaCurrent currents = new gnuPoaCurrent(); - + + /** + * Maps the active threads to the interceptor data ("Interceptor Current's"). + */ + public gnuIcCurrent ic_current = new gnuIcCurrent(this); + /** * Creates dynamic anys. */ @@ -91,11 +113,12 @@ public class ORB_1_4 initial_references.put("RootPOAManager", rootPOA.the_POAManager()); initial_references.put("POACurrent", currents); initial_references.put("DynAnyFactory", factory); + initial_references.put("PICurrent", ic_current); } /** - * If the super method detects that the object is not connected to - * this ORB, try to find and activate the object. + * If the super method detects that the object is not connected to this ORB, + * try to find and activate the object. */ public String object_to_string(org.omg.CORBA.Object forObject) { @@ -110,14 +133,12 @@ public class ORB_1_4 activeObjectMap.Obj exists = rootPOA.findObject(forObject); if (exists == null) throw new OBJECT_NOT_EXIST(forObject == null ? "null" - : forObject.toString() - ); + : forObject.toString()); else if (exists.poa instanceof gnuPOA) ((gnuPOA) exists.poa).connect_to_orb(exists.key, forObject); else exists.poa.create_reference_with_id(exists.key, - ((ObjectImpl) exists.object)._ids() [ 0 ] - ); + ((ObjectImpl) exists.object)._ids()[0]); } catch (Exception bex) { @@ -140,4 +161,96 @@ public class ORB_1_4 super.destroy(); } + + /** + * Do interceptor registration. + * + * @param properties the properties, between those names the agreed prefix + * "org.omg.PortableInterceptor.ORBInitializerClass." is searched. + * + * @param args the string array, passed to the ORB.init + */ + protected void registerInterceptors(Properties properties, String[] args) + { + Registrator registrator = new Registrator(this, properties, args); + + policyFactories = registrator.m_policyFactories; + + registrator.pre_init(); + initial_references.putAll(registrator.getRegisteredReferences()); + registrator.post_init(); + + if (registrator.hasIorInterceptors()) + iIor = new IORInterceptors(registrator); + + if (registrator.hasServerRequestInterceptors()) + iServer = new ServerRequestInterceptors(registrator); + + if (registrator.hasClientRequestInterceptors()) + iClient = new ClientRequestInterceptors(registrator); + + policyFactories = registrator.m_policyFactories; + } + + /** + * Create IOR and allow registered interceptors to add additional components. + */ + protected IOR createIOR(cObject ref) + throws BAD_OPERATION + { + IOR ior = super.createIOR(ref); + if (iIor != null) + { + activeObjectMap.Obj obj = rootPOA.findIorKey(ior.key); + + POA poa; + + // Null means that the object was connected to the ORB directly. + if (obj == null) + poa = rootPOA; + else + poa = obj.poa; + + gnuIorInfo info = new gnuIorInfo(this, poa, ior); + + // This may modify the ior. + iIor.establish_components(info); + } + return ior; + } + + /** + * Create policy using the previously registered factory. + */ + public Policy create_policy(int type, Any value) + throws PolicyError + { + Integer policy = new Integer(type); + + PolicyFactory forge = (PolicyFactory) policyFactories.get(policy); + if (forge == null) + throw new PolicyError("No factory registered for policy " + type, + (short) type); + else + return forge.create_policy(type, value); + } + + /** + * Set the parameters and then register interceptors. + */ + protected void set_parameters(Applet app, Properties props) + { + super.set_parameters(app, props); + registerInterceptors(props, new String[0]); + } + + /** + * Set the parameters and then register interceptors. + */ + protected void set_parameters(String[] para, Properties props) + { + super.set_parameters(para, props); + registerInterceptors(props, para); + } + }
\ No newline at end of file diff --git a/gnu/CORBA/Poa/gnuServantObject.java b/gnu/CORBA/Poa/gnuServantObject.java index f096104f9..1ad98d1ce 100644 --- a/gnu/CORBA/Poa/gnuServantObject.java +++ b/gnu/CORBA/Poa/gnuServantObject.java @@ -38,9 +38,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.Interceptor.gnuServerRequestInfo; +import gnu.CORBA.ObjectCreator; +import gnu.CORBA.Unexpected; +import gnu.CORBA.bufferedResponseHandler; +import gnu.CORBA.recordTypeCode; +import gnu.CORBA.streamReadyHolder; + +import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.CompletionStatus; @@ -48,15 +56,18 @@ import org.omg.CORBA.OBJECT_NOT_EXIST; import org.omg.CORBA.OBJ_ADAPTER; import org.omg.CORBA.ORB; import org.omg.CORBA.SystemException; +import org.omg.CORBA.TCKind; import org.omg.CORBA.TRANSIENT; +import org.omg.CORBA.UserException; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.InvokeHandler; import org.omg.CORBA.portable.ObjectImpl; import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.ResponseHandler; +import org.omg.PortableInterceptor.ForwardRequest; +import org.omg.PortableInterceptor.ServerRequestInterceptorOperations; import org.omg.PortableServer.CurrentOperations; import org.omg.PortableServer.DynamicImplementation; -import org.omg.PortableServer.ForwardRequest; import org.omg.PortableServer.ImplicitActivationPolicyValue; import org.omg.PortableServer.POA; import org.omg.PortableServer.POAManager; @@ -66,23 +77,24 @@ import org.omg.PortableServer.ServantLocatorPackage.CookieHolder; import org.omg.PortableServer.ServantRetentionPolicyValue; import org.omg.PortableServer.portable.Delegate; +import java.io.IOException; + import java.util.Arrays; /** - * Represents a CORBA object, being locally served by the associated - * servant. The calls to the object are forwarded to the calls to the - * servant. + * Represents a CORBA object, being locally served by the associated servant. + * The calls to the object are forwarded to the calls to the servant. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuServantObject - extends ObjectImpl - implements org.omg.CORBA.Object, InvokeHandler, CurrentOperations +public class gnuServantObject extends ObjectImpl + implements org.omg.CORBA.Object, + InvokeHandler, + CurrentOperations { /** - * The associated servant that must also implement the - * {@link InvokeHandler} interface. This value can be temporary - * null if the object was created using + * The associated servant that must also implement the {@link InvokeHandler} + * interface. This value can be temporary null if the object was created using * POA.create_reference or POA.create_reference_with_id, private to force * always to use {@link setServant}. */ @@ -109,23 +121,22 @@ public class gnuServantObject public final ORB_1_4 orb; /** - * The object repository ids, if they were specified separately. - * Normally, the ids are requested from the servant. + * The object repository ids, if they were specified separately. Normally, the + * ids are requested from the servant. */ public final String[] repository_ids; /** - * Create an object with no connected servant. The servant must be - * set later. + * Create an object with no connected servant. The servant must be set later. * - * @param a_repository_ids an array of repository ids, can be null - * (then ids will be requested from the servant). + * @param a_repository_ids an array of repository ids, can be null (then ids + * will be requested from the servant). * @param an_id the object id. * @param a_poa the POA. */ public gnuServantObject(String[] a_repository_ids, byte[] an_id, - gnuPOA a_poa, ORB_1_4 an_orb - ) + gnuPOA a_poa, ORB_1_4 an_orb + ) { repository_ids = a_repository_ids; Id = an_id; @@ -140,20 +151,23 @@ public class gnuServantObject * @param a_servant a servant, serving this object. * @param an_id an Object Id for this object. * - * @throws BAD_PARAM if the passed servant is not an - * {@link InvokeHandler}. + * @throws BAD_PARAM if the passed servant is not an {@link InvokeHandler}. */ public gnuServantObject(Servant a_servant, byte[] an_id, ORB_1_4 an_orb, - gnuPOA a_poa - ) + gnuPOA a_poa + ) { Id = an_id; setServant(a_servant); poa = a_poa; if (poa != null) - manager = poa.the_POAManager(); + { + manager = poa.the_POAManager(); + } else - manager = null; + { + manager = null; + } repository_ids = null; orb = an_orb; } @@ -161,22 +175,23 @@ public class gnuServantObject /** * Set a servant, if it has not been previously set. * - * @param a_servant a servant to set, can be null to indicate - * the necessity for the subsequent activation. + * @param a_servant a servant to set, can be null to indicate the necessity + * for the subsequent activation. * - * @throws BAD_PARAM if the passed servant is not an - * {@link InvokeHandler} or {@link DynamicImplementation} and also - * not null. + * @throws BAD_PARAM if the passed servant is not an {@link InvokeHandler} or + * {@link DynamicImplementation} and also not null. */ public void setServant(Servant a_servant) { - if (a_servant != null && !(a_servant instanceof InvokeHandler) && - !(a_servant instanceof DynamicImplementation) - ) - - throw new BAD_PARAM("Must be either InvokeHandler or " + - "DynamicImplementation, but is " + a_servant - ); + if (a_servant != null && + !(a_servant instanceof InvokeHandler) && + !(a_servant instanceof DynamicImplementation) + ) + { + throw new BAD_PARAM("Must be either InvokeHandler or " + + "DynamicImplementation, but is " + a_servant + ); + } servant = a_servant; } @@ -192,12 +207,13 @@ public class gnuServantObject * Return the associated invocation handler. */ public InvokeHandler getHandler(String operation, CookieHolder cookie, - boolean forwarding_allowed - ) - throws gnuForwardRequest + boolean forwarding_allowed + ) throws gnuForwardRequest { if (servant != null) - return servantToHandler(servant); + { + return servantToHandler(servant); + } else { // Use servant locator to locate the servant. @@ -209,10 +225,12 @@ public class gnuServantObject poa.servant_locator.preinvoke(Id, poa, operation, cookie); return servantToHandler(servant); } - catch (ForwardRequest forw_ex) + catch (org.omg.PortableServer.ForwardRequest forw_ex) { if (forwarding_allowed) - throw new gnuForwardRequest(forw_ex.forward_reference); + { + throw new gnuForwardRequest(forw_ex.forward_reference); + } else { servant = @@ -224,8 +242,8 @@ public class gnuServantObject else // Use servant activator to locate the servant. if (poa.applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION) && - poa.applies(ServantRetentionPolicyValue.RETAIN) - ) + poa.applies(ServantRetentionPolicyValue.RETAIN) + ) { try { @@ -243,8 +261,8 @@ public class gnuServantObject BAD_OPERATION bad = new BAD_OPERATION("Unable to activate", 0x5004, - CompletionStatus.COMPLETED_NO - ); + CompletionStatus.COMPLETED_NO + ); bad.initCause(ex); throw bad; } @@ -257,39 +275,46 @@ public class gnuServantObject // No servant and no servant manager - throw exception. else - throw new BAD_OPERATION("Unable to activate", 0x5002, - CompletionStatus.COMPLETED_NO - ); + { + throw new BAD_OPERATION("Unable to activate", 0x5002, + CompletionStatus.COMPLETED_NO + ); + } } } /** * Convert the servant to invocation handler. */ - public InvokeHandler servantToHandler(Servant servant) + public InvokeHandler servantToHandler(Servant a_servant) { - if (servant instanceof InvokeHandler) - return (InvokeHandler) servant; - else if (servant instanceof DynamicImplementation) - return new dynImpHandler((DynamicImplementation) servant); + if (a_servant instanceof InvokeHandler) + { + return (InvokeHandler) a_servant; + } + else if (a_servant instanceof DynamicImplementation) + { + return new dynImpHandler((DynamicImplementation) a_servant); + } else - throw new BAD_OPERATION(servant + " must be either InvokeHandler or " + - "POA DynamicImplementation" - ); + { + throw new BAD_OPERATION(a_servant + + " must be either InvokeHandler or " + "POA DynamicImplementation" + ); + } } /** - * Create a servant object, associated with the passed servant. - * Requests the object id from the servant. Depending on the - * policies of the servants POA, the calls are eithe not - * synchronized or synchronized on POA or ORB. + * Create a servant object, associated with the passed servant. Requests the + * object id from the servant. Depending on the policies of the servants POA, + * the calls are eithe not synchronized or synchronized on POA or ORB. * * @param a_servant a servant, serving this object. * @param an_id an Object Id for this object. */ - public gnuServantObject(Servant a_servant, gnuPOA poa) + public gnuServantObject(Servant a_servant, gnuPOA a_poa) { - this(a_servant, a_servant._object_id(), (ORB_1_4) a_servant._orb(), poa); + this(a_servant, a_servant._object_id(), (ORB_1_4) a_servant._orb(), a_poa); } /** @@ -298,9 +323,13 @@ public class gnuServantObject public String[] _ids() { if (repository_ids == null) - return getServant()._all_interfaces(poa, Id); + { + return getServant()._all_interfaces(poa, Id); + } else - return repository_ids; + { + return repository_ids; + } } /** @@ -328,10 +357,10 @@ public class gnuServantObject /** * 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. + * @return true if it is one of the possible repository ids of this object. */ public boolean _is_a(String idl_id) { @@ -339,13 +368,16 @@ public class gnuServantObject for (int i = 0; i < maybe.length; i++) { if (maybe [ i ].equals(idl_id)) - return true; + { + return true; + } } return false; } /** * Get an ORB, associated with the servant of this object. + * * @return */ public ORB _orb() @@ -358,139 +390,310 @@ public class gnuServantObject * * @throws TRANSIENT minor 0x535503e9 if the POA is in discarding mode. * @throws OBJ_ADAPTER minor 0x535503ea if the POA is inactivated. - * @throws OBJECT_NOT_EXISTS minor 0x535503ec if this object is - * inactivated. + * @throws OBJECT_NOT_EXISTS minor 0x535503ec if this object is inactivated. * - * @specnote see {@link POAManagerOperations} for specnotes about - * the minor codes. + * @specnote see {@link POAManagerOperations} for specnotes about the minor + * codes. */ public OutputStream _invoke(String method, InputStream input, - ResponseHandler r_handler - ) - throws SystemException + ResponseHandler r_handler + ) throws SystemException { + boolean intercept = false; + ServerRequestInterceptorOperations interceptor = null; + gnuServerRequestInfo info = null; + bufferedResponseHandler i_handler = null; + try { - CookieHolder cookie = null; - activeObjectMap.Obj self = poa.aom.get(Id); - - if (poa.servant_locator != null) + if (orb.iServer != null && + r_handler instanceof bufferedResponseHandler + ) { - // If the servant locator is in use, it is always responsible - // for providing the servant. - self.servant = servant = null; - cookie = new CookieHolder(); + interceptor = orb.iServer; + + i_handler = (bufferedResponseHandler) r_handler; + + info = + new gnuServerRequestInfo(this, i_handler.request_header, + i_handler.reply_header + ); + intercept = true; + + interceptor.receive_request_service_contexts(info); } - else if (self != null && self.isDeactiveted()) + + try { - if (poa.applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION) && - poa.servant_activator != null - ) + CookieHolder cookie = null; + activeObjectMap.Obj self = poa.aom.get(Id); + + if (poa.servant_locator != null) { - // Reset the servant, forcing the subsequent activation. - servant = null; + // If the servant locator is in use, it is always responsible + // for providing the servant. + self.servant = servant = null; + cookie = new CookieHolder(); + } + else if (self != null && self.isDeactiveted()) + { + if (poa.applies( + ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION + ) && + poa.servant_activator != null + ) + { + // Reset the servant, forcing the subsequent activation. + servant = null; + } + else + { + throw new OBJECT_NOT_EXIST("Object deactivated", + 0x535503ec, CompletionStatus.COMPLETED_NO + ); + } } - else - throw new OBJECT_NOT_EXIST("Object deactivated", 0x535503ec, - CompletionStatus.COMPLETED_NO - ); - } - InvokeHandler handler = getHandler(method, cookie, true); + InvokeHandler handler = getHandler(method, cookie, true); - Delegate d = null; + Delegate d = null; - try - { - d = servant._get_delegate(); - orb.currents.put(Thread.currentThread(), this); - } - catch (Exception ex) - { - // In some cases exception is thrown if the delegate is not set. - } - if (d instanceof servantDelegate) - { - // If the delegate is already set, check maybe we can - // reuse the existing instance. - if (((servantDelegate) d).object != this) - servant._set_delegate(new servantDelegate(servant, poa, Id)); - } - else - { - servant._set_delegate(new servantDelegate(servant, poa, Id)); - } + try + { + d = servant._get_delegate(); + orb.currents.put(Thread.currentThread(), this); + } + catch (Exception ex) + { + // In some cases exception is thrown if the delegate is not set. + } + if (d instanceof servantDelegate) + { + // If the delegate is already set, check maybe we can + // reuse the existing instance. + if (((servantDelegate) d).object != this) + { + servant._set_delegate(new servantDelegate(servant, poa, Id)); + } + } + else + { + servant._set_delegate(new servantDelegate(servant, poa, Id)); + } - try - { - switch (manager.get_state().value()) + try { - case State._ACTIVE : - return handler._invoke(method, input, r_handler); - - case State._HOLDING : - - // The holding mode is implemented - // relying on the holding capabilites of the network - // support (if any). - // TODO FIXME in more recent CORBA applications, the client - // ORB can free the connection and wait for a server side - // notification about the completed request. Implement this. - int sleep = 5; - int max = 500; - - // Wait till the state will be switched into some other - // mode. - while (manager.get_state().value() == State._HOLDING) - { + switch (manager.get_state().value()) + { + case State._ACTIVE : + + OutputStream rt; try { - Thread.sleep(sleep); - if (sleep < max) - sleep = max; + if (intercept) + { + interceptor.receive_request(info); + } + + rt = handler._invoke(method, input, r_handler); + + if (intercept) + { + // Handler is casted into i_handler. + if (i_handler.isExceptionReply()) + { + info.m_reply_header.reply_status = + ReplyHeader.USER_EXCEPTION; + + // Make Any, holding the user exception. + Any a = orb.create_any(); + OutputStream buf = i_handler.getBuffer(); + InputStream in = buf.create_input_stream(); + String uex_idl = "unknown"; + try + { + in.mark(Integer.MAX_VALUE); + uex_idl = in.read_string(); + in.reset(); + } + catch (IOException e) + { + throw new Unexpected(e); + } + + try + { + UserException exception = + ObjectCreator.readUserException(uex_idl, + in + ); + + ObjectCreator.insertWithHelper(a, + exception + ); + } + catch (Exception e) + { + // Failed due any reason, insert without + // helper. + a.insert_Streamable(new streamReadyHolder( + buf.create_input_stream() + ) + ); + + recordTypeCode r = + new recordTypeCode(TCKind.tk_except); + r.setId(uex_idl); + r.setName(ObjectCreator.getDefaultName( + uex_idl + ) + ); + } + + info.m_usr_exception = a; + interceptor.send_exception(info); + } + else + { + info.m_reply_header.reply_status = + ReplyHeader.NO_EXCEPTION; + interceptor.send_reply(info); + } + } } - catch (InterruptedException ex) + catch (SystemException sys_ex) + { + if (intercept) + { + info.m_reply_header.reply_status = + ReplyHeader.SYSTEM_EXCEPTION; + info.m_sys_exception = sys_ex; + interceptor.send_exception(info); + } + throw sys_ex; + } + + return rt; + + case State._HOLDING : + + // The holding mode is implemented + // relying on the holding capabilites of the network + // support (if any). + // TODO FIXME in more recent CORBA applications, the + // client + // ORB can free the connection and wait for a server side + // notification about the completed request. Implement + // this + // as soon as JDK specification would allow bidirectional + // policy. + int sleep = 5; + int max = 500; + + // Wait till the state will be switched into some other + // mode. + while (manager.get_state().value() == State._HOLDING) { + try + { + Thread.sleep(sleep); + if (sleep < max) + { + sleep = max; + } + } + catch (InterruptedException ex) + { + } } - } - // Handle another mode. - return _invoke(method, input, r_handler); + // Handle another mode. + return _invoke(method, input, r_handler); - case State._DISCARDING : - throw new TRANSIENT("Discarding mode", 0x535503e9, - CompletionStatus.COMPLETED_NO - ); + case State._DISCARDING : + throw new TRANSIENT("Discarding mode", 0x535503e9, + CompletionStatus.COMPLETED_NO + ); - case State._INACTIVE : - throw new OBJ_ADAPTER("POA deactivated", 0x535503ea, - CompletionStatus.COMPLETED_NO - ); + case State._INACTIVE : + throw new OBJ_ADAPTER("POA deactivated", 0x535503ea, + CompletionStatus.COMPLETED_NO + ); - default : - throw new InternalError(); // No more states. + default : + throw new InternalError(); // No more states. + } + } + finally + { + if (poa.servant_locator != null) + { + poa.servant_locator.postinvoke(Id, poa, method, + cookie.value, servant + ); + servant = null; + } } } finally { - if (poa.servant_locator != null) + orb.currents.remove(Thread.currentThread()); + } + } + catch (ForwardRequest fex) + { + // May be thrown by interceptor. + if (intercept) + { + Forwarding: + while (true) { - poa.servant_locator.postinvoke(Id, poa, method, cookie.value, - servant - ); - servant = null; + info.m_reply_header.reply_status = + ReplyHeader.LOCATION_FORWARD; + info.m_forward_reference = fex.forward; + try + { + interceptor.send_other(info); + break Forwarding; + } + catch (ForwardRequest fex2) + { + info.m_forward_reference = fex2.forward; + fex.forward = info.m_forward_reference; + } } } + throw new gnuForwardRequest(fex.forward); } - finally + catch (gnuForwardRequest fex) { - orb.currents.remove(Thread.currentThread()); + // May be thrown during activation. + if (intercept) + { + Forwarding: + while (true) + { + info.m_reply_header.reply_status = + ReplyHeader.LOCATION_FORWARD; + info.m_forward_reference = fex.forward_reference; + try + { + interceptor.send_other(info); + break Forwarding; + } + catch (ForwardRequest fex2) + { + info.m_forward_reference = fex2.forward; + fex.forward_reference = (ObjectImpl) fex2.forward; + } + } + } + throw fex; } } /** - * Compare with another object for equality, comparing the - * object keys. + * Compare with another object for equality, comparing the object keys. */ public boolean equals(java.lang.Object other) { @@ -501,7 +704,9 @@ public class gnuServantObject return Arrays.equals(o.Id, Id); } else - return false; + { + return false; + } } /** @@ -555,10 +760,9 @@ public class gnuServantObject } /** - * Checks if this object is equivalent to another instance. - * These objects are assumed equal if they are connected to the - * same orb and poa under the same Id, regardless of they - * delegates. + * Checks if this object is equivalent to another instance. These objects are + * assumed equal if they are connected to the same orb and poa under the same + * Id, regardless of they delegates. * * @param another instance to check. * @return @@ -578,9 +782,13 @@ public class gnuServantObject IOR_Delegate ird = (IOR_Delegate) ir._get_delegate(); byte[] ior_id = poa.idFormIor(ird.getIor().key); if (ior_id != null && Arrays.equals(ior_id, Id)) - return true; + { + return true; + } else - return false; + { + return false; + } } catch (Exception ex) { diff --git a/gnu/CORBA/Poa/servantDelegate.java b/gnu/CORBA/Poa/servantDelegate.java index 1825db386..f59c01c6b 100644 --- a/gnu/CORBA/Poa/servantDelegate.java +++ b/gnu/CORBA/Poa/servantDelegate.java @@ -191,9 +191,6 @@ public class servantDelegate } catch (NoContext ex) { - // TODO remove from mature code, this is a debug statement. - // The message should not appear during tests. - System.out.println("Not ok with object id"); return object.Id; } } diff --git a/gnu/CORBA/Restricted_ORB.java b/gnu/CORBA/Restricted_ORB.java index 698c8b11e..247cd205c 100644 --- a/gnu/CORBA/Restricted_ORB.java +++ b/gnu/CORBA/Restricted_ORB.java @@ -58,6 +58,9 @@ import org.omg.CORBA.TypeCodePackage.BadKind; import org.omg.CORBA.UnionMember; import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.ValueFactory; +import org.omg.PortableInterceptor.ClientRequestInterceptorOperations; +import org.omg.PortableInterceptor.IORInterceptorOperations; +import org.omg.PortableInterceptor.ServerRequestInterceptorOperations; import java.applet.Applet; @@ -66,22 +69,20 @@ import java.util.Properties; /** * This class implements so-called Singleton ORB, a highly restricted version - * that cannot communicate over network. This ORB is provided - * for the potentially malicious applets with heavy security restrictions. - * It, however, supports some basic features that might be needed even - * when the network access is not granted. + * that cannot communicate over network. This ORB is provided for the + * potentially malicious applets with heavy security restrictions. It, however, + * supports some basic features that might be needed even when the network + * access is not granted. * - * This ORB can only create typecodes, - * {@link Any}, {@link ContextList}, {@link NVList} and - * {@link org.omg.CORBA.portable.OutputStream} that writes to an - * internal buffer. + * This ORB can only create typecodes, {@link Any}, {@link ContextList}, + * {@link NVList} and {@link org.omg.CORBA.portable.OutputStream} that writes to + * an internal buffer. * * All other methods throw the {@link NO_IMPLEMENT} exception. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ -public class Restricted_ORB - extends org.omg.CORBA_2_3.ORB +public class Restricted_ORB extends org.omg.CORBA_2_3.ORB { /** * The singleton instance of this ORB. @@ -89,13 +90,41 @@ public class Restricted_ORB public static final ORB Singleton = new Restricted_ORB(); /** + * The cumulated listener for all IOR interceptors. Interceptors are used by + * {@link gnu.CORBA.Poa.ORB_1_4}. + */ + public IORInterceptorOperations iIor; + + /** + * The cumulated listener for all server request interceptors. Interceptors + * are used by {@link gnu.CORBA.Poa.ORB_1_4}. + */ + public ServerRequestInterceptorOperations iServer; + + /** + * The cumulated listener for all client request interceptros. Interceptors + * are used by {@link gnu.CORBA.Poa.ORB_1_4}. + */ + public ClientRequestInterceptorOperations iClient; + + /** + * The required size of the interceptor slot array. + */ + public int icSlotSize = 0; + + /** * The value factories. */ protected Hashtable factories = new Hashtable(); /** - * Create a new instance of the RestrictedORB. This is used - * in derived classes only. + * The policy factories. + */ + protected Hashtable policyFactories = new Hashtable(); + + /** + * Create a new instance of the RestrictedORB. This is used in derived classes + * only. */ protected Restricted_ORB() { @@ -159,8 +188,8 @@ public class Restricted_ORB /** {@inheritDoc} */ public TypeCode create_exception_tc(String id, String name, - StructMember[] members - ) + StructMember[] members + ) { recordTypeCode r = new recordTypeCode(TCKind.tk_except); r.setId(id); @@ -224,8 +253,8 @@ public class Restricted_ORB /** {@inheritDoc} */ public TypeCode create_struct_tc(String id, String name, - StructMember[] members - ) + StructMember[] members + ) { recordTypeCode r = new recordTypeCode(TCKind.tk_struct); r.setId(id); @@ -241,9 +270,8 @@ public class Restricted_ORB /** {@inheritDoc} */ public TypeCode create_union_tc(String id, String name, - TypeCode discriminator_type, - UnionMember[] members - ) + TypeCode discriminator_type, UnionMember[] members + ) { recordTypeCode r = new recordTypeCode(TCKind.tk_union); r.setId(id); @@ -277,8 +305,8 @@ public class Restricted_ORB catch (BadKind ex) { throw new BAD_PARAM("This is not a primitive type code: " + - tcKind.value() - ); + tcKind.value() + ); } } @@ -307,13 +335,13 @@ public class Restricted_ORB /** * This method is not allowed for a RestrictedORB. * - * @throws InvalidName never in this class, but it is thrown - * in the derived classes. + * @throws InvalidName never in this class, but it is thrown in the derived + * classes. * * @throws NO_IMPLEMENT, always. */ public org.omg.CORBA.Object resolve_initial_references(String name) - throws InvalidName + throws InvalidName { no(); throw new InternalError(); @@ -369,8 +397,8 @@ public class Restricted_ORB } /** - * Throws an exception, stating that the given method is not supported - * by the Restricted ORB. + * Throws an exception, stating that the given method is not supported by the + * Restricted ORB. */ private final void no() { @@ -384,8 +412,7 @@ public class Restricted_ORB * * @throws NO_IMPLEMENT, always. */ - public Request get_next_response() - throws org.omg.CORBA.WrongTransaction + public Request get_next_response() throws org.omg.CORBA.WrongTransaction { no(); throw new InternalError(); @@ -426,8 +453,8 @@ public class Restricted_ORB * Register the value factory under the given repository id. */ public ValueFactory register_value_factory(String repository_id, - ValueFactory factory - ) + ValueFactory factory + ) { factories.put(repository_id, factory); return factory; @@ -443,9 +470,9 @@ public class Restricted_ORB /** * Look for the value factory for the value, having the given repository id. - * The implementation checks for the registered value factories first. - * If none found, it tries to load and instantiate the class, mathing the - * given naming convention. If this faild, null is returned. + * The implementation checks for the registered value factories first. If none + * found, it tries to load and instantiate the class, mathing the given naming + * convention. If this faild, null is returned. * * @param repository_id a repository id. * @@ -455,14 +482,43 @@ public class Restricted_ORB { ValueFactory f = (ValueFactory) factories.get(repository_id); if (f != null) - return f; + { + return f; + } f = (ValueFactory) ObjectCreator.createObject(repository_id, - "DefaultFactory" - ); + "DefaultFactory" + ); if (f != null) - factories.put(repository_id, f); - + { + factories.put(repository_id, f); + } return f; } + + /** + * Destroy the interceptors, if they are present. + */ + public void destroy() + { + if (iIor != null) + { + iIor.destroy(); + iIor = null; + } + + if (iServer != null) + { + iServer.destroy(); + iServer = null; + } + + if (iClient != null) + { + iClient.destroy(); + iClient = null; + } + + super.destroy(); + } }
\ No newline at end of file diff --git a/gnu/CORBA/bufferedResponseHandler.java b/gnu/CORBA/bufferedResponseHandler.java index e7f00baeb..0fe945ca1 100644 --- a/gnu/CORBA/bufferedResponseHandler.java +++ b/gnu/CORBA/bufferedResponseHandler.java @@ -41,6 +41,7 @@ package gnu.CORBA; import gnu.CORBA.CDR.cdrBufOutput; import gnu.CORBA.GIOP.MessageHeader; import gnu.CORBA.GIOP.ReplyHeader; +import gnu.CORBA.GIOP.RequestHeader; import gnu.CORBA.GIOP.cxCodeSet; import org.omg.CORBA.ORB; @@ -48,31 +49,33 @@ import org.omg.CORBA.portable.OutputStream; import org.omg.CORBA.portable.ResponseHandler; /** - * Provides the CDR output streams for writing the response to the given - * buffer. + * Provides the CDR output streams for writing the response to the given buffer. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ -class bufferedResponseHandler +public class bufferedResponseHandler implements ResponseHandler { /** - * The message header. - * This field is used to compute the size and alignments. + * The message header. This field is used to compute the size and alignments. * It is, however, never directly written to the buffer stream. */ - final MessageHeader message_header; + public final MessageHeader message_header; /** * The associated orb. */ - final ORB orb; + public final ORB orb; /** - * The reply header. This field is used to compute the size and alignments. - * It is, however, never directly written to the buffer stream. + * The reply header. + */ + public final ReplyHeader reply_header; + + /** + * The request header. */ - final ReplyHeader reply_header; + public final RequestHeader request_header; /** * True if the stream was obtained by invoking {@link #createExceptionReply()}, @@ -86,28 +89,27 @@ class bufferedResponseHandler private cdrBufOutput buffer; /** - * Create a new buffered response handler that uses the given message - * headers. The headers are used to compute sizes and check the versions. - * They are not written into a stream inside this class. + * Create a new buffered response handler that uses the given message headers. + * The headers are used to compute sizes and check the versions. They are not + * written into a stream inside this class. * * @param m_header a message header. * @param r_header a reply header. */ bufferedResponseHandler(ORB an_orb, MessageHeader m_header, - ReplyHeader r_header - ) + ReplyHeader r_header, RequestHeader rq_header) { message_header = m_header; reply_header = r_header; + request_header = rq_header; orb = an_orb; prepareStream(); } /** - * Get an output stream for providing details about the exception. - * Before returning the stream, the handler automatically writes - * the message header and the reply about exception header, - * but not the message header. + * Get an output stream for providing details about the exception. Before + * returning the stream, the handler automatically writes the message header + * and the reply about exception header, but not the message header. * * @return the stream to write exception details into. */ @@ -121,8 +123,8 @@ class bufferedResponseHandler /** * Get an output stream for writing a regular reply (not an exception). * - * Before returning the stream, the handler automatically writes - * the regular reply header, but not the message header. + * Before returning the stream, the handler automatically writes the regular + * reply header, but not the message header. * * @return the output stream for writing a regular reply. */ @@ -135,27 +137,26 @@ class bufferedResponseHandler } /** - * Get the buffer, normally containing the written reply. - * The reply includes the reply header (or the exception header) - * but does not include the message header. + * Get the buffer, normally containing the written reply. The reply includes + * the reply header (or the exception header) but does not include the message + * header. * - * The stream buffer can also be empty if no data have been written - * into streams, returned by {@link #createReply()} or + * The stream buffer can also be empty if no data have been written into + * streams, returned by {@link #createReply()} or * {@link #createExceptionReply()}. * * @return the CDR output stream, containing the written output. */ - cdrBufOutput getBuffer() + public cdrBufOutput getBuffer() { return buffer; } /** - * True if the stream was obtained by invoking - * {@link #createExceptionReply()}, false otherwise - * (usually no-exception reply). + * True if the stream was obtained by invoking {@link #createExceptionReply()}, + * false otherwise (usually no-exception reply). */ - boolean isExceptionReply() + public boolean isExceptionReply() { return exceptionReply; } @@ -167,21 +168,22 @@ class bufferedResponseHandler { buffer = new cdrBufOutput(); buffer.setOrb(orb); - buffer.setOffset(message_header.getHeaderSize()); - - // Get the position after the reply header would be written. - reply_header.write(buffer); + buffer.setVersion(message_header.version); + buffer.setCodeSet(cxCodeSet.find(reply_header.service_context)); - int new_offset = message_header.getHeaderSize() + buffer.buffer.size(); + // Since 1.2, the data section is always aligned on the 8 byte boundary. + // In older versions, it is necessary to set the offset correctly. + if (message_header.version.until_inclusive(1, 1)) + { + buffer.setOffset(message_header.getHeaderSize()); - buffer.buffer.reset(); - buffer.setOffset(new_offset); + // Get the position after the reply header would be written. + reply_header.write(buffer); - if (message_header.version.since_inclusive(1, 2)) - buffer.align(8); + int new_offset = message_header.getHeaderSize() + buffer.buffer.size(); - buffer.setVersion(message_header.version); - - buffer.setCodeSet(cxCodeSet.find(reply_header.service_context)); + buffer.buffer.reset(); + buffer.setOffset(new_offset); + } } } diff --git a/gnu/CORBA/gnuCodecFactory.java b/gnu/CORBA/gnuCodecFactory.java index 8b71baf14..067de498c 100644 --- a/gnu/CORBA/gnuCodecFactory.java +++ b/gnu/CORBA/gnuCodecFactory.java @@ -38,12 +38,12 @@ exception statement from your version. */ package gnu.CORBA; -import org.omg.CORBA.*; import org.omg.CORBA.LocalObject; -import org.omg.IOP.*; +import org.omg.CORBA.ORB; import org.omg.IOP.Codec; import org.omg.IOP.CodecFactory; import org.omg.IOP.CodecFactoryPackage.UnknownEncoding; +import org.omg.IOP.ENCODING_CDR_ENCAPS; import org.omg.IOP.Encoding; /** @@ -52,9 +52,7 @@ import org.omg.IOP.Encoding; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class gnuCodecFactory - extends LocalObject - implements CodecFactory +public class gnuCodecFactory extends LocalObject implements CodecFactory { /** * The associated ORB. @@ -78,18 +76,15 @@ public class gnuCodecFactory * * @throws UnknownEncoding if the encoding is not a ENCODING_CDR_ENCAPS. */ - public Codec create_codec(Encoding for_encoding) - throws UnknownEncoding + public Codec create_codec(Encoding for_encoding) throws UnknownEncoding { if (for_encoding.format != ENCODING_CDR_ENCAPS.value) throw new UnknownEncoding("Only ENCODING_CDR_ENCAPS is " + - "supported by this factory." - ); + "supported by this factory." + ); return new cdrEncapsCodec(orb, - new Version(for_encoding.major_version, - for_encoding.minor_version - ) - ); + new Version(for_encoding.major_version, for_encoding.minor_version) + ); } }
\ No newline at end of file diff --git a/gnu/CORBA/gnuRequest.java b/gnu/CORBA/gnuRequest.java index cbff17f69..3784eba6a 100644 --- a/gnu/CORBA/gnuRequest.java +++ b/gnu/CORBA/gnuRequest.java @@ -44,27 +44,43 @@ import gnu.CORBA.GIOP.MessageHeader; import gnu.CORBA.GIOP.ReplyHeader; import gnu.CORBA.GIOP.RequestHeader; import gnu.CORBA.GIOP.cxCodeSet; +import gnu.CORBA.Interceptor.gnuClientRequestInfo; +import gnu.CORBA.Poa.ORB_1_4; import org.omg.CORBA.ARG_IN; import org.omg.CORBA.ARG_INOUT; import org.omg.CORBA.ARG_OUT; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_INV_ORDER; +import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.Bounds; import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.Context; import org.omg.CORBA.ContextList; import org.omg.CORBA.Environment; import org.omg.CORBA.ExceptionList; +import org.omg.CORBA.INV_POLICY; import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.NO_IMPLEMENT; import org.omg.CORBA.NO_RESOURCES; import org.omg.CORBA.NVList; import org.omg.CORBA.NamedValue; import org.omg.CORBA.ORB; +import org.omg.CORBA.Policy; import org.omg.CORBA.Request; import org.omg.CORBA.SystemException; import org.omg.CORBA.TypeCode; import org.omg.CORBA.UnknownUserException; +import org.omg.CORBA.portable.ObjectImpl; +import org.omg.IOP.ServiceContext; +import org.omg.IOP.TAG_CODE_SETS; +import org.omg.IOP.TAG_INTERNET_IOP; +import org.omg.IOP.TaggedComponent; +import org.omg.IOP.TaggedProfile; +import org.omg.PortableInterceptor.ClientRequestInfo; +import org.omg.PortableInterceptor.ClientRequestInterceptorOperations; +import org.omg.PortableInterceptor.ForwardRequest; +import org.omg.PortableInterceptor.InvalidSlot; import java.io.IOException; import java.io.InputStream; @@ -73,14 +89,14 @@ import java.io.OutputStream; import java.net.BindException; import java.net.Socket; +import java.util.ArrayList; + /** * The implementation of the CORBA request. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ -public class gnuRequest - extends Request - implements Cloneable +public class gnuRequest extends Request implements Cloneable { /** * The maximal supported GIOP version. @@ -88,25 +104,34 @@ public class gnuRequest public static Version MAX_SUPPORTED = new Version(1, 2); /** - * The initial pause that the Request makes when - * the required port is not available. + * The initial pause that the Request makes when the required port is not + * available. */ public static int PAUSE_INITIAL = 50; /** - * The number of repretetive attempts to get a required - * port, if it is not immediately available. + * The number of repretetive attempts to get a required port, if it is not + * immediately available. */ public static int PAUSE_STEPS = 12; /** - * The maximal pausing interval between two repetetive attempts. - * The interval doubles after each unsuccessful attempt, but - * will not exceed this value. + * The maximal pausing interval between two repetetive attempts. The interval + * doubles after each unsuccessful attempt, but will not exceed this value. */ public static int PAUSE_MAX = 1000; /** + * The interceptor, listening the major request submission points. + */ + ClientRequestInterceptorOperations m_interceptor; + + /** + * The request info, used by interceptor. + */ + ClientRequestInfo m_info = new gnuClientRequestInfo(this); + + /** * The empty byte array. */ private static final binaryReply EMPTY = @@ -123,14 +148,13 @@ public class gnuRequest protected ContextList m_context_list; /** - * The request environment for holding the exception - * the has possibly been thrown by the method being invoked. + * The request environment for holding the exception the has possibly been + * thrown by the method being invoked. */ protected Environment m_environment = new gnuEnvironment(); /** - * The list of all exceptions that can be thrown by the - * method being invoked. + * The list of all exceptions that can be thrown by the method being invoked. */ protected ExceptionList m_exceptions = new gnuExceptionList(); @@ -140,6 +164,16 @@ public class gnuRequest protected NamedValue m_result = new gnuNamedValue(); /** + * The exception id, received from the server, null if none. + */ + protected String m_exception_id; + + /** + * The thrown system exception. + */ + protected SystemException m_sys_ex; + + /** * The invocation target. */ protected org.omg.CORBA.Object m_target; @@ -150,20 +184,32 @@ public class gnuRequest protected String m_operation; /** - * The flag, indicating that the request has been sent - * and the result is already received. + * This field temporary remembers the value of the forwarded ior reference. If + * it is not null, the request was forwarded and the effective target is not + * the same as the default target. + */ + public IOR m_forward_ior; + + /** + * Is set when object, and not IOR is directly available. + */ + public org.omg.CORBA.Object m_forwarding_target; + + /** + * The flag, indicating that the request has been sent and the result is + * already received. */ protected boolean complete; /** - * The flag, indicating that the response to this request must be - * ignored (used with {@link #send_oneway()}). + * The flag, indicating that the response to this request must be ignored + * (used with {@link #send_oneway()}). */ protected boolean oneWay; /** - * The flag, indicating that the request has been sent - * and no result is yet received. + * The flag, indicating that the request has been sent and no result is yet + * received. */ protected boolean running; @@ -173,12 +219,27 @@ public class gnuRequest protected gnuNVList m_args = new gnuNVList(); /** - * The request arguments in the case when they are directly written into - * the parameter buffer. + * The request arguments in the case when they are directly written into the + * parameter buffer. */ protected streamRequest m_parameter_buffer; /** + * The array of slots. + */ + protected Any[] m_slots; + + /** + * The request header currently in use. + */ + protected RequestHeader m_rqh; + + /** + * The reply header currently in use. + */ + protected ReplyHeader m_rph; + + /** * The IOR of the target. */ private IOR ior; @@ -191,17 +252,16 @@ public class gnuRequest /** * The encoding, used to send the message. * - * The default encoding is inherited from the set IOR - * (that string reference can be encoded in either Big or - * Little endian). If the IOR encoding is not known - * (for example, by obtaining the reference from the naming - * service), the Big Endian is used. + * The default encoding is inherited from the set IOR (that string reference + * can be encoded in either Big or Little endian). If the IOR encoding is not + * known (for example, by obtaining the reference from the naming service), + * the Big Endian is used. */ private boolean Big_endian = true; /** - * Set the IOR data, sufficient to find the invocation target. - * This also sets default endian encoding for invocations. + * Set the IOR data, sufficient to find the invocation target. This also sets + * default endian encoding for invocations. * * @see IOR.parse(String) */ @@ -232,18 +292,26 @@ public class gnuRequest public void setORB(ORB an_orb) { orb = an_orb; + + // Take the interceptor from the ORB. + if (orb instanceof Restricted_ORB) + m_interceptor = ((Restricted_ORB) orb).iClient; + + if (m_interceptor != null && orb instanceof ORB_1_4) + { + m_slots = ((ORB_1_4) orb).ic_current.clone_slots(); + } } /** - * Set the encoding that will be used to send the message. - * The default encoding is inherited from the set IOR - * (that string reference can be encoded in either Big or - * Little endian). If the IOR encoding is not known - * (for example, by obtaining the reference from the naming - * service), the Big Endian is used. + * Set the encoding that will be used to send the message. The default + * encoding is inherited from the set IOR (that string reference can be + * encoded in either Big or Little endian). If the IOR encoding is not known + * (for example, by obtaining the reference from the naming service), the Big + * Endian is used. * - * @param use_big_endian true to use the Big Endian, false - * to use the Little Endian encoding. + * @param use_big_endian true to use the Big Endian, false to use the Little + * Endian encoding. */ public void setBigEndian(boolean use_big_endian) { @@ -261,15 +329,15 @@ public class gnuRequest } /** - * Get the parameter stream, where the invocation arguments should - * be written if they are written into the stream directly. + * Get the parameter stream, where the invocation arguments should be written + * if they are written into the stream directly. */ public streamRequest getParameterStream() { m_parameter_buffer = new streamRequest(); m_parameter_buffer.request = this; m_parameter_buffer.setVersion(ior.Internet.version); - m_parameter_buffer.setCodeSet(cxCodeSet.negotiate(ior.CodeSets)); + m_parameter_buffer.setCodeSet(cxCodeSet.negotiate(ior.Internet.CodeSets)); m_parameter_buffer.setOrb(orb); m_parameter_buffer.setBigEndian(Big_endian); return m_parameter_buffer; @@ -384,33 +452,29 @@ public class gnuRequest } /** {@inheritDoc} */ - public void get_response() - throws org.omg.CORBA.WrongTransaction + public void get_response() throws org.omg.CORBA.WrongTransaction { /** - * The response is ready after it is received. - * FIXME implement context checks and any other functionality, - * if required. + * The response is ready after it is received. FIXME implement context + * checks and any other functionality, if required. */ } /** - * Submit the request, suspending the current thread until the - * answer is received. + * Submit the request, suspending the current thread until the answer is + * received. * - * This implementation requires to set the IOR property - * ({@link #setIOR(IOR)} before calling this method. + * This implementation requires to set the IOR property ({@link #setIOR(IOR)} + * before calling this method. * - * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been - * previously set. + * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been previously + * set. * - * @throws SystemException if this exception has been thrown on - * remote side. The exact exception type and the minor code are - * the same as they have been for the exception, thrown on remoted - * side. + * @throws SystemException if this exception has been thrown on remote side. + * The exact exception type and the minor code are the same as they have been + * for the exception, thrown on remoted side. */ - public synchronized void invoke() - throws BAD_INV_ORDER + public synchronized void invoke() throws BAD_INV_ORDER { waitWhileBusy(); complete = false; @@ -421,7 +485,32 @@ public class gnuRequest try { - p_invoke(); + Forwardings: + while (true) + { + try + { + p_invoke(); + break Forwardings; + } + catch (ForwardRequest e) + { + try + { + ObjectImpl impl = (ObjectImpl) e.forward; + Simple_delegate delegate = + (Simple_delegate) impl._get_delegate(); + ior = delegate.getIor(); + } + catch (Exception ex) + { + BAD_PARAM bad = + new BAD_PARAM("Unsupported forwarding target"); + bad.initCause(ex); + throw bad; + } + } + } } finally { @@ -456,7 +545,8 @@ public class gnuRequest return m_result; } - /** {@inheritDoc} + /** + * {@inheritDoc} * */ public Any return_value() @@ -478,9 +568,8 @@ public class gnuRequest } /** - * Send a request and forget about it, not waiting for a response. - * This can be done also for methods that normally are expected - * to return some values. + * Send a request and forget about it, not waiting for a response. This can be + * done also for methods that normally are expected to return some values. * * TODO It is generally recommended to reuse the threads. Reuse? */ @@ -499,9 +588,8 @@ public class gnuRequest } /** - * Set the argument list. - * This field is initialised as empty non null instance by default, - * so the method is only used in cases when the direct replacement + * Set the argument list. This field is initialised as empty non null instance + * by default, so the method is only used in cases when the direct replacement * is desired. * * @param a_args the argument list. @@ -529,8 +617,8 @@ public class gnuRequest } /** - * Set the context list that is later returned by the - * method {@link #contexts()}. + * Set the context list that is later returned by the method + * {@link #contexts()}. * * @param a_context_list a new context list. */ @@ -540,10 +628,9 @@ public class gnuRequest } /** - * Set the exception container. - * This field is initialised as empty non null instance by default, - * so the method is only used in cases when the direct replacement - * is desired. + * Set the exception container. This field is initialised as empty non null + * instance by default, so the method is only used in cases when the direct + * replacement is desired. * * @param a_environment the new exception container. */ @@ -553,10 +640,9 @@ public class gnuRequest } /** - * Set the list of exceptions. - * This field is initialised as empty non null instance by default, - * so the method is only used in cases when the direct replacement - * is desired. + * Set the list of exceptions. This field is initialised as empty non null + * instance by default, so the method is only used in cases when the direct + * replacement is desired. * * @param a_exceptions a list of exceptions. */ @@ -576,10 +662,9 @@ public class gnuRequest } /** - * Set the named value, returned as result. - * This field is initialised as empty non null instance by default, - * so the method is only used in cases when the direct replacement - * is desired. + * Set the named value, returned as result. This field is initialised as empty + * non null instance by default, so the method is only used in cases when the + * direct replacement is desired. * * @param a_result the result keeper. */ @@ -589,8 +674,8 @@ public class gnuRequest } /** - * Set the type of the named value, returned as a result. - * Instantiates a new instance of the result value. + * Set the type of the named value, returned as a result. Instantiates a new + * instance of the result value. */ public void set_return_type(TypeCode returns) { @@ -612,17 +697,16 @@ public class gnuRequest } /** - * Do the actual invocation. - * This implementation requires to set the IOR property - * ({@link #setIOR(IOR)} before calling this method. + * Do the actual invocation. This implementation requires to set the IOR + * property ({@link #setIOR(IOR)} before calling this method. * - * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been - * previously set or if the direct argument addition is mixed with - * the direct argument writing into the output stream. + * @throws BAD_INV_ORDER, minor code 0, if the IOR has not been previously set + * or if the direct argument addition is mixed with the direct argument + * writing into the output stream. * * @return the server response in binary form. */ - public synchronized binaryReply submit() + public synchronized binaryReply submit() throws ForwardRequest { gnu.CORBA.GIOP.MessageHeader header = new gnu.CORBA.GIOP.MessageHeader(); @@ -633,16 +717,21 @@ public class gnuRequest header.version = useVersion(ior.Internet.version); RequestHeader rh = header.create_request_header(); - - rh.object_key = ior.key; rh.operation = m_operation; + rh.object_key = ior.key; + + // Update interceptor. + m_rqh = rh; + + if (m_interceptor != null) + m_interceptor.send_request(m_info); // Prepare the submission. cdrBufOutput request_part = new cdrBufOutput(); request_part.setOffset(header.getHeaderSize()); request_part.setVersion(header.version); - request_part.setCodeSet(cxCodeSet.negotiate(ior.CodeSets)); + request_part.setCodeSet(cxCodeSet.negotiate(ior.Internet.CodeSets)); request_part.setOrb(orb); request_part.setBigEndian(header.isBigEndian()); @@ -656,9 +745,8 @@ public class gnuRequest if (m_parameter_buffer != null) throw new BAD_INV_ORDER("Please either add parameters or " + - "write them into stream, but not both " + - "at once." - ); + "write them into stream, but not both " + "at once." + ); } if (m_parameter_buffer != null) @@ -714,8 +802,8 @@ public class gnuRequest if (socket == null) throw new NO_RESOURCES(ior.Internet.host + ":" + ior.Internet.port + - " in use" - ); + " in use" + ); socket.setKeepAlive(true); OutputStream socketOutput = socket.getOutputStream(); @@ -749,9 +837,9 @@ public class gnuRequest { MARSHAL m = new MARSHAL("Unable to open a socket at " + ior.Internet.host + ":" + - ior.Internet.port, 10000 + ior.Internet.port, - CompletionStatus.COMPLETED_NO - ); + ior.Internet.port, 10000 + ior.Internet.port, + CompletionStatus.COMPLETED_NO + ); m.initCause(io_ex); throw m; } @@ -781,9 +869,9 @@ public class gnuRequest } /** - * Get the used version. Normally, it is better to respond using the - * same version as it is specified in IOR, but not above the maximal - * supported version. + * Get the used version. Normally, it is better to respond using the same + * version as it is specified in IOR, but not above the maximal supported + * version. */ public Version useVersion(Version desired) { @@ -795,12 +883,11 @@ public class gnuRequest /** * Wait while the response to request, submitted using - * {@link #send_deferred()} or {@link #invoke()} (from other thread) - * is returned. + * {@link #send_deferred()} or {@link #invoke()} (from other thread) is + * returned. * - * FIXME It is possible to rewrite this using - * Object.wait() and Object.notify(), but be sure to prepare the test - * as well. + * FIXME It is possible to rewrite this using Object.wait() and + * Object.notify(), but be sure to prepare the test as well. */ public synchronized void waitWhileBusy() { @@ -824,24 +911,25 @@ public class gnuRequest } /** - * Do actual invocation. This method recursively calls itself if - * the redirection is detected. + * Do actual invocation. This method recursively calls itself if the + * redirection is detected. */ - private void p_invoke() - throws SystemException + private void p_invoke() throws SystemException, ForwardRequest { binaryReply response = submit(); - ReplyHeader rh = response.header.create_reply_header(); + if (m_rph == null) + m_rph = response.header.create_reply_header(); + cdrBufInput input = response.getStream(); input.setOrb(orb); - rh.read(input); + m_rph.read(input); // The stream must be aligned sinve v1.2, but only once. boolean align = response.header.version.since_inclusive(1, 2); - switch (rh.reply_status) + switch (m_rph.reply_status) { case ReplyHeader.NO_EXCEPTION : @@ -884,6 +972,9 @@ public class gnuRequest } } + if (m_interceptor != null) + m_interceptor.receive_reply(m_info); + break; case ReplyHeader.SYSTEM_EXCEPTION : @@ -892,12 +983,15 @@ public class gnuRequest input.align(8); align = false; } + readExceptionId(input); - SystemException exception = ObjectCreator.readSystemException(input); + m_sys_ex = ObjectCreator.readSystemException(input); + m_environment.exception(m_sys_ex); - m_environment.exception(exception); + if (m_interceptor != null) + m_interceptor.receive_exception(m_info); - throw exception; + throw m_sys_ex; case ReplyHeader.USER_EXCEPTION : if (align) @@ -905,15 +999,20 @@ public class gnuRequest input.align(8); align = false; } + readExceptionId(input); // Prepare an Any that will hold the exception. gnuAny exc = new gnuAny(); + exc.setOrb(orb); exc.insert_Streamable(new streamReadyHolder(input)); UnknownUserException unuex = new UnknownUserException(exc); m_environment.exception(unuex); + if (m_interceptor != null) + m_interceptor.receive_exception(m_info); + break; case ReplyHeader.LOCATION_FORWARD_PERM : @@ -929,24 +1028,39 @@ public class gnuRequest catch (IOException ex) { new MARSHAL("Cant read forwarding info", 5103, - CompletionStatus.COMPLETED_NO - ); + CompletionStatus.COMPLETED_NO + ); } setIor(forwarded); + m_forward_ior = forwarded; + + if (m_interceptor != null) + m_interceptor.receive_other(m_info); + // Repeat with the forwarded information. p_invoke(); return; default : - throw new MARSHAL("Unknow reply status", 8100 + rh.reply_status, - CompletionStatus.COMPLETED_NO - ); + throw new MARSHAL("Unknow reply status", 8100 + m_rph.reply_status, + CompletionStatus.COMPLETED_NO + ); } } /** + * Read exception id without changing the stream pointer position. + */ + void readExceptionId(cdrBufInput input) + { + input.mark(2048); + m_exception_id = input.read_string(); + input.reset(); + } + + /** * Write the operation parameters. * * @param header the message header @@ -955,9 +1069,8 @@ public class gnuRequest * @throws MARSHAL if the attempt to write the parameters has failde. */ protected void write_parameter_buffer(MessageHeader header, - cdrBufOutput request_part - ) - throws MARSHAL + cdrBufOutput request_part + ) throws MARSHAL { try { @@ -982,9 +1095,8 @@ public class gnuRequest * @throws MARSHAL if the attempt to write the parameters has failde. */ protected void write_parameters(MessageHeader header, - cdrBufOutput request_part - ) - throws MARSHAL + cdrBufOutput request_part + ) throws MARSHAL { // Align after 1.2, but only once. boolean align = header.version.since_inclusive(1, 2); @@ -997,7 +1109,7 @@ public class gnuRequest { para = m_args.item(i); - //This bit is set both for ARG_IN and ARG_INOUT + // This bit is set both for ARG_IN and ARG_INOUT if ((para.flags() & ARG_IN.value) != 0) { if (align) @@ -1016,4 +1128,272 @@ public class gnuRequest throw ierr; } } + + /* **************Implementation of the request info operations. ***** */ + + /** + * Add context to request. + */ + public void add_request_service_context(ServiceContext service_context, + boolean replace + ) + { + m_rqh.addContext(service_context, replace); + } + + /** + * Get the Internet profile as an effective profile. + */ + public TaggedProfile effective_profile() + { + cdrBufOutput buf = new cdrBufOutput(512); + buf.setOrb(orb); + ior.Internet.write(buf); + + TaggedProfile p = new TaggedProfile(); + p.tag = TAG_INTERNET_IOP.value; + p.profile_data = buf.buffer.toByteArray(); + return p; + } + + /** + * Return either target or forwarded targed. + */ + public org.omg.CORBA.Object effective_target() + { + return new IOR_contructed_object(orb, ior); + } + + /** + * Get effective component with the give id from the Internet profile. + */ + public TaggedComponent get_effective_component(int id) + throws BAD_PARAM + { + if (id == TAG_CODE_SETS.value) + { + // Codesets are encoded separately. + cdrBufOutput buf = new cdrBufOutput(512); + buf.setOrb(orb); + ior.Internet.CodeSets.write(buf); + + TaggedComponent t = new TaggedComponent(); + t.tag = TAG_CODE_SETS.value; + t.component_data = buf.buffer.toByteArray(); + return t; + } + else + { + for (int i = 0; i < ior.Internet.components.size(); i++) + { + TaggedComponent c = + (TaggedComponent) ior.Internet.components.get(i); + if (c.tag == id) + return c; + } + } + throw new BAD_PARAM("No component " + id + " in the Internet profile", 28, + CompletionStatus.COMPLETED_MAYBE + ); + } + + /** + * Get all components with the given id from the internet profile. + */ + public TaggedComponent[] get_effective_components(int id) + throws BAD_PARAM + { + if (id == TAG_CODE_SETS.value) + return new TaggedComponent[] { get_effective_component(TAG_CODE_SETS.value) }; + else + { + ArrayList components = new ArrayList(ior.Internet.components.size()); + for (int i = 0; i < ior.Internet.components.size(); i++) + { + TaggedComponent c = + (TaggedComponent) ior.Internet.components.get(i); + if (c.tag == id) + components.add(c); + } + if (components.size() == 0) + throw new BAD_PARAM("No component " + id + + " in the Internet profile", 28, CompletionStatus.COMPLETED_MAYBE + ); + else + { + TaggedComponent[] t = new TaggedComponent[ components.size() ]; + for (int i = 0; i < t.length; i++) + t [ i ] = (TaggedComponent) components.get(i); + return t; + } + } + } + + /** + * This should be not implemented up till jdk 1.5 inclusive. + */ + public Policy get_request_policy(int type) throws INV_POLICY + { + throw new NO_IMPLEMENT(); + } + + /** @inheritDoc */ + public String received_exception_id() + { + return m_exception_id; + } + + /** @inheritDoc */ + public Any received_exception() + { + if (m_exception_id == null) + return null; + + if (m_sys_ex != null) + { + Any a = orb.create_any(); + ObjectCreator.insertSysException(a, m_sys_ex); + return a; + } + + Exception mex = m_environment.exception(); + + UnknownUserException ex = (UnknownUserException) mex; + if (ex == null) + return null; + else + return ex.except; + } + + /** + * Return the forwarded reference, null if none. + */ + public org.omg.CORBA.Object forward_reference() + { + if (m_forwarding_target != null) + return m_forwarding_target; + + if (m_forward_ior != null) + return new IOR_contructed_object(orb, m_forward_ior); + else + return null; + } + + /** + * Get the slot from the slot array inside this request. + */ + public Any get_slot(int id) throws InvalidSlot + { + try + { + return m_slots [ id ]; + } + catch (Exception e) + { + throw new InvalidSlot("slot id " + id + ":" + e); + } + } + + /** + * Get the reply status. + */ + public short reply_status() + { + if (m_rph == null) + throw new BAD_INV_ORDER("Request not yet sent", 14, + CompletionStatus.COMPLETED_NO + ); + return (short) m_rph.reply_status; + } + + /** + * Get the request id. + */ + public int request_id() + { + return m_rqh.request_id; + } + + /** + * Return true if the response is expected. + */ + public boolean response_expected() + { + return !oneWay; + } + + /** + * Determines how far the request shall progress before control is returned to + * the client. However up till JDK 1.5 inclusive this method always returns + * SYNC_WITH_TRANSPORT. + * + * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always. + * + * @specnote as defined in the Suns 1.5 JDK API. + */ + public short sync_scope() + { + return org.omg.Messaging.SYNC_WITH_TRANSPORT.value; + } + + /** @inheritDoc */ + public ServiceContext get_request_service_context(int ctx_name) + throws BAD_PARAM + { + return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name, + m_rqh.service_context + ); + } + + /** @inheritDoc */ + public ServiceContext get_reply_service_context(int ctx_name) + throws BAD_PARAM + { + if (m_rph == null) + throw new BAD_INV_ORDER("Reply context not yet available"); + return gnu.CORBA.GIOP.ServiceContext.findContext(ctx_name, + m_rph.service_context + ); + } + + /** @inheritDoc */ + public String[] operation_context() + { + return ice_contexts(); + } + + /** + * Get contexts as required by interceptor. + */ + public String[] ice_contexts() + { + if (m_context_list == null) + return new String[ 0 ]; + else + { + try + { + String[] cn = new String[ m_context_list.count() ]; + for (int i = 0; i < cn.length; i++) + cn [ i ] = m_context_list.item(i); + return cn; + } + catch (Bounds e) + { + throw new Unexpected(e); + } + } + } + + /** + * Check if the call is done via DII. + */ + public void checkDii() + { + if (m_parameter_buffer != null) + throw new NO_RESOURCES("The invocation method provides " + + "no access to this resource. DII call required.", 1, + CompletionStatus.COMPLETED_MAYBE + ); + } }
\ No newline at end of file diff --git a/gnu/CORBA/primitiveArrayTypeCode.java b/gnu/CORBA/primitiveArrayTypeCode.java index 7e2beebc9..fc020bed7 100644 --- a/gnu/CORBA/primitiveArrayTypeCode.java +++ b/gnu/CORBA/primitiveArrayTypeCode.java @@ -1,39 +1,39 @@ /* primitiveArrayTypeCode.java -- - Copyright (C) 2005 Free Software Foundation, Inc. - - This file is part of GNU Classpath. - - GNU Classpath is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GNU Classpath is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Classpath; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. - - Linking this library statically or dynamically with other modules is - making a combined work based on this library. Thus, the terms and - conditions of the GNU General Public License cover the whole - combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent - modules, and to copy and distribute the resulting executable under - terms of your choice, provided that you also meet, for each linked - independent module, the terms and conditions of the license of that - module. An independent module is a module which is not derived from - or based on this library. If you modify this library, you may extend - this exception to your version of the library, but you are not - obligated to do so. If you do not wish to do so, delete this - exception statement from your version. */ + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ package gnu.CORBA; @@ -61,10 +61,10 @@ public class primitiveArrayTypeCode private int length; /** - * Create a primitive array type code, defining the sequence - * {@link TCKind.tk_sequence)} with + * Create a primitive array type code, defining the sequence + * {@link TCKind.tk_sequence)} with * the given member type. - * + * * @param array_of the sequence member type. */ public primitiveArrayTypeCode(TCKind array_of) @@ -76,7 +76,7 @@ public class primitiveArrayTypeCode /** * Create a primitive array type code, defining the array, sequence * or other type with the given member type. - * + * * @param this_type the type of this type (normally either * sequence of array). * @param array_of the sequence member type. diff --git a/gnu/CORBA/primitiveTypeCode.java b/gnu/CORBA/primitiveTypeCode.java index 1fa5cd09f..4bf97d023 100644 --- a/gnu/CORBA/primitiveTypeCode.java +++ b/gnu/CORBA/primitiveTypeCode.java @@ -1,40 +1,41 @@ /* primitiveTypeCode.java -- Copyright (C) 2005 Free Software Foundation, Inc. - This file is part of GNU Classpath. - - GNU Classpath is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - GNU Classpath is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Classpath; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. - - Linking this library statically or dynamically with other modules is - making a combined work based on this library. Thus, the terms and - conditions of the GNU General Public License cover the whole - combination. - - As a special exception, the copyright holders of this library give you - permission to link this library with independent modules to produce an - executable, regardless of the license terms of these independent - modules, and to copy and distribute the resulting executable under - terms of your choice, provided that you also meet, for each linked - independent module, the terms and conditions of the license of that - module. An independent module is a module which is not derived from - or based on this library. If you modify this library, you may extend - this exception to your version of the library, but you are not - obligated to do so. If you do not wish to do so, delete this - exception statement from your version. */ - + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. */ package gnu.CORBA; diff --git a/org/omg/CORBA/DynAnyPackage/Invalid.java b/org/omg/CORBA/DynAnyPackage/Invalid.java index 68c718638..dc66bea65 100644 --- a/org/omg/CORBA/DynAnyPackage/Invalid.java +++ b/org/omg/CORBA/DynAnyPackage/Invalid.java @@ -1,39 +1,40 @@ /* Invalid.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 org.omg.CORBA.DynAnyPackage; diff --git a/org/omg/CORBA/DynAnyPackage/InvalidSeq.java b/org/omg/CORBA/DynAnyPackage/InvalidSeq.java index ca1332939..ef0179e9d 100644 --- a/org/omg/CORBA/DynAnyPackage/InvalidSeq.java +++ b/org/omg/CORBA/DynAnyPackage/InvalidSeq.java @@ -1,39 +1,39 @@ /* InvalidSeq.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 org.omg.CORBA.DynAnyPackage; diff --git a/org/omg/CORBA/DynAnyPackage/InvalidValue.java b/org/omg/CORBA/DynAnyPackage/InvalidValue.java index bca6808c8..0c5ddf96d 100644 --- a/org/omg/CORBA/DynAnyPackage/InvalidValue.java +++ b/org/omg/CORBA/DynAnyPackage/InvalidValue.java @@ -1,39 +1,39 @@ /* InvalidValue.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 org.omg.CORBA.DynAnyPackage; diff --git a/org/omg/CORBA/DynAnyPackage/TypeMismatch.java b/org/omg/CORBA/DynAnyPackage/TypeMismatch.java index 0de38edeb..f4e9877c5 100644 --- a/org/omg/CORBA/DynAnyPackage/TypeMismatch.java +++ b/org/omg/CORBA/DynAnyPackage/TypeMismatch.java @@ -1,39 +1,39 @@ /* TypeMismatch.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 org.omg.CORBA.DynAnyPackage; diff --git a/org/omg/CORBA/ORB.java b/org/omg/CORBA/ORB.java index 772642e93..5761b9505 100644 --- a/org/omg/CORBA/ORB.java +++ b/org/omg/CORBA/ORB.java @@ -479,16 +479,26 @@ public abstract class ORB } /** - * This should create the new policy with the specified type and initial - * state. The policies and methods for getting them are not implemented till - * v1.4 inclusive. - * + * <p>Creates the new policy of the specified type, having the given value. + * This method looks for the policy factory that was previously registered + * during ORB initialization by + * {@link org.omg.PortableInterceptor.ORBInitialiser}. + * + * If the suitable factory is found, this factory creates the requested policy, + * otherwise the PolicyError is thrown. + * </p><p> + * The POA policies should be created by POA, not by this method. + * </p> * @param type the policy type. - * @param value the policy value. + * @param value the policy value, wrapped into Any. * - * @return never + * @throws PolicyError if the ORB fails to instantiate the policy object. * - * @throws NO_IMPLEMENT, always. + * @throws NO_IMPLEMENT always (in this class). Overridden in derived classes + * returned by ORB.init(..). + * + * @see org.omg.PortableInterceptor.ORBInitInfoOperations#register_policy_factory + * @see org.omg.PortableInterceptor.PolicyFactoryOperations */ public Policy create_policy(int type, Any value) throws PolicyError @@ -885,6 +895,12 @@ public abstract class ORB * <td>Creates DynAny's.</td> * </tr> * + * <tr><td>PICurrent</td><td>{@link org.omg.PortableInterceptor.Current}</td> + * Contains multiple slots where an interceptor can rememeber the + * request - specific values between subsequent + * calls of the interceptor methods.</td> + * </tr> + * * </table> * * @param name the object name. diff --git a/org/omg/CORBA/ServiceDetailHelper.java b/org/omg/CORBA/ServiceDetailHelper.java index 37b4f8351..fe0135d97 100644 --- a/org/omg/CORBA/ServiceDetailHelper.java +++ b/org/omg/CORBA/ServiceDetailHelper.java @@ -38,9 +38,10 @@ exception statement from your version. */ package org.omg.CORBA; +import gnu.CORBA.ServiceDetailHolder; + import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; -import gnu.CORBA.*; /** * The helper operations on the Service Detail. @@ -140,8 +141,8 @@ public abstract class ServiceDetailHelper TypeCode type = orb.create_alias_tc(_id, "ServiceDetailType", - orb.get_primitive_tc(TCKind.tk_ulong) - ); + orb.get_primitive_tc(TCKind.tk_ulong) + ); members [ 0 ] = new StructMember("service_detail_type", type, null); TypeCode data = @@ -166,7 +167,7 @@ public abstract class ServiceDetailHelper ostream.write_ulong(value.service_detail_type); ostream.write_long(value.service_detail.length); ostream.write_octet_array(value.service_detail, 0, - value.service_detail.length - ); + value.service_detail.length + ); } -} +}
\ No newline at end of file diff --git a/org/omg/CORBA/package.html b/org/omg/CORBA/package.html index 5885c65ca..3815b19b0 100644 --- a/org/omg/CORBA/package.html +++ b/org/omg/CORBA/package.html @@ -42,12 +42,31 @@ exception statement from your version. --> <body> This package provides the support of <a href="http://www.CORBA.org">CORBA</a>; see <a href="#overview">overview</a> of the implemented functionality. +<p> CORBA a system that applications use to work over networks. CORBA messages are binary, not text oriented. They practically cary no "data wrapping" information like XML <opening> </closing> tags. Hence CORBA -objects much easier exchange large amounts of binary data. CORBA can work +objects easier exchange large amounts of binary data. CORBA can work in such data-intensive application areas as telecommunications or radio -broadcasting. +broadcasting. Java programs connect to CORBA objects without care +about what platform they run on, where they exist in the network, or what +language they were written in. The remote CORBA objects appear to the +programmer as the ordinary Java objects and can be passed as +parameters in both remote or local method invocations. +</p><p> +The CORBA processing unit is divided into {@link org.omg.CORBA.Object} +that is exposed to the client and the servant +({@link org.omg.PortableServer.Servant} where the method, invoked on +object, is finally delegated. It can be multiple objects per servant or +multiple servants per object. The servant for particular object or +even particular call can be dynamically chosen at run time using +{@link org.omg.PortableServer.ServantManager}. +</p><p> +All stages of both local and remote invocations on CORBA objects can be +monitored and modified using {@link org.omg.PortableInterceptor.Interceptor}. +The interceptors can add an extra data to the CORBA message (these data +can be later accessed by other interceptor on remote side). +</p> <a name="overview"> <h4>Overview of the currently implemented CORBA functionality</h4> The CORBA implementation in the Classpath project is now a working @@ -89,6 +108,9 @@ see the {@link org.omg.PortableServer} package.</li> <li>We provide the implementation of the {@link org.omg.DynamicAny} package. ORB returns the working DynAnyFactory that produces working DynAny's as defined in OMG specification.</li> +<li>The Portable Interceptor is also complete. See +{@link org.omg.PortableInterceptor} package for details how to register +and use CORBA interceptors. <li>All GNU Classpath classes in omg.org namespace are newly written using the OMG .pdf document (Version 3.0.3, formal/04-03-12). </li> diff --git a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java index 06a5ced90..f110926b8 100644 --- a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java +++ b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java @@ -93,7 +93,7 @@ public abstract class NameDynAnyPairSeqHelper * Extract the NameDynAnyPairSeq from given Any. * This method uses the NameDynAnyPairSeqHolder. * - * @throws BAD_OPERATION if the passed Any does not contain NameDynAnyPairSeq. + * @throws BAD_OPERATION if the passed Any does not contain NameDynAnyPairSeq. */ public static NameDynAnyPair[] extract(Any any) { diff --git a/org/omg/DynamicAny/_DynAnyFactoryStub.java b/org/omg/DynamicAny/_DynAnyFactoryStub.java index 7554a52ca..b0f6d6052 100644 --- a/org/omg/DynamicAny/_DynAnyFactoryStub.java +++ b/org/omg/DynamicAny/_DynAnyFactoryStub.java @@ -1,33 +1,39 @@ /* _DynAnyFactoryStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynAnyStub.java b/org/omg/DynamicAny/_DynAnyStub.java index 90faf440e..af8d4e5ed 100644 --- a/org/omg/DynamicAny/_DynAnyStub.java +++ b/org/omg/DynamicAny/_DynAnyStub.java @@ -1,33 +1,39 @@ /* _DynAnyStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynArrayStub.java b/org/omg/DynamicAny/_DynArrayStub.java index eda532943..4484f1655 100644 --- a/org/omg/DynamicAny/_DynArrayStub.java +++ b/org/omg/DynamicAny/_DynArrayStub.java @@ -1,33 +1,39 @@ /* _DynArrayStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynEnumStub.java b/org/omg/DynamicAny/_DynEnumStub.java index 297ef3935..ea7879be1 100644 --- a/org/omg/DynamicAny/_DynEnumStub.java +++ b/org/omg/DynamicAny/_DynEnumStub.java @@ -1,33 +1,39 @@ /* _DynEnumStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynFixedStub.java b/org/omg/DynamicAny/_DynFixedStub.java index cbfcf607f..8e2747e4f 100644 --- a/org/omg/DynamicAny/_DynFixedStub.java +++ b/org/omg/DynamicAny/_DynFixedStub.java @@ -1,33 +1,39 @@ /* _DynFixedStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynSequenceStub.java b/org/omg/DynamicAny/_DynSequenceStub.java index 9e6e4a962..5f1f038ba 100644 --- a/org/omg/DynamicAny/_DynSequenceStub.java +++ b/org/omg/DynamicAny/_DynSequenceStub.java @@ -1,33 +1,39 @@ /* _DynSequenceStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynStructStub.java b/org/omg/DynamicAny/_DynStructStub.java index b0c608b30..0b8231b36 100644 --- a/org/omg/DynamicAny/_DynStructStub.java +++ b/org/omg/DynamicAny/_DynStructStub.java @@ -1,33 +1,39 @@ /* _DynStructStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynUnionStub.java b/org/omg/DynamicAny/_DynUnionStub.java index e128c271d..7f8eba778 100644 --- a/org/omg/DynamicAny/_DynUnionStub.java +++ b/org/omg/DynamicAny/_DynUnionStub.java @@ -1,33 +1,39 @@ /* _DynUnionStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/DynamicAny/_DynValueStub.java b/org/omg/DynamicAny/_DynValueStub.java index efe11c9de..5319a7b63 100644 --- a/org/omg/DynamicAny/_DynValueStub.java +++ b/org/omg/DynamicAny/_DynValueStub.java @@ -1,33 +1,39 @@ /* _DynValueStub.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. */ + +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 org.omg.DynamicAny; diff --git a/org/omg/IOP/ServiceContext.java b/org/omg/IOP/ServiceContext.java index 0dcd7781e..e011a4e9e 100644 --- a/org/omg/IOP/ServiceContext.java +++ b/org/omg/IOP/ServiceContext.java @@ -55,7 +55,7 @@ import java.io.Serializable; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class ServiceContext +public final class ServiceContext implements IDLEntity, Serializable { /** diff --git a/org/omg/IOP/TaggedComponentHelper.java b/org/omg/IOP/TaggedComponentHelper.java index f43216542..906d6390a 100644 --- a/org/omg/IOP/TaggedComponentHelper.java +++ b/org/omg/IOP/TaggedComponentHelper.java @@ -40,6 +40,7 @@ package org.omg.IOP; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.MARSHAL; import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TCKind; @@ -47,11 +48,13 @@ import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; +import java.io.IOException; + /** -* A helper operations for the {@link TaggedComponent}. -* -* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) -*/ + * A helper operations for the {@link TaggedComponent}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ public abstract class TaggedComponentHelper { /** @@ -60,49 +63,46 @@ public abstract class TaggedComponentHelper private static TypeCode typeCode; /** - * Create the TaggedComponent typecode (structure, - * named "TaggedComponent"). - * The typecode states that the structure contains the - * following fields: tag, component_data. + * Create the TaggedComponent typecode (structure, named "TaggedComponent"). + * The typecode states that the structure contains the following fields: tag, + * component_data. */ public static TypeCode type() { if (typeCode == null) { ORB orb = ORB.init(); - StructMember[] members = new StructMember[ 2 ]; + StructMember[] members = new StructMember[2]; TypeCode field; - field = - orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0", "ComponentId", - orb.get_primitive_tc(TCKind.tk_ulong) - ); - members [ 0 ] = new StructMember("tag", field, null); + field = orb.create_alias_tc("IDL:omg.org/IOP/ComponentId:1.0", + "ComponentId", + orb.get_primitive_tc(TCKind.tk_ulong)); + members[0] = new StructMember("tag", field, null); - field = - orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet)); - members [ 1 ] = new StructMember("component_data", field, null); + field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet)); + members[1] = new StructMember("component_data", field, null); typeCode = orb.create_struct_tc(id(), "TaggedComponent", members); } return typeCode; } /** - * Insert the TaggedComponent into the given Any. - * This method uses the TaggedComponentHolder. - * - * @param any the Any to insert into. - * @param that the TaggedComponent to insert. - */ + * Insert the TaggedComponent into the given Any. This method uses the + * TaggedComponentHolder. + * + * @param any the Any to insert into. + * @param that the TaggedComponent to insert. + */ public static void insert(Any any, TaggedComponent that) { any.insert_Streamable(new TaggedComponentHolder(that)); } /** - * Extract the TaggedComponent from given Any. - * This method uses the TaggedComponentHolder. + * Extract the TaggedComponent from given Any. This method uses the + * TaggedComponentHolder. * * @throws BAD_OPERATION if the passed Any does not contain TaggedComponent. */ @@ -132,9 +132,8 @@ public abstract class TaggedComponentHelper /** * Read the structure from the CDR intput stream. Expects the integer - * identifier of the tag, then the size of the tag data - * and then the specified number of bytes, representing the data - * of the tag. + * identifier of the tag, then the size of the tag data and then the specified + * number of bytes, representing the data of the tag. * * @param input a org.omg.CORBA.portable stream to read from. */ @@ -142,17 +141,24 @@ public abstract class TaggedComponentHelper { TaggedComponent value = new TaggedComponent(); value.tag = input.read_long(); - value.component_data = new byte[ input.read_long() ]; - for (int i0 = 0; i0 < value.component_data.length; i0++) - value.component_data [ i0 ] = input.read_octet(); + value.component_data = new byte[input.read_long()]; + try + { + input.read(value.component_data); + } + catch (IOException e) + { + MARSHAL m = new MARSHAL(); + m.initCause(e); + throw m; + } return value; } /** - * Write the structure to the CDR output stream. - * Writes the integer identifier of the tag, then the size of the tag data - * and then the specified number of bytes, representing the data - * of the tag. + * Write the structure to the CDR output stream. Writes the integer identifier + * of the tag, then the size of the tag data and then the specified number of + * bytes, representing the data of the tag. * * @param output a org.omg.CORBA.portable stream stream to write into. * @param value a value to write. @@ -161,7 +167,16 @@ public abstract class TaggedComponentHelper { output.write_long(value.tag); output.write_long(value.component_data.length); - for (int i0 = 0; i0 < value.component_data.length; i0++) - output.write_octet(value.component_data [ i0 ]); + + try + { + output.write(value.component_data); + } + catch (IOException e) + { + MARSHAL m = new MARSHAL(); + m.initCause(e); + throw m; + } } }
\ No newline at end of file diff --git a/org/omg/IOP/TaggedProfileHelper.java b/org/omg/IOP/TaggedProfileHelper.java index 0433e10cf..a23122eb9 100644 --- a/org/omg/IOP/TaggedProfileHelper.java +++ b/org/omg/IOP/TaggedProfileHelper.java @@ -38,8 +38,12 @@ exception statement from your version. */ package org.omg.IOP; +import gnu.CORBA.CDR.cdrBufInput; +import gnu.CORBA.CDR.cdrBufOutput; + import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.MARSHAL; import org.omg.CORBA.ORB; import org.omg.CORBA.StructMember; import org.omg.CORBA.TCKind; @@ -47,11 +51,13 @@ import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; +import java.io.IOException; + /** -* A helper operations for the structure {@link TaggedProfile}. -* -* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) -*/ + * A helper operations for the structure {@link TaggedProfile}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ public abstract class TaggedProfileHelper { /** @@ -60,49 +66,46 @@ public abstract class TaggedProfileHelper private static TypeCode typeCode; /** - * Create the TaggedProfile typecode (structure, - * named "TaggedProfile"). - * The typecode states that the structure contains the - * following fields: tag, profile_data. + * Create the TaggedProfile typecode (structure, named "TaggedProfile"). The + * typecode states that the structure contains the following fields: tag, + * profile_data. */ public static TypeCode type() { if (typeCode == null) { ORB orb = ORB.init(); - StructMember[] members = new StructMember[ 2 ]; + StructMember[] members = new StructMember[2]; TypeCode field; - field = - orb.create_alias_tc("IDL:omg.org/IOP/ProfileId:1.0", "ProfileId", - orb.get_primitive_tc(TCKind.tk_ulong) - ); - members [ 0 ] = new StructMember("tag", field, null); + field = orb.create_alias_tc("IDL:omg.org/IOP/ProfileId:1.0", + "ProfileId", + orb.get_primitive_tc(TCKind.tk_ulong)); + members[0] = new StructMember("tag", field, null); - field = - orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet)); - members [ 1 ] = new StructMember("profile_data", field, null); + field = orb.create_sequence_tc(0, orb.get_primitive_tc(TCKind.tk_octet)); + members[1] = new StructMember("profile_data", field, null); typeCode = orb.create_struct_tc(id(), "TaggedProfile", members); } return typeCode; } /** - * Insert the TaggedProfile into the given Any. - * This method uses the TaggedProfileHolder. - * - * @param any the Any to insert into. - * @param that the TaggedProfile to insert. - */ + * Insert the TaggedProfile into the given Any. This method uses the + * TaggedProfileHolder. + * + * @param any the Any to insert into. + * @param that the TaggedProfile to insert. + */ public static void insert(Any any, TaggedProfile that) { any.insert_Streamable(new TaggedProfileHolder(that)); } /** - * Extract the TaggedProfile from given Any. - * This method uses the TaggedProfileHolder. + * Extract the TaggedProfile from given Any. This method uses the + * TaggedProfileHolder. * * @throws BAD_OPERATION if the passed Any does not contain TaggedProfile. */ @@ -139,9 +142,18 @@ public abstract class TaggedProfileHelper { TaggedProfile value = new TaggedProfile(); value.tag = input.read_long(); - value.profile_data = new byte[ input.read_long() ]; - for (int i0 = 0; i0 < value.profile_data.length; i0++) - value.profile_data [ i0 ] = input.read_octet(); + + if (input instanceof cdrBufInput) + { + // Highly probable. + value.profile_data = ((cdrBufInput) input).read_sequence(); + } + else + { + value.profile_data = new byte[input.read_long()]; + for (int i0 = 0; i0 < value.profile_data.length; i0++) + value.profile_data[i0] = input.read_octet(); + } return value; } @@ -154,8 +166,27 @@ public abstract class TaggedProfileHelper public static void write(OutputStream output, TaggedProfile value) { output.write_long(value.tag); - output.write_long(value.profile_data.length); - for (int i0 = 0; i0 < value.profile_data.length; i0++) - output.write_octet(value.profile_data [ i0 ]); + + if (output instanceof cdrBufOutput) + { + // Highly probable. + output.write_long(value.profile_data.length); + try + { + output.write(value.profile_data); + } + catch (IOException e) + { + MARSHAL m = new MARSHAL(); + m.initCause(e); + throw m; + } + } + else + { + output.write_long(value.profile_data.length); + for (int i0 = 0; i0 < value.profile_data.length; i0++) + output.write_octet(value.profile_data[i0]); + } } }
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ClientRequestInfo.java b/org/omg/PortableInterceptor/ClientRequestInfo.java new file mode 100644 index 000000000..dd3cd5808 --- /dev/null +++ b/org/omg/PortableInterceptor/ClientRequestInfo.java @@ -0,0 +1,54 @@ +/* ClientRequestInfo.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * Provides request information, accessible for the + * {@link ClientRequestInterceptor}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ClientRequestInfo extends ClientRequestInfoOperations, + org.omg.CORBA.Object, + IDLEntity, + RequestInfo +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ClientRequestInfoOperations.java b/org/omg/PortableInterceptor/ClientRequestInfoOperations.java new file mode 100644 index 000000000..73efa122f --- /dev/null +++ b/org/omg/PortableInterceptor/ClientRequestInfoOperations.java @@ -0,0 +1,328 @@ +/* ClientRequestInfoOperations.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.INV_POLICY; +import org.omg.CORBA.Policy; +import org.omg.IOP.ServiceContext; +import org.omg.IOP.TaggedComponent; +import org.omg.IOP.TaggedProfile; + +/** + * Provides request information, accessible for the + * {@linkplain ClientRequestInterceptor}. Some methods of this interface are + * not valid at all interception points. The following table shows the validity + * of each method. If it is not valid, BAD_INV_ORDER minor 14 will be thrown. + * + * <table border="1"> + * <tr> + * <th></th> + * <th>{@linkplain ClientRequestInterceptorOperations#send_request send_request}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#send_poll send_poll}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#receive_reply receive_reply}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#receive_exception receive_exception}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#receive_other receive_other}</th> + * </tr> + * <tr> + * <td colspan="6" align="center" bgcolor="#E0E0FF"><i>Inherited from + * {@linkplain RequestInfoOperations}:</i></td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#arguments arguments}</th> + * <td bgcolor="#E0E0E0" title="in and inout only">yes <sub><a href="#1">1</a></sub></td> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#exceptions exceptions}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#contexts contexts}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#operation_context operation_context}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#result result}</th> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#sync_scope sync_scope}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#reply_status reply_status}</th> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#forward_reference forward_reference}</th> + * <td>no</td> + * <td bgcolor="lightgray" colspan="3" align="center">no</td> + * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">yes <sub><a + * href="#2">2</a></sub> </td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#get_request_service_context get_request_service_context}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#get_reply_service_context get_reply_service_context}</th> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#request_id request_id}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#operation operation}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#response_expected response_expected}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#get_slot get_slot}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <td colspan="6" align="center" bgcolor="#E0E0FF"><i>ClientRequestInfo-specific:</i></td> + * </tr> + * <tr> + * <th>{@linkplain #target target}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #effective_target effective_target}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #effective_profile effective_profile}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #received_exception received_exception}</th> + * <td bgcolor="lightgray" colspan="3" align="center">no</td> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * </tr> + * <tr> + * <th>{@linkplain #received_exception_id received_exception_id}</th> + * <td bgcolor="lightgray" colspan="3" align="center">no</td> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * </tr> + * <tr> + * <th>{@linkplain #get_effective_component get_effective_component}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #get_effective_components get_effective_components}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #get_request_policy get_request_policy}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #add_request_service_context add_request_service_context}</th> + * <td>yes</td> + * <td bgcolor="lightgray" colspan="4" align="center">no</td> + * </tr> + * <tr> + * <th></th> + * <th>{@linkplain ClientRequestInterceptorOperations#send_request send_request}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#send_poll send_poll}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#receive_reply receive_reply}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#receive_exception receive_exception}</th> + * <th>{@linkplain ClientRequestInterceptorOperations#receive_other receive_other}</th> + * </tr> + * </table> + * <ol> + * <li><a name="1">When ClientRequestInfo is passed to send_request, there is + * an entry in the list for every argument, but only the in and inout arguments + * will be available.</a></li> + * <li><a name="2">If the reply_status atribute is not LOCATION_FORWARD, + * accessing this attribute will throw BAD_INV_ORDER with a standard minor code + * of 14.</a></li> + * </ol> + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ClientRequestInfoOperations extends RequestInfoOperations +{ + /** + * Returns the object on that the client has invoked the the operation. If the + * request was forwarded, it will not be the same object that actually + * processed the request. + * + * @return the initial client invocation target. + * + * @see #effective_target() + */ + org.omg.CORBA.Object target(); + + /** + * Returns the object on that the operation will be invoked after handling the + * possible forwarding. + * + * @return the final invocation target. + * + * @see #target() + */ + org.omg.CORBA.Object effective_target(); + + /** + * Returns the tagged profile (IOR) of the invocation target. If the request + * was forwarded, the method returns the new location, shown by the forwarding + * message. + * + * @return the invocation IOR. + */ + TaggedProfile effective_profile(); + + /** + * Returns the given component of the invocation target profile. If the + * profile contains multiple components with the same Id, it is not defined, + * which one will be returned. + * + * @param id the component id. + * + * @return the profile component with the given Id. + * + * @throws BAD_PARAM minor 28 in there are no any components with the given Id + * in the profile. + */ + TaggedComponent get_effective_component(int id) throws BAD_PARAM; + + /** + * Returns the given components of the invocation target profile. This method + * is uses when the profile may contain multiple components with the same Id. + * + * @param id the component id. + * + * @return the array of all profile components with the given Id. + * + * @throws BAD_PARAM minor 28 in there are no any components with the given Id + * in the profile. + */ + TaggedComponent[] get_effective_components(int id) throws BAD_PARAM; + + /** + * This should return the policy of the given type that applies to this + * operation, but it is not implemented up till JDK 1.5 inclusive. + * + * @param type the type of the policy being requested. + * + * @return should return the policy that applies to this operation. + * + * @throws NO_IMPLEMENT always. + */ + Policy get_request_policy(int type) throws INV_POLICY; + + /** + * Returns the repository id of the remote exception that was thrown on the + * server side. + * + * @return the exception repository id. + * + * @see #received_exception() + */ + String received_exception_id(); + + /** + * Returns the remote exception that was thrown on the server side. + * + * @return the Any, holding this exception. + * + * @see #received_exception_id() + */ + Any received_exception(); + + /** + * Allows the interceptor to add the service contexts to the request. Such + * added contexts can carry arbitrary data and can be later accessed on the + * server side by the server request interceptor, using + * {@link RequestInfoOperations#get_request_service_context}. + * + * @param service_context the context to add. + * @param replace if true, the existing context with the same Id will be + * replaced. If false, the BAD_INV_ORDER will be thrown in that case. + * + * @throws BAD_INV_ORDER minor 15 if the context with the same Id already + * exists and replace=false. + */ + void add_request_service_context(ServiceContext service_context, + boolean replace + ); +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ClientRequestInterceptor.java b/org/omg/PortableInterceptor/ClientRequestInterceptor.java new file mode 100644 index 000000000..9fdf2f120 --- /dev/null +++ b/org/omg/PortableInterceptor/ClientRequestInterceptor.java @@ -0,0 +1,54 @@ +/* ClientRequestInterceptor.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * A client side request interceptor that is notified on various request + * processing steps on a client side. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ClientRequestInterceptor extends Interceptor, + ClientRequestInterceptorOperations, + org.omg.CORBA.Object, + IDLEntity +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java b/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java new file mode 100644 index 000000000..e9630dcc8 --- /dev/null +++ b/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java @@ -0,0 +1,132 @@ +/* ClientRequestInterceptorOperations.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 org.omg.PortableInterceptor; + + +/** + * Defines operations, applicable to the client side request interceptor. The + * operations are called by ORB at the appropriate interception points. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ClientRequestInterceptorOperations + extends InterceptorOperations +{ + /** + * ORB calls this method before sending the request to the server. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException if it does, the send_request is not called for the + * subsequent interceptors, calling receive_exception instead. The completion + * status of this exception must be COMPLETED_NO. + * + * @throws ForwardRequest to forward the invocation to another target. The + * send_request is not called for the subsequent interceptors, calling + * receive_other instead. + */ + void send_request(ClientRequestInfo info) throws ForwardRequest; + + /** + * ORB calls this method after the normal reply is received from the server + * and before the control is returned to the calling client code. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException if it does, the receive_reply is not called for the + * subsequent interceptors, calling receive_exception instead. The completion + * status of this exception must be COMPLETED_YES. + */ + void receive_reply(ClientRequestInfo info); + + /** + * ORB calls this method after the receiving the message that a remote + * exception has been thrown on a server side and before raising this + * exception in the client side. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException has the effect of changing the exception that + * successive interceptors receive on their calls to receive_other. If the + * original exception is a system exception, the completion_status of the new + * exception must match the exception being replaced. If the original + * exception is a user exception, then the completion_status of the new + * exception must be COMPLETED_YES. + * + * @throws ForwardRequest to forward the invocation to another target. The + * receive_exception is not called for the subsequent interceptors, calling + * receive_other instead. If the completion_status of the original exception + * is not a COMPLETED_NO, the ForwardRequest must not be raised. + */ + void receive_exception(ClientRequestInfo info) throws ForwardRequest; + + /** + * /** ORB normally calls this method after receiving the forwarding message. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException if it does, the receive_other is not called for the + * subsequent interceptors, calling receive_exception instead. + * + * @throws ForwardRequest has the effect of changing the redirection that + * successive interceptors receive on their calls to receive_other. + */ + void receive_other(ClientRequestInfo info) throws ForwardRequest; + + /** + * This method is called by if ORB uses the Time- Independent Invocation (TII) + * polling. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException if it does, the send_poll is not called for the + * subsequent interceptors, calling receive_exception instead. The completion + * status of this exception must be COMPLETED_NO. + * + * @throws ForwardRequest to forward the invocation to another target. The + * send_request is not called for the subsequent interceptors, calling + * receive_other instead. + */ + void send_poll(ClientRequestInfo info) throws ForwardRequest; +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/Current.java b/org/omg/PortableInterceptor/Current.java new file mode 100644 index 000000000..d53d5c33a --- /dev/null +++ b/org/omg/PortableInterceptor/Current.java @@ -0,0 +1,85 @@ +/* Current.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * <p> + * The portable interceptor Current (PICurrent) contains multiple slots where an + * interceptor can rememeber the request - specific values between subsequent + * calls of the interceptor methods. In multithreaded environment, it is not + * possible just to store such data in the interceptor object fields. + * </p> + * <p> + * On the client side, it is possible to set the initial slot values by + * modifying slots on the Current, returend by ORB.resolve_initial_references + * ("PICurrent"). The returned value is narrowed with the + * {@link CurrentHelper#narrow}. On the subsequent invocation, made from the + * same thread, the interceptors will see the initial slot values as they were + * set using this approach. + * </p> + * <p> + * There are no way to set the initial values for the server side interceptors, + * the default values (Any with typecode TCKind.tk_null) should be always + * assumed. + * </p> + * <p> + * Since an Interceptor is running in a thread, it is running with a thread + * context and there is a PICurrent on that context. If the Interceptor calls + * ORB.resolve_initial_references ("PICurrent"), it gets the PICurrent within + * its thread scope. This PICurrent is different than the request scope + * PICurrent that the Interceptor obtains via calls to the Client- or Server- + * RequestInfo object. + * </p> + * <p> + * On the client side the PICurrent can be used to detect the recursive + * invocations, performed by interceptors. If one of the interceptors makes call + * via the same ORB, this call is then showed to all interceptors, including the + * interceptor that made it. To avoid infinite recursion, the during each call + * this interceptor can set some "recursion flag" into one of the slots of the + * PICurrent. If the flag is set on the entry point, this indicates a recursive + * call of that request. + * </p> + */ +public interface Current extends CurrentOperations, + org.omg.CORBA.Current, + IDLEntity +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/CurrentHelper.java b/org/omg/PortableInterceptor/CurrentHelper.java new file mode 100644 index 000000000..b7a5a541e --- /dev/null +++ b/org/omg/PortableInterceptor/CurrentHelper.java @@ -0,0 +1,150 @@ +/* CurrentHelper.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.ORB; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for the CORBA object {@link Current}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class CurrentHelper +{ + /** + * The cached {@link Current} typecode, computed once. + */ + private static TypeCode typeCode; + + /** + * Get the type code of the {@link Current}. + */ + public static TypeCode type() + { + if (typeCode == null) + { + typeCode = ORB.init().create_interface_tc(id(), "Current"); + } + return typeCode; + } + + /** + * Insert the Current into the given Any. + * + * @param any the Any to insert into. + * @param that the Current to insert. + */ + public static void insert(Any any, Current that) + { + any.insert_Object(that); + } + + /** + * Extract the Current from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain Current. + */ + public static Current extract(Any any) + { + return narrow(any.extract_Object()); + } + + /** + * Get the Current repository id. + * + * @return "org.omg.PortableInterceptor.CurrentOperations", always. + */ + public static String id() + { + return "IDL:omg.org/PortableInterceptor/Current:1.0"; + } + + /** + * Cast the passed object into the Current. + * + * @param obj the object to narrow. + * @return narrowed instance. + * @throws BAD_PARAM if the passed object is not a Current. + */ + public static Current narrow(org.omg.CORBA.Object obj) + { + if (obj == null) + { + return null; + } + else if (obj instanceof Current) + { + return (Current) obj; + } + else + { + throw new BAD_PARAM("Not a Current"); + } + } + + /** + * Not supported for compatibility reasons. + * + * @specnote Not supported by Sun at least till jdk 1.5 inclusive. + * + * @throws MARSHAL always. + */ + public static Current read(InputStream input) + { + throw new MARSHAL(); + } + + /** + * Not supported for compatibility reasons. + * + * @specnote Not supported by Sun at least till jdk 1.5 inclusive. + * + * @throws MARSHAL always. + */ + public static void write(OutputStream output, Current value) + { + throw new MARSHAL(); + } +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/CurrentOperations.java b/org/omg/PortableInterceptor/CurrentOperations.java new file mode 100644 index 000000000..419ccfac1 --- /dev/null +++ b/org/omg/PortableInterceptor/CurrentOperations.java @@ -0,0 +1,86 @@ +/* CurrentOperations.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_INV_ORDER; + +/** + * Defines the operations, applicable to the portable interceptor Current. + * + * Portable Interceptors Current (also known as PICurrent) is a slot table. Each + * slot has an integer identifier, can hold a CORBA {@link Any} and is used by + * some service to transfer data between thread and request contexts. Each + * service which wishes to use PICurrent reserves a slot or slots at + * initialization time and uses those slots during the processing of requests + * and replies. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface CurrentOperations +{ + /** + * Get data from the slot with the given slot_id. + * + * @param slot_id the slot slot_id. + * + * @return the Any that was stored in the slot. If the given slot has not been + * set, the returned Any contains a type code with a TCKind value of tk_null + * and has no value. + * + * @throws InvalidSlot for the unknown slot. + * @throws BAD_INV_ORDER minor 10 if called from the {@link ORBInitializer} + * methods. + */ + Any get_slot(int slot_id) throws InvalidSlot, BAD_INV_ORDER; + + /** + * Sets data for the slot with the given slot_id. + * + * @param slot_id the slot slot_id. + * + * @param data the Any that will be stored into the slot. + * + * @throws InvalidSlot for the unknown slot. + * @throws BAD_INV_ORDER minor 10 if called from the {@link ORBInitializer} + * methods. + * + */ + void set_slot(int slot_id, Any data) throws InvalidSlot, BAD_INV_ORDER; +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ForwardRequest.java b/org/omg/PortableInterceptor/ForwardRequest.java new file mode 100644 index 000000000..7e7d7a3f4 --- /dev/null +++ b/org/omg/PortableInterceptor/ForwardRequest.java @@ -0,0 +1,97 @@ +/* ForwardRequest.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.UserException; +import org.omg.CORBA.portable.IDLEntity; + +import java.io.Serializable; + +/** + * The ForwardRequest is thrown by interceptors to forward the request to + * another target. The field {@link #forward} contains the reference to this + * alternative location. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class ForwardRequest extends UserException implements IDLEntity, + Serializable +{ + /** + * Use serialVersionUID (v1.4) for interoperability. + */ + private static final long serialVersionUID = 2128007517550526397L; + + /** + * The field forward. + */ + public org.omg.CORBA.Object forward; + + /** + * Create ForwardRequest with no explaining + * message and all fields left unitialised with the default initial java values. + */ + public ForwardRequest() + { + } + + /** + * Create the ForwardRequest with explaining + * message and all fields initialised to the given values. + * + * @param why a string, explaining, why this exception has been thrown. + * @param a_forward a value for forward. + */ + public ForwardRequest(String why, org.omg.CORBA.Object a_forward) + { + super(why); + this.forward = a_forward; + } + + /** + * Create the ForwardRequest without explaining + * message and all fields initialised to the given values. + * + * @param a_forward a value for forward. + */ + public ForwardRequest(org.omg.CORBA.Object a_forward) + { + this.forward = a_forward; + } +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ForwardRequestHelper.java b/org/omg/PortableInterceptor/ForwardRequestHelper.java new file mode 100644 index 000000000..11d6b7f0f --- /dev/null +++ b/org/omg/PortableInterceptor/ForwardRequestHelper.java @@ -0,0 +1,152 @@ +/* ForwardRequestHelper.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 org.omg.PortableInterceptor; + +import gnu.CORBA.Interceptor.ForwardRequestHolder; + +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.ORB; +import org.omg.CORBA.ObjectHelper; +import org.omg.CORBA.StructMember; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for the exception {@link ForwardRequest}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class ForwardRequestHelper +{ + /** + * The cached typecode value, computed only once. + */ + private static TypeCode typeCode; + + /** + * Create the ForwardRequest typecode (structure, named "ForwardRequest"). The + * typecode states that the structure contains the following fields: forward. + */ + public static TypeCode type() + { + if (typeCode == null) + { + ORB orb = ORB.init(); + StructMember[] members = new StructMember[ 1 ]; + + TypeCode field = ObjectHelper.type(); + members [ 0 ] = new StructMember("forward", field, null); + typeCode = orb.create_exception_tc(id(), "ForwardRequest", members); + } + return typeCode; + } + + /** + * Insert the ForwardRequest into the given Any. This method uses the + * ForwardRequestHolder. + * + * @param any the Any to insert into. + * @param that the ForwardRequest to insert. + */ + public static void insert(Any any, ForwardRequest that) + { + any.insert_Streamable(new ForwardRequestHolder(that)); + } + + /** + * Extract the ForwardRequest from given Any. This method uses the + * ForwardRequestHolder. + * + * @throws BAD_OPERATION if the passed Any does not contain ForwardRequest. + */ + public static ForwardRequest extract(Any any) + { + try + { + return ((ForwardRequestHolder) any.extract_Streamable()).value; + } + catch (ClassCastException cex) + { + BAD_OPERATION bad = new BAD_OPERATION(id() + " expected"); + bad.initCause(cex); + throw bad; + } + } + + /** + * Get the ForwardRequest repository id. + * + * @return "IDL:omg.org/PortableInterceptor/ForwardRequest:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/PortableInterceptor/ForwardRequest:1.0"; + } + + /** + * Read the exception from the CDR intput stream. + * + * @param input a org.omg.CORBA.portable stream to read from. + */ + public static ForwardRequest read(InputStream input) + { + // Read (and discard) the exception repository id. + input.read_string(); + + ForwardRequest value = new ForwardRequest(); + + value.forward = input.read_Object(); + return value; + } + + /** + * Write the exception to the CDR output stream. + * + * @param output a org.omg.CORBA.portable stream stream to write into. + * @param value a value to write. + */ + public static void write(OutputStream output, ForwardRequest value) + { + // Write the exception repository id. + output.write_string(id()); + output.write_Object(value.forward); + } +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/IORInfo.java b/org/omg/PortableInterceptor/IORInfo.java index 546cacafb..9495d79ec 100644 --- a/org/omg/PortableInterceptor/IORInfo.java +++ b/org/omg/PortableInterceptor/IORInfo.java @@ -50,7 +50,9 @@ import java.io.Serializable; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface IORInfo - extends IORInfoOperations, IDLEntity, org.omg.CORBA.Object, Serializable +public interface IORInfo extends IORInfoOperations, + IDLEntity, + org.omg.CORBA.Object, + Serializable { }
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/IORInfoOperations.java b/org/omg/PortableInterceptor/IORInfoOperations.java index f44420952..58ef02fb0 100644 --- a/org/omg/PortableInterceptor/IORInfoOperations.java +++ b/org/omg/PortableInterceptor/IORInfoOperations.java @@ -60,8 +60,8 @@ public interface IORInfoOperations * Internet profile where host and port are stored by default. */ void add_ior_component_to_profile(TaggedComponent tagged_component, - int profile_id - ); + int profile_id + ); /** * Adds a service-specific component to the IOR profile being constructed. @@ -73,7 +73,7 @@ public interface IORInfoOperations void add_ior_component(TaggedComponent tagged_component); /** - * Get the server side policy for an IOR being constructed. The method returns + * Get the server side policy for an IOR being constructed. The method returns * policies applying for POA where the object, represented by this IOR, is * connected. * diff --git a/org/omg/PortableInterceptor/IORInterceptor.java b/org/omg/PortableInterceptor/IORInterceptor.java index e543a7a5d..e78fbf2c3 100644 --- a/org/omg/PortableInterceptor/IORInterceptor.java +++ b/org/omg/PortableInterceptor/IORInterceptor.java @@ -44,15 +44,18 @@ import java.io.Serializable; /** * An ORB service implementation may need to add information describing the - * server�s or object�s ORB service related capabilities to object references + * serverORB service related capabilities to object references * (IORs). This is supported through the IORInterceptor and {@link IORInfo} * interfaces. The IOR Interceptor is used to establish tagged components in the * profiles within a new IOR being created. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface IORInterceptor - extends IDLEntity, Interceptor, InterceptorOperations, IORInterceptorOperations, - org.omg.CORBA.Object, Serializable +public interface IORInterceptor extends IDLEntity, + Interceptor, + InterceptorOperations, + IORInterceptorOperations, + org.omg.CORBA.Object, + Serializable { }
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/IORInterceptorOperations.java b/org/omg/PortableInterceptor/IORInterceptorOperations.java index 60394ec15..868fcab6c 100644 --- a/org/omg/PortableInterceptor/IORInterceptorOperations.java +++ b/org/omg/PortableInterceptor/IORInterceptorOperations.java @@ -44,15 +44,14 @@ package org.omg.PortableInterceptor; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface IORInterceptorOperations - extends InterceptorOperations +public interface IORInterceptorOperations extends InterceptorOperations { /** - * A server side ORB calls this method on all registered IORInterceptor's when + * A server side ORB calls this method on all registered IORInterceptor's when * creating the object reference (IOR). The interceptors have the possibility * to add additional tags to the IOR being created. * - * @param info the interface class providing methods to insert additional tags + * @param info the interface class providing methods to insert additional tags * into IOR being constructed. The same instan */ public void establish_components(IORInfo info); diff --git a/org/omg/PortableInterceptor/Interceptor.java b/org/omg/PortableInterceptor/Interceptor.java index 8b0e22420..8ec375c9a 100644 --- a/org/omg/PortableInterceptor/Interceptor.java +++ b/org/omg/PortableInterceptor/Interceptor.java @@ -46,12 +46,13 @@ import org.omg.CORBA.portable.IDLEntity; * intercept the normal flow of execution in creation of IOR, sending request, * receiving request and returning the reply. * - * See {@link org.omg.PortableInterceptor} for more details about the possible - * interceptors and how to register them within the ORB. + * See {@link ORBInitializer} for explanation, how the interceptors are + * registered within the ORB. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface Interceptor - extends InterceptorOperations, Object, IDLEntity +public interface Interceptor extends InterceptorOperations, + Object, + IDLEntity { }
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/InvalidSlot.java b/org/omg/PortableInterceptor/InvalidSlot.java new file mode 100644 index 000000000..72805cf72 --- /dev/null +++ b/org/omg/PortableInterceptor/InvalidSlot.java @@ -0,0 +1,76 @@ +/* InvalidSlot.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.UserException; +import org.omg.CORBA.portable.IDLEntity; + +import java.io.Serializable; + +/** + * The InvalidSlot is thrown when the slot identifier, passed in one of the + * methods, related to {@link Current}, does not define a valid slot. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class InvalidSlot extends UserException implements IDLEntity, + Serializable +{ + /** + * Use serialVersionUID (v1.4) for interoperability. + */ + private static final long serialVersionUID = 2471643293291821501L; + + /** + * Create InvalidSlot with no explaining message. + */ + public InvalidSlot() + { + } + + /** + * Create the InvalidSlot with explaining message. + * + * @param why a string, explaining, why this exception has been thrown. + */ + public InvalidSlot(String why) + { + super(why); + } +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/InvalidSlotHelper.java b/org/omg/PortableInterceptor/InvalidSlotHelper.java new file mode 100644 index 000000000..c0aa0ee1b --- /dev/null +++ b/org/omg/PortableInterceptor/InvalidSlotHelper.java @@ -0,0 +1,149 @@ +/* InvalidSlotHelper.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 org.omg.PortableInterceptor; + +import gnu.CORBA.EmptyExceptionHolder; + +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.ORB; +import org.omg.CORBA.StructMember; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +/** + * The helper operations for the exception {@link InvalidSlot}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public abstract class InvalidSlotHelper +{ + /** + * The cached typecode value, computed only once. + */ + private static TypeCode typeCode; + + /** + * Create the InvalidSlot typecode (structure, named "InvalidSlot"). + */ + public static TypeCode type() + { + if (typeCode == null) + { + ORB orb = ORB.init(); + StructMember[] members = new StructMember[ 0 ]; + typeCode = orb.create_exception_tc(id(), "InvalidSlot", members); + } + return typeCode; + } + + /* + * Every user exception with no user defined fields can use + * EmptyExceptionHolder + */ + + /** + * Insert the InvalidSlot into the given Any. + * + * @param any the Any to insert into. + * @param that the InvalidSlot to insert. + */ + public static void insert(Any any, InvalidSlot that) + { + any.insert_Streamable(new EmptyExceptionHolder(that, type())); + } + + /** + * Extract the InvalidSlot from given Any. + * + * @throws BAD_OPERATION if the passed Any does not contain InvalidSlot. + */ + public static InvalidSlot extract(Any any) + { + try + { + EmptyExceptionHolder h = + (EmptyExceptionHolder) any.extract_Streamable(); + return (InvalidSlot) h.value; + } + catch (ClassCastException cex) + { + BAD_OPERATION bad = new BAD_OPERATION("InvalidSlot expected"); + bad.initCause(cex); + throw bad; + } + } + + /** + * Get the InvalidSlot repository id. + * + * @return "IDL:omg.org/PortableInterceptor/InvalidSlot:1.0", always. + */ + public static String id() + { + return "IDL:omg.org/PortableInterceptor/InvalidSlot:1.0"; + } + + /** + * Read the exception from the CDR intput stream. + * + * @param input a org.omg.CORBA.portable stream to read from. + */ + public static InvalidSlot read(InputStream input) + { + // Read the exception repository id. + String id = input.read_string(); + InvalidSlot value = new InvalidSlot(id); + + return value; + } + + /** + * Write the exception to the CDR output stream. + * + * @param output a org.omg.CORBA.portable stream stream to write into. + * @param value a value to write. + */ + public static void write(OutputStream output, InvalidSlot value) + { + // Write the exception repository id. + output.write_string(id()); + } +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/LOCATION_FORWARD.java b/org/omg/PortableInterceptor/LOCATION_FORWARD.java index 2a84125db..bbd23f03f 100644 --- a/org/omg/PortableInterceptor/LOCATION_FORWARD.java +++ b/org/omg/PortableInterceptor/LOCATION_FORWARD.java @@ -38,7 +38,8 @@ exception statement from your version. */ package org.omg.PortableInterceptor; - /** + +/** * A reply status flag, indicating, that the object has * moved (temporary or permanently) to another location. * @@ -50,4 +51,4 @@ public interface LOCATION_FORWARD * Specifies the LOCATION_FORWARD value, 3. */ short value = 3; -} +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ORBInitInfo.java b/org/omg/PortableInterceptor/ORBInitInfo.java new file mode 100644 index 000000000..d13dacdd6 --- /dev/null +++ b/org/omg/PortableInterceptor/ORBInitInfo.java @@ -0,0 +1,54 @@ +/* ORBInitInfo.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Object; +import org.omg.CORBA.portable.IDLEntity; + +/** + * The instance of this interface is passed to {@link ORBInitializerOperations} + * and is used by {@link ORBInitializer} to register its {@link Interceptor}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ORBInitInfo extends ORBInitInfoOperations, + Object, + IDLEntity +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ORBInitInfoOperations.java b/org/omg/PortableInterceptor/ORBInitInfoOperations.java new file mode 100644 index 000000000..cc3930996 --- /dev/null +++ b/org/omg/PortableInterceptor/ORBInitInfoOperations.java @@ -0,0 +1,169 @@ +/* ORBInitInfoOperations.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 org.omg.PortableInterceptor; + +import org.omg.IOP.CodecFactory; +import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName; + +/** + * Defines operations, applicable to {@link ORBInitInfo}. The + * {@link ORBInitInfo} is passed to the {@link ORBInitializer} that is + * reponsible for registering an {@link Interceptor}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ORBInitInfoOperations +{ + /** + * Register the client request interceptor. + * + * @param interceptor the interceptor to register. + * + * @throws DuplicateName if the interceptor name is not an empty string and an + * interceptor with this name is already registered with the ORB being + * created. + */ + void add_client_request_interceptor(ClientRequestInterceptor interceptor) + throws DuplicateName; + + /** + * Register the IOR (object reference) interceptor. + * + * @param interceptor the interceptor to register. + * + * @throws DuplicateName if the interceptor name is not an empty string and an + * interceptor with this name is already registered with the ORB being + * created. + */ + void add_ior_interceptor(IORInterceptor interceptor) + throws DuplicateName; + + /** + * Register the server request interceptor. + * + * @param interceptor the interceptor to register. + * + * @throws DuplicateName if the interceptor name is not an empty string and an + * interceptor with this name is already registered with the ORB being + * created. + */ + void add_server_request_interceptor(ServerRequestInterceptor interceptor) + throws DuplicateName; + + /** + * Allocate a slot on a {@link PortableInterceptor.Current}. While slots can + * be allocated by this method, they cannot be initialized. + * {@link CurrentOperations#get_slot} and {@link CurrentOperations#set_slot} + * throw {@link org.omg.CORBA.BAD_INV_ORDER} while called from the interceptor + * initializer. + * + * @return the index to the slot that has been allocated. + */ + int allocate_slot_id(); + + /** + * Returns the arguments passed to the ORB.init. + * + * @return the first parameter, passed to the method + * {@link org.omg.CORBA.ORB#init}. + */ + String[] arguments(); + + /** + * Get the CodecFactory that may be needed during the interceptor + * initialization. The method ORB.resolve_initial_references (“CodecFactory") + * cannot be used during ORB initialization. + * + * @return the CodecFactory. + */ + CodecFactory codec_factory(); + + /** + * Returns the ID of the ORB being initialized. + * + * @return the ORB id that differs for each new ORB being created during the + * current run of the java virtual machine. + */ + String orb_id(); + + /** + * Register the initial reference. The registered object will be accessible by + * the {@link ORB.resolve_initial_references} under the object_name. + * + * @param object_name the name of the object to register. + * @param object the object to register. + * + * @throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName if the + * name being registered is assumed to be invalid. + */ + void register_initial_reference(String object_name, + org.omg.CORBA.Object object + ) throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName; + + /** + * Identical to {@link org.omg.CORBA.ORB#resolve_initial_references}. + * + * This method can only be called from + * {@link ORBInitializerOperations#post_init} and not during + * {@link ORBInitializerOperations#pre_init}. + * + * @param object_name the name of the object to search. + * + * @return the object, accessible by the given name. + * + * @throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName if the + * given name is not associated with the known object. + * + * @see org.omg.CORBA.ORB#resolve_initial_references + */ + org.omg.CORBA.Object resolve_initial_references(String object_name) + throws org.omg.PortableInterceptor.ORBInitInfoPackage.InvalidName; + + /** + * Registers a PolicyFactory for the given PolicyType. + * + * @param policy_type the type of policy for that the factory is being + * registered. + * @param policy_factory the policy factory to register. + * + * @throws BAD_INV_ORDER minor 16 if the policy of the given type already has + * the registered factory in this ORB. + */ + void register_policy_factory(int policy_type, PolicyFactory policy_factory); +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateName.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateName.java index 365aaf477..187273725 100644 --- a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateName.java +++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateName.java @@ -42,30 +42,28 @@ import org.omg.CORBA.UserException; import org.omg.CORBA.portable.IDLEntity; import java.io.Serializable; -import gnu.CORBA.*; /** -* This exception is raised on an attempt to register a second -* {@link org.omg.PortableInterceptor#Interceptor} with the same name. -* For each {@link org.omg.PortableInterceptor#Interceptor} type, only -* one {@link org.omg.PortableInterceptor#Interceptor} of a given name can -* be registered with the {@link org.omg.CORBA.ORB}. -* -* @see org.omg.PortableInterceptor.ORBInitInfoOperations -* -* @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) -*/ -public class DuplicateName - extends UserException - implements IDLEntity, Serializable + * This exception is raised on an attempt to register a second + * {@link org.omg.PortableInterceptor#Interceptor} with the same name. + * For each {@link org.omg.PortableInterceptor#Interceptor} type, only + * one {@link org.omg.PortableInterceptor#Interceptor} of a given name can + * be registered with the {@link org.omg.CORBA.ORB}. + * + * @see org.omg.PortableInterceptor.ORBInitInfoOperations + * + * @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) + */ +public class DuplicateName extends UserException implements IDLEntity, + Serializable { - /** - * Use serialVersionUID (v1.4) for interoperability. - */ - private static final long serialVersionUID = 7748239257677851130L; + /** + * Use serialVersionUID (v1.4) for interoperability. + */ + private static final long serialVersionUID = 7748239257677851130L; /** - * The name field. + * The name that appears to be duplicate. */ public String name; diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java index 6c93cff1d..a5c83fa80 100644 --- a/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java +++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHelper.java @@ -38,6 +38,8 @@ exception statement from your version. */ package org.omg.PortableInterceptor.ORBInitInfoPackage; +import gnu.CORBA.*; + import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.ORB; @@ -46,13 +48,12 @@ import org.omg.CORBA.TCKind; import org.omg.CORBA.TypeCode; import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; -import gnu.CORBA.*; /** -* The helper operations for the exception {@link DuplicateName}. -* -* @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) -*/ + * The helper operations for the exception {@link DuplicateName}. + * + * @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) + */ public abstract class DuplicateNameHelper { /** @@ -83,12 +84,12 @@ public abstract class DuplicateNameHelper } /** - * Insert the DuplicateName into the given Any. - * This method uses the DuplicateNameHolder. - * - * @param any the Any to insert into. - * @param that the DuplicateName to insert. - */ + * Insert the DuplicateName into the given Any. + * This method uses the DuplicateNameHolder. + * + * @param any the Any to insert into. + * @param that the DuplicateName to insert. + */ public static void insert(Any any, DuplicateName that) { any.insert_Streamable(new DuplicateNameHolder(that)); diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidName.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidName.java index ecdde8b47..17c6c6bc2 100644 --- a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidName.java +++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidName.java @@ -44,17 +44,16 @@ import org.omg.CORBA.portable.IDLEntity; import java.io.Serializable; /** -* This exception is raised by methods in -* {@link org.omg.PortableInterceptor.ORBInitInfoOperations} on the attempt to -* register or resolve an invalid name like empty string. The already -* registered names (including the default names, defined by OMG) are also -* invalid for registration. -* -* @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) -*/ -public class InvalidName - extends UserException - implements IDLEntity, Serializable + * This exception is raised by methods in + * {@link org.omg.PortableInterceptor.ORBInitInfoOperations} on the attempt to + * register or resolve an invalid name like empty string. The already + * registered names (including the default names, defined by OMG) are also + * invalid for registration. + * + * @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) + */ +public class InvalidName extends UserException implements IDLEntity, + Serializable { /** * Use serialVersionUID (v1.4) for interoperability. @@ -71,7 +70,7 @@ public class InvalidName /** * Create the InvalidName with explaining message. * - * @param why a string, explaining, why this exception has been thrown. + * @param why a string, explaining, why the name is invalid. */ public InvalidName(String why) { diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java index 841d6f99a..7f1132f98 100644 --- a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java +++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java @@ -50,10 +50,10 @@ import org.omg.CORBA.portable.InputStream; import org.omg.CORBA.portable.OutputStream; /** -* The helper operations for the exception {@link InvalidName}. -* -* @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) -*/ + * The helper operations for the exception {@link InvalidName}. + * + * @author Audrius Meskauskas, Lithiania (AudriusA@Bioinformatics.org) + */ public abstract class InvalidNameHelper { /** diff --git a/org/omg/PortableInterceptor/ORBInitializer.java b/org/omg/PortableInterceptor/ORBInitializer.java new file mode 100644 index 000000000..47191820c --- /dev/null +++ b/org/omg/PortableInterceptor/ORBInitializer.java @@ -0,0 +1,132 @@ +/* ORBInitializer.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Object; +import org.omg.CORBA.portable.IDLEntity; + +/** + * <p> + * Registers the interceptor. + * + * Direct interceptor registration would open a security hole. Hence instead the + * interceptors from the ORB.init(..) method, passing the names of the needed + * initialized classes via properties. + * </p> + * <p> + * These property names are of the form + * </p> + * <p><i>org.omg.PortableInterceptor.ORBInitializerClass.<Service></i></p> + * where <i><Service></i> is the string name of a class, which implements + * {@link ORBInitializer}. During <code>ORB.init(..)</code>, the properties + * begining with <i>org.omg.PortableInterceptor.ORBInitializerClass</i> are + * collected, the <i><Service></i> portion of each property is extracted, + * the initialiser is instantiated with the <i><Service></i> string as its + * class name and then <code>pre_init</code> and <code>post_init</code> + * (defined in {@link ORBInitializerOperations}) are called on that initializer. + * The runtime exceptions, thrown by these two methods, are ignored. + * </p> + * <p> + * <h3>Example</h3> + * A client-side logging service may have the following ORBInitializer + * implementation: + * + * <code><pre> + * package gnu.x.logging; + * + * import org.omg.PortableInterceptor.*; + * import org.omg.CORBA.LocalObject; + * + * public class LoggingService extends LocalObject implements ORBInitializer + * { + * public void pre_init (ORBInitInfo info) + * { + * // More than one interceptor can be registered. + * ServerRequestInterceptor log_requests = new rLoggingInterceptor(); + * info.add_server_request_interceptor(log_requests); + * + * IORInterceptor log_iors = new iLoggingInterceptor(); + * info.add_ior_interceptor(log_iors); + * } + * + * public void post_init (ORBInitInfo info) + * { + * // Unused. + * } + * } + * </code></pre> + * <p> + * Then, one of the used set of properties then must contain the property, named + * <i> + * org.omg.PortableInterceptor.ORBInitializerClass.gnu.x.Logging.LoggingService + * </i>. + * The value of the property is ignored and may empty string. The + * agreed locations, where this property will be searched for, are: + * </p><p> + * 1. The properties parameter in the ORB.init(..), if any.<br> + * 2. The System properties.<br> + * 3. The orb.properties file located in the user.home directory (if any).<br> + * 4. The orb.properties file located in the java.home/lib directory (if any). + * </p> + * <p> + * The applet parameters and command line arguments are <i>not</i> scanned + * for the possible initializers. + * </p> + * <p> + * Interceptors are registered on a per-ORB basis. The virtual per-object + * Interceptors can be simulated by checking the policies on the target from + * within the interception points to determine whether they should work. The + * virtual per-POA Interceptors can be obtained instantiating each POA such with + * a different ORB. + * </p> + * <p> + * The registration code should not call directly any methods on the ORB being + * registered. + * </p> + * <p> + * The new interceptors cannot be registered after the ORB.init(..) returns. + * </p> + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ORBInitializer extends ORBInitializerOperations, + Object, + IDLEntity +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ORBInitializerOperations.java b/org/omg/PortableInterceptor/ORBInitializerOperations.java new file mode 100644 index 000000000..90c2325f2 --- /dev/null +++ b/org/omg/PortableInterceptor/ORBInitializerOperations.java @@ -0,0 +1,73 @@ +/* ORBInitializerOperations.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 org.omg.PortableInterceptor; + + +/** + * Defines operations, applicable to the ORBInitializer. These operations are + * invoked on initializer from the ORB.init. + * + * @see ORBInitializer + */ +public interface ORBInitializerOperations +{ + /** + * This method is called during the first step of initialization. It must + * register all initial references that are expected to be used by other + * interceptors. + * + * @param info the object describing ORB being created and containing methods + * to register the interceptor. + * + * @see ORBInitInfoOperations#register_initial_reference + */ + void pre_init(ORBInitInfo info); + + /** + * This method called during the subsequent step of initialization. In this + * method it can be assumed that all required initial references are already + * registered. + * + * @param info the object describing ORB being created and containing methods + * to register the interceptor. + * + * @see ORBInitInfoOperations#register_initial_references + */ + void post_init(ORBInitInfo info); +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/PolicyFactory.java b/org/omg/PortableInterceptor/PolicyFactory.java new file mode 100644 index 000000000..6478e408c --- /dev/null +++ b/org/omg/PortableInterceptor/PolicyFactory.java @@ -0,0 +1,57 @@ +/* PolicyFactory.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * The {@link ORBInitializer} may register the PolicyFactory to create the + * service specific policies later. The factory will be later used by + * {@link org.omg.CORBA.ORB#create_policy}. + * + * @see org.omg.PortableInterceptor.ORBInitInfoOperations#register_policy_factory + * @see org.omg.CORBA.ORB#create_policy + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface PolicyFactory extends PolicyFactoryOperations, + org.omg.CORBA.Object, + IDLEntity +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/PolicyFactoryOperations.java b/org/omg/PortableInterceptor/PolicyFactoryOperations.java new file mode 100644 index 000000000..4e5a54ef7 --- /dev/null +++ b/org/omg/PortableInterceptor/PolicyFactoryOperations.java @@ -0,0 +1,69 @@ +/* PolicyFactoryOperations.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Any; +import org.omg.CORBA.Policy; +import org.omg.CORBA.PolicyError; + +/** + * A service implementation can register policy factory during ORB initialization + * for creating the service-specific policies. This factory then will be + * invoked form {@link org.omg.CORBA.ORB#create_policy(int, Any)}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + * + * @see org.omg.CORBA.ORB#create_policy + * @see ORBInitInfoOperations#register_policy_factory + */ +public interface PolicyFactoryOperations +{ + /** + * Create and return the policy of the given type, having the given value. + * + * @param policy_type the type of the policy being created + * @param policy_value the value of the policy, wrapped in {@link Any}. + * Depending from the policy, the Any can hold various values, + * including complex data structures. + * + * @return the created policy. + */ + Policy create_policy(int policy_type, Any policy_value) + throws PolicyError; +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/RequestInfo.java b/org/omg/PortableInterceptor/RequestInfo.java new file mode 100644 index 000000000..0285a8063 --- /dev/null +++ b/org/omg/PortableInterceptor/RequestInfo.java @@ -0,0 +1,55 @@ +/* RequestInfo.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * Provides access to request information, available to the + * {@link ClientRequestInterceptor} or {@link ServerRequestInterceptor}. The + * additional operations, specific to the server and client are defined in the + * derived interfaces {@link ServerRequestInfo} and {@link ClientRequestInfo}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface RequestInfo extends RequestInfoOperations, + org.omg.CORBA.Object, + IDLEntity +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/RequestInfoOperations.java b/org/omg/PortableInterceptor/RequestInfoOperations.java new file mode 100644 index 000000000..f865a14d2 --- /dev/null +++ b/org/omg/PortableInterceptor/RequestInfoOperations.java @@ -0,0 +1,190 @@ +/* RequestInfoOperations.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.TypeCode; +import org.omg.Dynamic.Parameter; +import org.omg.IOP.ServiceContext; + +/** + * Defines operations that are applicable for both server and client request. + * The additional operations, specific to the server and client request are + * defined in the derived interfaces {@link ServerRequestInfoOperations} and + * {@link ClientRequestInfoOperations}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface RequestInfoOperations +{ + /** + * Return the parameters of the operation being invoked. + * + * @return the array, containing parameters of the operations or an empty + * array for the operations with no parameters. + * + * @throws NO_RESOURCES if the parameters are not available. The parameters + * are only available for DII (via {@link org.omg.CORBA.Request} or DSI calls. + * They are not available for calls via IDL - generated stubs. + */ + Parameter[] arguments(); + + /** + * Returns the names of all contexts of the operation being invoked. + * + * @return the array of strings, defining contexts. + * + * @throws NO_RESOURCES if the contexts are not available. The contexts are + * only available for DII (via {@link org.omg.CORBA.Request} or DSI calls. + * They are not available for calls via IDL - generated stubs. + */ + String[] contexts(); + + /** + * Returns the typecodes, defining all exceptions that the operation may + * throw. + * + * @return the array of exception typecodes, empty array if the operation + * should not throw any exceptions. + * + * @throws NO_RESOURCES if the exception list is not available. This list is + * only available for DII (via {@link org.omg.CORBA.Request} or DSI calls and + * only on the client side. It is not available for calls via IDL - generated + * stubs or on the server side. + */ + TypeCode[] exceptions(); + + /** + * If the request contains forwarding information (the reply_status attribute + * being LOCATION_FORWARD), return the forwarding target. + * + * @return the object where the request should be forwarded. + */ + org.omg.CORBA.Object forward_reference(); + + /** + * Get the service context with the given ctx_name that is associated with the + * reply. + * + * @param ctx_name the name of the service context + * + * @return the copy of the corresponding context. + * + * @throws BAD_PARAM minor 26, if the context with the give ctx_name does not + * exist. + */ + ServiceContext get_reply_service_context(int ctx_name) + throws BAD_PARAM; + + /** + * Get the service context with the given ctx_name that is associated with the + * request. + * + * @param ctx_name the name of the service context + * + * @return the copy of the corresponding context. + * + * @throws BAD_PARAM minor 26, if the context with the give ctx_name does not + * exist. + */ + ServiceContext get_request_service_context(int ctx_name) + throws BAD_PARAM; + + /** + * Get the data from the given slot of the PortableInterceptor.Current that is + * in the scope of the request. + */ + Any get_slot(int id) throws InvalidSlot; + + /** + * Get the names of the service contexts being sent on the request. + * + * @return array of strings, naming the contexts. + */ + String[] operation_context(); + + /** + * Get the name of the operation being invoked. + * + * @return the name of the operation, usually the name of method being called. + */ + String operation(); + + /** + * Get the reoly state as result of the operation invocation. + * + * @return the value field of one of the following: {@link SUCCESSFUL}, + * {@link SYSTEM_EXCEPTION}, {@link USER_EXCEPTION}, + * {@link LOCATION_FORWARD} or {@link TRANSPORT_RETRY}. + */ + short reply_status(); + + /** + * Get the request id. + * + * @return an id that uniquely identifies the current request/reply sequence. + */ + int request_id(); + + /** + * Indicates whether request sender expected any response. + * + * @return true if the response was expected, false otherwise. + */ + boolean response_expected(); + + /** + * Get the result of the operation invocation. + * + * @return an Any, containing the value, returned by the performed operation. + */ + Any result(); + + /** + * Determines how far the request shall progress before control is returned to + * the client. However up till JDK 1.5 inclusive this method always returns + * SYNC_WITH_TRANSPORT. + * + * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always. + * + * @specnote as defined in the Suns 1.5 JDK API. + */ + short sync_scope(); +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/SUCCESSFUL.java b/org/omg/PortableInterceptor/SUCCESSFUL.java index 15cc32fbd..d26e032ab 100644 --- a/org/omg/PortableInterceptor/SUCCESSFUL.java +++ b/org/omg/PortableInterceptor/SUCCESSFUL.java @@ -38,6 +38,7 @@ exception statement from your version. */ package org.omg.PortableInterceptor; + /** * A reply status flag, indicating, that the remote method * has been called and returned without exception. @@ -50,4 +51,4 @@ public interface SUCCESSFUL * Specifies the SUCCESSFUL value, 0. */ short value = 0; -} +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/SYSTEM_EXCEPTION.java b/org/omg/PortableInterceptor/SYSTEM_EXCEPTION.java index a62ade9b1..9edf2ba21 100644 --- a/org/omg/PortableInterceptor/SYSTEM_EXCEPTION.java +++ b/org/omg/PortableInterceptor/SYSTEM_EXCEPTION.java @@ -38,6 +38,7 @@ exception statement from your version. */ package org.omg.PortableInterceptor; + /** * A reply status flag, indicating, that the * {@link org.omg.CORBA.SystemException} @@ -51,4 +52,4 @@ public interface SYSTEM_EXCEPTION * Specifies the SYSTEM_EXCEPTION value, 1. */ short value = 1; -} +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ServerRequestInfo.java b/org/omg/PortableInterceptor/ServerRequestInfo.java new file mode 100644 index 000000000..2aeba2b41 --- /dev/null +++ b/org/omg/PortableInterceptor/ServerRequestInfo.java @@ -0,0 +1,54 @@ +/* ServerRequestInfo.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * Provides request information, accessible for the + * {@link ServerRequestInterceptor}. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ServerRequestInfo extends ServerRequestInfoOperations, + org.omg.CORBA.Object, + IDLEntity, + RequestInfo +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ServerRequestInfoOperations.java b/org/omg/PortableInterceptor/ServerRequestInfoOperations.java new file mode 100644 index 000000000..7646253d1 --- /dev/null +++ b/org/omg/PortableInterceptor/ServerRequestInfoOperations.java @@ -0,0 +1,302 @@ +/* ServerRequestInfoOperations.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.Any; +import org.omg.CORBA.INV_POLICY; +import org.omg.CORBA.Policy; +import org.omg.IOP.ServiceContext; + +/** + * Provides request information, accessible for the + * {@link ClientRequestInterceptor}. Some methods of this interface are not + * valid at all interception points. The following table shows the validity of + * each method. If it is not valid, BAD_INV_ORDER minor 14 will be thrown. + * + * <table border="1"> + * <tr> + * <th></th> + * <th>{@link ServerRequestInterceptorOperations#receive_request_service_contexts receive_request_<br>service_contexts}</th> + * <th>{@link ServerRequestInterceptorOperations#receive_request receive_request}</th> + * <th>{@link ServerRequestInterceptorOperations#send_reply send_reply}</th> + * <th>{@link ServerRequestInterceptorOperations#send_exception send_exception}</th> + * <th>{@link ServerRequestInterceptorOperations#send_other send_other}</th> + * </tr> + * <tr> + * <td colspan="6" align="center" bgcolor="#E0E0FF"><i>Inherited from + * {@link RequestInfoOperations}:</i></td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#arguments arguments}</th> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="#E0E0E0" title="in and inout only">yes<sub><a href="#1">1</a></sub></td> + * <td>yes</td> + * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">no<sub><a + * href="#2">2</a></sub></td> + * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">no<sub><a + * href="#2">2</a></sub> </td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#exceptions exceptions}</th> + * <td bgcolor="lightgray">no </td> + * <td colspan="4" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#contexts contexts}</th> + * <td bgcolor="lightgray">no </td> + * <td colspan="4" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#operation_context operation_context}</th> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#result result}</th> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#reply_status reply_status}</th> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align="center">yes</td> * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#forward_reference forward_reference}</th> + * <td bgcolor="lightgray" colspan="4" align="center">no</td> + * <td bgcolor="#E0E0E0" title="When reply_status = LOCATION_FORWARD">yes<sub><a + * href="#2">2</a></sub> </td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#get_request_service_context get_request_service_context}</th> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align="center">yes</td> * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#get_reply_service_context get_reply_service_context}</th> + * <td bgcolor="lightgray">no </td> + * <td bgcolor="lightgray">no </td> + * <td colspan="3" align="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#request_id request_id}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#operation operation}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#response_expected response_expected}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#sync_scope sync_scope}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain RequestInfoOperations#get_slot get_slot}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <td colspan="6" align="center" bgcolor="#E0E0FF"> + * <i>ServerRequestInfo-specific:</i></td> + * </tr> + * <tr> + * <th>{@linkplain #get_server_policy get_server_policy}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #add_reply_service_context add_reply_service_context}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #set_slot set_slot}</th> + * <td colspan="5" align ="center">yes</td> + * </tr> + * <tr> + * <th>{@linkplain #sending_exception sending_exception}</th> + * <td bgcolor="lightgray" colspan="3" align="center">no</td> + * <td>yes</td> + * <td bgcolor="lightgray">no </td> + * </tr> + * <tr> + * <th>{@linkplain #object_id object_id}</th> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td>yes</td> + * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a + * href="#3">3</a></sub></td> + * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a + * href="#3">3</a></sub> </td> + * </tr> + * <tr> + * <th>{@linkplain #adapter_id adapter_id}</th> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td>yes</td> + * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a + * href="#3">3</a></sub></td> + * <td bgcolor="#E0E0E0" title="Not always (see note)">yes<sub><a + * href="#3">3</a></sub> </td> + * </tr> + * <tr> + * <th>{@linkplain #target_most_derived_interface target_most_derived_interface}</th> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td bgcolor="lightgray" colspan="3" align="center">no</td> + * </tr> + * <tr> + * <th>{@linkplain #target_is_a target_is_a}</th> + * <td bgcolor="lightgray">no </td> + * <td>yes</td> + * <td bgcolor="lightgray" colspan="3" align="center">no</td> + * </tr> + * <tr> + * <th></th> + * <th>{@link ServerRequestInterceptorOperations#receive_request_service_contexts receive_request_<br>service_contexts }</th> + * <th>{@link ServerRequestInterceptorOperations#receive_request receive_request}</th> + * <th>{@link ServerRequestInterceptorOperations#send_reply send_reply}</th> + * <th>{@link ServerRequestInterceptorOperations#send_exception send_exception}</th> + * <th>{@link ServerRequestInterceptorOperations#send_other send_other}</th> + * </tr> + * </table> + * <ol> + * <li><a name="1">When ServerRequestInfo is passed to receive_request, there + * is an entry in the list for every argument. But only the in and inout + * arguments will be available.</a></li> + * <li><a name="2">If the reply_status attribute is not LOCATION_FORWARD, + * accessing this attribute throws BAD_INV_ORDER minor code of 14.</a></li> + * <li><a name="3">If the servant locator caused a location forward, or thrown + * an exception, this attribute/operation may not be available (NO_RESOURCES + * with a standard minor code of 1 will be thrown).</a></li> + * </ol> + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ServerRequestInfoOperations extends RequestInfoOperations +{ + /** + * Allows the interceptor to add service contexts to the request. Such added + * contexts can carry arbitrary data and can be later accessed on the client + * side by the client request interceptor using + * {@link RequestInfoOperations#get_reply_service_context}. + * + * @param service_context the context to add. + * @param replace if true, the existing context with the same Id will be + * replaced. If false, the BAD_INV_ORDER will be thrown in that case. + * + * @throws BAD_INV_ORDER minor 15 if the context with the same Id already + * exists and replace=false. + */ + void add_reply_service_context(ServiceContext service_context, + boolean replace + ); + + /** + * Get the identifier for the object adapter (POA). + */ + byte[] adapter_id(); + + /** + * Get the object_id describing the target of the operation invocation. + */ + byte[] object_id(); + + /** + * Return the policy of the given type that applies to this operation. This + * method should only be used with policies, produced by the registered + * {@link PolicyFactory}. + * + * @param type the type of the policy being requested. + * + * @return the policy that applies to this operation. + * + * @throws INV_POLICY minor 2 if no factory was registered to produce this + * type of policy or the policy is otherwise invalid. + */ + Policy get_server_policy(int type) throws INV_POLICY; + + /** + * Get the exception to be returned to the client. If the returned Any cannot + * not support holding of that exception, it holds + * {@link org.omg.CORBA.UNKNOWN} minor 1 instead. + * + * @return an Any, holding exception that has been thrown and will be returned + * to client. + */ + Any sending_exception(); + + /** + * Allows the interceptor to set a slot in the PortableInterceptor.Current + * that is in the scope of the request. + * + * @param id the Id of the slot. + * @param data the value of the slot, replacing the previous value. + * + * @throws InvalidSlot if the slot with the given Id does not exist. + * + * @see RequestInfoOperations#get_slot(int) + * @see org.omg.PortableInterceptor#Current + */ + void set_slot(int id, Any data) throws InvalidSlot; + + /** + * Checks if the servant is the given repository id. + * + * @param the repository id to compare. + * + * @return true if the servant repository id matches the parameter, false + * otherwise. + */ + boolean target_is_a(String id); + + /** + * Get the most derived (most specific) repository Id of the servant. + * + * @return the repository id of the servant. + */ + String target_most_derived_interface(); +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ServerRequestInterceptor.java b/org/omg/PortableInterceptor/ServerRequestInterceptor.java new file mode 100644 index 000000000..e74872f6b --- /dev/null +++ b/org/omg/PortableInterceptor/ServerRequestInterceptor.java @@ -0,0 +1,54 @@ +/* ServerRequestInterceptor.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 org.omg.PortableInterceptor; + +import org.omg.CORBA.portable.IDLEntity; + +/** + * A server side request interceptor that is notified on various request + * processing steps on a server side. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ServerRequestInterceptor extends Interceptor, + ServerRequestInterceptorOperations, + org.omg.CORBA.Object, + IDLEntity +{ +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java b/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java new file mode 100644 index 000000000..b57ca28f7 --- /dev/null +++ b/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java @@ -0,0 +1,134 @@ +/* ServerRequestInterceptorOperations.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 org.omg.PortableInterceptor; + + +/** + * Defines operations, applicable to the server side request interceptor. The + * operations are called by ORB at the appropriate interception points. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ServerRequestInterceptorOperations + extends InterceptorOperations +{ + /** + * ORB calls this method before invoking the servant manager. Operation + * parameters are not available at this point. The interceptor has possibility + * to forward the request by throwing {@link ForwardRequest}. + * + * @throws SystemException if it does, the receive_request_service_contexts is + * not called for the subsequent interceptors, calling send_exception instead. + * The completion status of such exception must be COMPLETED_NO. + * + * @throws ForwardRequest to forward the invocation to another target. The + * receive_request_service_contexts is not called for the subsequent + * interceptors, calling send_other instead. + */ + void receive_request_service_contexts(ServerRequestInfo info) + throws ForwardRequest; + + /** + * ORB calls this method after all the information, including operation + * parameters, are available. The interceptor has possibility to forward the + * request by throwing {@link ForwardRequest}. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException if it does, the receive_request is not called for + * the subsequent interceptors, calling send_exception instead. The completion + * status of such exception must be COMPLETED_NO. + * + * @throws ForwardRequest to forward the invocation to another target. The + * receive_request is not called for the subsequent interceptors, calling + * send_other instead. + */ + void receive_request(ServerRequestInfo info) throws ForwardRequest; + + /** + * ORB calls this method after the target operation has been invoked and + * before the reply is returned to the client. This interception point shall + * execute in the same thread as the target invocation. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException if it does, the send_reply is not called for the + * subsequent interceptors, calling send_exception instead. The completion + * status of such exception must be COMPLETED_YES. + */ + void send_reply(ServerRequestInfo info); + + /** + * ORB calls this method if the exception has been throw during the request + * processing. The interceptor has possibility to forward the request by + * throwing {@link ForwardRequest}. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException has the effect of changing the exception that + * successive interceptors receive on their calls to send_exception. If the + * original exception is a system exception, the completion_status of the new + * exception must match the exception being replaced. If the original + * exception is a user exception, then the completion_status of the new + * exception must be COMPLETED_YES. + * + * @throws ForwardRequest to forward the invocation to another target. The + * send_exception is not called for the subsequent interceptors, calling + * send_other instead. If the completion_status of the original exception is + * not a COMPLETED_NO, the ForwardRequest must not be raised. + */ + void send_exception(ServerRequestInfo info) throws ForwardRequest; + + /** + * ORB normally calls this method if the request has been forwarded. + * + * @param info the object for accessing and manipulating the request + * information. + * + * @throws SystemException if it does, the send_other is not called for the + * subsequent interceptors, calling send_exception instead. + * + * @throws ForwardRequest has the effect of changing the redirection that + * successive interceptors receive on their calls to send_other. + */ + void send_other(ServerRequestInfo info) throws ForwardRequest; +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/TRANSPORT_RETRY.java b/org/omg/PortableInterceptor/TRANSPORT_RETRY.java index adc60da19..115cad2fc 100644 --- a/org/omg/PortableInterceptor/TRANSPORT_RETRY.java +++ b/org/omg/PortableInterceptor/TRANSPORT_RETRY.java @@ -38,7 +38,8 @@ exception statement from your version. */ package org.omg.PortableInterceptor; - /** + +/** * A reply status, indicating the necessity of the transport retry. * This may happen, for example, if the GIOP message status flag * is equal to NEEDS_ADDRESSING_MODE. @@ -51,4 +52,4 @@ public interface TRANSPORT_RETRY * Specifies the TRANSPORT_RETRY value, 4. */ short value = 4; -} +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/USER_EXCEPTION.java b/org/omg/PortableInterceptor/USER_EXCEPTION.java index e55793814..02c9535b4 100644 --- a/org/omg/PortableInterceptor/USER_EXCEPTION.java +++ b/org/omg/PortableInterceptor/USER_EXCEPTION.java @@ -38,6 +38,7 @@ exception statement from your version. */ package org.omg.PortableInterceptor; + /** * A reply status flag, indicating, that the * {@link org.omg.CORBA.UserException} @@ -51,4 +52,4 @@ public interface USER_EXCEPTION * Specifies the USER_EXCEPTION value, 2. */ short value = 2; -} +}
\ No newline at end of file diff --git a/org/omg/PortableInterceptor/package.html b/org/omg/PortableInterceptor/package.html new file mode 100644 index 000000000..b29c84fbf --- /dev/null +++ b/org/omg/PortableInterceptor/package.html @@ -0,0 +1,58 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<!-- package.html + Copyright (C) 2005 Free Software Foundation, Inc. + +This file is part of GNU Classpath. + +GNU Classpath is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +GNU Classpath is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Classpath; see the file COPYING. If not, write to the +Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +02110-1301 USA. + +Linking this library statically or dynamically with other modules is +making a combined work based on this library. Thus, the terms and +conditions of the GNU General Public License cover the whole +combination. + +As a special exception, the copyright holders of this library give you +permission to link this library with independent modules to produce an +executable, regardless of the license terms of these independent +modules, and to copy and distribute the resulting executable under +terms of your choice, provided that you also meet, for each linked +independent module, the terms and conditions of the license of that +module. An independent module is a module which is not derived from +or based on this library. If you modify this library, you may extend +this exception to your version of the library, but you are not +obligated to do so. If you do not wish to do so, delete this +exception statement from your version. --> + +<html> +<head><title>GNU Classpath - org.omg.PortableInterceptor</title></head> + +<body> +Interceptors are hooks than can monitor various stages of the CORBA request +processing. The {@link org.omg.PortableInterceptor.IORInterceptor} monitors +all new object refereces (IORs) being created and can add to them additional +information. The {@link org.omg.PortableInterceptor.ClientRequestInterceptor} +monitors request handling on the client side and the +{@link org.omg.PortableInterceptor.ServerRequestInterceptor} monitors request +handling on the server side. The client and server request interceptors can +add additional data to the CORBA message that is accessible on remote side +after the message is transmitted. They can also forward request to another +target. All interceptor functions also work for the local invocations. The +interceptors are registered in ORB.init(...) using +{@link org.omg.PortableInterceptor.ORBInitializer}. + +@author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) +</body> +</html> |