All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class distinct.rpc.JRPCServer

java.lang.Object
   |
   +----distinct.rpc.JRPCServer

public abstract class JRPCServer
extends Object
implements Runnable, Serializable
All JRPC servers are derived from this abstract class. It declares the methods for initializing a server and for registering it at the portmapper.


Constructor Index

 o JRPCServer(int, int, boolean)
Creates a RPC server and starts a portmapper thread if requested.

Method Index

 o DoAuth(int, Auth, Auth)
Overwrite this method only if you want your server to check authentication (by default there is no check).
 o DoCall(int, XDRStream, XDRStream)
Dispatch routine which interprets the call requests of a server.
 o DoVersionCheck(int)
Overwrite this method only if you want your server to check compatibility of program versions in a user-defined way (by default it simply checks whether it is the same version as given in the constructor).
 o getAddress()
Determines the host address of the sender of the currently processed RPC request.
 o getCallVersion()
Determines the version number of the currently processed RPC request.
 o getClientData()
Gets client-specific data for this server thread.
 o getPort()
Determines the port number of the sender of the currently processed RPC request.
 o getVersion()
Returns the version number of the server object.
 o IsBatched(int)
Overwrite this method only if you want to implement batched RPCs.
 o isTCPServer()
Determines whether the current thread serves a TCP or a UDP request.
 o RegisterServer(int, boolean)
Registers the RPC server in the local portmapper.
 o RegisterServer(int, int, boolean)
Registers the RPC server in the local portmapper.
 o run()
The TCP server thread.
 o setClientData(Object)
Sets client-specific data for this server thread.
 o StartTCP(int)
Starts the TPC server and its thread.
 o StartUDP(int)
Starts the UDP server and its thread.
 o Stop(boolean)
Stops the server.
 o UnregisterServer()
Unregisters the RPC server in the local portmapper.
 o UnregisterServer(int)
Unregisters the RPC server in the local portmapper.

Constructors

 o JRPCServer
 public JRPCServer(int prog,
                   int vers,
                   boolean do_portmap)
Creates a RPC server and starts a portmapper thread if requested.

Parameters:
prog - The program ID of the server as defined in the .x IDL file.
vers - The program version of the server as defined in the .x IDL file.
do_portmap - If true, it tries to start a portmapper.

Methods

 o DoCall
 public synchronized boolean DoCall(int proc,
                                    XDRStream xin,
                                    XDRStream out)
Dispatch routine which interprets the call requests of a server. Overwritten by derived classes that implement the actual interface.

Parameters:
proc - The index of the requested function.
xin - Read the input parameter from this XDR stream.
xout - Write the return parameter to this XDR stream.
Returns:
True if the function with the index proc can be served, false otherwise.
 o DoVersionCheck
 public synchronized boolean DoVersionCheck(int vers)
Overwrite this method only if you want your server to check compatibility of program versions in a user-defined way (by default it simply checks whether it is the same version as given in the constructor).

Parameters:
vers - The version of the server as requested by the incoming call.
Returns:
True if the version matches and the call should be further processed, false if the call should be rejected with a JRPC.kPROG_MISMATCH error.
 o DoAuth
 public synchronized Auth DoAuth(int proc,
                                 Auth cred,
                                 Auth verf) throws RPCError
Overwrite this method only if you want your server to check authentication (by default there is no check). Throw an RPCAuthError exception to indicate an authentication failure.

Parameters:
proc - The ID of the requested function.
cred - Authentication parameter provided by the client.
verf - Verifier parameter provided by the client.
Returns:
Verifier to send back to the client with the response ("null" means AuthNull).
Throws: RPCError
If the authentication fails.
 o getVersion
 public int getVersion()
Returns the version number of the server object.

Returns:
Version number of the server.
 o RegisterServer
 public boolean RegisterServer(int vers,
                               int port,
                               boolean stream)
Registers the RPC server in the local portmapper.

Parameters:
vers - A version number of the program of the server.
port - The port on which the server waits for requests.
stream - true for a TCP server, false for UDP.
Returns:
true if the registration was successful.
 o RegisterServer
 public boolean RegisterServer(int port,
                               boolean stream)
Registers the RPC server in the local portmapper.

Parameters:
port - The port on which the server waits for requests.
stream - true for a TCP server, false for UDP.
Returns:
true if the registration was successful.
 o run
 public final void run()
The TCP server thread.

 o StartTCP
 public int StartTCP(int port) throws RPCError
Starts the TPC server and its thread.

Parameters:
port - The port on which the server on which the server should wait for requests. If 0 an arbitrary port is chosen.
Returns:
portnumber of the selected port.
Throws: RPCError
If the server could not be started.
 o StartUDP
 public int StartUDP(int port) throws RPCError
Starts the UDP server and its thread.

Parameters:
port - The port on which the server on which the server should wait for requests. If 0 an arbitrary port is chosen.
Returns:
portnumber of the selected port.
Throws: RPCError
If the server could not be started.
 o Stop
 public synchronized void Stop(boolean stop_portmap)
Stops the server.

Parameters:
stop_portmap - If "true" a RPC Portmapper that was started by this server is stoped as well.
 o UnregisterServer
 public boolean UnregisterServer(int vers)
Unregisters the RPC server in the local portmapper.

Parameters:
vers - A version number of the program of the server.
Returns:
true if the deletion was successful.
 o UnregisterServer
 public boolean UnregisterServer()
Unregisters the RPC server in the local portmapper.

Parameters:
vers - A version number of the program of the server.
Returns:
true if the deletion was successful.
 o IsBatched
 public boolean IsBatched(int proc)
Overwrite this method only if you want to implement batched RPCs. Return true for all procedures that are called in batched mode (i.e. no reply message).

Parameters:
proc - The ID of the executed function.
Returns:
true if the procedure is called in batched mode.
 o setClientData
 public void setClientData(Object data)
Sets client-specific data for this server thread. Use this function if necessary to transfer data between DoAuth(), DoCall(), and IsBatched().

Parameters:
data - Any Java object.
 o getClientData
 public Object getClientData()
Gets client-specific data for this server thread. Use this function if necessary to transfer data between DoAuth(), DoCall(), and IsBatched().

Returns:
The Java object previously stored with setClientData().
 o isTCPServer
 public boolean isTCPServer()
Determines whether the current thread serves a TCP or a UDP request.

Returns:
true if the current thread serves a TCP request, false for UDP.
 o getAddress
 public InetAddress getAddress()
Determines the host address of the sender of the currently processed RPC request.

Returns:
Host address of the sender.
 o getPort
 public int getPort()
Determines the port number of the sender of the currently processed RPC request.

Returns:
Port number of the sender.
 o getCallVersion
 public int getCallVersion()
Determines the version number of the currently processed RPC request.

Returns:
Version number of the request.

All Packages  Class Hierarchy  This Package  Previous  Next  Index