summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/gnu/java/rmi/server
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/gnu/java/rmi/server')
-rw-r--r--libjava/classpath/gnu/java/rmi/server/ActivatableRef.java14
-rw-r--r--libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java32
-rw-r--r--libjava/classpath/gnu/java/rmi/server/CombinedClassLoader.java12
-rw-r--r--libjava/classpath/gnu/java/rmi/server/ConnectionRunnerPool.java90
-rw-r--r--libjava/classpath/gnu/java/rmi/server/ProtocolConstants.java2
-rw-r--r--libjava/classpath/gnu/java/rmi/server/RMIClassLoaderImpl.java56
-rw-r--r--libjava/classpath/gnu/java/rmi/server/RMIDefaultSocketFactory.java8
-rw-r--r--libjava/classpath/gnu/java/rmi/server/RMIHashes.java9
-rw-r--r--libjava/classpath/gnu/java/rmi/server/RMIIncomingThread.java40
-rw-r--r--libjava/classpath/gnu/java/rmi/server/RMIObjectInputStream.java26
-rw-r--r--libjava/classpath/gnu/java/rmi/server/RMIObjectOutputStream.java18
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastConnection.java164
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastConnectionManager.java226
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastRef.java6
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastRemoteCall.java150
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastRemoteStub.java6
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastServer.java46
-rw-r--r--libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java92
18 files changed, 497 insertions, 500 deletions
diff --git a/libjava/classpath/gnu/java/rmi/server/ActivatableRef.java b/libjava/classpath/gnu/java/rmi/server/ActivatableRef.java
index e7580bcd79d..a6faaca2e58 100644
--- a/libjava/classpath/gnu/java/rmi/server/ActivatableRef.java
+++ b/libjava/classpath/gnu/java/rmi/server/ActivatableRef.java
@@ -58,7 +58,7 @@ import java.rmi.server.RemoteRef;
* appears to be not accessible, it tries to reactivate it before reporting
* any errors. Apart the fields of the UnicastRef, the activatable reference
* contains the ActivationID that is used for this activation.
- *
+ *
* @author Audrius Meskauskas (Audriusa@Bioinformatics.org)
*/
public class ActivatableRef extends UnicastRef
@@ -67,12 +67,12 @@ public class ActivatableRef extends UnicastRef
* Use serial version UID for iteroperability
*/
private static final long serialVersionUID = 1;
-
+
/**
* The activation id.
*/
ActivationID actId;
-
+
/**
* Delegate call to the superclass.
*/
@@ -128,7 +128,7 @@ public class ActivatableRef extends UnicastRef
out.writeUTF("UnicastRef2");
super.writeExternal(out);
}
-
+
/**
* Invoke the remote method on the given object and try to activate the object
* if it is not reacheable with the current manager.
@@ -153,10 +153,10 @@ public class ActivatableRef extends UnicastRef
}
else if (Proxy.isProxyClass(reactivated.getClass()))
{
- RemoteObjectInvocationHandler hander =
- (RemoteObjectInvocationHandler)
+ RemoteObjectInvocationHandler hander =
+ (RemoteObjectInvocationHandler)
Proxy.getInvocationHandler(reactivated);
-
+
RemoteRef ref = hander.getRef();
manager = ((UnicastRef) ref).manager;
}
diff --git a/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java b/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java
index 5b7dadfd217..31e825a25ae 100644
--- a/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java
+++ b/libjava/classpath/gnu/java/rmi/server/ActivatableServerRef.java
@@ -54,7 +54,7 @@ import java.rmi.server.Skeleton;
* additionally activates the associated object on demand, during the first
* incoming call. When UnicastServerReference takes the working reference,
* the ActivatableServerRef takes the activation id instead.
- *
+ *
* @author Audrius Meskauskas (Audriusa@Bioinformatics.org)
*/
public class ActivatableServerRef extends UnicastServerRef
@@ -63,7 +63,7 @@ public class ActivatableServerRef extends UnicastServerRef
* Use SVUID for interoperability
*/
private static final long serialVersionUID = 1;
-
+
/**
* The object activation id.
*/
@@ -76,7 +76,7 @@ public class ActivatableServerRef extends UnicastServerRef
{
super();
}
-
+
/**
* Create the new activatable server reference that will activate object on
* the first call using the given activation id.
@@ -87,13 +87,13 @@ public class ActivatableServerRef extends UnicastServerRef
{
super(id, aPort, ssFactory);
actId = anId;
-
+
// The object ID will be placed in the object map and should deliver
// incoming call to {@link #incommingMessageCall}. The object itself
// is currently null.
UnicastServer.exportActivatableObject(this);
}
-
+
/**
* Inactivate the object (stop the server).
*/
@@ -101,7 +101,7 @@ public class ActivatableServerRef extends UnicastServerRef
{
manager.stopServer();
}
-
+
/**
* Activate the object (normally during the first call).
*/
@@ -110,7 +110,7 @@ public class ActivatableServerRef extends UnicastServerRef
try
{
Remote self = actId.activate(false);
-
+
// This will call UnicastServer.exportObject, replacing null by
// the activated object (self) in the object map.
exportObject(self);
@@ -139,7 +139,7 @@ public class ActivatableServerRef extends UnicastServerRef
}
/**
- * Export object and ensure it is present in the server activation table
+ * Export object and ensure it is present in the server activation table
* as well.
*/
public Remote exportObject(Remote obj) throws RemoteException
@@ -148,11 +148,11 @@ public class ActivatableServerRef extends UnicastServerRef
UnicastServer.registerActivatable(this);
return r;
}
-
+
/**
* Export object and ensure it is present in the server activation table as
* well.
- *
+ *
* @param aClass the class being exported, must implement Remote.
*/
public Remote exportClass(Class aClass) throws RemoteException
@@ -161,17 +161,17 @@ public class ActivatableServerRef extends UnicastServerRef
throw new InternalError(aClass.getName()+" must implement Remote");
String ignoreStubs;
-
- ClassLoader loader =aClass.getClassLoader();
-
+
+ ClassLoader loader =aClass.getClassLoader();
+
// Stubs are always searched for the bootstrap classes that may have
// obsolete pattern and may still need also skeletons.
if (loader==null)
ignoreStubs = "false";
else
- ignoreStubs = System.getProperty("java.rmi.server.ignoreStubClasses",
+ ignoreStubs = System.getProperty("java.rmi.server.ignoreStubClasses",
"false");
-
+
if (! ignoreStubs.equals("true"))
{
// Find and install the stub
@@ -223,5 +223,5 @@ public class ActivatableServerRef extends UnicastServerRef
super.writeExternal(out);
out.writeObject(actId);
}
-
+
}
diff --git a/libjava/classpath/gnu/java/rmi/server/CombinedClassLoader.java b/libjava/classpath/gnu/java/rmi/server/CombinedClassLoader.java
index 6225fb30bc6..3d01d098774 100644
--- a/libjava/classpath/gnu/java/rmi/server/CombinedClassLoader.java
+++ b/libjava/classpath/gnu/java/rmi/server/CombinedClassLoader.java
@@ -49,8 +49,8 @@ import java.util.ArrayList;
* This class supports the multiple class loaders to load the resources. It is
* used for constructing proxy classes that implement interfaces, loaded by
* the several different class loaders.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
public class CombinedClassLoader extends ClassLoader
{
@@ -58,20 +58,20 @@ public class CombinedClassLoader extends ClassLoader
* The class loader array.
*/
ClassLoader[] loaders;
-
+
/**
* Create a new combined class loader that uses the given collection of
* loaders to load the classes and resources. The loader order is equal to
* the order, returned by the collection interator. The duplicate loaders
* are discarded and the system class loader is added as the last loader.
- *
+ *
* @param a_loaders the loadery collection (may contain duplicate instances
* that will be discarded.
*/
public CombinedClassLoader(Collection a_loaders)
{
ArrayList sLoaders = new ArrayList(a_loaders.size());
-
+
Iterator iter = a_loaders.iterator();
Object cl;
while (iter.hasNext())
@@ -80,7 +80,7 @@ public class CombinedClassLoader extends ClassLoader
if (cl!=null && !sLoaders.contains(cl))
sLoaders.add(cl);
}
-
+
loaders = new ClassLoader[sLoaders.size()];
for (int i = 0; i < loaders.length; i++)
diff --git a/libjava/classpath/gnu/java/rmi/server/ConnectionRunnerPool.java b/libjava/classpath/gnu/java/rmi/server/ConnectionRunnerPool.java
index 9f2b3706e86..86660fea733 100644
--- a/libjava/classpath/gnu/java/rmi/server/ConnectionRunnerPool.java
+++ b/libjava/classpath/gnu/java/rmi/server/ConnectionRunnerPool.java
@@ -7,7 +7,7 @@ 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
@@ -45,61 +45,61 @@ import java.util.Arrays;
class ConnectionRunnerPool
{
-
- public static
+
+ public static
class ConnectionRunner extends Thread{
private UnicastConnection conn;
private volatile boolean exiting = false;
-
+
public ConnectionRunner(ThreadGroup group, String id){
super(group, id);
}
-
+
public synchronized void run(){
while(!exiting){
- if(conn == null)
- try{
- wait();
- }catch(InterruptedException e){
- continue;
- }
- else{
- conn.run();
- conn = null;
- synchronized(ConnectionRunnerPool.class){
- freelist.add(this);
- if(freelist.size() == 1)
- ConnectionRunnerPool.class.notifyAll();
- }
- }
+ if(conn == null)
+ try{
+ wait();
+ }catch(InterruptedException e){
+ continue;
+ }
+ else{
+ conn.run();
+ conn = null;
+ synchronized(ConnectionRunnerPool.class){
+ freelist.add(this);
+ if(freelist.size() == 1)
+ ConnectionRunnerPool.class.notifyAll();
+ }
+ }
}
}
-
+
public synchronized void dispatch(UnicastConnection conn){
this.conn = conn;
notify();
}
-
+
void exit(){
exiting = true;
if(conn != null)
- try{
- join(500);
- }catch(InterruptedException e){}
+ try{
+ join(500);
+ }catch(InterruptedException e){}
interrupt();
}
-
+
}
-
+
// Should this value equal to number of CPU?
private static int size = 5;
private static int max_size = 10;
-
+
// Package-private to avoid a trampoline.
static ArrayList freelist;
-
+
private static ThreadGroup group = new ThreadGroup("pool");
-
+
static {
ConnectionRunner[] pools = new ConnectionRunner[size];
for(int i = 0; i < pools.length; i++){
@@ -109,42 +109,42 @@ class ConnectionRunnerPool
}
freelist = new ArrayList(Arrays.asList(pools));
}
-
+
public static void setSize(int size_){
size = size_;
}
-
+
public static void setMaxSize(int size){
max_size = size;
}
-
+
private static synchronized ConnectionRunner getConnectionRunner()
{
if(freelist.size() == 0){
if(size < max_size){
- ++size;
- ConnectionRunner a = new ConnectionRunner(group, Integer.toString(size));
- a.start();
- freelist.add(a);
+ ++size;
+ ConnectionRunner a = new ConnectionRunner(group, Integer.toString(size));
+ a.start();
+ freelist.add(a);
}else
- while(freelist.size() == 0)
- try{
- ConnectionRunnerPool.class.wait();
- }catch(InterruptedException e){}
+ while(freelist.size() == 0)
+ try{
+ ConnectionRunnerPool.class.wait();
+ }catch(InterruptedException e){}
}
-
+
// always let the first in pool most busy or other scheduling plan??
ConnectionRunner a = (ConnectionRunner)freelist.get(0);
freelist.remove(a);
return a;
}
-
+
public static void dispatchConnection(UnicastConnection conn)
{
ConnectionRunner r = getConnectionRunner();
r.dispatch(conn);
}
-
+
public static void exit()
{
Thread[] list = new Thread[group.activeCount()];
@@ -152,5 +152,5 @@ class ConnectionRunnerPool
for(int i = 0; i < list.length; i++)
((ConnectionRunner)list[i]).exit();
}
-
+
}
diff --git a/libjava/classpath/gnu/java/rmi/server/ProtocolConstants.java b/libjava/classpath/gnu/java/rmi/server/ProtocolConstants.java
index 30fb5e89b39..72fbefe61df 100644
--- a/libjava/classpath/gnu/java/rmi/server/ProtocolConstants.java
+++ b/libjava/classpath/gnu/java/rmi/server/ProtocolConstants.java
@@ -7,7 +7,7 @@ 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
diff --git a/libjava/classpath/gnu/java/rmi/server/RMIClassLoaderImpl.java b/libjava/classpath/gnu/java/rmi/server/RMIClassLoaderImpl.java
index 9c3edef76d8..b090d3444d4 100644
--- a/libjava/classpath/gnu/java/rmi/server/RMIClassLoaderImpl.java
+++ b/libjava/classpath/gnu/java/rmi/server/RMIClassLoaderImpl.java
@@ -90,21 +90,21 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
private final String annotation;
}
- /**
- * This class is used to identify a cached classloader by its codebase and
+ /**
+ * This class is used to identify a cached classloader by its codebase and
* the context classloader that is its parent.
- */
+ */
private static class CacheKey
{
private String mCodeBase;
private ClassLoader mContextClassLoader;
-
+
public CacheKey (String theCodebase, ClassLoader theContextClassLoader)
{
mCodeBase = theCodebase;
mContextClassLoader = theContextClassLoader;
}
-
+
/**
* @return true if the codebase and the context classloader are equal
*/
@@ -113,13 +113,13 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
if (theOther instanceof CacheKey)
{
CacheKey key = (CacheKey) theOther;
-
+
return (equals (this.mCodeBase,key.mCodeBase)
&& equals (this.mContextClassLoader, key.mContextClassLoader));
}
return false;
}
-
+
/**
* Test if the two objects are equal or both null.
* @param theOne
@@ -132,17 +132,17 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
}
/**
- * @return hashCode
+ * @return hashCode
*/
public int hashCode()
{
- return ((mCodeBase != null ? mCodeBase.hashCode() : 0)
+ return ((mCodeBase != null ? mCodeBase.hashCode() : 0)
^(mContextClassLoader != null ? mContextClassLoader.hashCode() : -1));
}
public String toString()
{
- return "[" + mCodeBase + "," + mContextClassLoader + "]";
+ return "[" + mCodeBase + "," + mContextClassLoader + "]";
}
}
@@ -214,7 +214,7 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
ClassLoader defaultLoader)
throws MalformedURLException, ClassNotFoundException
{
- try
+ try
{
if (defaultLoader != null)
return Class.forName(name, false, defaultLoader);
@@ -236,7 +236,7 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
{
clss[i] = loadClass(codeBase, interfaces[i], defaultLoader);
}
-
+
// Chain all class loaders (they may differ).
ArrayList loaders = new ArrayList(clss.length);
ClassLoader loader = null;
@@ -266,11 +266,11 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
/**
* Gets a classloader for the given codebase and with the current
* context classloader as parent.
- *
+ *
* @param codebase
- *
+ *
* @return a classloader for the given codebase
- *
+ *
* @throws MalformedURLException if the codebase contains a malformed URL
*/
public ClassLoader getClassLoader(String codebase)
@@ -283,23 +283,23 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
CacheKey loaderKey = new CacheKey
(codebase, Thread.currentThread().getContextClassLoader());
loader = (ClassLoader) cacheLoaders.get (loaderKey);
-
+
if (loader == null)
{
//create an entry in cacheLoaders mapping a loader to codebases.
// codebases are separated by " "
StringTokenizer tok = new StringTokenizer (codebase, " ");
ArrayList urls = new ArrayList();
-
+
while (tok.hasMoreTokens())
urls.add (new URL(tok.nextToken()));
-
+
loader = new MyClassLoader((URL[]) urls.toArray(new URL [urls.size()]),
Thread.currentThread().getContextClassLoader(),
codebase);
cacheLoaders.put (loaderKey, loader);
}
-
+
return loader;
}
@@ -315,38 +315,38 @@ public class RMIClassLoaderImpl extends RMIClassLoaderSpi
public String getClassAnnotation(Class cl)
{
ClassLoader loader = cl.getClassLoader();
-
+
if (loader == null
|| loader == ClassLoader.getSystemClassLoader())
{
return System.getProperty ("java.rmi.server.codebase");
}
-
+
if (loader instanceof MyClassLoader)
{
return ((MyClassLoader) loader).getClassAnnotation();
}
-
+
String s = (String) cacheAnnotations.get (loader);
-
+
if (s != null)
return s;
-
+
if (loader instanceof URLClassLoader)
{
URL[] urls = ((URLClassLoader) loader).getURLs();
-
+
if (urls.length == 0)
return null;
-
+
CPStringBuilder annotation = new CPStringBuilder (64 * urls.length);
-
+
for (int i = 0; i < urls.length; i++)
{
annotation.append (urls [i].toExternalForm());
annotation.append (' ');
}
-
+
s = annotation.toString();
cacheAnnotations.put (loader, s);
return s;
diff --git a/libjava/classpath/gnu/java/rmi/server/RMIDefaultSocketFactory.java b/libjava/classpath/gnu/java/rmi/server/RMIDefaultSocketFactory.java
index 628e1cc8799..7115ba5431d 100644
--- a/libjava/classpath/gnu/java/rmi/server/RMIDefaultSocketFactory.java
+++ b/libjava/classpath/gnu/java/rmi/server/RMIDefaultSocketFactory.java
@@ -7,7 +7,7 @@ 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
@@ -43,17 +43,17 @@ import java.net.Socket;
import java.rmi.server.RMISocketFactory;
public class RMIDefaultSocketFactory
- extends RMISocketFactory {
+ extends RMISocketFactory {
public RMIDefaultSocketFactory() {
}
public Socket createSocket(String host, int port) throws IOException {
- return (new Socket(host, port));
+ return (new Socket(host, port));
}
public ServerSocket createServerSocket(int port) throws IOException {
- return (new ServerSocket(port));
+ return (new ServerSocket(port));
}
}
diff --git a/libjava/classpath/gnu/java/rmi/server/RMIHashes.java b/libjava/classpath/gnu/java/rmi/server/RMIHashes.java
index c3665a4e73b..03eb09fd002 100644
--- a/libjava/classpath/gnu/java/rmi/server/RMIHashes.java
+++ b/libjava/classpath/gnu/java/rmi/server/RMIHashes.java
@@ -7,7 +7,7 @@ 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
@@ -51,7 +51,7 @@ public class RMIHashes
{
//There're other places using DigestOutputStream to generate hash in classpath, but I think the way I used
//here is more efficient, anyway, you can switch to DigestOutputStream by doing like "//or:" comments say.
-
+
//or:add this statement: private static final NullOutputStream nullOutputStream = new NullOutputStream ();
public static long getMethodHash(Method meth)
{
@@ -62,7 +62,7 @@ public class RMIHashes
//or:remove this statement: DigestOutputStream digest_out = new DigestOutputStream (nullOutputStream, md);
ByteArrayOutputStream digest_out = new ByteArrayOutputStream();
DataOutputStream data_out = new DataOutputStream (digest_out);
-
+
CPStringBuilder sbuf = new CPStringBuilder();
sbuf.append(meth.getName());
sbuf.append('(');
@@ -75,7 +75,7 @@ public class RMIHashes
sbuf.append(TypeSignature.getEncodingOfClass(rcls));
else
sbuf.append('V');
-
+
data_out.writeUTF (sbuf.toString());
data_out.flush();
data_out.close ();
@@ -97,4 +97,3 @@ public class RMIHashes
return clazz.hashCode ();
}
}
-
diff --git a/libjava/classpath/gnu/java/rmi/server/RMIIncomingThread.java b/libjava/classpath/gnu/java/rmi/server/RMIIncomingThread.java
index 990d37bc521..352b48b31b5 100644
--- a/libjava/classpath/gnu/java/rmi/server/RMIIncomingThread.java
+++ b/libjava/classpath/gnu/java/rmi/server/RMIIncomingThread.java
@@ -7,7 +7,7 @@ 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
@@ -35,24 +35,24 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
-package gnu.java.rmi.server;
-
-public class RMIIncomingThread extends Thread {
-
- private String clientHost = null;
-
- public RMIIncomingThread(Runnable runnable, String s_clientHost) {
- super(runnable);
- clientHost = s_clientHost;
- }
-
- public String toString() {
- return "RMIIncoming from " + clientHost + " " + super.toString();
- }
-
- public String getClientHost() {
- return clientHost;
- }
-
+package gnu.java.rmi.server;
+
+public class RMIIncomingThread extends Thread {
+
+ private String clientHost = null;
+
+ public RMIIncomingThread(Runnable runnable, String s_clientHost) {
+ super(runnable);
+ clientHost = s_clientHost;
+ }
+
+ public String toString() {
+ return "RMIIncoming from " + clientHost + " " + super.toString();
+ }
+
+ public String getClientHost() {
+ return clientHost;
+ }
+
}
diff --git a/libjava/classpath/gnu/java/rmi/server/RMIObjectInputStream.java b/libjava/classpath/gnu/java/rmi/server/RMIObjectInputStream.java
index 65a13f991b3..4ac7a0ae8c5 100644
--- a/libjava/classpath/gnu/java/rmi/server/RMIObjectInputStream.java
+++ b/libjava/classpath/gnu/java/rmi/server/RMIObjectInputStream.java
@@ -8,7 +8,7 @@ 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
@@ -48,44 +48,44 @@ import java.net.MalformedURLException;
import java.rmi.server.RMIClassLoader;
public class RMIObjectInputStream
- extends ObjectInputStream {
+ extends ObjectInputStream {
public RMIObjectInputStream(InputStream strm) throws IOException {
- super(strm);
- enableResolveObject(true);
+ super(strm);
+ enableResolveObject(true);
}
protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
- try {
+ try {
return RMIClassLoader.loadClass(
(String)getAnnotation(),
desc.getName(),
VMStackWalker.firstNonNullClassLoader());
- }
- catch (MalformedURLException x) {
- throw new ClassNotFoundException(desc.getName(), x);
- }
+ }
+ catch (MalformedURLException x) {
+ throw new ClassNotFoundException(desc.getName(), x);
+ }
}
//Separate it for override by MarshalledObject
protected Object getAnnotation()
- throws IOException, ClassNotFoundException
+ throws IOException, ClassNotFoundException
{
return readObject();
}
-
+
protected Class resolveProxyClass(String intfs[]) throws IOException,
ClassNotFoundException
{
- try
+ try
{
return RMIClassLoader.loadProxyClass(
(String)getAnnotation(),
intfs,
VMStackWalker.firstNonNullClassLoader());
}
- catch (MalformedURLException x)
+ catch (MalformedURLException x)
{
throw new ClassNotFoundException(null, x);
}
diff --git a/libjava/classpath/gnu/java/rmi/server/RMIObjectOutputStream.java b/libjava/classpath/gnu/java/rmi/server/RMIObjectOutputStream.java
index d42908a4147..aaf09860ccd 100644
--- a/libjava/classpath/gnu/java/rmi/server/RMIObjectOutputStream.java
+++ b/libjava/classpath/gnu/java/rmi/server/RMIObjectOutputStream.java
@@ -8,7 +8,7 @@ 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
@@ -47,11 +47,11 @@ import java.rmi.server.RMIClassLoader;
import java.rmi.server.RemoteStub;
public class RMIObjectOutputStream
- extends ObjectOutputStream {
+ extends ObjectOutputStream {
public RMIObjectOutputStream(OutputStream strm) throws IOException {
- super(strm);
- enableReplaceObject(true);
+ super(strm);
+ enableReplaceObject(true);
}
//Separate it for override by MarshalledObject
@@ -60,7 +60,7 @@ protected void setAnnotation(String annotation) throws IOException{
}
protected void annotateClass(Class cls) throws IOException {
- setAnnotation(RMIClassLoader.getClassAnnotation(cls));
+ setAnnotation(RMIClassLoader.getClassAnnotation(cls));
}
protected void annotateProxyClass(Class cls)
@@ -68,14 +68,14 @@ protected void annotateProxyClass(Class cls)
{
annotateClass(cls);
}
-
+
protected Object replaceObject(Object obj)
throws IOException
{
if((obj instanceof Remote) && !(obj instanceof RemoteStub)){
- UnicastServerRef ref = UnicastServer.getExportedRef((Remote)obj);
- if (ref != null)
- return ref.getStub();
+ UnicastServerRef ref = UnicastServer.getExportedRef((Remote)obj);
+ if (ref != null)
+ return ref.getStub();
}
return obj;
}
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastConnection.java b/libjava/classpath/gnu/java/rmi/server/UnicastConnection.java
index 216e453e72f..8245e0469e1 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastConnection.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastConnection.java
@@ -8,7 +8,7 @@ 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
@@ -49,8 +49,8 @@ import java.io.ObjectOutputStream;
import java.net.Socket;
import java.rmi.RemoteException;
-public class UnicastConnection
- implements Runnable, ProtocolConstants {
+public class UnicastConnection
+ implements Runnable, ProtocolConstants {
UnicastConnectionManager manager;
Socket sock;
@@ -64,78 +64,78 @@ long reviveTime = 0;
long expireTime = Long.MAX_VALUE;
UnicastConnection(UnicastConnectionManager man, Socket sock) {
- this.manager = man;
- this.sock = sock;
+ this.manager = man;
+ this.sock = sock;
}
void acceptConnection() throws IOException {
//System.out.println("Accepting connection on " + sock);
//Use BufferedXXXStream would be more efficient
- din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
- dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
-
- int sig = din.readInt();
- if (sig != PROTOCOL_HEADER) {
- throw new IOException("bad protocol header");
- }
- short ver = din.readShort();
- if (ver != PROTOCOL_VERSION) {
- throw new IOException("bad protocol version");
- }
- int protocol = din.readUnsignedByte();
- if (protocol != SINGLE_OP_PROTOCOL) {
- // Send an ACK
- dout.writeByte(PROTOCOL_ACK);
-
- // Send my hostname and port
- dout.writeUTF(manager.serverName);
- dout.writeInt(manager.serverPort);
- dout.flush();
-
- // Read their hostname and port
- String rhost = din.readUTF();
- int rport = din.readInt();
- }
- // Okay, ready to roll ...
+ din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
+ dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
+
+ int sig = din.readInt();
+ if (sig != PROTOCOL_HEADER) {
+ throw new IOException("bad protocol header");
+ }
+ short ver = din.readShort();
+ if (ver != PROTOCOL_VERSION) {
+ throw new IOException("bad protocol version");
+ }
+ int protocol = din.readUnsignedByte();
+ if (protocol != SINGLE_OP_PROTOCOL) {
+ // Send an ACK
+ dout.writeByte(PROTOCOL_ACK);
+
+ // Send my hostname and port
+ dout.writeUTF(manager.serverName);
+ dout.writeInt(manager.serverPort);
+ dout.flush();
+
+ // Read their hostname and port
+ String rhost = din.readUTF();
+ int rport = din.readInt();
+ }
+ // Okay, ready to roll ...
}
void makeConnection(int protocol) throws IOException {
//Use BufferedXXXStream would be more efficient
- din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
+ din = new DataInputStream(new BufferedInputStream(sock.getInputStream()));
- dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
+ dout = new DataOutputStream(new BufferedOutputStream(sock.getOutputStream()));
- // Send header
- dout.writeInt(PROTOCOL_HEADER);
- dout.writeShort(PROTOCOL_VERSION);
- dout.writeByte(protocol);
+ // Send header
+ dout.writeInt(PROTOCOL_HEADER);
+ dout.writeShort(PROTOCOL_VERSION);
+ dout.writeByte(protocol);
dout.flush();
-
- if (protocol != SINGLE_OP_PROTOCOL) {
- // Get back ack.
- int ack = din.readUnsignedByte();
- if (ack != PROTOCOL_ACK) {
- throw new RemoteException("Unsupported protocol");
- }
-
- // Read in host and port
- String dicard_rhost = din.readUTF();
- int discard_rport = din.readInt();
-
- // Send them my endpoint
- dout.writeUTF(manager.serverName);
- dout.writeInt(manager.serverPort);
- dout.flush();
- }
- // Okay, ready to roll ...
+
+ if (protocol != SINGLE_OP_PROTOCOL) {
+ // Get back ack.
+ int ack = din.readUnsignedByte();
+ if (ack != PROTOCOL_ACK) {
+ throw new RemoteException("Unsupported protocol");
+ }
+
+ // Read in host and port
+ String dicard_rhost = din.readUTF();
+ int discard_rport = din.readInt();
+
+ // Send them my endpoint
+ dout.writeUTF(manager.serverName);
+ dout.writeInt(manager.serverPort);
+ dout.flush();
+ }
+ // Okay, ready to roll ...
}
DataInputStream getDataInputStream() throws IOException {
- return (din);
+ return (din);
}
DataOutputStream getDataOutputStream() throws IOException {
- return (dout);
+ return (dout);
}
/*
@@ -144,10 +144,10 @@ DataOutputStream getDataOutputStream() throws IOException {
*
*/
ObjectInputStream getObjectInputStream() throws IOException {
- if (oin == null) {
- throw new IOException("no ObjectInputtream for reading more objects");
- }
- return (oin);
+ if (oin == null) {
+ throw new IOException("no ObjectInputtream for reading more objects");
+ }
+ return (oin);
}
/**
@@ -156,7 +156,7 @@ ObjectInputStream getObjectInputStream() throws IOException {
*
*/
ObjectInputStream startObjectInputStream() throws IOException {
- return (oin = new RMIObjectInputStream(din));
+ return (oin = new RMIObjectInputStream(din));
}
/**
@@ -165,10 +165,10 @@ ObjectInputStream startObjectInputStream() throws IOException {
*
*/
ObjectOutputStream getObjectOutputStream() throws IOException {
- if (oout == null) {
- throw new IOException("no ObjectOutputStream for sending more objects");
- }
- return (oout);
+ if (oout == null) {
+ throw new IOException("no ObjectOutputStream for sending more objects");
+ }
+ return (oout);
}
/**
@@ -177,23 +177,23 @@ ObjectOutputStream getObjectOutputStream() throws IOException {
*
*/
ObjectOutputStream startObjectOutputStream() throws IOException {
- return (oout = new RMIObjectOutputStream(dout));
-}
+ return (oout = new RMIObjectOutputStream(dout));
+}
void disconnect() {
- try {
- if(oout != null)
- oout.close();
+ try {
+ if(oout != null)
+ oout.close();
sock.close();
- }
- catch (IOException _) {
+ }
+ catch (IOException _) {
}
- oin = null;
+ oin = null;
oout = null;
- din = null;
- dout = null;
- sock = null;
+ din = null;
+ dout = null;
+ sock = null;
}
public static final long CONNECTION_TIMEOUT = 10000L;
@@ -215,15 +215,15 @@ static void resetTime(UnicastConnection conn){
*/
public void run() {
do{
- try {
- UnicastServer.dispatch(this);
+ try {
+ UnicastServer.dispatch(this);
//don't discardConnection explicitly, only when
- // exception happens or the connection's expireTime
+ // exception happens or the connection's expireTime
// comes
} catch (Exception e ){
- manager.discardConnection(this);
+ manager.discardConnection(this);
break;
- }
+ }
}while(true);
}
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastConnectionManager.java b/libjava/classpath/gnu/java/rmi/server/UnicastConnectionManager.java
index a9992af9fa4..981d1179218 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastConnectionManager.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastConnectionManager.java
@@ -8,7 +8,7 @@ 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
@@ -56,7 +56,7 @@ import java.util.Hashtable;
import java.util.Iterator;
public class UnicastConnectionManager
- implements Runnable, ProtocolConstants {
+ implements Runnable, ProtocolConstants {
private static String localhost;
// use different maps for server/client type UnicastConnectionManager
@@ -100,8 +100,8 @@ static {
catch (UnknownHostException _) {
localhost = "localhost";
}
-
-
+
+
}
//Only one scavenger thread running globally
@@ -134,7 +134,7 @@ private static void startScavenger(){
if (UnicastConnection.isExpired(conn, l)){
conns.remove(last);
conn.disconnect();
- conn = null;
+ conn = null;
}else
liveon = true; //there're still live connections
}
@@ -159,11 +159,11 @@ private static void startScavenger(){
* Client UnicastConnectionManager constructor
*/
private UnicastConnectionManager(String host, int port, RMIClientSocketFactory csf) {
- ssock = null;
- serverName = host;
- serverPort = port;
- serverFactory = null;
- clientFactory = csf;
+ ssock = null;
+ serverName = host;
+ serverPort = port;
+ serverFactory = null;
+ clientFactory = csf;
connections = new ArrayList();
}
@@ -172,24 +172,24 @@ private UnicastConnectionManager(String host, int port, RMIClientSocketFactory c
*/
private UnicastConnectionManager(int port, RMIServerSocketFactory ssf) throws RemoteException {
- try {
- ssock = ssf.createServerSocket(port);
- serverPort = ssock.getLocalPort();
- }
- catch (IOException ioex) {
- ssock = null;
- serverPort = 0;
- throw new java.rmi.server.ExportException("can not create Server Socket on port " + port,ioex);
- }
- // Note that for compatibility the serverName is "localhost",
- // not UnicastConnectionManager.localhost, which is the name
- // of the local box. A server listening on localhost:port is
- // listening on the loopback interface, 127.0.0.1, but
- // UnicastConnectionManager.localhost is an externally
- // accessible IP address.
- serverName = "localhost";
- serverFactory = ssf;
- clientFactory = null;
+ try {
+ ssock = ssf.createServerSocket(port);
+ serverPort = ssock.getLocalPort();
+ }
+ catch (IOException ioex) {
+ ssock = null;
+ serverPort = 0;
+ throw new java.rmi.server.ExportException("can not create Server Socket on port " + port,ioex);
+ }
+ // Note that for compatibility the serverName is "localhost",
+ // not UnicastConnectionManager.localhost, which is the name
+ // of the local box. A server listening on localhost:port is
+ // listening on the loopback interface, 127.0.0.1, but
+ // UnicastConnectionManager.localhost is an externally
+ // accessible IP address.
+ serverName = "localhost";
+ serverFactory = ssf;
+ clientFactory = null;
}
/**
@@ -198,31 +198,31 @@ private UnicastConnectionManager(int port, RMIServerSocketFactory ssf) throws Re
*/
public static synchronized UnicastConnectionManager getInstance(String host, int port, RMIClientSocketFactory csf) {
//System.out.println("getInstance: " + host + "," + port + "," + csf);
- if (csf == null) {
+ if (csf == null) {
csf = defaultSocketFactory;
- }
- // change host name to host address to avoid name resolving issues
- try{
- host = InetAddress.getByName(host).getHostAddress();
+ }
+ // change host name to host address to avoid name resolving issues
+ try{
+ host = InetAddress.getByName(host).getHostAddress();
}catch(Exception _){}
-
- TripleKey key = new TripleKey(host, port, csf);
- UnicastConnectionManager man = (UnicastConnectionManager)clients.get(key);
- if (man == null) {
- man = new UnicastConnectionManager(host, port, csf);
+
+ TripleKey key = new TripleKey(host, port, csf);
+ UnicastConnectionManager man = (UnicastConnectionManager)clients.get(key);
+ if (man == null) {
+ man = new UnicastConnectionManager(host, port, csf);
if (debug) {
ncmanager++;
System.out.println("\n\n ====== " + ncmanager + " client managers.\n\n");
}
- clients.put(key, man);
-
+ clients.put(key, man);
+
// Detect if client and server are in the same VM, i.e., their keys are equal
UnicastConnectionManager svrman = (UnicastConnectionManager)servers.get(key);
if(svrman != null){ // server and client are in the same VM
man.serverobj = svrman.serverobj;
}
- }
- return (man);
+ }
+ return (man);
}
/**
@@ -231,50 +231,50 @@ public static synchronized UnicastConnectionManager getInstance(String host, int
*/
public static synchronized UnicastConnectionManager getInstance(int port, RMIServerSocketFactory ssf) throws RemoteException {
//System.out.println("getInstance: " + port + "," + ssf);
- if (ssf == null) {
+ if (ssf == null) {
ssf = defaultSocketFactory;
- }
- TripleKey key = new TripleKey(localhost, port, ssf);
- UnicastConnectionManager man = (UnicastConnectionManager)servers.get(key);
- if (man == null) {
- man = new UnicastConnectionManager(port, ssf);
+ }
+ TripleKey key = new TripleKey(localhost, port, ssf);
+ UnicastConnectionManager man = (UnicastConnectionManager)servers.get(key);
+ if (man == null) {
+ man = new UnicastConnectionManager(port, ssf);
if (debug) {
nsmanager++;
System.out.println("\n\n ****** " + nsmanager + " server managers.\n\n");
}
- // The provided port might not be the set port.
- key.port = man.serverPort;
- servers.put(key, man);
- }
- return (man);
+ // The provided port might not be the set port.
+ key.port = man.serverPort;
+ servers.put(key, man);
+ }
+ return (man);
}
/**
* Get a connection from this manager.
*/
public UnicastConnection getConnection() throws IOException {
- if (ssock == null) {
- return (getClientConnection());
- }
- else {
- return (getServerConnection());
- }
+ if (ssock == null) {
+ return (getClientConnection());
+ }
+ else {
+ return (getServerConnection());
+ }
}
/**
* Accept a connection to this server.
*/
private UnicastConnection getServerConnection() throws IOException {
- Socket sock = ssock.accept();
+ Socket sock = ssock.accept();
sock.setTcpNoDelay(true); //??
- UnicastConnection conn = new UnicastConnection(this, sock);
- conn.acceptConnection();
+ UnicastConnection conn = new UnicastConnection(this, sock);
+ conn.acceptConnection();
if (debug){
nssock++;
System.out.println("\n\n ****** " + nssock + " server socks.\n\n");
}
//System.out.println("Server connection " + sock);
- return (conn);
+ return (conn);
}
/**
@@ -283,37 +283,37 @@ private UnicastConnection getServerConnection() throws IOException {
private UnicastConnection getClientConnection() throws IOException {
ArrayList conns = connections;
UnicastConnection conn;
-
+
synchronized(conns) {
int nconn = conns.size() - 1;
-
+
// if there're free connections in connection pool
if(nconn >= 0) {
conn = (UnicastConnection)conns.get(nconn);
//Should we check if conn is alive using Ping??
conns.remove(nconn);
-
+
// Check if the connection is already expired
long l = System.currentTimeMillis();
if (!UnicastConnection.isExpired(conn, l)){
return conn;
}else {
conn.disconnect();
- conn = null;
+ conn = null;
}
}
}
-
- Socket sock = clientFactory.createSocket(serverName, serverPort);
+
+ Socket sock = clientFactory.createSocket(serverName, serverPort);
conn = new UnicastConnection(this, sock);
- conn.makeConnection(DEFAULT_PROTOCOL);
-
+ conn.makeConnection(DEFAULT_PROTOCOL);
+
if (debug) {
ncsock++;
System.out.println("\n\n ====== " + ncsock + " client socks.\n\n");
}
- return (conn);
+ return (conn);
}
/**
@@ -332,13 +332,13 @@ public void discardConnection(UnicastConnection conn) {
//System.out.println("Discarding connection " + conn);
//conn.disconnect();
if (ssock != null) //server connection
- conn.disconnect();
+ conn.disconnect();
else {
// To client connection, we'd like to return back to pool
UnicastConnection.resetTime(conn);
//Ensure there're only one scavenger globally
synchronized(GLOBAL_LOCK) {
- connections.add(conn); //borrow this lock to garantee thread safety
+ connections.add(conn); //borrow this lock to garantee thread safety
if (scavenger == null)
startScavenger();
}
@@ -350,15 +350,15 @@ public void discardConnection(UnicastConnection conn) {
* already got one running.
*/
public void startServer() {
- synchronized(this) {
- if (ssock == null || serverThread != null) {
- return;
- }
- serverThread = new Thread(this);
+ synchronized(this) {
+ if (ssock == null || serverThread != null) {
+ return;
+ }
+ serverThread = new Thread(this);
// The following is not necessary when java.lang.Thread's constructor do this.
// serverThread.setContextClassLoader(Thread.currentThread().getContextClassLoader());
- }
- serverThread.start();
+ }
+ serverThread.start();
}
/**
@@ -366,12 +366,12 @@ public void startServer() {
*/
public void stopServer() {
synchronized(this) {
- if(serverThread != null){
- serverThread = null;
- try{
- ssock.close();
- }catch(Exception _){}
- }
+ if(serverThread != null){
+ serverThread = null;
+ try{
+ ssock.close();
+ }catch(Exception _){}
+ }
}
}
@@ -379,26 +379,26 @@ public void stopServer() {
* Server thread for connection manager.
*/
public void run() {
- for (;serverThread != null;) { // if serverThread==null, then exit thread
- try {
+ for (;serverThread != null;) { // if serverThread==null, then exit thread
+ try {
//System.out.println("Waiting for connection on " + serverPort);
- UnicastConnection conn = getServerConnection();
+ UnicastConnection conn = getServerConnection();
- // get address of remote host for the RMIIncomingThread object
- String remoteHost = null;
- if (conn.sock != null) {
- remoteHost = conn.sock.getInetAddress().getHostAddress();
- }
+ // get address of remote host for the RMIIncomingThread object
+ String remoteHost = null;
+ if (conn.sock != null) {
+ remoteHost = conn.sock.getInetAddress().getHostAddress();
+ }
- // use a thread pool to improve performance
+ // use a thread pool to improve performance
//ConnectionRunnerPool.dispatchConnection(conn);
(new RMIIncomingThread(conn, remoteHost)).start();
-// (new Thread(conn)).start();
- }
- catch (Exception e) {
+// (new Thread(conn)).start();
+ }
+ catch (Exception e) {
e.printStackTrace();
- }
- }
+ }
+ }
}
/**
@@ -432,9 +432,9 @@ int port;
Object other;
TripleKey(String host, int port, Object other) {
- this.host = host;
- this.port = port;
- this.other = other;
+ this.host = host;
+ this.port = port;
+ this.other = other;
}
/**
@@ -442,19 +442,19 @@ TripleKey(String host, int port, Object other) {
* this has unusual matching behaviour.
*/
public int hashCode() {
- return (host.hashCode() ^ other.hashCode());
+ return (host.hashCode() ^ other.hashCode());
}
public boolean equals(Object obj) {
- if (obj instanceof TripleKey) {
- TripleKey other = (TripleKey)obj;
- if (this.host.equals(other.host) &&
- this.other == other.other &&
+ if (obj instanceof TripleKey) {
+ TripleKey other = (TripleKey)obj;
+ if (this.host.equals(other.host) &&
+ this.other == other.other &&
(this.port == other.port /* || this.port == 0 || other.port == 0*/)) {
- return (true);
- }
- }
- return (false);
+ return (true);
+ }
+ }
+ return (false);
}
/**
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastRef.java b/libjava/classpath/gnu/java/rmi/server/UnicastRef.java
index def1acdcfc1..ca2bab51a8f 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastRef.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastRef.java
@@ -8,7 +8,7 @@ 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
@@ -461,7 +461,7 @@ public class UnicastRef
{
return ("UnicastRef");
}
-
+
/**
* Return the string representing the remote reference information.
*/
@@ -497,7 +497,7 @@ public class UnicastRef
/**
* Check if this UnicastRef points to the object as the passed UnicastRef.
* Both the object Id and manager must be the same.
- *
+ *
* @return true if the passed reference points to the same remote object as
* this reference, false otherwise.
*/
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastRemoteCall.java b/libjava/classpath/gnu/java/rmi/server/UnicastRemoteCall.java
index c5206e76df2..d0d77304ce8 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastRemoteCall.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastRemoteCall.java
@@ -54,7 +54,7 @@ import java.rmi.server.UID;
import java.util.Vector;
public class UnicastRemoteCall
- implements RemoteCall, ProtocolConstants
+ implements RemoteCall, ProtocolConstants
{
private UnicastConnection conn;
@@ -89,12 +89,12 @@ public class UnicastRemoteCall
this.hash = hash;
this.objid = objid;
}
-
+
UnicastConnection getConnection()
{
return conn;
}
-
+
public ObjectOutput getOutputStream() throws IOException
{
if (vec == null)
@@ -106,33 +106,33 @@ public class UnicastRemoteCall
{
if (vec != null)
{
- oout = conn.getObjectOutputStream();
-
- for (int i = 0; i < vec.size(); i += 2)
- {
- boolean primitive = ((Boolean)vec.elementAt(i)).booleanValue();
- Object data = vec.elementAt(i+1);
-
- // No type, this is
- if (!primitive)
- oout.writeObject(data);
- else
- {
- if (data instanceof Boolean)
- oout.writeBoolean(((Boolean)data).booleanValue());
- else if (data instanceof Character)
- oout.writeChar(((Character)data).charValue());
- else if (data instanceof Byte)
- oout.writeByte(((Byte)data).byteValue());
- else if (data instanceof Short)
- oout.writeShort(((Short)data).shortValue());
- else if (data instanceof Integer)
- oout.writeInt(((Integer)data).intValue());
- else if (data instanceof Long)
- oout.writeLong(((Long)data).longValue());
- }
- }
- vec = null;
+ oout = conn.getObjectOutputStream();
+
+ for (int i = 0; i < vec.size(); i += 2)
+ {
+ boolean primitive = ((Boolean)vec.elementAt(i)).booleanValue();
+ Object data = vec.elementAt(i+1);
+
+ // No type, this is
+ if (!primitive)
+ oout.writeObject(data);
+ else
+ {
+ if (data instanceof Boolean)
+ oout.writeBoolean(((Boolean)data).booleanValue());
+ else if (data instanceof Character)
+ oout.writeChar(((Character)data).charValue());
+ else if (data instanceof Byte)
+ oout.writeByte(((Byte)data).byteValue());
+ else if (data instanceof Short)
+ oout.writeShort(((Short)data).shortValue());
+ else if (data instanceof Integer)
+ oout.writeInt(((Integer)data).intValue());
+ else if (data instanceof Long)
+ oout.writeLong(((Long)data).longValue());
+ }
+ }
+ vec = null;
}
if(oout != null)
oout.flush();
@@ -142,14 +142,14 @@ public class UnicastRemoteCall
*
* (re)starts ObjectInputStream
*
- */
+ */
public ObjectInput startInputStream() throws IOException
{
- if (conn != null) {
- return (oin = conn.startObjectInputStream());
- } else {
- return getInputStream(); // dummy Input Stream
- }
+ if (conn != null) {
+ return (oin = conn.startObjectInputStream());
+ } else {
+ return getInputStream(); // dummy Input Stream
+ }
}
@@ -157,15 +157,15 @@ public class UnicastRemoteCall
{
if (conn != null)
{
- if(oin == null)
- return (oin = conn.getObjectInputStream());
- else
- return oin;
+ if(oin == null)
+ return (oin = conn.getObjectInputStream());
+ else
+ return oin;
}
else
{
- ptr = 0;
- return (new DummyObjectInputStream());
+ ptr = 0;
+ return (new DummyObjectInputStream());
}
}
@@ -180,34 +180,34 @@ public class UnicastRemoteCall
vec = new Vector();
return new DummyObjectOutputStream();
}
-
+
public void executeCall() throws Exception
{
byte returncode;
ObjectInput oin;
-
+
// signal the call when constructing
try
{
- DataOutputStream dout = conn.getDataOutputStream();
- dout.write(MESSAGE_CALL);
-
- oout = conn.startObjectOutputStream(); // (re)start ObjectOutputStream
- objid.write(oout);
- oout.writeInt(opnum);
- oout.writeLong(hash);
+ DataOutputStream dout = conn.getDataOutputStream();
+ dout.write(MESSAGE_CALL);
+
+ oout = conn.startObjectOutputStream(); // (re)start ObjectOutputStream
+ objid.write(oout);
+ oout.writeInt(opnum);
+ oout.writeLong(hash);
}
catch(IOException ex)
{
- throw new MarshalException("Try to write header but failed.", ex);
+ throw new MarshalException("Try to write header but failed.", ex);
}
try
{
- releaseOutputStream();
- DataInputStream din = conn.getDataInputStream();
+ releaseOutputStream();
+ DataInputStream din = conn.getDataInputStream();
if (din.readByte() != MESSAGE_CALL_ACK)
- throw new RemoteException("Call not acked");
+ throw new RemoteException("Call not acked");
oin = startInputStream();
returncode = oin.readByte();
@@ -217,31 +217,31 @@ public class UnicastRemoteCall
{
throw new UnmarshalException("Try to read header but failed:", ex);
}
-
+
//check return code
switch(returncode)
{
case RETURN_ACK: //it's ok
- return;
+ return;
case RETURN_NACK:
- Object returnobj;
- try
- {
- returnobj = oin.readObject();
- }
- catch(Exception ex2)
- {
- throw new UnmarshalException
- ("Try to read exception object but failed", ex2);
- }
-
- if(!(returnobj instanceof Exception))
- throw new UnmarshalException("Should be Exception type here: "
- + returnobj);
- throw (Exception)returnobj;
-
+ Object returnobj;
+ try
+ {
+ returnobj = oin.readObject();
+ }
+ catch(Exception ex2)
+ {
+ throw new UnmarshalException
+ ("Try to read exception object but failed", ex2);
+ }
+
+ if(!(returnobj instanceof Exception))
+ throw new UnmarshalException("Should be Exception type here: "
+ + returnobj);
+ throw (Exception)returnobj;
+
default:
- throw new UnmarshalException("Invalid return code");
+ throw new UnmarshalException("Invalid return code");
}
}
@@ -254,7 +254,7 @@ public class UnicastRemoteCall
{
return vec.size() > 0;
}
-
+
Object returnValue()
{
// This is not the first one (Boolean) but the second.
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastRemoteStub.java b/libjava/classpath/gnu/java/rmi/server/UnicastRemoteStub.java
index 87e932de559..179f3017991 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastRemoteStub.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastRemoteStub.java
@@ -7,7 +7,7 @@ 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
@@ -41,10 +41,10 @@ import java.rmi.server.RemoteRef;
import java.rmi.server.RemoteStub;
public class UnicastRemoteStub
- extends RemoteStub {
+ extends RemoteStub {
public static void setStubRef(RemoteStub stub, RemoteRef ref) {
- setRef(stub, ref);
+ setRef(stub, ref);
}
}
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastServer.java b/libjava/classpath/gnu/java/rmi/server/UnicastServer.java
index 7fe539546e9..db2bd2ff854 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastServer.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastServer.java
@@ -8,7 +8,7 @@ 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
@@ -75,21 +75,21 @@ public class UnicastServer
* Mapping obj itself to server ref by identity.
*/
static private Map refcache = Collections.synchronizedMap(new WeakIdentityHashMap());
-
+
/**
* Mapping the registered activatable objects into they server references.
*/
public static Map actIds = new Hashtable();
-
+
/**
- * The reference to the local distributed garbage collector.
+ * The reference to the local distributed garbage collector.
*/
static private DGCImpl dgc;
-
+
/**
* Connect this server reference to the server, allowing the local
* implementation, associated with this object, to receive remote calls.
- *
+ *
* @param obj the server reference, encloses the (usually local) remote
* object.
*/
@@ -100,7 +100,7 @@ public class UnicastServer
refcache.put(obj.myself, obj);
obj.manager.startServer();
}
-
+
/**
* Register the activatable object into the table of the activatable
* objects.
@@ -109,7 +109,7 @@ public class UnicastServer
{
actIds.put(ref.actId, ref);
}
-
+
/**
* Export tha activatable object. The object id is placed into the map,
* but the object itself not. This is enough to deliver call to
@@ -123,8 +123,8 @@ public class UnicastServer
ref.manager.startServer();
actIds.put(ref.actId, ref);
}
-
-
+
+
/**
* Get the activatable server reference that is handling activation of the
* given activation id.
@@ -137,15 +137,15 @@ public class UnicastServer
throw new ActivationException(id + " was not registered with this server");
return ref;
}
-
+
/**
* Unregister the previously registered activatable server reference.
*/
public static void unregisterActivatable(ActivationID id)
{
- actIds.remove(id);
+ actIds.remove(id);
}
-
+
// FIX ME: I haven't handle force parameter
/**
* Remove the given server reference. The remote object, associated with
@@ -156,7 +156,7 @@ public class UnicastServer
objects.remove(obj.objid);
refcache.remove(obj.myself);
obj.manager.stopServer();
-
+
if (obj instanceof ActivatableServerRef)
{
ActivationID id = ((ActivatableServerRef) obj).actId;
@@ -164,15 +164,15 @@ public class UnicastServer
}
return true;
}
-
+
/**
* Get the exported reference of the given Remote. The identity map is used,
* the non-null value will only be returned if exactly the passed remote
- * is part of the registered UnicastServerRef.
- *
- * @param remote the Remote that is connected to this server via
+ * is part of the registered UnicastServerRef.
+ *
+ * @param remote the Remote that is connected to this server via
* {@link UnicastServerRef}.
- *
+ *
* @return the UnicastServerRef that is used to connect the passed
* remote with this server or null, if this Remote is not connected
* to this server.
@@ -186,7 +186,7 @@ public class UnicastServer
* Get the server references to the object, previously exported via this
* server. As the identity map is scanned, more than one reference may match
* this Id.
- *
+ *
* @param id the id of the exported object
* @return the server reference to this object, null if none.
*/
@@ -244,10 +244,10 @@ public class UnicastServer
throw new Exception("bad method type");
}
}
-
+
/**
* This method is invoked when the remote call is received. The method
- * dispatches the call to the responsible object, connected to this
+ * dispatches the call to the responsible object, connected to this
* server via UnicastServerReference.
*/
private static void incomingMessageCall(UnicastConnection conn)
@@ -287,7 +287,7 @@ public class UnicastServer
catch (Error e)
{
returnval = new ServerError(
- "Server error, ObjID: " + objid +
+ "Server error, ObjID: " + objid +
", method: " + method + ", hash: "+ hash, e);
returncode = RETURN_NACK;
}
diff --git a/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java b/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java
index 2f7cb9a2d94..59a9f080be9 100644
--- a/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java
+++ b/libjava/classpath/gnu/java/rmi/server/UnicastServerRef.java
@@ -8,7 +8,7 @@ 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
@@ -60,39 +60,39 @@ import java.util.Iterator;
/**
* This class connects the local, remotely available (exported) object to
- * the local RMI server that accepts the remote calls.
+ * the local RMI server that accepts the remote calls.
*/
public class UnicastServerRef
extends UnicastRef
-{
+{
/**
* Use GNU Classpath v 0.20 SVUID for interoperability
*/
private static final long serialVersionUID = - 5585608108300801246L;
-
+
/**
- * The class array, defining parameters of the jdk 1.2 RMI stub constructor.
+ * The class array, defining parameters of the jdk 1.2 RMI stub constructor.
*/
private static final Class[] stubprototype = new Class[] { RemoteRef.class };
-
+
/**
* The exported remote object itself.
*/
Remote myself; // save the remote object itself
-
+
/**
* The skeleton (if any), associated with the exported remote object.
*/
protected Skeleton skel;
-
+
/**
* The stub, associated with the exported remote object (may be proxy class).
*/
protected Remote stub;
-
+
/**
- * The method table (RMI hash code to method) of the methods of the
+ * The method table (RMI hash code to method) of the methods of the
* exported object.
*/
protected Hashtable methods = new Hashtable();
@@ -110,15 +110,15 @@ public class UnicastServerRef
super(id);
manager = UnicastConnectionManager.getInstance(port, ssf);
}
-
+
/**
* Export the object and return its remote stub. The method tries to locate
* existing stubs and skeletons. If this fails, the method instantiates the
* proxy stub class.
- *
- * Stubs and skeletons are always ignored (even if present) if the
+ *
+ * Stubs and skeletons are always ignored (even if present) if the
* java.rmi.server.ignoreStubClasses property is set to true.
- *
+ *
* @param obj the object being exported.
* @return the stub (existing class or proxy) of the exported object.
* @throws RemoteException if the export failed due any reason
@@ -133,17 +133,17 @@ public class UnicastServerRef
manager.serverobj = obj;
String ignoreStubs;
-
- ClassLoader loader =obj.getClass().getClassLoader();
-
+
+ ClassLoader loader =obj.getClass().getClassLoader();
+
// Stubs are always searched for the bootstrap classes that may have
// obsolete pattern and may still need also skeletons.
if (loader==null)
ignoreStubs = "false";
else
- ignoreStubs = System.getProperty("java.rmi.server.ignoreStubClasses",
+ ignoreStubs = System.getProperty("java.rmi.server.ignoreStubClasses",
"false");
-
+
if (! ignoreStubs.equals("true"))
{
// Find and install the stub
@@ -172,21 +172,21 @@ public class UnicastServerRef
return stub;
}
-
+
/**
* Get the stub (actual class or proxy) of the exported remote object.
- *
+ *
* @return the remote stub (null if exportObject has not been called).
*/
public Remote getStub()
{
return stub;
}
-
+
/**
- * Unexport the object (remove methods from the method hashcode table
+ * Unexport the object (remove methods from the method hashcode table
* and call UnicastServer.unexportObject.
- *
+ *
* @param obj the object being unexported
* @param force passed to the UnicastServer.unexportObject.
* @return value, returned by the UnicastServer.unexportObject.
@@ -202,7 +202,7 @@ public class UnicastServerRef
* Return the class in the hierarchy for that the stub class is defined.
* The Subs/Skels might not there for the actual class, but maybe for one of
* the superclasses.
- *
+ *
* @return the class having stub defined, null if none.
*/
protected Class findStubSkelClass(Class startCls)
@@ -231,17 +231,17 @@ public class UnicastServerRef
}
}
}
-
+
/**
- * Get the helper (assisting) class with the given type.
- *
+ * Get the helper (assisting) class with the given type.
+ *
* @param cls the class, for that the helper class is requested. This class
* and the requested helper class must share the same class loader.
- *
+ *
* @param type the type of the assisting helper. The only currently supported
* non deprecated value is "_Stub" (load jdk 1.1 or 1.2 RMI stub). Another
* (deprecated) value is "_Skel" (load skeleton).
- *
+ *
* @return the instantiated instance of the helper class or null if the
* helper class cannot be found or instantiated.
*/
@@ -303,14 +303,14 @@ public class UnicastServerRef
{
return RemoteServer.getClientHost();
}
-
+
/**
* Build the method has code table and put it into {@link #methods}
* (mapping RMI hashcode tos method). The same method is used to remove
* the table.
- *
- * @param cls the class for that the method table is built.
- * @param build if true, the class methods are added to the table. If
+ *
+ * @param cls the class for that the method table is built.
+ * @param build if true, the class methods are added to the table. If
* false, they are removed from the table.
*/
protected void buildMethodHash(Class cls, boolean build)
@@ -342,7 +342,7 @@ public class UnicastServerRef
else
return null;
}
-
+
/**
* This method is called from the {@link UnicastServer#incomingMessageCall}
* to deliver the remote call to this object.
@@ -422,7 +422,7 @@ public class UnicastServerRef
{
if (skel == null)
throw new NoSuchMethodException("JDK 1.1 call - Skeleton required");
-
+
UnicastRemoteCall call = new UnicastRemoteCall(conn);
skel.dispatch(myself, call, method, hash);
if (! call.isReturnValue())
@@ -431,16 +431,16 @@ public class UnicastServerRef
return (call.returnValue());
}
}
-
+
/**
* Create the 1.2 proxy stub in the case when the pre-generated stub is not
* available of the system is explicitly instructed to use proxy stubs.
- *
+ *
* @param stubFor the class for that the proxy class must be constructed.
* @param reference the remote reference, used to find the given object
- *
+ *
* @return the applicable proxy stub.
- *
+ *
* @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
*/
Remote createProxyStub(Class stubFor, RemoteRef reference)
@@ -467,17 +467,15 @@ public class UnicastServerRef
for (int i = 0; i < intfs.length; i++)
intfs[i] = (Class) it.next();
-
- RemoteObjectInvocationHandler handler =
+
+ RemoteObjectInvocationHandler handler =
new RemoteObjectInvocationHandler(reference);
-
- Object proxy =
+
+ Object proxy =
Proxy.newProxyInstance(stubFor.getClassLoader(), intfs, handler);
return (Remote) proxy;
}
-
-
-}
+}
OpenPOWER on IntegriCloud