diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
commit | 8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch) | |
tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/javax/rmi | |
parent | 02e549bfaaec38f68307e7f34e46ea57ea1809af (diff) | |
download | gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.gz |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
From-SVN: r107049
Diffstat (limited to 'libjava/classpath/javax/rmi')
-rw-r--r-- | libjava/classpath/javax/rmi/BAD_OPERATION.java | 4 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/ClassDesc.java | 33 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/ObjectImpl.java | 9 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/PortableRemoteObjectDelegate.java | 84 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/Stub.java | 170 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/StubDelegate.java | 56 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/SystemException.java | 4 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/Tie.java | 101 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/Util.java | 413 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/UtilDelegate.java | 285 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/ValueHandler.java | 101 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/ValueHandlerMultiFormat.java | 94 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/CORBA/package.html | 36 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/ORB.java | 4 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/PortableRemoteObject.java | 201 | ||||
-rw-r--r-- | libjava/classpath/javax/rmi/package.html | 36 |
16 files changed, 1331 insertions, 300 deletions
diff --git a/libjava/classpath/javax/rmi/BAD_OPERATION.java b/libjava/classpath/javax/rmi/BAD_OPERATION.java deleted file mode 100644 index 36081a47c57..00000000000 --- a/libjava/classpath/javax/rmi/BAD_OPERATION.java +++ /dev/null @@ -1,4 +0,0 @@ -package javax.rmi; - -/** XXX - Stub till we have org.omg.CORBA */ -public class BAD_OPERATION extends Exception { } diff --git a/libjava/classpath/javax/rmi/CORBA/ClassDesc.java b/libjava/classpath/javax/rmi/CORBA/ClassDesc.java index 01befa49339..c8b38ead095 100644 --- a/libjava/classpath/javax/rmi/CORBA/ClassDesc.java +++ b/libjava/classpath/javax/rmi/CORBA/ClassDesc.java @@ -1,5 +1,5 @@ -/* ClassDesc.java -- - Copyright (C) 2002 Free Software Foundation, Inc. +/* ClassDesc.java -- + Copyright (C) 2002, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,16 +40,27 @@ package javax.rmi.CORBA; import java.io.Serializable; -public class ClassDesc - implements Serializable +/** + * This class is used to marshal java.lang.Class objects over IIOP. + * When used as a parameter type, return type, or data member, the Java Class + * is mapped to the OMG IDL type ::javax::rmi::CORBA::ClassDesc. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public class ClassDesc implements Serializable { - /* - * The following is serialized form required by Java API Doc + /** + * Use serialVersionUID (V1.4) for interoperability. */ - private String repid; - private String codebase; + private static final long serialVersionUID = -3477057297839810709L; + + /** + * The class repository Id. + */ + String repid; - public ClassDesc() - { - } + /** + * Space separeted list of URL's from where the code can be downloaded. + */ + String codebase; } diff --git a/libjava/classpath/javax/rmi/CORBA/ObjectImpl.java b/libjava/classpath/javax/rmi/CORBA/ObjectImpl.java deleted file mode 100644 index d76d673cede..00000000000 --- a/libjava/classpath/javax/rmi/CORBA/ObjectImpl.java +++ /dev/null @@ -1,9 +0,0 @@ -package javax.rmi.CORBA; - -/** XXX - Stub till we have org.omg.CORBA */ -public class ObjectImpl -{ - public ObjectImpl _orb() { return null; } - public String object_to_string(ObjectImpl o) - throws javax.rmi.BAD_OPERATION { return null; } -} diff --git a/libjava/classpath/javax/rmi/CORBA/PortableRemoteObjectDelegate.java b/libjava/classpath/javax/rmi/CORBA/PortableRemoteObjectDelegate.java index 9ae45a33d04..2849707632b 100644 --- a/libjava/classpath/javax/rmi/CORBA/PortableRemoteObjectDelegate.java +++ b/libjava/classpath/javax/rmi/CORBA/PortableRemoteObjectDelegate.java @@ -1,5 +1,5 @@ /* PortableRemoteObjectDelegate.java -- Interface supporting PortableRemoteObject - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,23 +43,95 @@ import java.rmi.Remote; import java.rmi.RemoteException; /** - * A delegate is a singleton class that support delegation for method - * implementation in PortableRemoteObject. + * A delegate, implementing the functionality, provided by the + * {@link PortableRemoteObject}. + * + * The default delegate can be altered by setting the system property + * "javax.rmi.CORBA.PortableRemoteObjectClass" to the name of the alternative + * class that must implement {@link PortableRemoteObjectDelegate}. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */ public interface PortableRemoteObjectDelegate { + /** + * <p> + * Makes the remote object <code>target</code> ready for remote + * communication using the same communications runtime as for the passed + * <code>source</code> parameter. Connection normally happens implicitly + * when the object is sent or received as an argument on a remote method call. + * </p> + * <p> + * The target object is connected to the same ORB as source by calling the + * {@link Stub#connect} if it is a stub or by associating its tie with an ORB + * if it is an implementation object. + * </p> + * + * @param target the target object that may be either an RMI/IDL stub or an + * exported RMI/IDL implementation object + * @param source the source object may also be either an RMI/IDL stub or an + * exported RMI/IDL implementation object. + * + * @throws RemoteException if the target is already connected to another ORB. + */ void connect(Remote target, Remote source) throws RemoteException; - + + /** + * Register the passed object with the ORB runtimes, making it remotely + * accessible. When called on jre with no objects exported, creates a + * non-daemon thread that prevents jre from terminating until all objects are + * unexported. Also, such object cannot be collected by garbage collector. + * This is usually impemented via {@link Util#unexportObject} + * + * @param object the object to export. + * + * @throws RemoteException + */ void exportObject(Remote obj) throws RemoteException; + /** + * Narrows the passed object to conform to the given interface or IDL type. + * This method may return different instance and cannot be replaced by the + * direct cast. + * + * @param narrowFrom an object to narrow. + * @param narrowTo a type to that the object must be narrowed. + * + * @return On success, an object of type narrowTo or null, if narrowFrom = + * null. + * + * @throws ClassCastException if no narrowing is possible. + */ Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException; - + + /** + * Takes a server implementation object and returns a stub object that can be + * used to access that server object (target). If the target is connected, the + * returned stub is also connected to the same ORB. If the target is + * unconnected, the returned stub is unconnected. + * + * @param target a server side object. + * @return a stub object that can be used to access that server object. + * + * @throws NoSuchObjectException if a stub cannot be located for the given + * target. + */ Remote toStub(Remote obj) throws NoSuchObjectException; - + + /** + * Deregister a currently exported server object from the ORB runtimes. The + * object to becomes available for garbage collection. This is usually + * impemented via {@link Util#unexportObject} + * + * @param object the object to unexport. + * + * @throws NoSuchObjectException if the passed object is not currently + * exported. + */ void unexportObject(Remote obj) throws NoSuchObjectException; } diff --git a/libjava/classpath/javax/rmi/CORBA/Stub.java b/libjava/classpath/javax/rmi/CORBA/Stub.java index a35a08fa9d3..190b10dad57 100644 --- a/libjava/classpath/javax/rmi/CORBA/Stub.java +++ b/libjava/classpath/javax/rmi/CORBA/Stub.java @@ -1,5 +1,5 @@ -/* Stub.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. +/* Stub.java -- + Copyright (C) 2004, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,7 +39,7 @@ exception statement from your version. */ package javax.rmi.CORBA; import gnu.javax.rmi.CORBA.DelegateFactory; -import gnu.javax.rmi.CORBA.GetDelegateInstanceException; +import gnu.javax.rmi.CORBA.StubDelegateImpl; import java.io.IOException; import java.io.ObjectInputStream; @@ -47,7 +47,27 @@ import java.io.ObjectOutputStream; import java.io.Serializable; import java.rmi.RemoteException; -public abstract class Stub extends ObjectImpl +import javax.rmi.PortableRemoteObject; + +import org.omg.CORBA.ORB; +import org.omg.CORBA_2_3.portable.ObjectImpl; + +/** + * A Stub descendants provide access to the object on the client side. This base + * class implements methods, required for remote or local invocation using CORBA + * mechanisms. The most of the functionality is forwarded to the stub delegate. + * This delegate can be altered by setting the system property + * "javax.rmi.CORBA.StubClass" to the name of the alternative class that must + * implement {@link StubDelegate}. Hence Stub contains two delegates, one for + * Stub-related operations and another inherited from the ObjectImpl. + * + * @specnote GNU Classpath uses separate delegate per each Stub. The delegate + * holds information about the ORB and other data, specific for the each Stub. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public abstract class Stub + extends ObjectImpl implements Serializable { /** @@ -55,69 +75,129 @@ public abstract class Stub extends ObjectImpl */ private static final long serialVersionUID = 1087775603798577179L; - private transient StubDelegate delegate; - - protected Stub() - { - try - { - delegate = (StubDelegate)DelegateFactory.getInstance("Stub"); - } - catch(GetDelegateInstanceException e) - { - delegate = null; - } - } + /** + * The hashcode, computed once (expensive operation). + */ + transient int m_hash = Integer.MIN_VALUE; + + /** + * The stringified reference, computed once (expensive operation). + */ + transient String m_ior; + + /** + * The ORB, where the stub is connected on the client side. + */ + transient ORB m_orb; + /** + * The associated delegate, responsible for the major of the functionality of + * this stub. + */ + static StubDelegate delegate = (StubDelegate) DelegateFactory.getInstance(DelegateFactory.STUB); + + /** + * Returns the same hashcode for all stubs that point to the same remote + * object. + */ public int hashCode() { - if(delegate != null) - return delegate.hashCode(this); - else - return 0; + if (m_hash == Integer.MIN_VALUE) + m_hash = delegate.hashCode(this); + // This should finally result to the IOR comparison. + return m_hash; } - public boolean equals(Object obj) + /** + * The stubs are equal if they point to the same remote object. + */ + public boolean equals(java.lang.Object obj) { - if(delegate != null) - return delegate.equals(this, obj); - else - return false; + return delegate.equals(this, obj); } + /** + * Get the string representation of this Stub. + * + * @return the CORBA IOR reference. + */ public String toString() { - String s = null; - if(delegate != null) - s = delegate.toString(this); - if(s == null) - s = super.toString(); - return s; + if (m_ior == null) + m_ior = delegate.toString(this); + return m_ior; } - // XXX javax.rmi.ORB -> org.omg.CORBA.ORB - public void connect(javax.rmi.ORB orb) + /** + * <p> + * Finds the suitable {@link Tie} for this Stub and connects it to the given + * ORB. The tie is found by the name pattern. If the found tie is derived from + * {@link org.omg.CORBA.PortableServer.Servant}, it is connected to the root + * POA, also activating it (if not already active). + * </p> + * <p> + * This method does not allow to specify, to which POA the found Tie must be + * connected and requires to use the deprecated method {@link ORB#connect}. + * Many useful POA features remain unaccessible. A better alternative it might + * be to generate a {@link org.omg.CORBA.PortableServer.Servant} - derived Tie + * (-poa key in rmic) and connect it to POA in one of the many ways, listed in + * the description of the {@link orb.omg.PortableServer} package). The + * obtained CORBA object can be narrowed into stub using + * {@link PortableRemoteObject#narrow}. + * </p> + * <p> + * It is frequently easier to call {@link PortableRemoteObject#connect} rather + * than this method. + * </p> + * + * @param orb the ORB where the Stub must be connected. + * + * @throws RemoteException if the stub is already connected to some other ORB. + * If the stub is already connected to the ORB that was passed as parameter, + * the method returns without action. + * + * @throws BAD_PARAM if the name of this stub does not match the stub name + * pattern, "_*_Stub" or if the Tie class, "_*Impl_Tie", does not exists or an + * instance of this class cannot be instantiated. + */ + public void connect(ORB orb) throws RemoteException { - if(delegate != null) - delegate.connect(this, orb); + if (m_orb != null && orb != null) + { + if (m_orb.equals(orb)) + throw new RemoteException("Stub " + this + + " is connected to another ORB, " + orb); + else + return; + } + m_orb = orb; + delegate.connect(this, orb); } /** - * The following two routines are required by serialized form of Java API doc. + * Required by serialized form of Java API doc. */ - private void readObject(ObjectInputStream stream) + private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException { - if(delegate != null) - delegate.readObject(this, stream); + if (delegate instanceof StubDelegateImpl) + ((StubDelegateImpl) delegate).readObject(this, input, m_orb); + else + delegate.readObject(this, input); } - private void writeObject(ObjectOutputStream stream) + /** + * Required by serialized form of Java API doc. + */ + private void writeObject(ObjectOutputStream output) throws IOException { - if(delegate != null) - delegate.writeObject(this, stream); - } + // The m_orb in this case may be either known or not. + if (delegate instanceof StubDelegateImpl) + ((StubDelegateImpl) delegate).writeObject(this, output, m_orb); + else -} + delegate.writeObject(this, output); + } +}
\ No newline at end of file diff --git a/libjava/classpath/javax/rmi/CORBA/StubDelegate.java b/libjava/classpath/javax/rmi/CORBA/StubDelegate.java index 5c00a038f0c..cdf76e841c3 100644 --- a/libjava/classpath/javax/rmi/CORBA/StubDelegate.java +++ b/libjava/classpath/javax/rmi/CORBA/StubDelegate.java @@ -1,5 +1,5 @@ -/* StubDelegate.java -- - Copyright (C) 2002 Free Software Foundation, Inc. +/* StubDelegate.java -- + Copyright (C) 2002, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,28 +38,66 @@ exception statement from your version. */ package javax.rmi.CORBA; +import org.omg.CORBA.ORB; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; + import java.rmi.RemoteException; -//import org.omg.CORBA.ORB; +/** + * A delegate, implementing the functionality, provided by the {@link Stub}. + * The default delegate can be altered by setting the system property + * "javax.rmi.CORBA.StubClass" to the name of the alternative class that must + * implement StubDelegate. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ public interface StubDelegate { - - // XXX javax.rmi.ORB -> org.omg.CORBA.ORB - void connect(Stub self, javax.rmi.ORB orb) + /** + * <p> + * Makes the stub ready for remote communication using the given ORB. + * </p> + * <p> + * It is frequently easier to call {@link PortableRemoteObject#connect} rather + * than this method. + * </p> + * + * @param orb the ORB where the Stub must be connected. + * + * @throws RemoteException if the stub is already connected to some other ORB. + * If the stub is already connected to the ORB that was passed as parameter, + * the method returns without action. + */ + void connect(Stub self, ORB orb) throws RemoteException; + /** + * The objects stubs are equal if they refer the same remote object. + */ boolean equals(Stub self, Object obj); + /** + * Get the hashcode fo this delegate. + */ int hashCode(Stub self); + /** + * Read this stub from the object input stream. + */ void readObject(Stub self, ObjectInputStream s) throws IOException, ClassNotFoundException; - String toString(Stub self); - + /** + * Write this stub to the object output stream. + */ void writeObject(Stub self, ObjectOutputStream s) throws IOException; -} + + /** + * Get the string representation of this stub. + */ + String toString(Stub self); +}
\ No newline at end of file diff --git a/libjava/classpath/javax/rmi/CORBA/SystemException.java b/libjava/classpath/javax/rmi/CORBA/SystemException.java deleted file mode 100644 index f8afdc35e35..00000000000 --- a/libjava/classpath/javax/rmi/CORBA/SystemException.java +++ /dev/null @@ -1,4 +0,0 @@ -package javax.rmi.CORBA; - -/** XXX - Stub till we have org.omg.CORBA */ -public class SystemException extends Exception { } diff --git a/libjava/classpath/javax/rmi/CORBA/Tie.java b/libjava/classpath/javax/rmi/CORBA/Tie.java index 4b1984c58e9..b8611838822 100644 --- a/libjava/classpath/javax/rmi/CORBA/Tie.java +++ b/libjava/classpath/javax/rmi/CORBA/Tie.java @@ -1,5 +1,5 @@ -/* Tie.java -- - Copyright (C) 2002 Free Software Foundation, Inc. +/* Tie.java -- + Copyright (C) 2002, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -35,28 +35,91 @@ 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 javax.rmi.CORBA; +import java.rmi.NoSuchObjectException; import java.rmi.Remote; -//import org.omg.CORBA.ORB; -//import org.omg.CORBA.portable.InvokeHandler; +import org.omg.CORBA.ORB; +import org.omg.CORBA.portable.InvokeHandler; -public interface Tie // XXX extends InvokeHandler +/** + * <p> + * A Tie serves as a CORBA Servant or implementation base. It is connected to + * the ORB on a server side, providing the implementation of the required + * functionality. ORB access this implementation using {@link InvokeHandler} + * ._invoke(..). All such calls are finally delegated to the object, returned by + * {@link #getTarget()}. + * </p> + * <p> + * Ties are generated from implementations (name pattern *Impl) and have the + * name pattern _*Impl_Tie, for instance:<br> + * <code>rmic -keep -iiop -poa -always gnu.testlet.java.rmi.Remote.CalculatorImpl</code> + * </p> + * <p> + * Ties should normally be derived from the + * {@link org.omg.PortableServer.Servant}. Such ties are generated by + * <code>rmic</code> compiler using <code>-poa</code> key. Ties can be also + * derived from {@link org.omg.CORBA_2_3.portable.ObjectImpl}. + * </p> + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ +public interface Tie + extends InvokeHandler { - - void deactivate(); - + /** + * Get the invocation target, where all method calls should be delegated. + * + * @return the object, implementing methods, defined in the interface being + * served by this Tie. + */ Remote getTarget(); - // XXX javax.rmi.ORB -> org.omg.CORBA.ORB - javax.rmi.ORB orb(); - - // XXX javax.rmi.ORB -> org.omg.CORBA.ORB - void orb(javax.rmi.ORB orb); - + /** + * Set the invocation target, where all method calls should be delegated. + * + * @param target the object, implementing methods, defined in the interface + * being served by this Tie. The code, produced by a typical rmic compiler + * usually requires the target to be an instance of the implementation from + * that the Tie was generated. + * + * @throws ClassCastException if the passed parameter is not an instance of + * the implementation from that the Tie was generated. + */ void setTarget(Remote target); - - // XXX Object -> org.omg.CORBA.Object - Object thisObject(); -} + + /** + * Get the ORB to that this Tie is connected. + * + * @see org.omg.PortableServer.Servant#_orb + */ + ORB orb(); + + /** + * Connect this Tie to the given ORB. + */ + void orb(ORB orb); + + /** + * Get the object that delegates calls to this tie. + * + * @see org.omg.PortableServer.Servant#_this_object + */ + org.omg.CORBA.Object thisObject(); + + /** + * Deactivate this Tie. The tie is normally deactivated using POA mechanisms. + * Depending on the POA policies, it may be possible to activate the Tie + * again. The ties that are not derived from + * {@link org.omg.PortableServer.Servant} deactivate themselves by + * {@link ORB.disconnect}. + * + * @throws NoSuchObjectException if there are no objects served by this Tie, + * or if the these objects are already deactivated. + * + * @see org.omg.PortableServer.POA#deactivate_object + */ + void deactivate() + throws NoSuchObjectException; + +}
\ No newline at end of file diff --git a/libjava/classpath/javax/rmi/CORBA/Util.java b/libjava/classpath/javax/rmi/CORBA/Util.java index 0370cce83a2..cfd3d7bd686 100644 --- a/libjava/classpath/javax/rmi/CORBA/Util.java +++ b/libjava/classpath/javax/rmi/CORBA/Util.java @@ -1,5 +1,5 @@ -/* Util.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. +/* Util.java -- + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,148 +38,379 @@ exception statement from your version. */ package javax.rmi.CORBA; +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.COMM_FAILURE; +import org.omg.CORBA.CompletionStatus; +import org.omg.CORBA.INVALID_TRANSACTION; +import org.omg.CORBA.INV_OBJREF; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.NO_PERMISSION; +import org.omg.CORBA.OBJECT_NOT_EXIST; +import org.omg.CORBA.OMGVMCID; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.TRANSACTION_REQUIRED; +import org.omg.CORBA.TRANSACTION_ROLLEDBACK; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + import gnu.javax.rmi.CORBA.DelegateFactory; -import gnu.javax.rmi.CORBA.GetDelegateInstanceException; -import java.io.InputStream; -import java.io.OutputStream; +import java.rmi.AccessException; +import java.rmi.MarshalException; +import java.rmi.NoSuchObjectException; import java.rmi.Remote; import java.rmi.RemoteException; +import java.rmi.ServerError; +import java.rmi.ServerException; +import java.rmi.UnexpectedException; +import java.rmi.server.RMIClassLoader; + +import javax.transaction.InvalidTransactionException; +import javax.transaction.TransactionRequiredException; +import javax.transaction.TransactionRolledbackException; +/** + * Provides utility methods used by stubs and ties to perform common operations. + * The functionality is forwarded to the enclosed UtilDelegate. This delegate + * can be altered by setting the system property "javax.rmi.CORBA.UtilClass" to + * the name of the alternative class that must implement {@link UtilDelegate}. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ public class Util { + /** + * The delegate, responsible for all functionality. + */ + static UtilDelegate delegate = (UtilDelegate) DelegateFactory.getInstance(DelegateFactory.UTIL); - private static UtilDelegate delegate; - static - { - try - { - delegate = (UtilDelegate)DelegateFactory.getInstance("Util"); - } - catch(GetDelegateInstanceException e) - { - delegate = null; - } - } - + /** + * Prevents this class from being instantiated. + */ private Util() { } - // XXX - javax.rmi.ORB -> org.omg.CORBA.ORB - public static Object copyObject(Object obj, javax.rmi.ORB orb) + /** + * Used by local stubs to create a copy of the object. The object must be + * Serializable for this operation to succeed. Strings are not copied and + * 1D-3D string arrays are only cloned. + */ + public static java.lang.Object copyObject(java.lang.Object object, ORB orb) throws RemoteException { - if(delegate != null) - return delegate.copyObject(obj, orb); - else - return null; + return delegate.copyObject(object, orb); } - // XXX - javax.rmi.ORB -> org.omg.CORBA.ORB - public static Object[] copyObjects(Object obj[], javax.rmi.ORB orb) + /** + * Used by local stubs to create a multiple copies of the object, preserving + * sharing accross the parameters if necessary. + */ + public static java.lang.Object[] copyObjects(java.lang.Object[] object, + ORB orb) throws RemoteException { - if(delegate != null) - return delegate.copyObjects(obj, orb); - else - return null; + return delegate.copyObjects(object, orb); } - + + /** + * Get the value handler that Serializes Java objects to and from CDR (GIOP) + * streams. + * + * When using the default Util implementation, the class of the returned + * handler can be altered by setting by setting the system property + * "javax.rmi.CORBA.ValueHandlerClass" to the name of the alternative class + * that must implement {@link ValueHandler}. + */ public static ValueHandler createValueHandler() { - if(delegate != null) - return delegate.createValueHandler(); - else - return null; + return delegate.createValueHandler(); } - + + /** + * This call is finally delegated to {@link RMIClassLoader#getClassAnnotation}; + */ public static String getCodebase(Class clz) { - if(delegate != null) - return delegate.getCodebase(clz); - else - return null; + return delegate.getCodebase(clz); } - + + /** + * Get the Tie that handles invocations on the given target. If the target/Tie + * pair has not been previously registered using {@link #registerTarget}, + * this method tries to locate a tie class by the name pattern. If this + * succeeds, the tie-target pair is also registered. + * + * @return the Tie. + */ public static Tie getTie(Remote target) { - if(delegate != null) - return delegate.getTie(target); - else - return null; + return delegate.getTie(target); } + /** + * Checks if the given stub is local. The implementation it delegates call to + * {@link ObjectImpl#_is_local(). + * + * @param stub a stub to check. + * @return true if the stub is local, false otherwise. + * + * @throws RemoteException if the {@link ObjectImpl#_is_local()} throws a + * {@link org.omg.CORBA.SystemException}. + */ public static boolean isLocal(Stub stub) throws RemoteException { - if(delegate != null) - return delegate.isLocal(stub); - else - return false; + return delegate.isLocal(stub); } - public static Class loadClass(String className, String remoteCodebase, ClassLoader loader) + /** + * Load the class. The method uses class loaders from the call stact first. If + * this fails, the further behaviour depends on the System Property + * "java.rmi.server.useCodebaseOnly" with default value "false". + * + * <ul> + * <li>If remoteCodebase is non-null and useCodebaseOnly is "false" then call + * java.rmi.server.RMIClassLoader.loadClass (remoteCodebase, className)</li> + * <li> If remoteCodebase is null or useCodebaseOnly is true then call + * java.rmi.server.RMIClassLoader.loadClass(className)</li> + * <li>If a class is still not successfully loaded and the loader != null + * then try Class.forName(className, false, loader). </li> + * </ul> + * + * @param className the name of the class. + * @param remoteCodebase the codebase. + * @param loader the class loader. + * @return the loaded class. + * + * @throws ClassNotFoundException of the class cannot be loaded. + */ + public static Class loadClass(String className, String remoteCodebase, + ClassLoader loader) throws ClassNotFoundException { - if(delegate != null) - return delegate.loadClass(className, remoteCodebase, loader); - else - throw new ClassNotFoundException(className + ": delegate == null"); - } - - public static RemoteException mapSystemException(SystemException ex) - { - if(delegate != null) - return delegate.mapSystemException(ex); - else - return null; + return delegate.loadClass(className, remoteCodebase, loader); } - public static Object readAny(InputStream in) + /** + * Converts CORBA {@link SystemException} into RMI {@link RemoteException}. + * The exception is converted as defined in the following table: + * <p> + * <table border = "1"> + * <tr> + * <th>CORBA Exception</th> + * <th>RMI Exception</th> + * </tr> + * <tr> + * <td>{@link COMM_FAILURE}</td> + * <td>{@link MarshalException}</td> + * </tr> + * <tr> + * <td>{@link INV_OBJREF}</td> + * <td>{@link NoSuchObjectException}</td> + * </tr> + * <tr> + * <td>{@link NO_PERMISSION}</td> + * <td>{@link AccessException}</td> + * </tr> + * <tr> + * <td>{@link MARSHAL}</td> + * <td>{@link MarshalException}</td> + * </tr> + * <tr> + * <td>{@link BAD_PARAM} (all other cases)</td> + * <td>{@link MarshalException}</td> + * </tr> + * <tr> + * <td>{@link OBJECT_NOT_EXIST}</td> + * <td>{@link NoSuchObjectException}</td> + * </tr> + * <tr> + * <td>{@link TRANSACTION_REQUIRED}</td> + * <td>{@link TransactionRequiredException}</td> + * </tr> + * <tr> + * <td>{@link TRANSACTION_ROLLEDBACK}</td> + * <td>{@link TransactionRolledbackException}</td> + * </tr> + * <tr> + * <td>{@link INVALID_TRANSACTION}</td> + * <td>{@link InvalidTransactionException}</td> + * </tr> + * <tr> + * <td bgcolor="lightgray">Any other {@link SystemException}</td> + * <td bgcolor="lightgray">{@link RemoteException}</td> + * </tr> + * </table> + * </p> + * <p> + * The exception detailed message always consists of + * <ol> + * <li>the string "CORBA "</li> + * <li>the CORBA name of the system exception</li> + * <li>single space</li> + * <li>the hexadecimal value of the system exception's minor code, preceeded + * by 0x (higher bits contain {@link OMGVMCID}).</li> + * <li>single space</li> + * <li>the {@link CompletionStatus} of the exception: "Yes", "No" or "Maybe".</li> + * </ol> + * The subsequent content is not part of the official RMI-IIOP standart and is + * added for compatibility with Sun's implementation: + * <ol> + * <li>the phrase "<code>; nested exception is: <i>(line feed)(tab)</i></code>"</li> + * <li>the full name of the mapped SystemException, as returned by + * Class.getName().</li> + * <li>the ": ". + * <li>the value, returned by .getMessage() of the passed parameter.</li> + * </ol> + * <p> + * For instance, if the Internet connection was refused: + * </p><p> + * <code>CORBA COMM_FAILURE 0x535500C9 No</code> + * </p><p> + * The original CORBA exception is set as the cause of the RemoteException + * being created. + * </p> + */ + public static RemoteException mapSystemException(SystemException ex) { - if(delegate != null) - return delegate.readAny(in); - else - return null; + return delegate.mapSystemException(ex); } + /** + * Register the Tie-target pair. As the Tie is a Servant, it can potentially + * be connected to several objects and hence may be registered with several + * targets. + */ public static void registerTarget(Tie tie, Remote target) { - if(delegate != null) - delegate.registerTarget(tie, target); + delegate.registerTarget(tie, target); } - + + /** + * Deactivate the associated Tie, if it is found and is not connected to other + * registered targets. Independing from the POA policies, the transparent + * reactivation will not be possible. + */ public static void unexportObject(Remote target) + throws NoSuchObjectException { - if(delegate != null) - delegate.unexportObject(target); + delegate.unexportObject(target); } - - public static RemoteException wrapException(Throwable orig) + + /** + * Converts the exception that was thrown by the implementation method on a + * server side into RemoteException that can be transferred and re-thrown on a + * client side. The method converts exceptions as defined in the following + * table: <table border = "1"> + * <tr> + * <th>Exception to map (or subclass)</th> + * <th>Maps into</th> + * </tr> + * <tr> + * <td>{@link Error}</td> + * <td>{@link ServerError}</td> + * </tr> + * <tr> + * <td>{@link RemoteException}</td> + * <td>{@link ServerException}</td> + * </tr> + * <tr> + * <td>{@link SystemException}</td> + * <td>wrapException({@link #mapSystemException})</td> + * </tr> + * <tr> + * <td>{@link RuntimeException}</td> + * <td><b>rethrows</b></td> + * </tr> + * <tr> + * <td>Any other exception</td> + * <td>{@link UnexpectedException}</td> + * </tr> + * </table> + * + * @param ex an exception that was thrown on a server side implementation. + * + * @return the corresponding RemoteException unless it is a RuntimeException. + * + * @throws RuntimeException the passed exception if it is an instance of + * RuntimeException. + * + * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0. + */ + public static RemoteException wrapException(Throwable exception) { - if(delegate != null) - return delegate.wrapException(orig); - else - return null; + return delegate.wrapException(exception); } - - public static void writeAbstractObject(OutputStream out, Object obj) + + /** + * Write abstract interface to the CORBA output stream. The write format is + * matching CORBA abstract interface. Remotes and CORBA objects are written as + * objects, other classes are supposed to be value types and are written as + * such. {@link Remote}s are processed as defined in + * {@link #writeRemoteObject}. The written data contains discriminator, + * defining, that was written. Another method that writes the same content is + * {@link org.omg.CORBA_2_3.portable.OutputStream#write_abstract_interface(java.lang.Object)}. + * + * @param output a stream to write to, must be + * {@link org.omg.CORBA_2_3.portable.OutputStream}. + * + * @param object an object to write, must be CORBA object, Remote + */ + public static void writeAbstractObject(OutputStream output, + java.lang.Object object) { - if(delegate != null) - delegate.writeAbstractObject(out, obj); + delegate.writeAbstractObject(output, object); } - - public static void writeAny(OutputStream out, Object obj) + + /** + * Write the passed java object to the output stream in the form of the CORBA + * {@link Any}. This includes creating an writing the object {@link TypeCode} + * first. Such Any can be later read by a non-RMI-IIOP CORBA implementation + * and manipulated, for instance, by means, provided in + * {@link org.omg.DynamicAny.DynAny}. Depending from the passed value, this + * method writes CORBA object, value type or value box. For value types Null + * is written with the abstract interface, its typecode having repository id + * "IDL:omg.org/CORBA/AbstractBase:1.0" and the empty string name. + * + * @param output the object to write. + * @param object the java object that must be written in the form of the CORBA + * {@link Any}. + */ + public static void writeAny(OutputStream output, java.lang.Object object) { - if(delegate != null) - delegate.writeAny(out, obj); + delegate.writeAny(output, object); } - - public static void writeRemoteObject(OutputStream out, Object obj) + + /** + * Read Any from the input stream. + */ + public static java.lang.Object readAny(InputStream input) { - if(delegate != null) - delegate.writeRemoteObject(out, obj); + return delegate.readAny(input); } -} + /** + * Write the passed parameter to the output stream as CORBA object. If the + * parameter is an instance of Remote and not an instance of Stub, the method + * instantiates a suitable Tie, connects the parameter to this Tie and then + * connects that Tie to the ORB that is requested from the output stream. Then + * the object reference is written to the stream, making remote invocations + * possible (the ORB is started and activated, if required). This method is + * used in write_value(..) method group in + * {@link org.omg.CORBA_2_3.portable.OutputStream} and also may be called + * directly from generated Stubs and Ties. + * + * @param output a stream to write to, must be + * org.omg.CORBA_2_3.portable.OutputStream + * @param object an object to write. + */ + public static void writeRemoteObject(OutputStream output, + java.lang.Object object) + { + delegate.writeRemoteObject(output, object); + } +}
\ No newline at end of file diff --git a/libjava/classpath/javax/rmi/CORBA/UtilDelegate.java b/libjava/classpath/javax/rmi/CORBA/UtilDelegate.java index deeb94f68b5..cacb925810b 100644 --- a/libjava/classpath/javax/rmi/CORBA/UtilDelegate.java +++ b/libjava/classpath/javax/rmi/CORBA/UtilDelegate.java @@ -1,5 +1,5 @@ -/* UtilDelegate.java -- - Copyright (C) 2002 Free Software Foundation, Inc. +/* UtilDelegate.java -- + Copyright (C) 2002, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,48 +38,273 @@ exception statement from your version. */ package javax.rmi.CORBA; -import java.io.InputStream; -import java.io.OutputStream; +import org.omg.CORBA.Any; +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.COMM_FAILURE; +import org.omg.CORBA.CompletionStatus; +import org.omg.CORBA.INVALID_TRANSACTION; +import org.omg.CORBA.INV_OBJREF; +import org.omg.CORBA.MARSHAL; +import org.omg.CORBA.NO_PERMISSION; +import org.omg.CORBA.OBJECT_NOT_EXIST; +import org.omg.CORBA.OMGVMCID; +import org.omg.CORBA.ORB; +import org.omg.CORBA.SystemException; +import org.omg.CORBA.TRANSACTION_REQUIRED; +import org.omg.CORBA.TRANSACTION_ROLLEDBACK; +import org.omg.CORBA.TypeCode; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; + +import java.rmi.AccessException; +import java.rmi.MarshalException; +import java.rmi.NoSuchObjectException; import java.rmi.Remote; import java.rmi.RemoteException; -//import org.omg.CORBA.ORB; -//import org.omg.CORBA.SystemException; -//import org.omg.CORBA.portable.InputStream; -//import org.omg.CORBA.portable.OutputStream; +import java.rmi.ServerError; +import java.rmi.ServerException; +import java.rmi.UnexpectedException; + +import javax.transaction.InvalidTransactionException; +import javax.transaction.TransactionRequiredException; +import javax.transaction.TransactionRolledbackException; +/** + * A delegate, implementing the functionality, provided by the {@link Util}. + * + * The default delegate can be altered by setting the system property + * "javax.rmi.CORBA.UtilClass" to the name of the alternative class that must + * implement this interface. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ public interface UtilDelegate { + /** + * Used by local stubs to create a copy of the object. + */ + Object copyObject(Object obj, ORB orb) + throws RemoteException; - // XXX javax.rmi.ORB -> org.omg.CORBA.ORB - Object copyObject(Object obj, javax.rmi.ORB orb) throws RemoteException; - - // XXX javax.rmi.ORB -> org.omg.CORBA.ORB - Object[] copyObjects(Object obj[], javax.rmi.ORB orb) throws RemoteException; + /** + * Used by local stubs to create a multiple copies of the object, preserving + * sharing accross the parameters if necessary. + */ + Object[] copyObjects(Object[] obj, ORB orb) + throws RemoteException; + /** + * Get the value handler that Serializes Java objects to and from CDR (GIOP) + * streams. + */ ValueHandler createValueHandler(); - + String getCodebase(Class clz); - - Tie getTie(Remote target); - - boolean isLocal(Stub stub) throws RemoteException; - Class loadClass(String className, String remoteCodebase, - ClassLoader loader) throws ClassNotFoundException; + /** + * Checks if the given stub is local. + */ + boolean isLocal(Stub stub) + throws RemoteException; + + Class loadClass(String className, String remoteCodebase, ClassLoader loader) + throws ClassNotFoundException; + /** + * Converts CORBA {@link SystemException} into RMI {@link RemoteException}. + * The exception is converted as defined in the following table: + * <p> + * <table border = "1"> + * <tr> + * <th>CORBA Exception</th> + * <th>RMI Exception</th> + * </tr> + * <tr> + * <td>{@link COMM_FAILURE}</td> + * <td>{@link MarshalException}</td> + * </tr> + * <tr> + * <td>{@link INV_OBJREF}</td> + * <td>{@link NoSuchObjectException}</td> + * </tr> + * <tr> + * <td>{@link NO_PERMISSION}</td> + * <td>{@link AccessException}</td> + * </tr> + * <tr> + * <td>{@link MARSHAL}</td> + * <td>{@link MarshalException}</td> + * </tr> + * <tr> + * <td>{@link BAD_PARAM} (all other cases)</td> + * <td>{@link MarshalException}</td> + * </tr> + * <tr> + * <td>{@link OBJECT_NOT_EXIST}</td> + * <td>{@link NoSuchObjectException}</td> + * </tr> + * <tr> + * <td>{@link TRANSACTION_REQUIRED}</td> + * <td>{@link TransactionRequiredException}</td> + * </tr> + * <tr> + * <td>{@link TRANSACTION_ROLLEDBACK}</td> + * <td>{@link TransactionRolledbackException}</td> + * </tr> + * <tr> + * <td>{@link INVALID_TRANSACTION}</td> + * <td>{@link InvalidTransactionException}</td> + * </tr> + * <tr> + * <td bgcolor="lightgray">Any other {@link SystemException}</td> + * <td bgcolor="lightgray">{@link RemoteException}</td> + * </tr> + * </table> + * </p> + * <p> + * The exception detailed message always consists of + * <ol> + * <li>the string "CORBA "</li> + * <li>the CORBA name of the system exception</li> + * <li>single space</li> + * <li>the hexadecimal value of the system exception's minor code, preceeded + * by 0x (higher bits contain {@link OMGVMCID}).</li> + * <li>single space</li> + * <li>the {@link CompletionStatus} of the exception: "Yes", "No" or "Maybe".</li> + * </ol> + * The subsequent content is not part of the official RMI-IIOP standart and is + * added for compatibility with Sun's implementation: + * <ol> + * <li>the phrase "<code>; nested exception is: <i>(line feed)(tab)</i></code>"</li> + * <li>the full name of the mapped SystemException, as returned by + * Class.getName().</li> + * <li>the ": ". + * <li>the value, returned by .getMessage() of the passed parameter.</li> + * </ol> + * <p> + * For instance, if the Internet connection was refused: + * </p><p> + * <code>CORBA COMM_FAILURE 0x535500C9 No</code> + * </p><p> + * The original CORBA exception is set as the cause of the RemoteException + * being created. + * </p> + */ RemoteException mapSystemException(SystemException ex); - Object readAny(InputStream in); + /** + * Get the Tie that handles invocations on the given target. The target/Tie + * pair must be previously registered using {@link #registerTarget}. + * + * @return the Tie, or null if no such is known. + */ + Tie getTie(Remote target); + /** + * Register the Tie-target pair. + */ void registerTarget(Tie tie, Remote target); - - void unexportObject(Remote target); - + + /** + * Deactivate the associated Tie, if it is found and is not connected to other + * registered targets. + */ + void unexportObject(Remote target) + throws NoSuchObjectException; + + /** + * Converts the exception that was thrown by the implementation method on a + * server side into RemoteException that can be transferred and re-thrown on a + * client side. The method converts exceptions as defined in the following + * table: <table border = "1"> + * <tr> + * <th>Exception to map (or subclass)</th> + * <th>Maps into</th> + * </tr> + * <tr> + * <td>{@link Error}</td> + * <td>{@link ServerError}</td> + * </tr> + * <tr> + * <td>{@link RemoteException}</td> + * <td>{@link ServerException}</td> + * </tr> + * <tr> + * <td>{@link SystemException}</td> + * <td>wrapException({@link #mapSystemException})</td> + * </tr> + * <tr> + * <td>{@link RuntimeException}</td> + * <td><b>rethrows</b></td> + * </tr> + * <tr> + * <td>Any other exception</td> + * <td>{@link UnexpectedException}</td> + * </tr> + * </table> + * + * @param ex an exception that was thrown on a server side implementation. + * + * @return the corresponding RemoteException unless it is a RuntimeException. + * + * @throws RuntimeException the passed exception if it is an instance of + * RuntimeException. + * + * @specnote It is the same behavior, as in Suns implementations 1.4.0-1.5.0. + */ RemoteException wrapException(Throwable orig); - - void writeAbstractObject(OutputStream out, Object obj); - - void writeAny(OutputStream out, Object obj); - void writeRemoteObject(OutputStream out, Object obj); -} + /** + * Write the passed parameter to the output stream as CORBA object. If the + * parameter is an instance of Remote and not an instance of Stub, the method + * instantiates a suitable Tie, connects the parameter to this Tie and then + * connects that Tie to the ORB that is requested from the output stream. Then + * the object reference is written to the stream, making remote invocations + * possible. This method is used in write_value(..) method group in + * {@link org.omg.CORBA_2_3.portable.OutputStream} and also may be called + * directly from generated Stubs and Ties. + * + * @param output a stream to write to, must be + * org.omg.CORBA_2_3.portable.OutputStream + * @param object an object to write. + */ + void writeRemoteObject(OutputStream output, Object obj); + + /** + * Write abstract interface to the CORBA output stream. The write format is + * matching CORBA abstract interface. Remotes and CORBA objects are written as + * objects, other classes are supposed to be value types and are written as + * such. {@link Remote}s are processed as defined in + * {@link #writeRemoteObject}. The written data contains discriminator, + * defining, that was written. Another method that writes the same content is + * {@link org.omg.CORBA_2_3.portable.OutputStream#write_abstract_interface(java.lang.Object)}. + * + * @param output a stream to write to, must be + * {@link org.omg.CORBA_2_3.portable.OutputStream}. + * + * @param object an object to write, must be CORBA object, Remote + */ + void writeAbstractObject(OutputStream output, Object object); + + /** + * Write the passed java object to the output stream in the form of the CORBA + * {@link Any}. This includes creating an writing the object {@link TypeCode} + * first. Such Any can be later read by a non-RMI-IIOP CORBA implementation + * and manipulated, for instance, by means, provided in + * {@link org.omg.DynamicAny.DynAny}. Depending from the passed value, this + * method writes CORBA object, value type or value box. For value types Null + * is written with the abstract interface, its typecode having repository id + * "IDL:omg.org/CORBA/AbstractBase:1.0" and the empty string name. + * + * @param output the object to write. + * @param object the java object that must be written in the form of the CORBA + * {@link Any}. + */ + void writeAny(OutputStream output, Object object); + + /** + * Read Any from the input stream. + */ + Object readAny(InputStream input); + +}
\ No newline at end of file diff --git a/libjava/classpath/javax/rmi/CORBA/ValueHandler.java b/libjava/classpath/javax/rmi/CORBA/ValueHandler.java index f26e75b2a86..c4213efdcfb 100644 --- a/libjava/classpath/javax/rmi/CORBA/ValueHandler.java +++ b/libjava/classpath/javax/rmi/CORBA/ValueHandler.java @@ -1,5 +1,5 @@ -/* ValueHandler.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. +/* ValueHandler.java -- + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,28 +38,93 @@ exception statement from your version. */ package javax.rmi.CORBA; -import java.io.InputStream; -import java.io.OutputStream; import java.io.Serializable; -//import org.omg.CORBA.portable.InputStream; -//import org.omg.CORBA.portable.OutputStream; -//import org.omg.SendingContext.RunTime; +import org.omg.CORBA.CustomMarshal; +import org.omg.CORBA.portable.InputStream; +import org.omg.CORBA.portable.OutputStream; +import org.omg.CORBA.portable.Streamable; +import org.omg.SendingContext.RunTime; + +/** + * Serializes Java objects to and from CDR (GIOP) streams. The working instance + * of the value handler is returned by {@link Util#createValueHandler} and can + * be altered by setting the system property "javax.rmi.CORBA.ValueHandlerClass" + * to the name of the alternative class that must implement ValueHandler. + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ public interface ValueHandler { - + /** + * Get CORBA repository Id for the given java class. + * + * The syntax of the repository ID is the initial ?RMI:?, followed by the Java + * class name, followed by name, followed by a hash code string, followed + * optionally by a serialization version UID string. + * + * For Java identifiers that contain illegal OMG IDL identifier characters + * such as ?$?, any such illegal characters are replaced by ?\U? followed by + * the 4 hexadecimal characters (in upper case) representing the Unicode + * value. + * + * @param clz a class for that the repository Id is required. + * + * @return the class repository id. + */ String getRMIRepositoryID(Class clz); - - // XXX Runtime -> RunTime - Runtime getRunTimeCodeBase(); - + + /** + * Returns the CodeBase for this ValueHandler. + * + * @return the codebase. + */ + RunTime getRunTimeCodeBase(); + + /** + * Indicates that the given class is responsible itself for writing its + * content to the stream. Such classes implement either {@link Streamable} + * (default marshalling, generated by IDL-to-java compiler) or + * {@link CustomMarshal} (the user-programmed marshalling). + * + * @param clz the class being checked. + * @return true if the class supports custom or default marshalling, false + * otherwise. + */ boolean isCustomMarshaled(Class clz); - - // XXX Runtime -> RunTime + + /** + * Read value from the CORBA input stream in the case when the value is not + * Streamable or CustomMarshall'ed. The fields of the class being written will + * be accessed using reflection. + * + * @param in a CORBA stream to read. + * @param offset the current position in the input stream. + * @param clz the type of value being read. + * @param repositoryID the repository Id of the value being read. + * @param sender the sending context that should provide data about the + * message originator. + * + * @return the object, extracted from the stream. + */ Serializable readValue(InputStream in, int offset, Class clz, - String repositoryID, Runtime sender); - + String repositoryID, RunTime sender); + + /** + * When the value provides the writeReplace method, the result of this method + * is written. Otherwise, the value itself is written. + * + * @param the value that should be written to the stream. + * + * @return the value that will be actually written to the stream. + */ Serializable writeReplace(Serializable value); - + + /** + * Write value to CORBA output stream using java senmatics. + * + * @param out a stream to write into. + * @param value a java object to write. + */ void writeValue(OutputStream out, Serializable value); -} +}
\ No newline at end of file diff --git a/libjava/classpath/javax/rmi/CORBA/ValueHandlerMultiFormat.java b/libjava/classpath/javax/rmi/CORBA/ValueHandlerMultiFormat.java new file mode 100644 index 00000000000..4db65c1dbfd --- /dev/null +++ b/libjava/classpath/javax/rmi/CORBA/ValueHandlerMultiFormat.java @@ -0,0 +1,94 @@ +/* ValueHandlerMultiFormat.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 javax.rmi.CORBA; + +import org.omg.CORBA.portable.OutputStream; + +import java.io.Serializable; + +/** + * This interface extends the previous ValueHandler, supporting various stream + * format versions. The {@link ValueHandler} can be casted into this interface + * to access additional features. + * + * @since 1.5 + * + * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) + */ +public interface ValueHandlerMultiFormat + extends ValueHandler +{ + /** + * Get the maximal supported version for the value types, supported by + * this value handler. The versions are integer numbers, the currently valid + * values being 1 and 2. + * + * These two versions differ in how the additional data, stored by the + * writeObject method, are encoded. + * <ul> + * <li> For version 1 (GNU Classpath default), that data (if present) are + * written "as is". </li> + * <li>For version 2, this data fragment is enclosed within a CDR custom + * valuetype with no codebase and repository Id "RMI:org.omg.custom.<class>" + * where <class> is the fully-qualified name of the class whose writeObject + * method is being invoked. If the object does not write any data via + * writeObject method, the null valuetype (0x0) must be written.</li> + * </ul> + * As the version number is part of the value type record, there is no need + * to the format control during the reading. + * + * @return the maximal supported version. + */ + byte getMaximumStreamFormatVersion(); + + /** + * Write the value type to the output stream using the given format version. + * The older method {@link ValueHandler#writeValue} always uses the version 1. + * + * @param output the stream, where the value should be written, must implement + * {@link ValueOutputStream}. + * @param value the value that should be written. + * @param version the version of the format that must be used to write the + * value. + * + * @throws BAD_PARAM if the version number is less than 1 or greater than the + * maximal supported version. + */ + void writeValue(OutputStream output, Serializable value, byte version); +} diff --git a/libjava/classpath/javax/rmi/CORBA/package.html b/libjava/classpath/javax/rmi/CORBA/package.html index f5a5ac758f9..6014c8c8533 100644 --- a/libjava/classpath/javax/rmi/CORBA/package.html +++ b/libjava/classpath/javax/rmi/CORBA/package.html @@ -1,5 +1,5 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> -<!-- package.html - describes classes in javax.rmi.CORBA package. +<!-- package.html - describes classes in javax.rmi package. Copyright (C) 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,7 +40,37 @@ exception statement from your version. --> <head><title>GNU Classpath - javax.rmi.CORBA</title></head> <body> -<p></p> - +<p> +Java RMI over IIOP combines RMI technology with CORBA technology. Like plain RMI, +RMI over IIOP allows to work completely in the Java programming language +(no IDL). When CORBA needs a separate helper class for each structure being +passed, RMI over IIOP only needs stubs and ties for the objects that are remotely +accessible. As a result, development with RMI-IIOP is easier. However the +specialised pure CORBA helpers needs no reflection to transfer they structures +and hence may be faster than methods, used by both RMI-IIOP and plain RMI. +</p><p> +Like RMI, RMI over IIOP provides flexibility by allowing to pass any serializable +Java object (Objects By Value) between application components. A certain +"imaginary IDL" is automatically supposed; this IDL can be explicitly generated +and later used to interoperate with non-java application. +</p><p> +Like CORBA, RMI over IIOP is based on open standards defined with the +participation of hundredsof vendors and users in the OMG. It uses IIOP +communication protocol that provides much better interoperability with other +programming languages. +</p><p> +With RMI/IIOP you can use advanced CORBA features: multiple objects per servant +and servants per object, servant activators and locators, servant, client and +ior interceptors, CORBA naming service, various ORB policies, stringified object +references and so on. This functionality is based on CORBA value type standard. +RMI/IIOP supports (and GNU Classpath implements) transferring of the arbitrary +connected object graphs (graph flattenning). +</p><p> +GNU Classpath RMI-IIOP functionality is implemented as described in +OMG formal/03-09-04 (IDL to Java mapping v1.3). Value types are written as +described in formal/04-03-12 (CORBA 3.0.3). +</p> +@author Wu Gansha (gansha.wu@intel.com), headers. +@author Audrius Meskauskas (AudriusA@Bioinformatics.org), implementation. </body> </html> diff --git a/libjava/classpath/javax/rmi/ORB.java b/libjava/classpath/javax/rmi/ORB.java deleted file mode 100644 index be7a894e65a..00000000000 --- a/libjava/classpath/javax/rmi/ORB.java +++ /dev/null @@ -1,4 +0,0 @@ -package javax.rmi; - -/** XXX - Stub till we have org.omg.CORBA */ -public class ORB { } diff --git a/libjava/classpath/javax/rmi/PortableRemoteObject.java b/libjava/classpath/javax/rmi/PortableRemoteObject.java index 5e5d1fd29d7..5bb6b112613 100644 --- a/libjava/classpath/javax/rmi/PortableRemoteObject.java +++ b/libjava/classpath/javax/rmi/PortableRemoteObject.java @@ -1,5 +1,5 @@ -/* PortableRemoteObject.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. +/* PortableRemoteObject.java -- + Copyright (C) 2004, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -39,77 +39,190 @@ exception statement from your version. */ package javax.rmi; import gnu.javax.rmi.CORBA.DelegateFactory; -import gnu.javax.rmi.CORBA.GetDelegateInstanceException; + +import org.omg.CORBA.BAD_PARAM; +import org.omg.CORBA.ORB; +import org.omg.CORBA.portable.ObjectImpl; +import org.omg.PortableServer.POA; +import org.omg.PortableServer.Servant; import java.rmi.NoSuchObjectException; import java.rmi.Remote; import java.rmi.RemoteException; import javax.rmi.CORBA.PortableRemoteObjectDelegate; - +import javax.rmi.CORBA.Stub; +import javax.rmi.CORBA.Tie; +import javax.rmi.CORBA.Util; + +/** + * <p> + * An utility class for RMI/IDL server side object implementations. Server side + * implementation objects may inherit from this class, but this is not + * mandatory, as the needed methds are static. Server side implementations may + * choose to inherit from {@link ObjectImpl} or {@link Servant} instead. + * </p> + * <p> + * The functionality of methods in this class is forwarded to the enclosed + * PortableRemoteObjectDelegate. This delegate can be altered by setting the + * system property "javax.rmi.CORBA.PortableRemoteObjectClass" to the name of + * the alternative class that must implement + * {@link PortableRemoteObjectDelegate}. + * </p> + * + * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) + */ public class PortableRemoteObject - implements Remote /* why doc doesn't say should implement Remote */ { - - private static PortableRemoteObjectDelegate delegate; - static - { - try - { - delegate = (PortableRemoteObjectDelegate)DelegateFactory.getInstance - ("PortableRemoteObject"); - } - catch(GetDelegateInstanceException e) - { - e.printStackTrace(); - delegate = null; - } - } - + /** + * A delegate where the functionality is forwarded. + */ + static PortableRemoteObjectDelegate delegate = (PortableRemoteObjectDelegate) DelegateFactory.getInstance(DelegateFactory.PORTABLE_REMOTE_OBJECT); + + /** + * The protected constructor calls {@link exportObject} (this). + * + * @throws RemoteException if the exportObject(this) throws one. + */ protected PortableRemoteObject() throws RemoteException { - if(delegate != null) - exportObject((Remote)this); + exportObject((Remote) this); } + /** + * <p> + * Makes the remote object <code>a_target</code> ready for remote + * communication using the same communications runtime as for the passed + * <code>a_source</code> parameter. The a_target is connected to the same + * ORB (and, if applicable, to the same {@link POA}) as the a_source. + * + * @param a_target the target to connect to ORB, must be an instance of either + * {@link ObjectImpl} (Stubs and old-style ties) or {@link Tie}. + * + * @param a_source the object, providing the connection information, must be + * an instance of either {@link ObjectImpl} (Stubs and old-style ties) or + * {@link Servant} (the next-generation Ties supporting {@link POA}). + * + * @throws RemoteException if the target is already connected to another ORB. + */ public static void connect(Remote target, Remote source) throws RemoteException { - if(delegate != null) - delegate.connect(target, source); + delegate.connect(target, source); } - - public static void exportObject(Remote obj) + + /** + * <p> + * Makes a server object ready for remote calls. The subclasses of + * PortableRemoteObject do not need to call this method, as it is called by + * the constructor. + * </p> + * <p> + * This method only creates a tie object and caches it for future usage. The + * created tie does not have a delegate or an ORB associated. + * </p> + * + * @param object the object to export. + * + * @throws RemoteException if export fails due any reason. + */ + public static void exportObject(Remote object) throws RemoteException { - if(delegate != null) - delegate.exportObject(obj); + delegate.exportObject(object); } - public static Object narrow(Object narrowFrom, Class narrowTo) + /** + * Narrows the passed object to conform to the given interface or IDL type. In + * RMI-IIOP, this method replaces the narrow(org.omg.CORBA.Object) method that + * was present in the CORBA Helpers. This method frequently returns different + * instance and cannot be replaced by the direct cast. The typical narrowing + * cases (all supported by GNU Classpath) are: + * <ul> + * <li>A CORBA object (for instance, returned by the + * {@link ORB#string_to_object} or from the naming service) can be narrowed + * into interface, derived from Remote. The method will try to locate an + * appropriate {@link Stub} by the name pattern (_*_Stub). If the object being + * narrowed is connected to an ORB, the returned instance will inherit that + * connection, representing the same remote (or local) object, but now with + * the possibility to invoke remote methods. </li> + * <li>A CORBA object may be directly narrowed into the appropriate + * {@link Stub} class, if it is and passed as a second parameter. This allows + * to use non-standard stubs without parameterless constructors.</li> + * <li>Any two classes, derived from the {@link ObjectImpl} (may be Stub's) + * can be narrowed one into another (a delegate is transferred). </li> + * <li>An implementation of Remote can be narrowed into {@link Tie} that can + * later connected to an ORB, making the methods accessible remotely. The + * Remote being narrowed normally provides a local implementation, but you can + * also narrow remote Stub, creating "forwarding Tie".</li> + * <li>null is narrowed into null regardless of the second parameter.</li> + * <li>A {@link Tie} can be narrowed into Remote, representing the + * implementation for this Tie (if one is set).</li> + * </ul> + * + * @param object the object like CORBA Object, Stub or Remote that must be + * narrowed to the given interface. + * + * @param narrowToInstaceOf the class of the interface to that the object must + * be narrowed. + * + * @return On success, an object of type narrowTo or null, if narrowFrom = + * null. + * + * @throws ClassCastException if no narrowing is possible. + */ + public static Object narrow(Object object, Class narrowToInstaceOf) throws ClassCastException { - if(delegate != null) - return delegate.narrow(narrowFrom, narrowTo); - else - return null; + return delegate.narrow(object, narrowToInstaceOf); } - public static Remote toStub(Remote obj) + /** + * <p> + * Takes a server implementation object (name pattern *imp) and returns a stub + * object that can be used to access that server object (target), name + * (pattern _*_Stub). + * + * The returned stub is not connected to any ORB and must be explicitly + * connected using {@link #connect}. + * </p> + * <p> + * The method signature prevents it from returning stubs that does not + * implement Remote (ClassCastException will be thrown). + * </p> + * + * @param target a server side object implementation. + * @return a stub object that can be used to access that server object. + * + * @throws NoSuchObjectException if a stub class cannot be located by supposed + * name pattern, or an instance of stub fails to be instantiated. + * + * @throws ClassCastException if the stub class can be located, but it does + * not inherit from Remote. + * + * @throws BAD_PARAM if the name of the passed class does not match the + * implementation name pattern (does not end by 'Impl'). + */ + public static Remote toStub(Remote targetImpl) throws NoSuchObjectException { - if(delegate != null) - return delegate.toStub(obj); - else - return null; + return delegate.toStub(targetImpl); } - public static void unexportObject(Remote obj) + /** + * Deregister a currently exported server object from the ORB runtimes. The + * object to becomes available for garbage collection. This is usually + * impemented via {@link Util#unexportObject} + * + * @param object the object to unexport. + * + * @throws NoSuchObjectException if the passed object is not currently + * exported. + */ + public static void unexportObject(Remote object) throws NoSuchObjectException { - if(delegate != null) - delegate.unexportObject(obj); + delegate.unexportObject(object); } - -} +}
\ No newline at end of file diff --git a/libjava/classpath/javax/rmi/package.html b/libjava/classpath/javax/rmi/package.html index febf59bd61c..6014c8c8533 100644 --- a/libjava/classpath/javax/rmi/package.html +++ b/libjava/classpath/javax/rmi/package.html @@ -37,10 +37,40 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. --> <html> -<head><title>GNU Classpath - javax.rmi</title></head> +<head><title>GNU Classpath - javax.rmi.CORBA</title></head> <body> -<p></p> - +<p> +Java RMI over IIOP combines RMI technology with CORBA technology. Like plain RMI, +RMI over IIOP allows to work completely in the Java programming language +(no IDL). When CORBA needs a separate helper class for each structure being +passed, RMI over IIOP only needs stubs and ties for the objects that are remotely +accessible. As a result, development with RMI-IIOP is easier. However the +specialised pure CORBA helpers needs no reflection to transfer they structures +and hence may be faster than methods, used by both RMI-IIOP and plain RMI. +</p><p> +Like RMI, RMI over IIOP provides flexibility by allowing to pass any serializable +Java object (Objects By Value) between application components. A certain +"imaginary IDL" is automatically supposed; this IDL can be explicitly generated +and later used to interoperate with non-java application. +</p><p> +Like CORBA, RMI over IIOP is based on open standards defined with the +participation of hundredsof vendors and users in the OMG. It uses IIOP +communication protocol that provides much better interoperability with other +programming languages. +</p><p> +With RMI/IIOP you can use advanced CORBA features: multiple objects per servant +and servants per object, servant activators and locators, servant, client and +ior interceptors, CORBA naming service, various ORB policies, stringified object +references and so on. This functionality is based on CORBA value type standard. +RMI/IIOP supports (and GNU Classpath implements) transferring of the arbitrary +connected object graphs (graph flattenning). +</p><p> +GNU Classpath RMI-IIOP functionality is implemented as described in +OMG formal/03-09-04 (IDL to Java mapping v1.3). Value types are written as +described in formal/04-03-12 (CORBA 3.0.3). +</p> +@author Wu Gansha (gansha.wu@intel.com), headers. +@author Audrius Meskauskas (AudriusA@Bioinformatics.org), implementation. </body> </html> |