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.
-
JRPCServer(int, int, boolean)
- Creates a RPC server and starts a portmapper thread if requested.
-
DoAuth(int, Auth, Auth)
- Overwrite this method only if you want your server to check authentication (by default there is no check).
-
DoCall(int, XDRStream, XDRStream)
- Dispatch routine which interprets the call requests of a server.
-
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).
-
getAddress()
- Determines the host address of the sender of the currently processed RPC request.
-
getCallVersion()
- Determines the version number of the currently processed RPC request.
-
getClientData()
- Gets client-specific data for this server thread.
-
getPort()
- Determines the port number of the sender of the currently processed RPC request.
-
getVersion()
- Returns the version number of the server object.
-
IsBatched(int)
- Overwrite this method only if you want to implement batched RPCs.
-
isTCPServer()
- Determines whether the current thread serves a TCP or a UDP request.
-
RegisterServer(int, boolean)
- Registers the RPC server in the local portmapper.
-
RegisterServer(int, int, boolean)
- Registers the RPC server in the local portmapper.
-
run()
- The TCP server thread.
-
setClientData(Object)
- Sets client-specific data for this server thread.
-
StartTCP(int)
- Starts the TPC server and its thread.
-
StartUDP(int)
- Starts the UDP server and its thread.
-
Stop(boolean)
- Stops the server.
-
UnregisterServer()
- Unregisters the RPC server in the local portmapper.
-
UnregisterServer(int)
- Unregisters the RPC server in the local portmapper.
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.
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.
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.
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.
getVersion
public int getVersion()
- Returns the version number of the server object.
- Returns:
- Version number of the server.
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.
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.
run
public final void run()
- The TCP server thread.
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.
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.
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.
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.
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.
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.
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.
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().
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.
getAddress
public InetAddress getAddress()
- Determines the host address of the sender of the currently processed RPC request.
- Returns:
- Host address of the sender.
getPort
public int getPort()
- Determines the port number of the sender of the currently processed RPC request.
- Returns:
- Port number of the sender.
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