diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-15 23:20:01 +0000 |
| commit | 3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 (patch) | |
| tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/gnu/CORBA/Poa | |
| parent | 7e55c49d7d91ef9f09e93c1100119b1ab3652446 (diff) | |
| download | ppe42-gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.tar.gz ppe42-gcc-3b3101d8b5ae4f08a16c0b7111da6cad41bbd282.zip | |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/CORBA/Poa')
20 files changed, 562 insertions, 283 deletions
diff --git a/libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java b/libjava/classpath/gnu/CORBA/Poa/AOM.java index 1354ba9c5e1..9faf0883ded 100644 --- a/libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java +++ b/libjava/classpath/gnu/CORBA/Poa/AOM.java @@ -1,4 +1,4 @@ -/* activeObjectMap.java -- +/* AOM.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,7 +40,6 @@ package gnu.CORBA.Poa; import gnu.CORBA.ByteArrayComparator; -import org.omg.PortableServer.POA; import org.omg.PortableServer.Servant; import java.util.Iterator; @@ -57,7 +56,7 @@ import java.util.TreeMap; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class activeObjectMap +public class AOM { /** * The reference data about the object, placed on the AOM. @@ -67,7 +66,7 @@ public class activeObjectMap /** * Create an initialised instance. */ - Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, POA _poa) + Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, gnuPOA _poa) { object = _object; key = _key; @@ -96,7 +95,7 @@ public class activeObjectMap /** * The POA, where the object is connected. */ - public final POA poa; + public final gnuPOA poa; /** * The object key. @@ -142,17 +141,6 @@ public class activeObjectMap { deactivated = state; } - - public boolean equals(java.lang.Object other) - { - if (other instanceof Obj) - { - Obj o = (Obj) other; - return o.object.equals(object); - } - else - return false; - } } /** @@ -269,7 +257,7 @@ public class activeObjectMap * * @return the newly created object record. */ - public Obj add(org.omg.CORBA.Object object, Servant servant, POA poa) + public Obj add(org.omg.CORBA.Object object, Servant servant, gnuPOA poa) { return add(generateObjectKey(object), object, servant, poa); } @@ -283,7 +271,7 @@ public class activeObjectMap * @param poa the POA, where the object is connected. */ public Obj add(byte[] key, org.omg.CORBA.Object object, Servant servant, - POA poa + gnuPOA poa ) { Obj rec = new Obj(object, key, servant, poa); @@ -298,7 +286,7 @@ public class activeObjectMap * and object. * @param port the port that this object would take. */ - public Obj add(servantDelegate delegate) + public Obj add(ServantDelegateImpl delegate) { Obj rec = new Obj(delegate.object, delegate.servant_id, delegate.servant, diff --git a/libjava/classpath/gnu/CORBA/Poa/vPolicy.java b/libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java index 9e45b56d7ee..44ebaf45351 100644 --- a/libjava/classpath/gnu/CORBA/Poa/vPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java @@ -1,4 +1,4 @@ -/* vPolicy.java -- +/* AccessiblePolicy.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -46,7 +46,7 @@ import org.omg.CORBA.Policy; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public interface vPolicy +public interface AccessiblePolicy extends Policy { /** diff --git a/libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java b/libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java index 1cc3e131cd7..903f8bfbbe1 100644 --- a/libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java +++ b/libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java @@ -1,4 +1,4 @@ -/* dynImpHandler.java -- +/* DynamicImpHandler.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -53,7 +53,7 @@ import org.omg.PortableServer.DynamicImplementation; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class dynImpHandler +public class DynamicImpHandler implements InvokeHandler { /** @@ -66,7 +66,7 @@ public class dynImpHandler * Create a new instance, wrapping some dyn implementation. * @param _servant */ - public dynImpHandler(DynamicImplementation _servant) + public DynamicImpHandler(DynamicImplementation _servant) { servant = _servant; } diff --git a/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java b/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java index 2df378df6a4..b1d5eaf8c03 100644 --- a/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java +++ b/libjava/classpath/gnu/CORBA/Poa/ForwardedServant.java @@ -39,8 +39,9 @@ exception statement from your version. */ package gnu.CORBA.Poa; import gnu.CORBA.IOR; -import gnu.CORBA.IOR_Delegate; -import gnu.CORBA.IOR_contructed_object; +import gnu.CORBA.IorDelegate; +import gnu.CORBA.IorObject; +import gnu.CORBA.Minor; import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.CompletionStatus; @@ -101,9 +102,9 @@ public class ForwardedServant ObjectImpl fto = (ObjectImpl) a_ref; // Check maybe the remote side forwarded back to our local object. - if (fto instanceof IOR_contructed_object) + if (fto instanceof IorObject) { - IOR_contructed_object iref = (IOR_contructed_object) fto; + IorObject iref = (IorObject) fto; // Check maybe the IOR is local. ORB t_orb = iref._orb(); @@ -111,13 +112,13 @@ public class ForwardedServant { ORB_1_4 orb = (ORB_1_4) t_orb; Delegate d = iref._get_delegate(); - if (d instanceof IOR_Delegate) + if (d instanceof IorDelegate) { - IOR_Delegate ird = (IOR_Delegate) iref._get_delegate(); + IorDelegate ird = (IorDelegate) iref._get_delegate(); IOR ior = ird.getIor(); if (orb.LOCAL_HOST.equalsIgnoreCase(ior.Internet.host)) { - activeObjectMap.Obj rx = orb.rootPOA.findIorKey(ior.key); + AOM.Obj rx = orb.rootPOA.findIorKey(ior.key); if (rx != null) { if (rx.object == fto || @@ -175,6 +176,7 @@ public class ForwardedServant catch (IOException io_ex) { MARSHAL m = new MARSHAL(); + m.minor = Minor.Forwarding; m.initCause(io_ex); throw m; } diff --git a/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java b/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java index 7af3369d2e8..72dd8f0cf50 100644 --- a/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java +++ b/libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java @@ -38,8 +38,10 @@ exception statement from your version. */ package gnu.CORBA.Poa; -import gnu.CORBA.CDR.cdrOutput; -import gnu.CORBA.streamRequest; +import gnu.CORBA.CDR.AbstractCdrOutput; +import gnu.CORBA.IOR; +import gnu.CORBA.IorProvider; +import gnu.CORBA.StreamBasedRequest; import org.omg.CORBA.ARG_INOUT; import org.omg.CORBA.Bounds; @@ -68,17 +70,22 @@ import java.util.Arrays; * A local delegate, transferring all object requests to the locally available * servant. This class is involved in handling the method invocations on the * local object, obtained by POA.create_reference_with_id. - * + * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate +public class LocalDelegate + extends org.omg.CORBA_2_3.portable.Delegate + implements IorProvider { /** * The same servant as an invocation handler. */ gnuServantObject object; + String operation; - final gnuPOA poa; + + public final gnuPOA poa; + final byte[] Id; /** @@ -91,6 +98,14 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate poa = a_poa; Id = an_id; } + + /** + * Get the IOR of the connected object. + */ + public IOR getIor() + { + return object.getIor(); + } public Request request(org.omg.CORBA.Object target, String method) { @@ -107,8 +122,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate } public boolean is_equivalent(org.omg.CORBA.Object target, - org.omg.CORBA.Object other - ) + org.omg.CORBA.Object other) { if (target == other) return true; @@ -157,9 +171,9 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate /** * Check if this object could be named by the given repository id. - * + * * @param idl_id the repository id to check. - * + * * @return true if it is one of the possible repository ids of this object. */ public boolean is_a(org.omg.CORBA.Object a_servant, String idl_id) @@ -167,7 +181,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate String[] maybe = object._ids(); for (int i = 0; i < maybe.length; i++) { - if (maybe [ i ].equals(idl_id)) + if (maybe[i].equals(idl_id)) return true; } return false; @@ -186,8 +200,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate */ public Request create_request(org.omg.CORBA.Object target, Context context, String method, NVList parameters, NamedValue returns, - ExceptionList exceptions, ContextList ctx_list - ) + ExceptionList exceptions, ContextList ctx_list) { operation = method; @@ -204,8 +217,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate * Create request for using with DII. */ public Request create_request(org.omg.CORBA.Object target, Context context, - String method, NVList parameters, NamedValue returns - ) + String method, NVList parameters, NamedValue returns) { operation = method; @@ -226,23 +238,20 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate /** * Create a request to invoke the method of this CORBA object. - * + * * @param operation the name of the method to invoke. * @param response_expected specifies if this is one way message or the * response to the message is expected. - * + * * @return the stream where the method arguments should be written. */ public org.omg.CORBA.portable.OutputStream request( - org.omg.CORBA.Object target, - String method, - boolean response_expected - ) + org.omg.CORBA.Object target, String method, boolean response_expected) { operation = method; // Check if the object is not explicitly deactivated. - activeObjectMap.Obj e = poa.aom.get(Id); + AOM.Obj e = poa.aom.get(Id); if (e != null && e.isDeactiveted()) { if (poa.servant_activator != null || poa.servant_locator != null) @@ -280,7 +289,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate /** * Make an invocation. - * + * * @param target not in use. * @param output the stream request that should be returned by * {@link #m_request} in this method. @@ -292,31 +301,29 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate { try { - streamRequest sr = (streamRequest) output; + StreamBasedRequest sr = (StreamBasedRequest) output; LocalRequest lr = (LocalRequest) sr.request; - InvokeHandler handler = - lr.object.getHandler(lr.operation(), lr.cookie, false); + InvokeHandler handler = lr.object.getHandler(lr.operation(), lr.cookie, + false); - if (handler instanceof dynImpHandler) + if (handler instanceof DynamicImpHandler) { // The local request known how to handle it, but the different // method must be called. lr.invoke(); // The encapsulation will inherit orb, endian, charsets, etc. - cdrOutput buf = sr.createEncapsulation(); + AbstractCdrOutput buf = sr.createEncapsulation(); // Write all request parameters to the buffer stream. if (lr.env().exception() != null) { try { - UnknownUserException uex = - (UnknownUserException) lr.env().exception(); + UnknownUserException uex = (UnknownUserException) lr.env().exception(); throw new ApplicationException(uex.except.type().id(), - uex.except.create_input_stream() - ); + uex.except.create_input_stream()); } catch (BadKind ex) { @@ -334,9 +341,8 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate for (int i = 0; i < lr.arguments().count(); i++) { a = lr.arguments().item(i); - if (a.flags() == ARG_INOUT.value || - a.flags() == ARG_INOUT.value - ) + if (a.flags() == ARG_INOUT.value + || a.flags() == ARG_INOUT.value) { a.value().write_value(buf); } @@ -362,10 +368,7 @@ public class LocalDelegate extends org.omg.CORBA_2_3.portable.Delegate try { return ((ObjectImpl) f.forward_reference)._invoke(f.forward_reference._request( - operation, - true - ) - ); + operation, true)); } catch (RemarshalException e) { diff --git a/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java b/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java index a727499fce5..a2c0bb106c3 100644 --- a/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java +++ b/libjava/classpath/gnu/CORBA/Poa/LocalRequest.java @@ -38,19 +38,19 @@ exception statement from your version. */ package gnu.CORBA.Poa; -import gnu.CORBA.CDR.cdrBufOutput; +import gnu.CORBA.CDR.BufferedCdrOutput; import gnu.CORBA.GIOP.MessageHeader; import gnu.CORBA.GIOP.v1_2.ReplyHeader; import gnu.CORBA.GIOP.v1_2.RequestHeader; import gnu.CORBA.Interceptor.gnuClientRequestInfo; import gnu.CORBA.Interceptor.gnuServerRequestInfo; +import gnu.CORBA.typecodes.RecordTypeCode; import gnu.CORBA.ObjectCreator; import gnu.CORBA.Unexpected; import gnu.CORBA.gnuAny; import gnu.CORBA.gnuRequest; -import gnu.CORBA.recordTypeCode; -import gnu.CORBA.streamReadyHolder; -import gnu.CORBA.streamRequest; +import gnu.CORBA.StreamHolder; +import gnu.CORBA.StreamBasedRequest; import org.omg.CORBA.ARG_OUT; import org.omg.CORBA.Any; @@ -115,7 +115,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, /** * The buffer to write into. */ - cdrBufOutput buffer; + BufferedCdrOutput buffer; /** * The responsible POA. @@ -252,7 +252,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, handler = object.getHandler(operation(), cookie, false); } - cdrBufOutput request_part = new cdrBufOutput(); + BufferedCdrOutput request_part = new BufferedCdrOutput(); request_part.setOrb(orb()); @@ -288,7 +288,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, request_part.create_input_stream(); // Ensure the servant (handler) has a delegate set. - servantDelegate sd = null; + ServantDelegateImpl sd = null; Delegate d = null; @@ -300,19 +300,19 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, { // In some cases exception is thrown if the delegate is not set. } - if (d instanceof servantDelegate) + if (d instanceof ServantDelegateImpl) { // If the delegate is already set, try to reuse the existing // instance. - sd = (servantDelegate) d; + sd = (ServantDelegateImpl) d; if (sd.object != object) { - sd = new servantDelegate(servant, poa, Id); + sd = new ServantDelegateImpl(servant, poa, Id); } } else { - sd = new servantDelegate(servant, poa, Id); + sd = new ServantDelegateImpl(servant, poa, Id); } servant._set_delegate(sd); @@ -368,13 +368,13 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, { // Failed due any reason, insert without // helper. - a.insert_Streamable(new streamReadyHolder( + a.insert_Streamable(new StreamHolder( buf.create_input_stream() ) ); - recordTypeCode r = - new recordTypeCode(TCKind.tk_except); + RecordTypeCode r = + new RecordTypeCode(TCKind.tk_except); r.setId(uex_idl); r.setName(ObjectCreator.getDefaultName(uex_idl)); } @@ -531,9 +531,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, { InvokeHandler handler = object.getHandler(operation(), cookie, false); - if (handler instanceof dynImpHandler) + if (handler instanceof DynamicImpHandler) { - DynamicImplementation dyn = ((dynImpHandler) handler).servant; + DynamicImplementation dyn = ((DynamicImpHandler) handler).servant; if (serverRequest == null) { serverRequest = new LocalServerRequest(this); @@ -589,7 +589,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, // Prepare an Any that will hold the exception. gnuAny exc = new gnuAny(); - exc.insert_Streamable(new streamReadyHolder(input)); + exc.insert_Streamable(new StreamHolder(input)); UnknownUserException unuex = new UnknownUserException(exc); m_environment.exception(unuex); @@ -637,7 +637,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, * * @return the CDR output stream, containing the written output. */ - cdrBufOutput getBuffer() + BufferedCdrOutput getBuffer() { return buffer; } @@ -656,7 +656,7 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, */ private void prepareStream() { - buffer = new cdrBufOutput(); + buffer = new BufferedCdrOutput(); buffer.setOrb(orb()); } @@ -664,9 +664,9 @@ public class LocalRequest extends gnuRequest implements ResponseHandler, * Get the parameter stream, where the invocation arguments should be written * if they are written into the stream directly. */ - public streamRequest getParameterStream() + public StreamBasedRequest getParameterStream() { - m_parameter_buffer = new streamRequest(); + m_parameter_buffer = new StreamBasedRequest(); m_parameter_buffer.request = this; m_parameter_buffer.setOrb(poa.orb()); return m_parameter_buffer; diff --git a/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java b/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java index d95bf2be8f6..bb00aab70eb 100644 --- a/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java +++ b/libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java @@ -38,7 +38,7 @@ exception statement from your version. */ package gnu.CORBA.Poa; -import gnu.CORBA.Functional_ORB; +import gnu.CORBA.OrbFunctional; import gnu.CORBA.IOR; import gnu.CORBA.Connected_objects.cObject; import gnu.CORBA.DynAn.gnuDynAnyFactory; @@ -53,11 +53,13 @@ import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.OBJECT_NOT_EXIST; +import org.omg.CORBA.ORB; import org.omg.CORBA.Policy; import org.omg.CORBA.PolicyError; import org.omg.CORBA.portable.ObjectImpl; import org.omg.PortableInterceptor.PolicyFactory; -import org.omg.PortableServer.POA; +import org.omg.PortableServer.Servant; +import org.omg.PortableServer.POAManagerPackage.State; import org.omg.PortableServer.POAPackage.InvalidPolicy; import java.applet.Applet; @@ -69,7 +71,7 @@ import java.util.Properties; * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ public class ORB_1_4 - extends Functional_ORB + extends OrbFunctional { /** * The root POA. @@ -100,7 +102,7 @@ public class ORB_1_4 super(); try { - rootPOA = new gnuPOA(null, "RootPOA", null, policySets.rootPoa(), this); + rootPOA = new gnuPOA(null, "RootPOA", null, StandardPolicies.rootPoa(), this); } catch (InvalidPolicy ex) { @@ -130,7 +132,7 @@ public class ORB_1_4 { try { - activeObjectMap.Obj exists = rootPOA.findObject(forObject); + AOM.Obj exists = rootPOA.findObject(forObject); if (exists == null) throw new OBJECT_NOT_EXIST(forObject == null ? "null" : forObject.toString()); @@ -201,9 +203,9 @@ public class ORB_1_4 IOR ior = super.createIOR(ref); if (iIor != null) { - activeObjectMap.Obj obj = rootPOA.findIorKey(ior.key); + AOM.Obj obj = rootPOA.findIorKey(ior.key); - POA poa; + gnuPOA poa; // Null means that the object was connected to the ORB directly. if (obj == null) @@ -215,6 +217,7 @@ public class ORB_1_4 // This may modify the ior. iIor.establish_components(info); + iIor.components_established(info); } return ior; } @@ -252,5 +255,39 @@ public class ORB_1_4 super.set_parameters(para, props); registerInterceptors(props, para); } + + /** + * This method is called by RMI-IIOP {@link javax.rmi.Tie#orb(ORB)}, passing + * <code>this</code> as parameter. The ORB will try to connect that tie as + * one of its objects, if it is not already connected. If the wrapper is an + * instance of Servant this method also activates the root poa (if not already + * active). + */ + public void set_delegate(java.lang.Object wrapper) + { + if (wrapper instanceof org.omg.CORBA.Object) + { + org.omg.CORBA.Object object = (org.omg.CORBA.Object) wrapper; + if (connected_objects.getKey(object) == null) + connect(object); + } + else if (wrapper instanceof Servant) + { + Servant s = (Servant) wrapper; + if (rootPOA.findServant(s) == null) + try + { + rootPOA.servant_to_reference(s); + if (rootPOA.the_POAManager().get_state().value() == State._HOLDING) + rootPOA.the_POAManager().activate(); + } + catch (Exception e) + { + BAD_OPERATION bad = new BAD_OPERATION("Unable to connect " + + wrapper + " to " + this); + throw bad; + } + } + } }
\ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/servantDelegate.java b/libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java index f59c01c6b3e..e65214d4a9a 100644 --- a/libjava/classpath/gnu/CORBA/Poa/servantDelegate.java +++ b/libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java @@ -1,4 +1,4 @@ -/* servantDelegate.java -- +/* ServantDelegateImpl.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -60,7 +60,7 @@ import org.omg.PortableServer.portable.Delegate; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class servantDelegate +public class ServantDelegateImpl implements Delegate { /** @@ -93,7 +93,7 @@ public class servantDelegate * @param a_servant the servant. * @param a_servant_id the servant id. */ - public servantDelegate(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id) + public ServantDelegateImpl(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id) { poa = a_poa; servant = a_servant; diff --git a/libjava/classpath/gnu/CORBA/Poa/policySets.java b/libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java index eb688467ae7..b2edc4056ab 100644 --- a/libjava/classpath/gnu/CORBA/Poa/policySets.java +++ b/libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java @@ -1,4 +1,4 @@ -/* policySets.java -- +/* StandardPolicies.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -56,14 +56,14 @@ import java.util.ArrayList; * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */ -public class policySets +public class StandardPolicies { /** * The default policy set, as defined in OMG specs. This is also * the policy set for the root POA. */ - private static final vPolicy[] rootPOASet = - new vPolicy[] + private static final AccessiblePolicy[] rootPOASet = + new AccessiblePolicy[] { new gnuThreadPolicy(ThreadPolicyValue.ORB_CTRL_MODEL), new gnuLifespanPolicy(LifespanPolicyValue.TRANSIENT), diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java b/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java index 3019a2ae966..17d5a0f9e04 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuAdapterActivator.java @@ -69,7 +69,7 @@ public class gnuAdapterActivator { try { - POA n = parent.create_POA(child_name, null, policySets.rootPoa()); + POA n = parent.create_POA(child_name, null, StandardPolicies.rootPoa()); n.the_POAManager().activate(); } catch (Exception ex) diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java index a404486ce70..91531909a6a 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuIdAssignmentPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.IdAssignmentPolicyValue; */ public class gnuIdAssignmentPolicy extends _PolicyImplBase - implements IdAssignmentPolicy, vPolicy + implements IdAssignmentPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java index 2abd1f4845f..0b5fa1420bd 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuIdUniquenessPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.IdUniquenessPolicyValue; */ public class gnuIdUniquenessPolicy extends _PolicyImplBase - implements IdUniquenessPolicy, vPolicy + implements IdUniquenessPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java index 1e539a2c4e0..f1721beef64 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuImplicitActivationPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.ImplicitActivationPolicyValue; */ public class gnuImplicitActivationPolicy extends _PolicyImplBase - implements ImplicitActivationPolicy, vPolicy + implements ImplicitActivationPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java index 97b3f2d7a9b..f26596cd951 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.LifespanPolicyValue; */ public class gnuLifespanPolicy extends _PolicyImplBase - implements LifespanPolicy, vPolicy + implements LifespanPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java b/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java index 1d9e838532a..6f2a019a3bb 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuPOA.java @@ -49,10 +49,15 @@ import org.omg.CORBA.LocalObject; import org.omg.CORBA.NO_IMPLEMENT; import org.omg.CORBA.OBJ_ADAPTER; import org.omg.CORBA.ORB; +import org.omg.CORBA.Object; import org.omg.CORBA.Policy; import org.omg.CORBA.SetOverrideType; import org.omg.CORBA.TRANSIENT; import org.omg.CORBA.portable.ObjectImpl; +import org.omg.PortableInterceptor.NON_EXISTENT; +import org.omg.PortableInterceptor.ObjectReferenceFactory; +import org.omg.PortableInterceptor.ObjectReferenceTemplate; +import org.omg.PortableInterceptor.ObjectReferenceTemplateHelper; import org.omg.PortableServer.AdapterActivator; import org.omg.PortableServer.ForwardRequest; import org.omg.PortableServer.IdAssignmentPolicy; @@ -87,8 +92,10 @@ import org.omg.PortableServer.POAPackage.ServantAlreadyActive; import org.omg.PortableServer.POAPackage.ServantNotActive; import org.omg.PortableServer.POAPackage.WrongAdapter; import org.omg.PortableServer.POAPackage.WrongPolicy; -import gnu.CORBA.CDR.cdrBufInput; -import gnu.CORBA.CDR.cdrBufOutput; + +import gnu.CORBA.OrbFunctional; +import gnu.CORBA.CDR.BufferredCdrInput; +import gnu.CORBA.CDR.BufferedCdrOutput; /** * Our POA implementation. @@ -97,12 +104,108 @@ import gnu.CORBA.CDR.cdrBufOutput; */ public class gnuPOA extends LocalObject - implements POA + implements POA, ObjectReferenceFactory { /** + * The object reference template, associated with this POA. + * + * @since 1.5 + */ + class RefTemplate implements ObjectReferenceTemplate + { + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + RefTemplate() + { + // The adapter name is computed once. + ArrayList names = new ArrayList(); + names.add(the_name()); + + POA poa = the_parent(); + while (poa != null) + { + names.add(poa.the_name()); + poa = poa.the_parent(); + } + + // Fill in the string array in reverse (more natural) order, + // root POA first. + m_adapter_name = new String[names.size()]; + + for (int i = 0; i < m_adapter_name.length; i++) + m_adapter_name[i] = (String) names.get(m_adapter_name.length - i - 1); + } + + /** + * The adapter name + */ + final String[] m_adapter_name; + + /** + * Get the name of this POA. + */ + public String[] adapter_name() + { + return (String[]) m_adapter_name.clone(); + } + + /** + * Get the ORB id. + */ + public String orb_id() + { + return m_orb.orb_id; + } + + /** + * Get the server id. + */ + public String server_id() + { + return OrbFunctional.server_id; + } + + /** + * Create the object. + */ + public Object make_object(String repositoryId, byte[] objectId) + { + return create_reference_with_id(objectId, repositoryId); + } + + /** + * Get the array of truncatible repository ids. + */ + public String[] _truncatable_ids() + { + return ref_template_ids; + } + } + + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + + /** + * The adapter reference template. + */ + ObjectReferenceTemplate refTemplate; + + /** + * The reference template repository ids. Defined outside the class as it + * cannot have static members. + */ + final static String[] ref_template_ids = + new String[] { ObjectReferenceTemplateHelper.id() }; + + /** * The active object map, mapping between object keys, objects and servants. */ - public final activeObjectMap aom = new activeObjectMap(); + public final AOM aom = new AOM(); /** * The children of this POA. @@ -182,6 +285,12 @@ public class gnuPOA * necessity of the frequent checks. */ public final boolean retain_servant; + + /** + * The object reference factory, used to create the new object + * references. + */ + ObjectReferenceFactory m_object_factory = this; /** * Create a new abstract POA. @@ -199,7 +308,7 @@ public class gnuPOA throws InvalidPolicy { // Add default policies. - Policy[] all_policies = policySets.withDefault(a_policies); + Policy[] all_policies = StandardPolicies.withDefault(a_policies); name = a_name; parent = a_parent; @@ -222,12 +331,14 @@ public class gnuPOA for (int i = 0; i < s_policies.length; i++) { s_policies [ i ] = all_policies [ i ].copy(); - m_policies.add(((vPolicy) s_policies [ i ]).getValue()); + m_policies.add(((AccessiblePolicy) s_policies [ i ]).getValue()); } retain_servant = applies(ServantRetentionPolicyValue.RETAIN); validatePolicies(a_policies); + + refTemplate = new RefTemplate(); } /** @@ -281,7 +392,7 @@ public class gnuPOA keys.addAll(aom.keySet()); byte[] key; - activeObjectMap.Obj obj; + AOM.Obj obj; boolean last; for (int i = 0; i < keys.size(); i++) { @@ -422,30 +533,30 @@ public class gnuPOA } /** - * Generate the Object Id for the given servant and add the servant to - * the Active Object Map using this Id a a key. If the servant - * activator is set, its incarnate method will be called. - * - * @param a_servant a servant that would serve the object with the - * returned Object Id. If null is passed, under apporoprate policies the - * servant activator is invoked. - * + * Generate the Object Id for the given servant and add the servant to the + * Active Object Map using this Id a a key. If the servant activator is set, + * its incarnate method will be called. + * + * @param a_servant a servant that would serve the object with the returned + * Object Id. If null is passed, under apporoprate policies the servant + * activator is invoked. + * * @return the generated objert Id for the given servant. - * - * @throws ServantAlreadyActive if this servant is already in the - * Active Object Map and the UNIQUE_ID policy applies. - * - * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN - * do not apply to this POA. + * + * @throws ServantAlreadyActive if this servant is already in the Active + * Object Map and the UNIQUE_ID policy applies. + * + * @throws WrongPolicy if the required policies SYSTEM_ID and RETAIN do not + * apply to this POA. */ public byte[] activate_object(Servant a_servant) - throws ServantAlreadyActive, WrongPolicy + throws ServantAlreadyActive, WrongPolicy { checkDiscarding(); required(ServantRetentionPolicyValue.RETAIN); required(IdAssignmentPolicyValue.SYSTEM_ID); - activeObjectMap.Obj exists = aom.findServant(a_servant); + AOM.Obj exists = aom.findServant(a_servant); if (exists != null) { @@ -464,28 +575,30 @@ public class gnuPOA // activations. } - byte[] object_key = activeObjectMap.getFreeId(); - servantDelegate delegate = new servantDelegate(a_servant, this, object_key); - connectDelegate(object_key, delegate); + byte[] object_key = AOM.getFreeId(); + ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this, + object_key); + create_and_connect(object_key, + a_servant._all_interfaces(this, object_key)[0], delegate); return object_key; } /** - * Add the given servant to the Active Object Map as a servant for the - * object with the provided Object Id. If the servant activator is - * set, its incarnate method will be called. - * + * Add the given servant to the Active Object Map as a servant for the object + * with the provided Object Id. If the servant activator is set, its incarnate + * method will be called. + * * @param an_Object_Id an object id for the given object. - * @param a_servant a servant that will serve the object with the given - * Object Id. If null is passed, under apporoprate policies the - * servant activator is invoked. - * - * @throws ObjectAlreadyActive if the given object id is already in the - * Active Object Map. - * @throws ServantAlreadyActive if the UNIQUE_ID policy applies and - * this servant is already in use. - * @throws WrongPolicy if the required RETAIN policy does not apply to - * this POA. + * @param a_servant a servant that will serve the object with the given Object + * Id. If null is passed, under apporoprate policies the servant activator is + * invoked. + * + * @throws ObjectAlreadyActive if the given object id is already in the Active + * Object Map. + * @throws ServantAlreadyActive if the UNIQUE_ID policy applies and this + * servant is already in use. + * @throws WrongPolicy if the required RETAIN policy does not apply to this + * POA. * @throws BAD_PARAM if the passed object id is invalid due any reason. */ public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant) @@ -496,16 +609,14 @@ public class gnuPOA } /** - * Same as activate_object_with_id, but permits gnuForwardRequest - * forwarding exception. This is used when the activation is called - * from the remote invocation context and we have possibility - * to return the forwarding message. + * Same as activate_object_with_id, but permits gnuForwardRequest forwarding + * exception. This is used when the activation is called from the remote + * invocation context and we have possibility to return the forwarding + * message. */ public void activate_object_with_id(byte[] an_Object_Id, Servant a_servant, - boolean use_forwarding - ) - throws ServantAlreadyActive, ObjectAlreadyActive, - WrongPolicy + boolean use_forwarding) + throws ServantAlreadyActive, ObjectAlreadyActive, WrongPolicy { checkDiscarding(); required(ServantRetentionPolicyValue.RETAIN); @@ -514,12 +625,12 @@ public class gnuPOA // already active. if (applies(IdUniquenessPolicyValue.UNIQUE_ID)) { - activeObjectMap.Obj sx = aom.findServant(a_servant, false); + AOM.Obj sx = aom.findServant(a_servant, false); if (sx != null) throw new ServantAlreadyActive(); } - activeObjectMap.Obj exists = aom.get(an_Object_Id); + AOM.Obj exists = aom.get(an_Object_Id); if (exists != null) { if (exists.servant == null) @@ -537,26 +648,27 @@ public class gnuPOA } else { - servantDelegate delegate = - new servantDelegate(a_servant, this, an_Object_Id); - connectDelegate(an_Object_Id, delegate); + ServantDelegateImpl delegate = new ServantDelegateImpl(a_servant, this, + an_Object_Id); + create_and_connect(an_Object_Id, a_servant._all_interfaces(this, + an_Object_Id)[0], delegate); } } /** * Locate the servant for this object Id and connect it to ORB. - * + * * @param an_Object_Id the object id. * @param a_servant the servant (may be null). * @param exists an existing active object map entry. - * @param use_forwarding allow to throw the gnuForwardRequest - * if the activator throws ForwardRequest. - * - * @throws OBJ_ADAPTER minor 4 if the servant cannot be located - * (the required servant manager may be missing). + * @param use_forwarding allow to throw the gnuForwardRequest if the activator + * throws ForwardRequest. + * + * @throws OBJ_ADAPTER minor 4 if the servant cannot be located (the required + * servant manager may be missing). */ private void locateServant(byte[] an_Object_Id, Servant a_servant, - activeObjectMap.Obj exists, boolean use_forwarding + AOM.Obj exists, boolean use_forwarding ) throws InternalError { @@ -582,8 +694,8 @@ public class gnuPOA throw new OBJ_ADAPTER("no servant", 4, CompletionStatus.COMPLETED_NO); } - servantDelegate delegate = - new servantDelegate(exists.servant, this, an_Object_Id); + ServantDelegateImpl delegate = + new ServantDelegateImpl(exists.servant, this, an_Object_Id); exists.servant._set_delegate(delegate); object.setServant(exists.servant); connect_to_orb(an_Object_Id, delegate.object); @@ -605,7 +717,7 @@ public class gnuPOA { required(ServantRetentionPolicyValue.RETAIN); - activeObjectMap.Obj exists = aom.get(the_Object_Id); + AOM.Obj exists = aom.get(the_Object_Id); if (exists == null || exists.isDeactiveted()) throw new ObjectNotActive(); @@ -615,7 +727,7 @@ public class gnuPOA // Check if this servant is serving something else. aom.remove(the_Object_Id); - activeObjectMap.Obj other = aom.findServant(exists.servant, false); + AOM.Obj other = aom.findServant(exists.servant, false); boolean remaining = other != null; @@ -643,7 +755,7 @@ public class gnuPOA throws WrongPolicy { required(IdAssignmentPolicyValue.SYSTEM_ID); - return create_reference_with_id(activeObjectMap.getFreeId(), a_repository_id); + return create_reference_with_id(AOM.getFreeId(), a_repository_id); } /** @@ -662,8 +774,8 @@ public class gnuPOA * servant. */ public org.omg.CORBA.Object create_reference_with_id(byte[] an_object_id, - String a_repository_id - ) + String a_repository_id + ) { String[] ids; if (a_repository_id == null) @@ -672,7 +784,7 @@ public class gnuPOA ids = new String[] { a_repository_id }; // Check maybe such object is already activated. - activeObjectMap.Obj e = aom.get(an_object_id); + AOM.Obj e = aom.get(an_object_id); Servant servant; if (e == null) @@ -847,7 +959,7 @@ public class gnuPOA return m_poa_id; else { - cdrBufOutput buffer = new cdrBufOutput(); + BufferedCdrOutput buffer = new BufferedCdrOutput(); POA p = this; while (p != null) { @@ -874,7 +986,7 @@ public class gnuPOA { required(ServantRetentionPolicyValue.RETAIN); - activeObjectMap.Obj ref = aom.get(the_Object_Id); + AOM.Obj ref = aom.get(the_Object_Id); if (ref == null) throw new ObjectNotActive(); else @@ -897,7 +1009,7 @@ public class gnuPOA { if (applies(ServantRetentionPolicyValue.RETAIN)) { - activeObjectMap.Obj ref = aom.get(the_Object_Id); + AOM.Obj ref = aom.get(the_Object_Id); if (ref == null || ref.isDeactiveted()) { if (default_servant != null) @@ -932,7 +1044,7 @@ public class gnuPOA public byte[] reference_to_id(org.omg.CORBA.Object the_Object) throws WrongAdapter, WrongPolicy { - activeObjectMap.Obj ref = aom.findObject(the_Object); + AOM.Obj ref = aom.findObject(the_Object); if (ref == null) throw new WrongAdapter(); return ref.key; @@ -958,7 +1070,7 @@ public class gnuPOA { if (applies(ServantRetentionPolicyValue.RETAIN)) { - activeObjectMap.Obj ref = aom.findObject(the_Object); + AOM.Obj ref = aom.findObject(the_Object); if (ref == null) throw new WrongAdapter(); else if (ref.isDeactiveted() || ref.servant == null) @@ -1017,7 +1129,7 @@ public class gnuPOA ) ) { - activeObjectMap.Obj ref = null; + AOM.Obj ref = null; if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID)) ref = aom.findServant(the_Servant); if (ref == null && @@ -1047,31 +1159,31 @@ public class gnuPOA } /** - * <p>Converts the given servant to the object reference. - * The servant will serve all methods, invoked on the returned object. - * The returned object reference can be passed to the remote client, - * enabling remote invocations. - * </p><p> - * If the specified servant is active, it is returned. Otherwise, - * if the POA has the IMPLICIT_ACTIVATION policy the method activates - * the servant. In this case, if the servant activator is set, - * the {@link ServantActivatorOperations#incarnate} method will be called. + * <p> + * Converts the given servant to the object reference. The servant will serve + * all methods, invoked on the returned object. The returned object reference + * can be passed to the remote client, enabling remote invocations. * </p> - * + * <p> + * If the specified servant is active, it is returned. Otherwise, if the POA + * has the IMPLICIT_ACTIVATION policy the method activates the servant. In + * this case, if the servant activator is set, the + * {@link ServantActivatorOperations#incarnate} method will be called. + * </p> + * * @throws ServantNotActive if the servant is inactive and no * IMPLICIT_ACTIVATION policy applies. * @throws WrongPolicy This method needs the RETAIN policy and either the * UNIQUE_ID or IMPLICIT_ACTIVATION policies. - * + * * @return the object, exposing the given servant in the context of this POA. */ public org.omg.CORBA.Object servant_to_reference(Servant the_Servant) - throws ServantNotActive, - WrongPolicy + throws ServantNotActive, WrongPolicy { required(ServantRetentionPolicyValue.RETAIN); - activeObjectMap.Obj exists = null; + AOM.Obj exists = null; if (!applies(IdUniquenessPolicyValue.MULTIPLE_ID)) exists = aom.findServant(the_Servant); @@ -1092,17 +1204,17 @@ public class gnuPOA else return exists.object; } - if (exists == null && - applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION) - ) + if (exists == null + && applies(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION)) { checkDiscarding(); - byte[] object_key = activeObjectMap.getFreeId(); + byte[] object_key = AOM.getFreeId(); - servantDelegate delegate = - new servantDelegate(the_Servant, this, object_key); - connectDelegate(object_key, delegate); + ServantDelegateImpl delegate = new ServantDelegateImpl(the_Servant, + this, object_key); + create_and_connect(object_key, the_Servant._all_interfaces(this, + object_key)[0], delegate); return delegate.object; } @@ -1111,22 +1223,22 @@ public class gnuPOA } /** - * Incarnate in cases when request forwarding is not expected - * because the servant must be provided by the servant activator. - * - * @param x the aom entry, where the object is replaced by - * value, returned by servant activator (if not null). - * + * Incarnate in cases when request forwarding is not expected because the + * servant must be provided by the servant activator. + * + * @param x the aom entry, where the object is replaced by value, returned by + * servant activator (if not null). + * * @param key the object key. - * + * * @param a_servant the servant that was passed as a parameter in the * activation method. - * - * @param use_forwarding if true, the gnuForwardRequest is throw - * under the forwarding exception (for remote client). Otherwise, the - * request is internally redirected (for local invocation). + * + * @param use_forwarding if true, the gnuForwardRequest is throw under the + * forwarding exception (for remote client). Otherwise, the request is + * internally redirected (for local invocation). */ - private Servant incarnate(activeObjectMap.Obj x, byte[] object_key, + private Servant incarnate(AOM.Obj x, byte[] object_key, Servant a_servant, boolean use_forwarding ) { @@ -1281,34 +1393,46 @@ public class gnuPOA } /** - * <p> Destroy this POA and all descendant POAs. The destroyed POAs can be - * later re-created via {@link AdapterActivator} or by invoking - * {@link #create_POA}. - * This differs from {@link PoaManagerOperations#deactivate} that does - * not allow recreation of the deactivated POAs. After deactivation, - * recreation is only possible if the POAs were later destroyed. - * </p><p> - * The remote invocation on the target, belonging to the POA that is - * currently destroyed return the remote exception ({@link TRANSIENT}, - * minor code 4). + * <p> + * Destroy this POA and all descendant POAs. The destroyed POAs can be later + * re-created via {@link AdapterActivator} or by invoking {@link #create_POA}. + * This differs from {@link PoaManagerOperations#deactivate} that does not + * allow recreation of the deactivated POAs. After deactivation, recreation is + * only possible if the POAs were later destroyed. * </p> + * <p> + * The remote invocation on the target, belonging to the POA that is currently + * destroyed return the remote exception ({@link TRANSIENT}, minor code 4). + * </p> + * * @param etherealize_objects if true, and POA has RETAIN policy, and the * servant manager is available, the servant manager method - * {@link ServantActivatorOperations#etherealize} is called for each - * <i>active</i> object in the Active Object Map. This method should not - * try to access POA being destroyed. If <code>destroy</code> is called - * multiple times before the destruction completes, - * the etherialization should be invoked only once. - * + * {@link ServantActivatorOperations#etherealize} is called for each <i>active</i> + * object in the Active Object Map. This method should not try to access POA + * being destroyed. If <code>destroy</code> is called multiple times before + * the destruction completes, the etherialization should be invoked only once. + * * @param wait_for_completion if true, the method waits till the POA being - * destroyed completes all current requests and etherialization. If false, - * the method returns immediately. + * destroyed completes all current requests and etherialization. If false, the + * method returns immediately. */ public void destroy(boolean etherealize_objects, boolean wait_for_completion) { + // Notify the IOR interceptors about that the POA is destroyed. + if (m_orb.iIor != null) + m_orb.iIor.adapter_state_changed( + new ObjectReferenceTemplate[] { getReferenceTemplate() }, + NON_EXISTENT.value); + if (wait_for_completion) waitWhileRunning(); + // Nofify the IOR interceptors that the POA is destroyed. + if (m_manager instanceof gnuPOAManager) + { + ((gnuPOAManager) m_manager).poaDestroyed(this); + } + // Put the brake instead of manager, preventing the subsequent // requests. gnuPOAManager g = new gnuPOAManager(); @@ -1328,7 +1452,7 @@ public class gnuPOA keys.addAll(aom.keySet()); byte[] key; - activeObjectMap.Obj obj; + AOM.Obj obj; for (int i = 0; i < keys.size(); i++) { key = (byte[]) keys.get(i); @@ -1348,7 +1472,7 @@ public class gnuPOA POA[] ch = the_children(); for (int i = 0; i < ch.length; i++) { - ch [ i ].destroy(etherealize_objects, wait_for_completion); + ch[i].destroy(etherealize_objects, wait_for_completion); } } @@ -1430,13 +1554,14 @@ public class gnuPOA } /** - * Connect the given delegate under the given key, also calling - * incarnate. + * Connect the given delegate under the given key, also calling incarnate. */ - private void connectDelegate(byte[] object_key, servantDelegate delegate) + private void create_and_connect(byte[] object_key, String repository_id, + ServantDelegateImpl delegate) { aom.add(delegate); - connect_to_orb(object_key, delegate.object); + connect_to_orb(object_key, getReferenceFactory().make_object(repository_id, + object_key)); if (servant_activator != null) incarnate(null, object_key, delegate.servant, false); } @@ -1517,9 +1642,9 @@ public class gnuPOA /** * Recursively searches for the given object in the POA tree. */ - public activeObjectMap.Obj findObject(org.omg.CORBA.Object object) + public AOM.Obj findObject(org.omg.CORBA.Object object) { - activeObjectMap.Obj h = aom.findObject(object); + AOM.Obj h = aom.findObject(object); if (h != null) return h; else @@ -1533,16 +1658,16 @@ public class gnuPOA } return h; } - + /** * Recursively searches for the given key in the POA tree. * @param ior_key the key, ecapsulating both object * and poa ids. * @return */ - public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id) + public AOM.Obj findKey(byte[] object_id, byte[] poa_id) { - activeObjectMap.Obj h = null; + AOM.Obj h = null; if (Arrays.equals(poa_id, id())) h = aom.get(object_id); if (h != null) @@ -1563,9 +1688,9 @@ public class gnuPOA * Parses the given key, extracts poa and object id and searches * for such reference. */ - public activeObjectMap.Obj findIorKey(byte[] ior_key) + public AOM.Obj findIorKey(byte[] ior_key) { - cdrBufInput in = new cdrBufInput(ior_key); + BufferredCdrInput in = new BufferredCdrInput(ior_key); int signature = in.read_long(); if (signature != SIGNATURE) return null; @@ -1582,7 +1707,7 @@ public class gnuPOA */ public byte[] toIORKey(byte[] object_id) { - cdrBufOutput buffer = new cdrBufOutput(); + BufferedCdrOutput buffer = new BufferedCdrOutput(); buffer.write_long(SIGNATURE); buffer.write_sequence(object_id); buffer.write_sequence(id()); @@ -1600,7 +1725,7 @@ public class gnuPOA */ public byte[] idFormIor(byte[] ior_key) { - cdrBufInput in = new cdrBufInput(ior_key); + BufferredCdrInput in = new BufferredCdrInput(ior_key); int signature = in.read_long(); if (signature != SIGNATURE) return null; @@ -1612,4 +1737,70 @@ public class gnuPOA else return null; } + + /** + * Recursively searches for the given servant in the POA tree. + */ + public AOM.Obj findServant(Servant servant) + { + AOM.Obj h = aom.findServant(servant); + if (h != null) + return h; + else + { + for (int i = 0; i < children.size(); i++) + { + h = ((gnuPOA) children.get(i)).findServant(servant); + if (h != null) + return h; + } + } + return h; + } + + /** + * Get the object reference template of this POA. + * Instantiate a singleton instance, if required. + */ + public ObjectReferenceTemplate getReferenceTemplate() + { + if (refTemplate == null) + refTemplate = new RefTemplate(); + + return refTemplate; + } + + public ObjectReferenceFactory getReferenceFactory() + { + return m_object_factory; + } + + public void setReferenceFactory(ObjectReferenceFactory factory) + { + m_object_factory = factory; + } + + /** + * Create the object (needed by the factory interface). + */ + public Object make_object(String a_repository_id, byte[] an_object_id) + { + AOM.Obj existing = aom.get(an_object_id); + // The object may already exist. In this case, it is just returned. + if (existing != null && existing.object != null) + return existing.object; + else + { + return new gnuServantObject(new String[] { a_repository_id }, + an_object_id, this, m_orb); + } + } + + /** + * Required by object reference factory ops. + */ + public String[] _truncatable_ids() + { + return ref_template_ids; + } }
\ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java b/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java index 6c1b5644f36..7710306b748 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java @@ -40,6 +40,8 @@ package gnu.CORBA.Poa; import org.omg.CORBA.BAD_INV_ORDER; import org.omg.CORBA.LocalObject; +import org.omg.PortableInterceptor.NON_EXISTENT; +import org.omg.PortableInterceptor.ObjectReferenceTemplate; import org.omg.PortableServer.POAManager; import org.omg.PortableServer.POAManagerPackage.AdapterInactive; import org.omg.PortableServer.POAManagerPackage.State; @@ -59,18 +61,22 @@ public class gnuPOAManager extends LocalObject implements POAManager { + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + /** - * The POAs, controlled by this manager. The members must be instances of - * the gnuAbstractPOA. + * The POAs, controlled by this manager. */ - HashSet POAs = new HashSet(); + private HashSet POAs = new HashSet(); /** * The state of the manager. The newly created manager is always * in the holding state. */ State state = State.HOLDING; - + /** * Get the state of the POA manager. */ @@ -94,6 +100,8 @@ public class gnuPOAManager state = State.ACTIVE; else throw new AdapterInactive(); + + notifyInterceptors(state.value()); } /** @@ -113,6 +121,9 @@ public class gnuPOAManager state = State.HOLDING; else throw new AdapterInactive(); + + notifyInterceptors(state.value()); + if (wait_for_completion) waitForIdle(); } @@ -144,6 +155,9 @@ public class gnuPOAManager if (state == State.INACTIVE) throw new AdapterInactive("Repetetive inactivation"); state = State.INACTIVE; + + notifyInterceptors(state.value()); + if (wait_for_completion) waitForIdle(); @@ -178,6 +192,9 @@ public class gnuPOAManager state = State.DISCARDING; else throw new AdapterInactive(); + + notifyInterceptors(state.value()); + if (wait_for_completion) waitForIdle(); } @@ -193,11 +210,13 @@ public class gnuPOAManager { if (state == State.ACTIVE) throw new BAD_INV_ORDER("The state is active"); - + + gnuPOA poa; Iterator iter = POAs.iterator(); + while (iter.hasNext()) { - gnuPOA poa = (gnuPOA) iter.next(); + poa = (gnuPOA) iter.next(); poa.waitWhileRunning(); } } @@ -222,4 +241,33 @@ public class gnuPOAManager { POAs.remove(poa); } + + /** + * This method is called when POA is destryed. The interceptors are + * notified. + */ + public void poaDestroyed(gnuPOA poa) + { + notifyInterceptors(NON_EXISTENT.value); + } + + /** + * Notify CORBA 3.0 interceptors about the status change. + */ + public synchronized void notifyInterceptors(int new_state) + { + gnuPOA poa; + Iterator iter = POAs.iterator(); + + // The System.identityHashCode is also called in gnuIorInfo. + while (iter.hasNext()) + { + poa = (gnuPOA) iter.next(); + if (poa.m_orb.iIor != null) + { + poa.m_orb.iIor.adapter_manager_state_changed( + System.identityHashCode(this), (short) new_state); + } + } + } }
\ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java index 5bbcd1321b3..2f77639c698 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.RequestProcessingPolicyValue; */ public class gnuRequestProcessingPolicy extends _PolicyImplBase - implements RequestProcessingPolicy, vPolicy + implements RequestProcessingPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java b/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java index 1ad98d1cecd..020897a45b4 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java @@ -39,14 +39,17 @@ exception statement from your version. */ package gnu.CORBA.Poa; import gnu.CORBA.GIOP.ReplyHeader; -import gnu.CORBA.IOR_Delegate; -import gnu.CORBA.IOR_contructed_object; +import gnu.CORBA.IorDelegate; +import gnu.CORBA.IorObject; import gnu.CORBA.Interceptor.gnuServerRequestInfo; +import gnu.CORBA.typecodes.RecordTypeCode; +import gnu.CORBA.IOR; +import gnu.CORBA.IorProvider; +import gnu.CORBA.Minor; import gnu.CORBA.ObjectCreator; import gnu.CORBA.Unexpected; -import gnu.CORBA.bufferedResponseHandler; -import gnu.CORBA.recordTypeCode; -import gnu.CORBA.streamReadyHolder; +import gnu.CORBA.ResponseHandlerImpl; +import gnu.CORBA.StreamHolder; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; @@ -90,7 +93,8 @@ import java.util.Arrays; public class gnuServantObject extends ObjectImpl implements org.omg.CORBA.Object, InvokeHandler, - CurrentOperations + CurrentOperations, + IorProvider { /** * The associated servant that must also implement the {@link InvokeHandler} @@ -144,6 +148,14 @@ public class gnuServantObject extends ObjectImpl poa = a_poa; orb = an_orb; } + + /** + * Get the IOR as it would be for this object. + */ + public IOR getIor() + { + return orb.getLocalIor(this); + } /** * Create a servant object, associated with the passed servant. @@ -257,10 +269,8 @@ public class gnuServantObject extends ObjectImpl } catch (Exception ex) { - ex.printStackTrace(); - BAD_OPERATION bad = - new BAD_OPERATION("Unable to activate", 0x5004, + new BAD_OPERATION("Unable to activate", Minor.Activation, CompletionStatus.COMPLETED_NO ); bad.initCause(ex); @@ -276,7 +286,7 @@ public class gnuServantObject extends ObjectImpl // No servant and no servant manager - throw exception. else { - throw new BAD_OPERATION("Unable to activate", 0x5002, + throw new BAD_OPERATION("Unable to activate", Minor.Activation, CompletionStatus.COMPLETED_NO ); } @@ -294,7 +304,7 @@ public class gnuServantObject extends ObjectImpl } else if (a_servant instanceof DynamicImplementation) { - return new dynImpHandler((DynamicImplementation) a_servant); + return new DynamicImpHandler((DynamicImplementation) a_servant); } else { @@ -402,17 +412,17 @@ public class gnuServantObject extends ObjectImpl boolean intercept = false; ServerRequestInterceptorOperations interceptor = null; gnuServerRequestInfo info = null; - bufferedResponseHandler i_handler = null; + ResponseHandlerImpl i_handler = null; try { if (orb.iServer != null && - r_handler instanceof bufferedResponseHandler + r_handler instanceof ResponseHandlerImpl ) { interceptor = orb.iServer; - i_handler = (bufferedResponseHandler) r_handler; + i_handler = (ResponseHandlerImpl) r_handler; info = new gnuServerRequestInfo(this, i_handler.request_header, @@ -426,7 +436,7 @@ public class gnuServantObject extends ObjectImpl try { CookieHolder cookie = null; - activeObjectMap.Obj self = poa.aom.get(Id); + AOM.Obj self = poa.aom.get(Id); if (poa.servant_locator != null) { @@ -467,18 +477,18 @@ public class gnuServantObject extends ObjectImpl { // In some cases exception is thrown if the delegate is not set. } - if (d instanceof servantDelegate) + if (d instanceof ServantDelegateImpl) { // If the delegate is already set, check maybe we can // reuse the existing instance. - if (((servantDelegate) d).object != this) + if (((ServantDelegateImpl) d).object != this) { - servant._set_delegate(new servantDelegate(servant, poa, Id)); + servant._set_delegate(new ServantDelegateImpl(servant, poa, Id)); } } else { - servant._set_delegate(new servantDelegate(servant, poa, Id)); + servant._set_delegate(new ServantDelegateImpl(servant, poa, Id)); } try @@ -536,13 +546,13 @@ public class gnuServantObject extends ObjectImpl { // Failed due any reason, insert without // helper. - a.insert_Streamable(new streamReadyHolder( + a.insert_Streamable(new StreamHolder( buf.create_input_stream() ) ); - recordTypeCode r = - new recordTypeCode(TCKind.tk_except); + RecordTypeCode r = + new RecordTypeCode(TCKind.tk_except); r.setId(uex_idl); r.setName(ObjectCreator.getDefaultName( uex_idl @@ -774,12 +784,12 @@ public class gnuServantObject extends ObjectImpl gnuServantObject g = (gnuServantObject) other; return orb == g.orb && poa == g.poa && Arrays.equals(Id, g.Id); } - else if (other instanceof IOR_contructed_object) + else if (other instanceof IorObject) { - IOR_contructed_object ir = ((IOR_contructed_object) other); + IorObject ir = ((IorObject) other); try { - IOR_Delegate ird = (IOR_Delegate) ir._get_delegate(); + IorDelegate ird = (IorDelegate) ir._get_delegate(); byte[] ior_id = poa.idFormIor(ird.getIor().key); if (ior_id != null && Arrays.equals(ior_id, Id)) { diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java index 009e70e1b35..9fb61ab3f1f 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.ServantRetentionPolicyValue; */ public class gnuServantRetentionPolicy extends _PolicyImplBase - implements ServantRetentionPolicy, vPolicy + implements ServantRetentionPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java index f42ebefb363..1de94a10145 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.ThreadPolicyValue; */ public class gnuThreadPolicy extends _PolicyImplBase - implements ThreadPolicy, vPolicy + implements ThreadPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. |

