gnu.java.rmi.server

Class UnicastServerRef

Implemented Interfaces:
Externalizable, ProtocolConstants, RemoteRef, Serializable
Known Direct Subclasses:
ActivatableServerRef, DGCImpl

public class UnicastServerRef
extends UnicastRef

This class connects the local, remotely available (exported) object to the local RMI server that accepts the remote calls.

Field Summary

protected Hashtable<K,V>
methods
The method table (RMI hash code to method) of the methods of the exported object.
protected Skeleton
skel
The skeleton (if any), associated with the exported remote object.
protected Remote
stub
The stub, associated with the exported remote object (may be proxy class).

Fields inherited from class gnu.java.rmi.server.UnicastRef

objid

Fields inherited from interface gnu.java.rmi.server.ProtocolConstants

DEFAULT_PROTOCOL, MESSAGE_CALL, MESSAGE_CALL_ACK, MESSAGE_DGCACK, MESSAGE_PING, MESSAGE_PING_ACK, MULTIPLEX_PROTOCOL, PROTOCOL_ACK, PROTOCOL_HEADER, PROTOCOL_NACK, PROTOCOL_VERSION, RETURN_ACK, RETURN_NACK, SINGLE_OP_PROTOCOL, STREAM_PROTOCOL

Fields inherited from interface java.rmi.server.RemoteRef

packagePrefix, serialVersionUID

Constructor Summary

UnicastServerRef(ObjID id, int port, RMIServerSocketFactory ssf)

Method Summary

protected void
buildMethodHash(Class<T> cls, boolean build)
Build the method has code table and put it into methods (mapping RMI hashcode tos method).
Remote
exportObject(Remote obj)
Export the object and return its remote stub.
protected Class<T>
findStubSkelClass(Class<T> startCls)
Return the class in the hierarchy for that the stub class is defined.
String
getClientHost()
protected Object
getHelperClass(Class<T> cls, String type)
Get the helper (assisting) class with the given type.
Remote
getStub()
Get the stub (actual class or proxy) of the exported remote object.
Object
incomingMessageCall(UnicastConnection conn, int method, long hash)
This method is called from the UnicastServer to deliver the remote call to this object.
boolean
unexportObject(Remote obj, boolean force)
Unexport the object (remove methods from the method hashcode table and call UnicastServer.unexportObject.

Methods inherited from class gnu.java.rmi.server.UnicastRef

done, dump, equals, getRefClass, hashCode, invoke, invoke, invokeCommon, invokeCommon, newCall, notifyDGC, readExternal, remoteEquals, remoteHashCode, remoteToString, writeExternal

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

methods

protected Hashtable<K,V> methods
The method table (RMI hash code to method) of the methods of the exported object.

skel

protected Skeleton skel
The skeleton (if any), associated with the exported remote object.

stub

protected Remote stub
The stub, associated with the exported remote object (may be proxy class).

Constructor Details

UnicastServerRef

public UnicastServerRef(ObjID id,
                        int port,
                        RMIServerSocketFactory ssf)
            throws RemoteException

Method Details

buildMethodHash

protected void buildMethodHash(Class<T> cls,
                               boolean build)
Build the method has code table and put it into methods (mapping RMI hashcode tos method). The same method is used to remove the table.
Parameters:
cls - the class for that the method table is built.
build - if true, the class methods are added to the table. If false, they are removed from the table.

exportObject

public Remote exportObject(Remote obj)
            throws RemoteException
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 java.rmi.server.ignoreStubClasses property is set to true.
Parameters:
obj - the object being exported.
Returns:
the stub (existing class or proxy) of the exported object.
Throws:
RemoteException - if the export failed due any reason

findStubSkelClass

protected Class<T> findStubSkelClass(Class<T> startCls)
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.
Returns:
the class having stub defined, null if none.

getClientHost

public String getClientHost()
            throws ServerNotActiveException

getHelperClass

protected Object getHelperClass(Class<T> cls,
                                String type)
Get the helper (assisting) class with the given type.
Parameters:
cls - the class, for that the helper class is requested. This class and the requested helper class must share the same class loader.
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).
Returns:
the instantiated instance of the helper class or null if the helper class cannot be found or instantiated.

getStub

public Remote getStub()
Get the stub (actual class or proxy) of the exported remote object.
Returns:
the remote stub (null if exportObject has not been called).

incomingMessageCall

public Object incomingMessageCall(UnicastConnection conn,
                                  int method,
                                  long hash)
            throws Exception
This method is called from the UnicastServer to deliver the remote call to this object.

unexportObject

public boolean unexportObject(Remote obj,
                              boolean force)
Unexport the object (remove methods from the method hashcode table and call UnicastServer.unexportObject.
Parameters:
obj - the object being unexported
force - passed to the UnicastServer.unexportObject.
Returns:
value, returned by the UnicastServer.unexportObject.

UnicastServerRef.java -- Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003, 2004, 2006 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.