Imported GNU Classpath 0.90
Imported GNU Classpath 0.90 * scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore. * gnu/classpath/jdwp/VMFrame.java (SIZE): New constant. * java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5. * java/lang/Math.java: New override file. * java/lang/Character.java: Merged from Classpath. (start, end): Now 'int's. (canonicalName): New field. (CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants. (UnicodeBlock): Added argument. (of): New overload. (forName): New method. Updated unicode blocks. (sets): Updated. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r111942
This commit is contained in:
parent
27079765d0
commit
8aa540d2f7
1367 changed files with 188789 additions and 22762 deletions
|
@ -38,10 +38,13 @@ exception statement from your version. */
|
|||
|
||||
package java.rmi.server;
|
||||
|
||||
import gnu.classpath.ServiceFactory;
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.rmi.server.RMIClassLoaderImpl;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* This class provides a set of public static utility methods for supporting
|
||||
|
@ -84,6 +87,16 @@ public class RMIClassLoader
|
|||
return spi.loadClass(codebase, name, defaultLoader);
|
||||
}
|
||||
|
||||
public static Class loadProxyClass (String codeBase, String[] interfaces,
|
||||
ClassLoader defaultLoader)
|
||||
throws MalformedURLException, ClassNotFoundException
|
||||
{
|
||||
RMIClassLoaderSpi spi = getProviderInstance();
|
||||
if (spi == null)
|
||||
spi = getDefaultProviderInstance();
|
||||
return spi.loadProxyClass(codeBase, interfaces, defaultLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a class from <code>codeBase</code>.
|
||||
*
|
||||
|
@ -171,7 +184,20 @@ public class RMIClassLoader
|
|||
*/
|
||||
private static RMIClassLoaderSpi getProviderInstance()
|
||||
{
|
||||
// TODO: Do something more useful here.
|
||||
return null;
|
||||
// If the user asked for the default, return it. We do a special
|
||||
// check here because our standard service lookup function does not
|
||||
// handle this -- nor should it.
|
||||
String prop = SystemProperties.getProperty("java.rmi.server.RMIClassLoaderSpi");
|
||||
if ("default".equals(prop))
|
||||
return null;
|
||||
Iterator it = ServiceFactory.lookupProviders(RMIClassLoaderSpi.class,
|
||||
null);
|
||||
if (it == null || ! it.hasNext())
|
||||
return null;
|
||||
// FIXME: the spec says we ought to throw an Error of some kind if
|
||||
// the specified provider is not suitable for some reason. However
|
||||
// our service factory simply logs the problem and moves on to the next
|
||||
// provider in this situation.
|
||||
return (RMIClassLoaderSpi) it.next();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,221 @@
|
|||
/* RemoteObjectInvocationHandler.java -- RMI stub replacement.
|
||||
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 java.rmi.server;
|
||||
|
||||
import gnu.java.rmi.server.RMIHashes;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.UnexpectedException;
|
||||
import java.rmi.registry.Registry;
|
||||
import java.rmi.server.RemoteObject;
|
||||
import java.rmi.server.RemoteRef;
|
||||
import java.rmi.server.UnicastRemoteObject;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* Together with dynamic proxy instance, this class replaces the generated RMI
|
||||
* stub (*_Stub) classes that (following 1.5 specification) should be no longer
|
||||
* required. It is unusual to use the instances of this class directly in the
|
||||
* user program. Such instances are automatically created and returned by
|
||||
* {@link Registry} or {@link UnicastRemoteObject} methods if the remote
|
||||
* reference is known but the corresponding stub class is not accessible.
|
||||
*
|
||||
* @see Registry#lookup
|
||||
*
|
||||
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
|
||||
*/
|
||||
public class RemoteObjectInvocationHandler extends RemoteObject implements
|
||||
InvocationHandler, Remote, Serializable
|
||||
{
|
||||
/**
|
||||
* Use the jdk 1.5 SUID for interoperability.
|
||||
*/
|
||||
static final long serialVersionUID = 2L;
|
||||
|
||||
/**
|
||||
* The RMI method hash codes, computed once as described in the section 8.3
|
||||
* of the Java Remote Method Invocation (RMI) Specification.
|
||||
*/
|
||||
static Hashtable methodHashCodes = new Hashtable();
|
||||
|
||||
/**
|
||||
* The empty class array to define parameters of .hashCode and .toString.
|
||||
*/
|
||||
static final Class[] noArgsC = new Class[0];
|
||||
|
||||
/**
|
||||
* The class array to define parameters of .equals
|
||||
*/
|
||||
static final Class[] anObjectC = new Class[] { Object.class };
|
||||
|
||||
/**
|
||||
* Construct the remote invocation handler that forwards calls to the given
|
||||
* remote object.
|
||||
*
|
||||
* @param reference the reference to the remote object where the method
|
||||
* calls should be forwarded.
|
||||
*/
|
||||
public RemoteObjectInvocationHandler(RemoteRef reference)
|
||||
{
|
||||
super(reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke the remote method. When the known method is invoked on a created RMI
|
||||
* stub proxy class, the call is delivered to this method and then transferred
|
||||
* to the {@link RemoteRef#invoke(Remote, Method, Object[], long)} of the
|
||||
* remote reference that was passed in constructor. The methods are handled as
|
||||
* following:
|
||||
* <ul>
|
||||
* <li> The toString() method is delegated to the passed proxy instance.</li>
|
||||
* <li>The .equals method only returns true if the passed object is an
|
||||
* instance of proxy class and its invocation handler is equal to this
|
||||
* invocation handles.</li>
|
||||
* <li>The .hashCode returns the hashCode of this invocation handler (if the.</li>
|
||||
* <li>All other methods are converted to remote calls and forwarded to the
|
||||
* remote reference. </li>
|
||||
* </ul>
|
||||
*
|
||||
* @param proxyInstance
|
||||
* the instance of the proxy stub
|
||||
* @param method
|
||||
* the method being invoked
|
||||
* @param parameters
|
||||
* the method parameters
|
||||
* @return the method return value, returned by RemoteRef.invoke
|
||||
* @throws IllegalAccessException
|
||||
* if the passed proxy instance does not implement Remote interface.
|
||||
* @throws UnexpectedException
|
||||
* if remote call throws some exception, not listed in the
|
||||
* <code>throws</code> clause of the method being called.
|
||||
* @throws Throwable
|
||||
* that is thrown by remote call, if that exception is listend in
|
||||
* the <code>throws</code> clause of the method being called.
|
||||
*/
|
||||
public Object invoke(Object proxyInstance, Method method, Object[] parameters)
|
||||
throws Throwable
|
||||
{
|
||||
if (!(proxyInstance instanceof Remote))
|
||||
{
|
||||
String name = proxyInstance == null ? "null"
|
||||
: proxyInstance.getClass().getName();
|
||||
throw new IllegalAccessException(name + " does not implement "
|
||||
+ Remote.class.getName());
|
||||
}
|
||||
|
||||
String name = method.getName();
|
||||
switch (name.charAt(0))
|
||||
{
|
||||
case 'e':
|
||||
if (parameters.length == 1 && name.equals("equals")
|
||||
&& method.getParameterTypes()[0].equals(Object.class))
|
||||
{
|
||||
if (parameters[0] instanceof Proxy)
|
||||
{
|
||||
Object handler = Proxy.getInvocationHandler(parameters[0]);
|
||||
if (handler == null)
|
||||
return Boolean.FALSE;
|
||||
else
|
||||
return handler.equals(this) ? Boolean.TRUE : Boolean.FALSE;
|
||||
}
|
||||
else
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
break;
|
||||
case 'h':
|
||||
if (parameters.length == 0 && name.equals("hashCode"))
|
||||
{
|
||||
int hashC = Proxy.getInvocationHandler(proxyInstance).hashCode();
|
||||
return new Integer(hashC);
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
if (parameters.length == 0 && name.equals("toString"))
|
||||
return proxyInstance.toString();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Long hash = (Long) methodHashCodes.get(method);
|
||||
if (hash == null)
|
||||
{
|
||||
hash = new Long(RMIHashes.getMethodHash(method));
|
||||
methodHashCodes.put(method, hash);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return getRef().invoke((Remote) proxyInstance, method, parameters,
|
||||
hash.longValue());
|
||||
}
|
||||
catch (RuntimeException exception)
|
||||
{
|
||||
// RuntimeException is always supported.
|
||||
throw exception;
|
||||
}
|
||||
catch (RemoteException exception)
|
||||
{
|
||||
// All remote methods can throw RemoteException.
|
||||
throw exception;
|
||||
}
|
||||
catch (Error exception)
|
||||
{
|
||||
throw exception;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Class[] exceptions = method.getExceptionTypes();
|
||||
Class exceptionClass = exception.getClass();
|
||||
|
||||
for (int i = 0; i < exceptions.length; i++)
|
||||
{
|
||||
if (exceptions[i].equals(exceptionClass))
|
||||
throw exception;
|
||||
}
|
||||
throw new UnexpectedException(method.getName(), exception);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
/* RemoteRef.java --
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2004 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2004, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -44,8 +45,16 @@ import java.lang.reflect.Method;
|
|||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
/**
|
||||
* Represents a handler to the remote object. Each instance of the
|
||||
* {@link RemoteStub} contains such handler and uses it to invoke remote
|
||||
* methods via {@link #invoke(Remote, Method, Object[], long)}.
|
||||
*/
|
||||
public interface RemoteRef extends Externalizable
|
||||
{
|
||||
/**
|
||||
* Indicates compatibility with JDK 1.1.*
|
||||
*/
|
||||
long serialVersionUID = 3632638527362204081L;
|
||||
|
||||
/**
|
||||
|
@ -55,29 +64,74 @@ public interface RemoteRef extends Externalizable
|
|||
String packagePrefix = "sun.rmi.server";
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
|
||||
*/
|
||||
void invoke (RemoteCall call) throws Exception;
|
||||
|
||||
Object invoke (Remote obj, Method method, Object[] params, long opnum)
|
||||
/**
|
||||
* Invoke a method. This method either returns the result of remote invocation
|
||||
* or throws RemoteException if the remote call failed. Other exceptions may
|
||||
* be thrown if some problem has occured in the application level.
|
||||
*
|
||||
* @param obj the object, containing the remote reference (for instance,
|
||||
* remote stub, generated by rmic).
|
||||
* @param method the method to invoke
|
||||
* @param params the method parameters
|
||||
* @param methodHash a persistent hash code that can be used to represent a
|
||||
* method
|
||||
* @return the result of the remote invocation
|
||||
* @throws RemoteException if the remote call has failed
|
||||
* @throws Exception if one is raised at the application level
|
||||
*/
|
||||
Object invoke (Remote obj, Method method, Object[] params, long methodHash)
|
||||
throws Exception;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
|
||||
*/
|
||||
RemoteCall newCall (RemoteObject obj, Operation[] op, int opnum, long hash)
|
||||
throws RemoteException;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated use {@link #invoke(Remote, Method, Object[], long)} instead.
|
||||
*/
|
||||
void done (RemoteCall call) throws RemoteException;
|
||||
|
||||
/**
|
||||
* Compare two remote objects for equality. The references are equal if
|
||||
* they point to the same remote object.
|
||||
*
|
||||
* @param ref the reference to compare.
|
||||
*
|
||||
* @return true if this and passed references both point to the same remote
|
||||
* object, false otherwise.
|
||||
*/
|
||||
boolean remoteEquals (RemoteRef ref);
|
||||
|
||||
/**
|
||||
* Get the hashcode for a remote object. Two remote object stubs, referring
|
||||
* to the same remote object, have the same hash code.
|
||||
*
|
||||
* @return the hashcode of the remote object
|
||||
*/
|
||||
int remoteHashCode();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the class name of the reference type that must be written to the
|
||||
* given stream. When writing, this returned name is passed first, and
|
||||
* the reference.writeExternal(out) writes the reference specific data.
|
||||
*
|
||||
* @param out the stream, where the data must be written
|
||||
*
|
||||
* @return the class name.
|
||||
*/
|
||||
String getRefClass (ObjectOutput out);
|
||||
|
||||
/**
|
||||
* Get the string representation of this remote reference.
|
||||
*
|
||||
* @return the string representation.
|
||||
*/
|
||||
String remoteToString();
|
||||
}
|
||||
|
|
|
@ -37,21 +37,40 @@ exception statement from your version. */
|
|||
|
||||
package java.rmi.server;
|
||||
|
||||
/**
|
||||
* This is a base class for the automatically generated RMI stubs.
|
||||
*/
|
||||
public abstract class RemoteStub extends RemoteObject
|
||||
{
|
||||
/**
|
||||
* Use serialVersionUID for interoperability.
|
||||
*/
|
||||
static final long serialVersionUID = -1585587260594494182l;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs the remote stub with no reference set.
|
||||
*/
|
||||
protected RemoteStub ()
|
||||
{
|
||||
super ();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs the remote stub that uses given remote reference for the
|
||||
* method invocations.
|
||||
*
|
||||
* @param ref the remote reference for the method invocation.
|
||||
*/
|
||||
protected RemoteStub (RemoteRef ref)
|
||||
{
|
||||
super (ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the given remote reference for the given stub. This method is
|
||||
* deprecated. Pass the stub remote reference to the RemoteStub
|
||||
* constructor instead.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
protected static void setRef (RemoteStub stub, RemoteRef ref)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* UnicastRemoteObject.java --
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003 Free Software Foundation, Inc.
|
||||
Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -44,61 +45,175 @@ import java.rmi.NoSuchObjectException;
|
|||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
/**
|
||||
* This class obtains stub that communicates with the remote object.
|
||||
*/
|
||||
public class UnicastRemoteObject extends RemoteServer
|
||||
{
|
||||
private static final long serialVersionUID = 4974527148936298033L;
|
||||
//The following serialized fields are from Java API Documentation "Serialized form"
|
||||
private int port = 0;
|
||||
private RMIClientSocketFactory csf = null;
|
||||
private RMIServerSocketFactory ssf = null;
|
||||
/**
|
||||
* Use SVUID for interoperability.
|
||||
*/
|
||||
private static final long serialVersionUID = 4974527148936298033L;
|
||||
|
||||
protected UnicastRemoteObject() throws RemoteException {
|
||||
//The following serialized fields are from Java API Documentation
|
||||
// "Serialized form"
|
||||
|
||||
/**
|
||||
* The port, on that the created remote object becomes available,
|
||||
* zero meaning the anonymous port.
|
||||
*/
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* The client socket factory for producing client sockets, used by this
|
||||
* object.
|
||||
*/
|
||||
private RMIClientSocketFactory csf;
|
||||
|
||||
/**
|
||||
* The server socket factory for producing server sockets, used by this
|
||||
* object.
|
||||
*/
|
||||
private RMIServerSocketFactory ssf;
|
||||
|
||||
/**
|
||||
* Create and export new remote object without specifying the port value.
|
||||
*
|
||||
* @throws RemoteException if the attempt to export the object failed.
|
||||
*/
|
||||
protected UnicastRemoteObject()
|
||||
throws RemoteException
|
||||
{
|
||||
this(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and export the new remote object, making it available at the
|
||||
* given port, local host.
|
||||
*
|
||||
* @param port the port, on that the object should become available.
|
||||
* Zero means anonymous port.
|
||||
*
|
||||
* @throws RemoteException if the attempt to export the object failed.
|
||||
*/
|
||||
protected UnicastRemoteObject(int port)
|
||||
throws RemoteException
|
||||
{
|
||||
this(port, RMISocketFactory.getSocketFactory(),
|
||||
RMISocketFactory.getSocketFactory());
|
||||
}
|
||||
|
||||
protected UnicastRemoteObject(int port) throws RemoteException {
|
||||
this(port, RMISocketFactory.getSocketFactory(), RMISocketFactory.getSocketFactory());
|
||||
}
|
||||
/**
|
||||
* Create and export the new remote object, making it available at the
|
||||
* given port, using sockets, produced by the specified factories.
|
||||
*
|
||||
* @param port the port, on that the object should become available.
|
||||
* Zero means anonymous port.
|
||||
*
|
||||
* @param clientSocketFactory the client socket factory
|
||||
* @param serverSocketFactory the server socket factory
|
||||
*
|
||||
* @throws RemoteException if the attempt to export the object failed.
|
||||
*/
|
||||
protected UnicastRemoteObject(int port,
|
||||
RMIClientSocketFactory clientSocketFactory,
|
||||
RMIServerSocketFactory serverSocketFactory)
|
||||
throws RemoteException
|
||||
{
|
||||
this.port = port;
|
||||
//Is RMIXXXSocketFactory serializable
|
||||
//this.csf = csf;
|
||||
//this.ssf = ssf;
|
||||
this.ref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
|
||||
exportObject(this, port);
|
||||
}
|
||||
|
||||
protected UnicastRemoteObject(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException {
|
||||
this.port = port;
|
||||
//Is RMIXXXSocketFactory serializable
|
||||
//this.csf = csf;
|
||||
//this.ssf = ssf;
|
||||
this.ref = new UnicastServerRef(new ObjID(), port, ssf);
|
||||
exportObject(this);
|
||||
}
|
||||
protected UnicastRemoteObject(RemoteRef ref)
|
||||
throws RemoteException
|
||||
{
|
||||
super((UnicastServerRef) ref);
|
||||
exportObject(this, 0);
|
||||
}
|
||||
|
||||
protected UnicastRemoteObject(RemoteRef ref) throws RemoteException {
|
||||
super((UnicastServerRef)ref);
|
||||
exportObject(this);
|
||||
}
|
||||
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
public Object clone()
|
||||
throws CloneNotSupportedException
|
||||
{
|
||||
throw new Error("Not implemented");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Export object, making it available for the remote calls at the
|
||||
* anonymous port.
|
||||
*
|
||||
* This method returns the instance of the abstract class, not an interface.
|
||||
* Hence it will not work with the proxy stubs that are supported since
|
||||
* jdk 1.5 (such stubs cannot be derived from the RemoteStub). Only use
|
||||
* this method if you are sure that the stub class will be accessible.
|
||||
*
|
||||
* @param obj the object being exported.
|
||||
*
|
||||
* @return the remote object stub
|
||||
*
|
||||
* @throws RemoteException if the attempt to export the object failed.
|
||||
*/
|
||||
public static RemoteStub exportObject(Remote obj)
|
||||
throws RemoteException
|
||||
{
|
||||
return (RemoteStub) exportObject(obj, 0);
|
||||
}
|
||||
|
||||
public static RemoteStub exportObject(Remote obj) throws RemoteException {
|
||||
UnicastServerRef sref = (UnicastServerRef)((RemoteObject)obj).getRef();
|
||||
return (sref.exportObject(obj));
|
||||
}
|
||||
|
||||
public static Remote exportObject(Remote obj, int port) throws RemoteException
|
||||
/**
|
||||
* Export object, making it available for the remote calls at the
|
||||
* specified port.
|
||||
*
|
||||
* Since jdk 1.5 this method does not longer require the stub class to be
|
||||
* present. If such class is not found, the stub is replaced by the
|
||||
* dynamically constructed proxy class. No attempt to find and load the stubs
|
||||
* is made if the system property java.rmi.server.ignoreStubClasses
|
||||
* is set to true (set to reduce the starting time if the stubs are
|
||||
* surely not present and exclusively 1.2 RMI is used).
|
||||
*
|
||||
* @param obj the object being exported.
|
||||
* @param port the remote object port
|
||||
*
|
||||
* @return the remote object stub
|
||||
*
|
||||
* @throws RemoteException if the attempt to export the object failed.
|
||||
*/
|
||||
public static Remote exportObject(Remote obj, int port)
|
||||
throws RemoteException
|
||||
{
|
||||
return exportObject(obj, port, null);
|
||||
}
|
||||
|
||||
static Remote exportObject(Remote obj, int port, RMIServerSocketFactory ssf)
|
||||
throws RemoteException
|
||||
|
||||
/**
|
||||
* Create and export the new remote object, making it available at the
|
||||
* given port, using sockets, produced by the specified factories.
|
||||
*
|
||||
* Since jdk 1.5 this method does not longer require the stub class to be
|
||||
* present. If such class is not found, the stub is replaced by the
|
||||
* dynamically constructed proxy class. No attempt to find and load the stubs
|
||||
* is made if the system property java.rmi.server.ignoreStubClasses
|
||||
* is set to true (set to reduce the starting time if the stubs are
|
||||
* surely not present and exclusively 1.2 RMI is used).
|
||||
*
|
||||
* @param port the port, on that the object should become available.
|
||||
* Zero means anonymous port.
|
||||
*
|
||||
* @param serverSocketFactory the server socket factory
|
||||
*/
|
||||
static Remote exportObject(Remote obj, int port,
|
||||
RMIServerSocketFactory serverSocketFactory)
|
||||
throws RemoteException
|
||||
{
|
||||
UnicastServerRef sref = null;
|
||||
if (obj instanceof RemoteObject)
|
||||
sref = (UnicastServerRef)((RemoteObject)obj).getRef ();
|
||||
if(sref == null)
|
||||
{
|
||||
sref = new UnicastServerRef(new ObjID (), port, ssf);
|
||||
}
|
||||
Remote stub = sref.exportObject (obj);
|
||||
sref = (UnicastServerRef) ((RemoteObject) obj).getRef();
|
||||
|
||||
if (sref == null)
|
||||
sref = new UnicastServerRef(new ObjID(), port, serverSocketFactory);
|
||||
|
||||
Remote stub = sref.exportObject(obj);
|
||||
addStub(obj, stub);
|
||||
return stub;
|
||||
}
|
||||
|
@ -106,8 +221,9 @@ public static RemoteStub exportObject(Remote obj) throws RemoteException {
|
|||
/**
|
||||
* FIXME
|
||||
*/
|
||||
public static Remote exportObject(Remote obj, int port, RMIClientSocketFactory csf,
|
||||
RMIServerSocketFactory ssf)
|
||||
public static Remote exportObject(Remote obj, int port,
|
||||
RMIClientSocketFactory csf,
|
||||
RMIServerSocketFactory ssf)
|
||||
throws RemoteException
|
||||
{
|
||||
return (exportObject(obj, port, ssf));
|
||||
|
@ -118,14 +234,15 @@ public static RemoteStub exportObject(Remote obj) throws RemoteException {
|
|||
{
|
||||
if (obj instanceof RemoteObject)
|
||||
{
|
||||
deleteStub(obj);
|
||||
UnicastServerRef sref = (UnicastServerRef)((RemoteObject)obj).getRef();
|
||||
return sref.unexportObject(obj, force);
|
||||
deleteStub(obj);
|
||||
UnicastServerRef sref =
|
||||
(UnicastServerRef) ((RemoteObject) obj).getRef();
|
||||
return sref.unexportObject(obj, force);
|
||||
}
|
||||
else
|
||||
{
|
||||
//FIX ME
|
||||
;
|
||||
// FIXME
|
||||
;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue