From 3b3101d8b5ae4f08a16c0b7111da6cad41bbd282 Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 15 Nov 2005 23:20:01 +0000 Subject: 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 --- libjava/classpath/gnu/CORBA/Poa/AOM.java | 382 +++++++++++++++++ .../classpath/gnu/CORBA/Poa/AccessiblePolicy.java | 62 +++ .../classpath/gnu/CORBA/Poa/DynamicImpHandler.java | 85 ++++ .../classpath/gnu/CORBA/Poa/ForwardedServant.java | 16 +- libjava/classpath/gnu/CORBA/Poa/LocalDelegate.java | 79 ++-- libjava/classpath/gnu/CORBA/Poa/LocalRequest.java | 42 +- libjava/classpath/gnu/CORBA/Poa/ORB_1_4.java | 51 ++- .../gnu/CORBA/Poa/ServantDelegateImpl.java | 232 ++++++++++ .../classpath/gnu/CORBA/Poa/StandardPolicies.java | 128 ++++++ .../classpath/gnu/CORBA/Poa/activeObjectMap.java | 394 ----------------- libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java | 85 ---- .../gnu/CORBA/Poa/gnuAdapterActivator.java | 2 +- .../gnu/CORBA/Poa/gnuIdAssignmentPolicy.java | 2 +- .../gnu/CORBA/Poa/gnuIdUniquenessPolicy.java | 2 +- .../gnu/CORBA/Poa/gnuImplicitActivationPolicy.java | 2 +- .../classpath/gnu/CORBA/Poa/gnuLifespanPolicy.java | 2 +- libjava/classpath/gnu/CORBA/Poa/gnuPOA.java | 471 +++++++++++++++------ libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java | 60 ++- .../gnu/CORBA/Poa/gnuRequestProcessingPolicy.java | 2 +- .../classpath/gnu/CORBA/Poa/gnuServantObject.java | 60 +-- .../gnu/CORBA/Poa/gnuServantRetentionPolicy.java | 2 +- .../classpath/gnu/CORBA/Poa/gnuThreadPolicy.java | 2 +- libjava/classpath/gnu/CORBA/Poa/policySets.java | 128 ------ .../classpath/gnu/CORBA/Poa/servantDelegate.java | 232 ---------- libjava/classpath/gnu/CORBA/Poa/vPolicy.java | 62 --- 25 files changed, 1432 insertions(+), 1153 deletions(-) create mode 100644 libjava/classpath/gnu/CORBA/Poa/AOM.java create mode 100644 libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java create mode 100644 libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java create mode 100644 libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java create mode 100644 libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java delete mode 100644 libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java delete mode 100644 libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java delete mode 100644 libjava/classpath/gnu/CORBA/Poa/policySets.java delete mode 100644 libjava/classpath/gnu/CORBA/Poa/servantDelegate.java delete mode 100644 libjava/classpath/gnu/CORBA/Poa/vPolicy.java (limited to 'libjava/classpath/gnu/CORBA/Poa') diff --git a/libjava/classpath/gnu/CORBA/Poa/AOM.java b/libjava/classpath/gnu/CORBA/Poa/AOM.java new file mode 100644 index 00000000000..9faf0883ded --- /dev/null +++ b/libjava/classpath/gnu/CORBA/Poa/AOM.java @@ -0,0 +1,382 @@ +/* AOM.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.Poa; + +import gnu.CORBA.ByteArrayComparator; + +import org.omg.PortableServer.Servant; + +import java.util.Iterator; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; + +/** + * Implements the conception of the Active Object Map. + * If the POA supports the RETAIN policy, it maintains an Active + * Object Map, that associates Object Ids with active servants. + * Each association constitutes an active object. We use a single map + * for all POAs on the given orb. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class AOM +{ + /** + * The reference data about the object, placed on the AOM. + */ + public class Obj + { + /** + * Create an initialised instance. + */ + Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, gnuPOA _poa) + { + object = _object; + key = _key; + servant = _servant; + poa = _poa; + } + + /** + * The object. + */ + public final org.omg.CORBA.Object object; + + /** + * The servant, serving the given object. + */ + public Servant servant; + + /** + * The local servant that once served this object. + * This field is used by {@link ForwardedServant} when it discovers that + * the forwarding chaing returns back to the original location. + * It should not be used anywhere else. + */ + Servant primary_servant; + + /** + * The POA, where the object is connected. + */ + public final gnuPOA poa; + + /** + * The object key. + */ + public final byte[] key; + + /** + * If true, this entry is deactivated. + */ + public boolean deactivated; + + /** + * Set the servant value, preserving any non null + * value as the primary servant. + */ + public void setServant(Servant s) + { + if (primary_servant == null) + primary_servant = s; + servant = s; + } + + /** + * Get the servant. + */ + public Servant getServant() + { + return servant; + } + + /** + * Get the deactivation state. + */ + public boolean isDeactiveted() + { + return deactivated; + } + + /** + * Set the deactivation state. + */ + public void setDeactivated(boolean state) + { + deactivated = state; + } + } + + /** + * The free number to give for the next instance. + * This field is incremented each time the + * new collection of the connected objects is created. + * Each collection has its own unique instance number. + */ + private static long free_id; + + /** + * The map of the all connected objects, maps the object key to the + * object. + */ + Map objects = new TreeMap(new ByteArrayComparator()); + + /** + * Get the record of the stored object. If the object is mapped + * several times under the different keys, one of the mappings + * is used. + * + * @param object the stored object + * + * @return the record about the stored object, null if + * this object is not stored here. + */ + public Obj findObject(org.omg.CORBA.Object stored_object) + { + if (stored_object == null) + return null; + + Map.Entry item; + Iterator iter = objects.entrySet().iterator(); + Obj ref; + + while (iter.hasNext()) + { + item = (Map.Entry) iter.next(); + ref = (Obj) item.getValue(); + if (stored_object.equals(ref.object)) + return ref; + } + return null; + } + + /** + * Find the reference info for the given servant. + * If the servant is mapped to several objects, this + * returns the first found occurence. + * + * @param servant a servant to find. + * + * @return the servant/object/POA binding or null if no such found. + */ + public Obj findServant(Servant servant) + { + if (servant == null) + return null; + + Map.Entry item; + Iterator iter = objects.entrySet().iterator(); + Obj ref; + + while (iter.hasNext()) + { + item = (Map.Entry) iter.next(); + ref = (Obj) item.getValue(); + if (servant.equals(ref.servant)) + return ref; + } + return null; + } + + /** + * Find the reference info for the given servant. + * If the servant is mapped to several objects, this + * returns the first found occurence. + * + * @param servant a servant to find. + * @param speficies if to search for the inactive (true) or active + * (false) servant. A servant with unmatching activity is ignored + * by this method. + * + * @return the servant/object/POA binding or null if no such found. + */ + public Obj findServant(Servant servant, boolean inactive) + { + if (servant == null) + return null; + + Map.Entry item; + Iterator iter = objects.entrySet().iterator(); + Obj ref; + + while (iter.hasNext()) + { + item = (Map.Entry) iter.next(); + ref = (Obj) item.getValue(); + if (ref.deactivated == inactive) + if (ref.servant != null) + if (servant.equals(ref.servant)) + return ref; + } + return null; + } + + /** + * Add the new object to the repository. The object key is + * generated automatically. + * + * @param object the object to add. + * @param servant a servant, serving the given object. + * @param poa the poa, where the object is connected. + * + * @return the newly created object record. + */ + public Obj add(org.omg.CORBA.Object object, Servant servant, gnuPOA poa) + { + return add(generateObjectKey(object), object, servant, poa); + } + + /** + * Add the new object to the repository. + * + * @param key the object key. + * @param object the object to add. + * @param servant a servant, serving the given object. + * @param poa the POA, where the object is connected. + */ + public Obj add(byte[] key, org.omg.CORBA.Object object, Servant servant, + gnuPOA poa + ) + { + Obj rec = new Obj(object, key, servant, poa); + objects.put(key, rec); + return rec; + } + + /** + * Add the new object to the repository. + * + * @param delegate the delegate, providing data about the servant, key, POA + * and object. + * @param port the port that this object would take. + */ + public Obj add(ServantDelegateImpl delegate) + { + Obj rec = + new Obj(delegate.object, delegate.servant_id, delegate.servant, + delegate.poa + ); + objects.put(delegate.servant_id, rec); + return rec; + } + + /** + * Put back the definition structure that has probably been removed earlier. + */ + public void put(Obj obj) + { + objects.put(obj.key, obj); + } + + /** + * Get the stored object. + * + * @param key the key (in the byte array form). + * + * @return the matching object, null if none is matching. + */ + public Obj get(byte[] key) + { + return (Obj) objects.get(key); + } + + /** + * Get the map key set. + */ + public Set keySet() + { + return objects.keySet(); + } + + /** + * Remove the given object, indiciating it by the key. + * + * @param object the object to remove. + */ + public void remove(byte[] key) + { + objects.remove(key); + } + + /** + * Generate the object key, unique in the currently + * running java virtual machine. The passed object + * parameter is currently not in use. + * + * @return the generated key. + */ + protected byte[] generateObjectKey(org.omg.CORBA.Object object) + { + byte[] key; + + // The repetetive keys cannot be generated, but theoretically + // the same keys can be passed when calling add(byte[]...). + // Hence we check if the key is not already in the map and, + // if it is, use the subsequent value. + do + { + key = getFreeId(); + } + while (objects.containsKey(key)); + return key; + } + + /** + * Get the next free 8 byte id, surely unique between calls of this + * method for the currently running virtual machine. + */ + public static synchronized byte[] getFreeId() + { + byte[] r = new byte[ 8 ]; + + // Start from the faster-changing. + r [ 0 ] = ((byte) (0xff & free_id)); + r [ 1 ] = ((byte) (0xff & (free_id >> 8))); + r [ 2 ] = ((byte) (0xff & (free_id >> 16))); + r [ 3 ] = ((byte) (0xff & (free_id >> 24))); + r [ 4 ] = ((byte) (0xff & (free_id >> 32))); + r [ 5 ] = ((byte) (0xff & (free_id >> 40))); + r [ 6 ] = ((byte) (0xff & (free_id >> 48))); + r [ 7 ] = ((byte) (0xff & (free_id >> 56))); + + free_id++; + + return r; + } +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java b/libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java new file mode 100644 index 00000000000..44ebaf45351 --- /dev/null +++ b/libjava/classpath/gnu/CORBA/Poa/AccessiblePolicy.java @@ -0,0 +1,62 @@ +/* AccessiblePolicy.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.Poa; + +import org.omg.CORBA.Policy; + +/** + * The Classpath implementation of the policy, providing the policy + * value and the code of the policy type. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface AccessiblePolicy + extends Policy +{ + /** + * Get the value of this policy + */ + java.lang.Object getValue(); + + /** + * Get the integer code of this policy value. + */ + int getCode(); + +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java b/libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java new file mode 100644 index 00000000000..903f8bfbbe1 --- /dev/null +++ b/libjava/classpath/gnu/CORBA/Poa/DynamicImpHandler.java @@ -0,0 +1,85 @@ +/* DynamicImpHandler.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.Poa; + +import org.omg.CORBA.BAD_OPERATION; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.InvokeHandler; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.ResponseHandler; +import org.omg.PortableServer.DynamicImplementation; + +/** + * The InvokeHandler, indicating, that the target is a dynamic + * implementation rather than an invoke handler. These two + * types are not substitutable, but in some methods have possibility + * just to handle them differently. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class DynamicImpHandler + implements InvokeHandler +{ + /** + * The servant that is a dynamic implementation rather than + * invoke handler. + */ + public final DynamicImplementation servant; + + /** + * Create a new instance, wrapping some dyn implementation. + * @param _servant + */ + public DynamicImpHandler(DynamicImplementation _servant) + { + servant = _servant; + } + + /** + * We cannot invoke properly without having parameter info. + * + * @throws BAD_OPERATION, always. + */ + public OutputStream _invoke(String method, InputStream input, + ResponseHandler handler + ) + { + throw new BAD_OPERATION(servant + " is not an InvokeHandler."); + } +} \ No newline at end of file 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 + * this 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/ServantDelegateImpl.java b/libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java new file mode 100644 index 00000000000..e65214d4a9a --- /dev/null +++ b/libjava/classpath/gnu/CORBA/Poa/ServantDelegateImpl.java @@ -0,0 +1,232 @@ +/* ServantDelegateImpl.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.Poa; + +import gnu.CORBA.Unexpected; + +import org.omg.CORBA.NO_IMPLEMENT; +import org.omg.CORBA.ORB; +import org.omg.CORBA.ORBPackage.InvalidName; +import org.omg.CORBA.Object; +import org.omg.PortableServer.CurrentPackage.NoContext; +import org.omg.PortableServer.POA; +import org.omg.PortableServer.POAHelper; +import org.omg.PortableServer.Servant; +import org.omg.PortableServer.portable.Delegate; + +/** + * The implementation of the servant delegate for the locally existing + * servant.The associated servant that must also implement the + * {@link InvokeHandler} interface. Each servant requires a separate + * instance of this delegate and can serve a single object only. + * Hence the fields are final, but the delegate is typically reused + * unless the same servant is connected to different objects. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public class ServantDelegateImpl + implements Delegate +{ + /** + * The servant, associated with this object. + */ + final Servant servant; + + /** + * The servant (not object) id. + */ + final byte[] servant_id; + + /** + * The POA, where the servant is connected. + */ + final gnuPOA poa; + + /** + * The object, exposed as an object, served by this servant. + */ + final gnuServantObject object; + + /** + * Create the delegat for the servant that will be connected to the + * given poa. The method is normally called from inside of gnuPOA. + * The constructor sets the newly created delegate as the delegate to this + * servant by calling Servant._set_delegate. + * + * @param a_poa the poa. + * @param a_servant the servant. + * @param a_servant_id the servant id. + */ + public ServantDelegateImpl(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id) + { + poa = a_poa; + servant = a_servant; + servant_id = a_servant_id; + servant._set_delegate(this); + object = + new gnuServantObject(servant, servant_id, (ORB_1_4) servant._orb(), a_poa); + object._set_delegate(new LocalDelegate(object, poa, a_servant_id)); + } + + /** + * 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(Servant a_servant, String idl_id) + { + same(a_servant); + + String[] maybe = object.repository_ids; + if (maybe == null) + maybe = servant._all_interfaces(poa, object.Id); + for (int i = 0; i < maybe.length; i++) + { + if (maybe [ i ].equals(idl_id)) + return true; + } + return false; + } + + /** + * Return the ORB's default POA. + */ + public POA default_POA(Servant a_servant) + { + same(a_servant); + try + { + return POAHelper.narrow(orb(a_servant).resolve_initial_references("RootPOA")); + } + catch (InvalidName ex) + { + throw new Unexpected(ex); + } + } + + /** + * Get ORB. + */ + public ORB orb(Servant a_servant) + { + same(a_servant); + return poa.orb(); + } + + /** + * Get the object, exposing the servant. + */ + public Object this_object(Servant a_servant) + { + same(a_servant); + try + { + return poa.aom.get(poa.m_orb.currents.get_object_id()).object; + } + catch (NoContext ex) + { + return object; + } + } + + /** + * Not supported. + * + * @specnote Same as for Sun up till 1.5 inclusive. + */ + public Object get_interface_def(Servant a_servant) + { + same(a_servant); + throw new NO_IMPLEMENT(); + } + + /** + * Get the Id of the object being currently served. + */ + public byte[] object_id(Servant a_servant) + { + same(a_servant); + try + { + byte[] id = poa.m_orb.currents.get_object_id(); + return id; + } + catch (NoContext ex) + { + return object.Id; + } + } + + /** + * Always returns false; + */ + public boolean non_existent(Servant a_servant) + { + same(a_servant); + return false; + } + + /** + * Return the associated POA. + */ + public POA poa(Servant a_servant) + { + same(a_servant); + try + { + return poa.m_orb.currents.get_POA(); + } + catch (NoContext ex) + { + return poa; + } + } + + /** + * Checks if the passed servant is the same as the servant, associated with + * this delegate. This class requires a single servant per delegate. + */ + void same(Servant some_servant) + { + if (servant != some_servant) + throw new InternalError("Only one servant per delegate is supported."); + } +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java b/libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java new file mode 100644 index 00000000000..b2edc4056ab --- /dev/null +++ b/libjava/classpath/gnu/CORBA/Poa/StandardPolicies.java @@ -0,0 +1,128 @@ +/* StandardPolicies.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.Poa; + +import org.omg.CORBA.Policy; +import org.omg.PortableServer.IdAssignmentPolicyValue; +import org.omg.PortableServer.IdUniquenessPolicyValue; +import org.omg.PortableServer.ImplicitActivationPolicyValue; +import org.omg.PortableServer.LifespanPolicyValue; +import org.omg.PortableServer.RequestProcessingPolicyValue; +import org.omg.PortableServer.ServantRetentionPolicyValue; +import org.omg.PortableServer.ThreadPolicyValue; + +import java.util.ArrayList; + +/** + * Contains the frequently uset POA policy sets. The policy + * arrays are package private for security reasons, the cloned + * copies are returned. + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +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 AccessiblePolicy[] rootPOASet = + new AccessiblePolicy[] + { + new gnuThreadPolicy(ThreadPolicyValue.ORB_CTRL_MODEL), + new gnuLifespanPolicy(LifespanPolicyValue.TRANSIENT), + new gnuIdUniquenessPolicy(IdUniquenessPolicyValue.UNIQUE_ID), + new gnuIdAssignmentPolicy(IdAssignmentPolicyValue.SYSTEM_ID), + new gnuServantRetentionPolicy(ServantRetentionPolicyValue.RETAIN), + new gnuRequestProcessingPolicy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY), + new gnuImplicitActivationPolicy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION) + }; + + /** + * Return the policy set, applicable for the root POA, as defined + * in OMG specs. + */ + public static Policy[] rootPoa() + { + Policy[] p = new Policy[ rootPOASet.length ]; + System.arraycopy(rootPOASet, 0, p, 0, p.length); + return p; + } + + /** + * Convert the potentially incomplete policy array into array, containing + * the complete policy set. + * + * @param policies the policy list, may be incomplete (even zero size). + * + * @return the complete policy array. The missing, but needed policies + * are added with they default values. + */ + public static Policy[] withDefault(Policy[] policies) + { + ArrayList current = new ArrayList(rootPOASet.length); + Policy p_default; + boolean specified; + + for (int i = 0; i < rootPOASet.length; i++) + { + p_default = rootPOASet [ i ]; + specified = false; + ForThis: + for (int j = 0; j < policies.length; j++) + { + if (policies [ j ].policy_type() == p_default.policy_type()) + { + specified = true; + current.add(policies [ j ]); + break ForThis; + } + } + if (!specified) + current.add(p_default.copy()); + } + + Policy[] complete = new Policy[ current.size() ]; + for (int i = 0; i < complete.length; i++) + { + complete [ i ] = (Policy) current.get(i); + } + return complete; + } +} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java b/libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java deleted file mode 100644 index 1354ba9c5e1..00000000000 --- a/libjava/classpath/gnu/CORBA/Poa/activeObjectMap.java +++ /dev/null @@ -1,394 +0,0 @@ -/* activeObjectMap.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.Poa; - -import gnu.CORBA.ByteArrayComparator; - -import org.omg.PortableServer.POA; -import org.omg.PortableServer.Servant; - -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; - -/** - * Implements the conception of the Active Object Map. - * If the POA supports the RETAIN policy, it maintains an Active - * Object Map, that associates Object Ids with active servants. - * Each association constitutes an active object. We use a single map - * for all POAs on the given orb. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public class activeObjectMap -{ - /** - * The reference data about the object, placed on the AOM. - */ - public class Obj - { - /** - * Create an initialised instance. - */ - Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, POA _poa) - { - object = _object; - key = _key; - servant = _servant; - poa = _poa; - } - - /** - * The object. - */ - public final org.omg.CORBA.Object object; - - /** - * The servant, serving the given object. - */ - public Servant servant; - - /** - * The local servant that once served this object. - * This field is used by {@link ForwardedServant} when it discovers that - * the forwarding chaing returns back to the original location. - * It should not be used anywhere else. - */ - Servant primary_servant; - - /** - * The POA, where the object is connected. - */ - public final POA poa; - - /** - * The object key. - */ - public final byte[] key; - - /** - * If true, this entry is deactivated. - */ - public boolean deactivated; - - /** - * Set the servant value, preserving any non null - * value as the primary servant. - */ - public void setServant(Servant s) - { - if (primary_servant == null) - primary_servant = s; - servant = s; - } - - /** - * Get the servant. - */ - public Servant getServant() - { - return servant; - } - - /** - * Get the deactivation state. - */ - public boolean isDeactiveted() - { - return deactivated; - } - - /** - * Set the deactivation state. - */ - public void setDeactivated(boolean state) - { - 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; - } - } - - /** - * The free number to give for the next instance. - * This field is incremented each time the - * new collection of the connected objects is created. - * Each collection has its own unique instance number. - */ - private static long free_id; - - /** - * The map of the all connected objects, maps the object key to the - * object. - */ - Map objects = new TreeMap(new ByteArrayComparator()); - - /** - * Get the record of the stored object. If the object is mapped - * several times under the different keys, one of the mappings - * is used. - * - * @param object the stored object - * - * @return the record about the stored object, null if - * this object is not stored here. - */ - public Obj findObject(org.omg.CORBA.Object stored_object) - { - if (stored_object == null) - return null; - - Map.Entry item; - Iterator iter = objects.entrySet().iterator(); - Obj ref; - - while (iter.hasNext()) - { - item = (Map.Entry) iter.next(); - ref = (Obj) item.getValue(); - if (stored_object.equals(ref.object)) - return ref; - } - return null; - } - - /** - * Find the reference info for the given servant. - * If the servant is mapped to several objects, this - * returns the first found occurence. - * - * @param servant a servant to find. - * - * @return the servant/object/POA binding or null if no such found. - */ - public Obj findServant(Servant servant) - { - if (servant == null) - return null; - - Map.Entry item; - Iterator iter = objects.entrySet().iterator(); - Obj ref; - - while (iter.hasNext()) - { - item = (Map.Entry) iter.next(); - ref = (Obj) item.getValue(); - if (servant.equals(ref.servant)) - return ref; - } - return null; - } - - /** - * Find the reference info for the given servant. - * If the servant is mapped to several objects, this - * returns the first found occurence. - * - * @param servant a servant to find. - * @param speficies if to search for the inactive (true) or active - * (false) servant. A servant with unmatching activity is ignored - * by this method. - * - * @return the servant/object/POA binding or null if no such found. - */ - public Obj findServant(Servant servant, boolean inactive) - { - if (servant == null) - return null; - - Map.Entry item; - Iterator iter = objects.entrySet().iterator(); - Obj ref; - - while (iter.hasNext()) - { - item = (Map.Entry) iter.next(); - ref = (Obj) item.getValue(); - if (ref.deactivated == inactive) - if (ref.servant != null) - if (servant.equals(ref.servant)) - return ref; - } - return null; - } - - /** - * Add the new object to the repository. The object key is - * generated automatically. - * - * @param object the object to add. - * @param servant a servant, serving the given object. - * @param poa the poa, where the object is connected. - * - * @return the newly created object record. - */ - public Obj add(org.omg.CORBA.Object object, Servant servant, POA poa) - { - return add(generateObjectKey(object), object, servant, poa); - } - - /** - * Add the new object to the repository. - * - * @param key the object key. - * @param object the object to add. - * @param servant a servant, serving the given object. - * @param poa the POA, where the object is connected. - */ - public Obj add(byte[] key, org.omg.CORBA.Object object, Servant servant, - POA poa - ) - { - Obj rec = new Obj(object, key, servant, poa); - objects.put(key, rec); - return rec; - } - - /** - * Add the new object to the repository. - * - * @param delegate the delegate, providing data about the servant, key, POA - * and object. - * @param port the port that this object would take. - */ - public Obj add(servantDelegate delegate) - { - Obj rec = - new Obj(delegate.object, delegate.servant_id, delegate.servant, - delegate.poa - ); - objects.put(delegate.servant_id, rec); - return rec; - } - - /** - * Put back the definition structure that has probably been removed earlier. - */ - public void put(Obj obj) - { - objects.put(obj.key, obj); - } - - /** - * Get the stored object. - * - * @param key the key (in the byte array form). - * - * @return the matching object, null if none is matching. - */ - public Obj get(byte[] key) - { - return (Obj) objects.get(key); - } - - /** - * Get the map key set. - */ - public Set keySet() - { - return objects.keySet(); - } - - /** - * Remove the given object, indiciating it by the key. - * - * @param object the object to remove. - */ - public void remove(byte[] key) - { - objects.remove(key); - } - - /** - * Generate the object key, unique in the currently - * running java virtual machine. The passed object - * parameter is currently not in use. - * - * @return the generated key. - */ - protected byte[] generateObjectKey(org.omg.CORBA.Object object) - { - byte[] key; - - // The repetetive keys cannot be generated, but theoretically - // the same keys can be passed when calling add(byte[]...). - // Hence we check if the key is not already in the map and, - // if it is, use the subsequent value. - do - { - key = getFreeId(); - } - while (objects.containsKey(key)); - return key; - } - - /** - * Get the next free 8 byte id, surely unique between calls of this - * method for the currently running virtual machine. - */ - public static synchronized byte[] getFreeId() - { - byte[] r = new byte[ 8 ]; - - // Start from the faster-changing. - r [ 0 ] = ((byte) (0xff & free_id)); - r [ 1 ] = ((byte) (0xff & (free_id >> 8))); - r [ 2 ] = ((byte) (0xff & (free_id >> 16))); - r [ 3 ] = ((byte) (0xff & (free_id >> 24))); - r [ 4 ] = ((byte) (0xff & (free_id >> 32))); - r [ 5 ] = ((byte) (0xff & (free_id >> 40))); - r [ 6 ] = ((byte) (0xff & (free_id >> 48))); - r [ 7 ] = ((byte) (0xff & (free_id >> 56))); - - free_id++; - - return r; - } -} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java b/libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java deleted file mode 100644 index 1cc3e131cd7..00000000000 --- a/libjava/classpath/gnu/CORBA/Poa/dynImpHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/* dynImpHandler.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.Poa; - -import org.omg.CORBA.BAD_OPERATION; -import org.omg.CORBA.portable.InputStream; -import org.omg.CORBA.portable.InvokeHandler; -import org.omg.CORBA.portable.OutputStream; -import org.omg.CORBA.portable.ResponseHandler; -import org.omg.PortableServer.DynamicImplementation; - -/** - * The InvokeHandler, indicating, that the target is a dynamic - * implementation rather than an invoke handler. These two - * types are not substitutable, but in some methods have possibility - * just to handle them differently. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public class dynImpHandler - implements InvokeHandler -{ - /** - * The servant that is a dynamic implementation rather than - * invoke handler. - */ - public final DynamicImplementation servant; - - /** - * Create a new instance, wrapping some dyn implementation. - * @param _servant - */ - public dynImpHandler(DynamicImplementation _servant) - { - servant = _servant; - } - - /** - * We cannot invoke properly without having parameter info. - * - * @throws BAD_OPERATION, always. - */ - public OutputStream _invoke(String method, InputStream input, - ResponseHandler handler - ) - { - throw new BAD_OPERATION(servant + " is not an InvokeHandler."); - } -} \ No newline at end of file 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 } /** - *

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. - *

- * 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. + *

+ * 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. *

- * + *

+ * 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. + *

+ * * @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 } /** - *

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. - *

- * The remote invocation on the target, belonging to the POA that is - * currently destroyed return the remote exception ({@link TRANSIENT}, - * minor code 4). + *

+ * 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. *

+ *

+ * The remote invocation on the target, belonging to the POA that is currently + * destroyed return the remote exception ({@link TRANSIENT}, minor code 4). + *

+ * * @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 - * active object in the Active Object Map. This method should not - * try to access POA being destroyed. If destroy is called - * multiple times before the destruction completes, - * the etherialization should be invoked only once. - * + * {@link ServantActivatorOperations#etherealize} is called for each active + * object in the Active Object Map. This method should not try to access POA + * being destroyed. If destroy is called multiple times before + * the destruction completes, the etherialization should be invoked only once. + * * @param wait_for_completion if true, the method waits till the POA being - * destroyed completes all current requests and etherialization. If false, - * the method returns immediately. + * destroyed completes all current requests and etherialization. If false, the + * method returns immediately. */ public void destroy(boolean etherealize_objects, boolean wait_for_completion) { + // Notify the IOR interceptors about that the POA is destroyed. + if (m_orb.iIor != null) + m_orb.iIor.adapter_state_changed( + new ObjectReferenceTemplate[] { getReferenceTemplate() }, + NON_EXISTENT.value); + if (wait_for_completion) waitWhileRunning(); + // Nofify the IOR interceptors that the POA is destroyed. + if (m_manager instanceof gnuPOAManager) + { + ((gnuPOAManager) m_manager).poaDestroyed(this); + } + // Put the brake instead of manager, preventing the subsequent // requests. gnuPOAManager g = new gnuPOAManager(); @@ -1328,7 +1452,7 @@ public class gnuPOA keys.addAll(aom.keySet()); byte[] key; - activeObjectMap.Obj obj; + AOM.Obj obj; for (int i = 0; i < keys.size(); i++) { key = (byte[]) keys.get(i); @@ -1348,7 +1472,7 @@ public class gnuPOA POA[] ch = the_children(); for (int i = 0; i < ch.length; i++) { - ch [ i ].destroy(etherealize_objects, wait_for_completion); + ch[i].destroy(etherealize_objects, wait_for_completion); } } @@ -1430,13 +1554,14 @@ public class gnuPOA } /** - * Connect the given delegate under the given key, also calling - * incarnate. + * Connect the given delegate under the given key, also calling incarnate. */ - private void connectDelegate(byte[] object_key, servantDelegate delegate) + private void create_and_connect(byte[] object_key, String repository_id, + ServantDelegateImpl delegate) { aom.add(delegate); - connect_to_orb(object_key, delegate.object); + connect_to_orb(object_key, getReferenceFactory().make_object(repository_id, + object_key)); if (servant_activator != null) incarnate(null, object_key, delegate.servant, false); } @@ -1517,9 +1642,9 @@ public class gnuPOA /** * Recursively searches for the given object in the POA tree. */ - public activeObjectMap.Obj findObject(org.omg.CORBA.Object object) + public AOM.Obj findObject(org.omg.CORBA.Object object) { - activeObjectMap.Obj h = aom.findObject(object); + AOM.Obj h = aom.findObject(object); if (h != null) return h; else @@ -1533,16 +1658,16 @@ public class gnuPOA } return h; } - + /** * Recursively searches for the given key in the POA tree. * @param ior_key the key, ecapsulating both object * and poa ids. * @return */ - public activeObjectMap.Obj findKey(byte[] object_id, byte[] poa_id) + public AOM.Obj findKey(byte[] object_id, byte[] poa_id) { - activeObjectMap.Obj h = null; + AOM.Obj h = null; if (Arrays.equals(poa_id, id())) h = aom.get(object_id); if (h != null) @@ -1563,9 +1688,9 @@ public class gnuPOA * Parses the given key, extracts poa and object id and searches * for such reference. */ - public activeObjectMap.Obj findIorKey(byte[] ior_key) + public AOM.Obj findIorKey(byte[] ior_key) { - cdrBufInput in = new cdrBufInput(ior_key); + BufferredCdrInput in = new BufferredCdrInput(ior_key); int signature = in.read_long(); if (signature != SIGNATURE) return null; @@ -1582,7 +1707,7 @@ public class gnuPOA */ public byte[] toIORKey(byte[] object_id) { - cdrBufOutput buffer = new cdrBufOutput(); + BufferedCdrOutput buffer = new BufferedCdrOutput(); buffer.write_long(SIGNATURE); buffer.write_sequence(object_id); buffer.write_sequence(id()); @@ -1600,7 +1725,7 @@ public class gnuPOA */ public byte[] idFormIor(byte[] ior_key) { - cdrBufInput in = new cdrBufInput(ior_key); + BufferredCdrInput in = new BufferredCdrInput(ior_key); int signature = in.read_long(); if (signature != SIGNATURE) return null; @@ -1612,4 +1737,70 @@ public class gnuPOA else return null; } + + /** + * Recursively searches for the given servant in the POA tree. + */ + public AOM.Obj findServant(Servant servant) + { + AOM.Obj h = aom.findServant(servant); + if (h != null) + return h; + else + { + for (int i = 0; i < children.size(); i++) + { + h = ((gnuPOA) children.get(i)).findServant(servant); + if (h != null) + return h; + } + } + return h; + } + + /** + * Get the object reference template of this POA. + * Instantiate a singleton instance, if required. + */ + public ObjectReferenceTemplate getReferenceTemplate() + { + if (refTemplate == null) + refTemplate = new RefTemplate(); + + return refTemplate; + } + + public ObjectReferenceFactory getReferenceFactory() + { + return m_object_factory; + } + + public void setReferenceFactory(ObjectReferenceFactory factory) + { + m_object_factory = factory; + } + + /** + * Create the object (needed by the factory interface). + */ + public Object make_object(String a_repository_id, byte[] an_object_id) + { + AOM.Obj existing = aom.get(an_object_id); + // The object may already exist. In this case, it is just returned. + if (existing != null && existing.object != null) + return existing.object; + else + { + return new gnuServantObject(new String[] { a_repository_id }, + an_object_id, this, m_orb); + } + } + + /** + * Required by object reference factory ops. + */ + public String[] _truncatable_ids() + { + return ref_template_ids; + } } \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java b/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java index 6c1b5644f36..7710306b748 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuPOAManager.java @@ -40,6 +40,8 @@ package gnu.CORBA.Poa; import org.omg.CORBA.BAD_INV_ORDER; import org.omg.CORBA.LocalObject; +import org.omg.PortableInterceptor.NON_EXISTENT; +import org.omg.PortableInterceptor.ObjectReferenceTemplate; import org.omg.PortableServer.POAManager; import org.omg.PortableServer.POAManagerPackage.AdapterInactive; import org.omg.PortableServer.POAManagerPackage.State; @@ -59,18 +61,22 @@ public class gnuPOAManager extends LocalObject implements POAManager { + /** + * Use serialVersionUID for interoperability. + */ + private static final long serialVersionUID = 1; + /** - * The POAs, controlled by this manager. The members must be instances of - * the gnuAbstractPOA. + * The POAs, controlled by this manager. */ - HashSet POAs = new HashSet(); + private HashSet POAs = new HashSet(); /** * The state of the manager. The newly created manager is always * in the holding state. */ State state = State.HOLDING; - + /** * Get the state of the POA manager. */ @@ -94,6 +100,8 @@ public class gnuPOAManager state = State.ACTIVE; else throw new AdapterInactive(); + + notifyInterceptors(state.value()); } /** @@ -113,6 +121,9 @@ public class gnuPOAManager state = State.HOLDING; else throw new AdapterInactive(); + + notifyInterceptors(state.value()); + if (wait_for_completion) waitForIdle(); } @@ -144,6 +155,9 @@ public class gnuPOAManager if (state == State.INACTIVE) throw new AdapterInactive("Repetetive inactivation"); state = State.INACTIVE; + + notifyInterceptors(state.value()); + if (wait_for_completion) waitForIdle(); @@ -178,6 +192,9 @@ public class gnuPOAManager state = State.DISCARDING; else throw new AdapterInactive(); + + notifyInterceptors(state.value()); + if (wait_for_completion) waitForIdle(); } @@ -193,11 +210,13 @@ public class gnuPOAManager { if (state == State.ACTIVE) throw new BAD_INV_ORDER("The state is active"); - + + gnuPOA poa; Iterator iter = POAs.iterator(); + while (iter.hasNext()) { - gnuPOA poa = (gnuPOA) iter.next(); + poa = (gnuPOA) iter.next(); poa.waitWhileRunning(); } } @@ -222,4 +241,33 @@ public class gnuPOAManager { POAs.remove(poa); } + + /** + * This method is called when POA is destryed. The interceptors are + * notified. + */ + public void poaDestroyed(gnuPOA poa) + { + notifyInterceptors(NON_EXISTENT.value); + } + + /** + * Notify CORBA 3.0 interceptors about the status change. + */ + public synchronized void notifyInterceptors(int new_state) + { + gnuPOA poa; + Iterator iter = POAs.iterator(); + + // The System.identityHashCode is also called in gnuIorInfo. + while (iter.hasNext()) + { + poa = (gnuPOA) iter.next(); + if (poa.m_orb.iIor != null) + { + poa.m_orb.iIor.adapter_manager_state_changed( + System.identityHashCode(this), (short) new_state); + } + } + } } \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java index 5bbcd1321b3..2f77639c698 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuRequestProcessingPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.RequestProcessingPolicyValue; */ public class gnuRequestProcessingPolicy extends _PolicyImplBase - implements RequestProcessingPolicy, vPolicy + implements RequestProcessingPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java b/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java index 1ad98d1cecd..020897a45b4 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuServantObject.java @@ -39,14 +39,17 @@ exception statement from your version. */ package gnu.CORBA.Poa; import gnu.CORBA.GIOP.ReplyHeader; -import gnu.CORBA.IOR_Delegate; -import gnu.CORBA.IOR_contructed_object; +import gnu.CORBA.IorDelegate; +import gnu.CORBA.IorObject; import gnu.CORBA.Interceptor.gnuServerRequestInfo; +import gnu.CORBA.typecodes.RecordTypeCode; +import gnu.CORBA.IOR; +import gnu.CORBA.IorProvider; +import gnu.CORBA.Minor; import gnu.CORBA.ObjectCreator; import gnu.CORBA.Unexpected; -import gnu.CORBA.bufferedResponseHandler; -import gnu.CORBA.recordTypeCode; -import gnu.CORBA.streamReadyHolder; +import gnu.CORBA.ResponseHandlerImpl; +import gnu.CORBA.StreamHolder; import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; @@ -90,7 +93,8 @@ import java.util.Arrays; public class gnuServantObject extends ObjectImpl implements org.omg.CORBA.Object, InvokeHandler, - CurrentOperations + CurrentOperations, + IorProvider { /** * The associated servant that must also implement the {@link InvokeHandler} @@ -144,6 +148,14 @@ public class gnuServantObject extends ObjectImpl poa = a_poa; orb = an_orb; } + + /** + * Get the IOR as it would be for this object. + */ + public IOR getIor() + { + return orb.getLocalIor(this); + } /** * Create a servant object, associated with the passed servant. @@ -257,10 +269,8 @@ public class gnuServantObject extends ObjectImpl } catch (Exception ex) { - ex.printStackTrace(); - BAD_OPERATION bad = - new BAD_OPERATION("Unable to activate", 0x5004, + new BAD_OPERATION("Unable to activate", Minor.Activation, CompletionStatus.COMPLETED_NO ); bad.initCause(ex); @@ -276,7 +286,7 @@ public class gnuServantObject extends ObjectImpl // No servant and no servant manager - throw exception. else { - throw new BAD_OPERATION("Unable to activate", 0x5002, + throw new BAD_OPERATION("Unable to activate", Minor.Activation, CompletionStatus.COMPLETED_NO ); } @@ -294,7 +304,7 @@ public class gnuServantObject extends ObjectImpl } else if (a_servant instanceof DynamicImplementation) { - return new dynImpHandler((DynamicImplementation) a_servant); + return new DynamicImpHandler((DynamicImplementation) a_servant); } else { @@ -402,17 +412,17 @@ public class gnuServantObject extends ObjectImpl boolean intercept = false; ServerRequestInterceptorOperations interceptor = null; gnuServerRequestInfo info = null; - bufferedResponseHandler i_handler = null; + ResponseHandlerImpl i_handler = null; try { if (orb.iServer != null && - r_handler instanceof bufferedResponseHandler + r_handler instanceof ResponseHandlerImpl ) { interceptor = orb.iServer; - i_handler = (bufferedResponseHandler) r_handler; + i_handler = (ResponseHandlerImpl) r_handler; info = new gnuServerRequestInfo(this, i_handler.request_header, @@ -426,7 +436,7 @@ public class gnuServantObject extends ObjectImpl try { CookieHolder cookie = null; - activeObjectMap.Obj self = poa.aom.get(Id); + AOM.Obj self = poa.aom.get(Id); if (poa.servant_locator != null) { @@ -467,18 +477,18 @@ public class gnuServantObject extends ObjectImpl { // In some cases exception is thrown if the delegate is not set. } - if (d instanceof servantDelegate) + if (d instanceof ServantDelegateImpl) { // If the delegate is already set, check maybe we can // reuse the existing instance. - if (((servantDelegate) d).object != this) + if (((ServantDelegateImpl) d).object != this) { - servant._set_delegate(new servantDelegate(servant, poa, Id)); + servant._set_delegate(new ServantDelegateImpl(servant, poa, Id)); } } else { - servant._set_delegate(new servantDelegate(servant, poa, Id)); + servant._set_delegate(new ServantDelegateImpl(servant, poa, Id)); } try @@ -536,13 +546,13 @@ public class gnuServantObject extends ObjectImpl { // Failed due any reason, insert without // helper. - a.insert_Streamable(new streamReadyHolder( + a.insert_Streamable(new StreamHolder( buf.create_input_stream() ) ); - recordTypeCode r = - new recordTypeCode(TCKind.tk_except); + RecordTypeCode r = + new RecordTypeCode(TCKind.tk_except); r.setId(uex_idl); r.setName(ObjectCreator.getDefaultName( uex_idl @@ -774,12 +784,12 @@ public class gnuServantObject extends ObjectImpl gnuServantObject g = (gnuServantObject) other; return orb == g.orb && poa == g.poa && Arrays.equals(Id, g.Id); } - else if (other instanceof IOR_contructed_object) + else if (other instanceof IorObject) { - IOR_contructed_object ir = ((IOR_contructed_object) other); + IorObject ir = ((IorObject) other); try { - IOR_Delegate ird = (IOR_Delegate) ir._get_delegate(); + IorDelegate ird = (IorDelegate) ir._get_delegate(); byte[] ior_id = poa.idFormIor(ird.getIor().key); if (ior_id != null && Arrays.equals(ior_id, Id)) { diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java index 009e70e1b35..9fb61ab3f1f 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuServantRetentionPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.ServantRetentionPolicyValue; */ public class gnuServantRetentionPolicy extends _PolicyImplBase - implements ServantRetentionPolicy, vPolicy + implements ServantRetentionPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java b/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java index f42ebefb363..1de94a10145 100644 --- a/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java +++ b/libjava/classpath/gnu/CORBA/Poa/gnuThreadPolicy.java @@ -51,7 +51,7 @@ import org.omg.PortableServer.ThreadPolicyValue; */ public class gnuThreadPolicy extends _PolicyImplBase - implements ThreadPolicy, vPolicy + implements ThreadPolicy, AccessiblePolicy { /** * Use serialVersionUID for interoperability. diff --git a/libjava/classpath/gnu/CORBA/Poa/policySets.java b/libjava/classpath/gnu/CORBA/Poa/policySets.java deleted file mode 100644 index eb688467ae7..00000000000 --- a/libjava/classpath/gnu/CORBA/Poa/policySets.java +++ /dev/null @@ -1,128 +0,0 @@ -/* policySets.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.Poa; - -import org.omg.CORBA.Policy; -import org.omg.PortableServer.IdAssignmentPolicyValue; -import org.omg.PortableServer.IdUniquenessPolicyValue; -import org.omg.PortableServer.ImplicitActivationPolicyValue; -import org.omg.PortableServer.LifespanPolicyValue; -import org.omg.PortableServer.RequestProcessingPolicyValue; -import org.omg.PortableServer.ServantRetentionPolicyValue; -import org.omg.PortableServer.ThreadPolicyValue; - -import java.util.ArrayList; - -/** - * Contains the frequently uset POA policy sets. The policy - * arrays are package private for security reasons, the cloned - * copies are returned. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public class policySets -{ - /** - * 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[] - { - new gnuThreadPolicy(ThreadPolicyValue.ORB_CTRL_MODEL), - new gnuLifespanPolicy(LifespanPolicyValue.TRANSIENT), - new gnuIdUniquenessPolicy(IdUniquenessPolicyValue.UNIQUE_ID), - new gnuIdAssignmentPolicy(IdAssignmentPolicyValue.SYSTEM_ID), - new gnuServantRetentionPolicy(ServantRetentionPolicyValue.RETAIN), - new gnuRequestProcessingPolicy(RequestProcessingPolicyValue.USE_ACTIVE_OBJECT_MAP_ONLY), - new gnuImplicitActivationPolicy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION) - }; - - /** - * Return the policy set, applicable for the root POA, as defined - * in OMG specs. - */ - public static Policy[] rootPoa() - { - Policy[] p = new Policy[ rootPOASet.length ]; - System.arraycopy(rootPOASet, 0, p, 0, p.length); - return p; - } - - /** - * Convert the potentially incomplete policy array into array, containing - * the complete policy set. - * - * @param policies the policy list, may be incomplete (even zero size). - * - * @return the complete policy array. The missing, but needed policies - * are added with they default values. - */ - public static Policy[] withDefault(Policy[] policies) - { - ArrayList current = new ArrayList(rootPOASet.length); - Policy p_default; - boolean specified; - - for (int i = 0; i < rootPOASet.length; i++) - { - p_default = rootPOASet [ i ]; - specified = false; - ForThis: - for (int j = 0; j < policies.length; j++) - { - if (policies [ j ].policy_type() == p_default.policy_type()) - { - specified = true; - current.add(policies [ j ]); - break ForThis; - } - } - if (!specified) - current.add(p_default.copy()); - } - - Policy[] complete = new Policy[ current.size() ]; - for (int i = 0; i < complete.length; i++) - { - complete [ i ] = (Policy) current.get(i); - } - return complete; - } -} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/servantDelegate.java b/libjava/classpath/gnu/CORBA/Poa/servantDelegate.java deleted file mode 100644 index f59c01c6b3e..00000000000 --- a/libjava/classpath/gnu/CORBA/Poa/servantDelegate.java +++ /dev/null @@ -1,232 +0,0 @@ -/* servantDelegate.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.Poa; - -import gnu.CORBA.Unexpected; - -import org.omg.CORBA.NO_IMPLEMENT; -import org.omg.CORBA.ORB; -import org.omg.CORBA.ORBPackage.InvalidName; -import org.omg.CORBA.Object; -import org.omg.PortableServer.CurrentPackage.NoContext; -import org.omg.PortableServer.POA; -import org.omg.PortableServer.POAHelper; -import org.omg.PortableServer.Servant; -import org.omg.PortableServer.portable.Delegate; - -/** - * The implementation of the servant delegate for the locally existing - * servant.The associated servant that must also implement the - * {@link InvokeHandler} interface. Each servant requires a separate - * instance of this delegate and can serve a single object only. - * Hence the fields are final, but the delegate is typically reused - * unless the same servant is connected to different objects. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public class servantDelegate - implements Delegate -{ - /** - * The servant, associated with this object. - */ - final Servant servant; - - /** - * The servant (not object) id. - */ - final byte[] servant_id; - - /** - * The POA, where the servant is connected. - */ - final gnuPOA poa; - - /** - * The object, exposed as an object, served by this servant. - */ - final gnuServantObject object; - - /** - * Create the delegat for the servant that will be connected to the - * given poa. The method is normally called from inside of gnuPOA. - * The constructor sets the newly created delegate as the delegate to this - * servant by calling Servant._set_delegate. - * - * @param a_poa the poa. - * @param a_servant the servant. - * @param a_servant_id the servant id. - */ - public servantDelegate(Servant a_servant, gnuPOA a_poa, byte[] a_servant_id) - { - poa = a_poa; - servant = a_servant; - servant_id = a_servant_id; - servant._set_delegate(this); - object = - new gnuServantObject(servant, servant_id, (ORB_1_4) servant._orb(), a_poa); - object._set_delegate(new LocalDelegate(object, poa, a_servant_id)); - } - - /** - * 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(Servant a_servant, String idl_id) - { - same(a_servant); - - String[] maybe = object.repository_ids; - if (maybe == null) - maybe = servant._all_interfaces(poa, object.Id); - for (int i = 0; i < maybe.length; i++) - { - if (maybe [ i ].equals(idl_id)) - return true; - } - return false; - } - - /** - * Return the ORB's default POA. - */ - public POA default_POA(Servant a_servant) - { - same(a_servant); - try - { - return POAHelper.narrow(orb(a_servant).resolve_initial_references("RootPOA")); - } - catch (InvalidName ex) - { - throw new Unexpected(ex); - } - } - - /** - * Get ORB. - */ - public ORB orb(Servant a_servant) - { - same(a_servant); - return poa.orb(); - } - - /** - * Get the object, exposing the servant. - */ - public Object this_object(Servant a_servant) - { - same(a_servant); - try - { - return poa.aom.get(poa.m_orb.currents.get_object_id()).object; - } - catch (NoContext ex) - { - return object; - } - } - - /** - * Not supported. - * - * @specnote Same as for Sun up till 1.5 inclusive. - */ - public Object get_interface_def(Servant a_servant) - { - same(a_servant); - throw new NO_IMPLEMENT(); - } - - /** - * Get the Id of the object being currently served. - */ - public byte[] object_id(Servant a_servant) - { - same(a_servant); - try - { - byte[] id = poa.m_orb.currents.get_object_id(); - return id; - } - catch (NoContext ex) - { - return object.Id; - } - } - - /** - * Always returns false; - */ - public boolean non_existent(Servant a_servant) - { - same(a_servant); - return false; - } - - /** - * Return the associated POA. - */ - public POA poa(Servant a_servant) - { - same(a_servant); - try - { - return poa.m_orb.currents.get_POA(); - } - catch (NoContext ex) - { - return poa; - } - } - - /** - * Checks if the passed servant is the same as the servant, associated with - * this delegate. This class requires a single servant per delegate. - */ - void same(Servant some_servant) - { - if (servant != some_servant) - throw new InternalError("Only one servant per delegate is supported."); - } -} \ No newline at end of file diff --git a/libjava/classpath/gnu/CORBA/Poa/vPolicy.java b/libjava/classpath/gnu/CORBA/Poa/vPolicy.java deleted file mode 100644 index 9e45b56d7ee..00000000000 --- a/libjava/classpath/gnu/CORBA/Poa/vPolicy.java +++ /dev/null @@ -1,62 +0,0 @@ -/* vPolicy.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.Poa; - -import org.omg.CORBA.Policy; - -/** - * The Classpath implementation of the policy, providing the policy - * value and the code of the policy type. - * - * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) - */ -public interface vPolicy - extends Policy -{ - /** - * Get the value of this policy - */ - java.lang.Object getValue(); - - /** - * Get the integer code of this policy value. - */ - int getCode(); - -} \ No newline at end of file -- cgit v1.2.3