|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.acplt.oncrpc.server.OncRpcServerTransport
public abstract class OncRpcServerTransport
Instances of class OncRpcServerTransport
encapsulate XDR
streams of ONC/RPC servers. Using server transports, ONC/RPC calls are
received and the corresponding replies are later sent back after
handling.
Note that the server-specific dispatcher handling requests
(done through OncRpcDispatchable
will only
directly deal with OncRpcCallInformation
objects. These
call information objects reference OncRpcServerTransport object, but
the server programmer typically will never touch them, as the call
information object already contains all necessary information about
a call, so replies can be sent back (and this is definetely a sentence
containing too many words).
OncRpcCallInformation
,
OncRpcDispatchable
Field Summary | |
---|---|
protected OncRpcDispatchable |
dispatcher
Reference to interface of an object capable of handling/dispatching ONC/RPC requests. |
protected OncRpcServerTransportRegistrationInfo[] |
info
Program and version number tuples handled by this server transport. |
protected int |
port
Port number where we're listening for incoming ONC/RPC requests. |
Constructor Summary | |
---|---|
protected |
OncRpcServerTransport(OncRpcDispatchable dispatcher,
int port,
OncRpcServerTransportRegistrationInfo[] info)
Create a new instance of a OncRpcServerTransport which
encapsulates XDR streams of an ONC/RPC server. |
Method Summary | |
---|---|
protected abstract void |
beginEncoding(OncRpcCallInformation callInfo,
OncRpcServerReplyMessage state)
Begins the sending phase for ONC/RPC replies. |
abstract void |
close()
Close the server transport and free any resources associated with it. |
protected abstract void |
endDecoding()
Finishes call parameter deserialization. |
protected abstract void |
endEncoding()
Finishes encoding the reply to this ONC/RPC call. |
abstract java.lang.String |
getCharacterEncoding()
Get the character encoding for (de-)serializing strings. |
int |
getPort()
Returns port number of socket this server transport listens on for incoming ONC/RPC calls. |
protected abstract XdrDecodingStream |
getXdrDecodingStream()
Returns XDR stream which can be used for deserializing the parameters of this ONC/RPC call. |
protected abstract XdrEncodingStream |
getXdrEncodingStream()
Returns XDR stream which can be used for eserializing the reply to this ONC/RPC call. |
abstract void |
listen()
Creates a new thread and uses this thread to listen to incoming ONC/RPC requests, then dispatches them and finally sends back the appropriate reply messages. |
abstract void |
register()
Register the port where this server transport waits for incoming requests with the ONC/RPC portmapper. |
protected abstract void |
reply(OncRpcCallInformation callInfo,
OncRpcServerReplyMessage state,
XdrAble reply)
Send back an ONC/RPC reply to the original caller. |
protected abstract void |
retrieveCall(XdrAble call)
Retrieves the parameters sent within an ONC/RPC call message. |
abstract void |
setCharacterEncoding(java.lang.String characterEncoding)
Set the character encoding for (de-)serializing strings. |
void |
unregister()
Unregisters the port where this server transport waits for incoming requests from the ONC/RPC portmapper. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected OncRpcDispatchable dispatcher
protected int port
protected OncRpcServerTransportRegistrationInfo[] info
Constructor Detail |
---|
protected OncRpcServerTransport(OncRpcDispatchable dispatcher, int port, OncRpcServerTransportRegistrationInfo[] info)
OncRpcServerTransport
which
encapsulates XDR streams of an ONC/RPC server. Using a server transport,
ONC/RPC calls are received and the corresponding replies are sent back.
We do not create any XDR streams here, as it is the responsibility of derived classes to create appropriate XDR stream objects for the respective kind of transport mechanism used (like TCP/IP and UDP/IP).
dispatcher
- Reference to interface of an object capable of
dispatching (handling) ONC/RPC calls.port
- Number of port where the server will wait for incoming
calls.info
- Array of program and version number tuples of the ONC/RPC
programs and versions handled by this transport.Method Detail |
---|
public abstract void register() throws OncRpcException
The contract of this method is, that derived classes implement the appropriate communication with the portmapper, so the transport is registered only for the protocol supported by a particular kind of server transport.
OncRpcException
- if the portmapper could not be contacted
successfully.public void unregister() throws OncRpcException
Note that due to the way Sun decided to implement its ONC/RPC portmapper process, deregistering one server transports causes all entries for the same program and version to be removed, regardless of the protocol (UDP/IP or TCP/IP) used. Sigh.
OncRpcException
- with a reason of
OncRpcException.RPC_FAILED
if
the portmapper could not be contacted successfully. Note that
it is not considered an error to remove a non-existing entry from
the portmapper.public abstract void close()
Note that the server transport is not deregistered. You'll have to do it manually if you need to do so. The reason for this behaviour is, that the portmapper removes all entries regardless of the protocol (TCP/IP or UDP/IP) for a given ONC/RPC program number and version.
Derived classes can choose between different behaviour for shuting down the associated transport handler threads:
public abstract void listen()
Note that you have to supply an implementation for this abstract method in derived classes. Your implementation needs to create a new thread to wait for incoming requests. The method has to return immediately for the calling thread.
public int getPort()
public abstract void setCharacterEncoding(java.lang.String characterEncoding)
characterEncoding
- the encoding to use for (de-)serializing strings.
If null
, the system's default encoding is to be used.public abstract java.lang.String getCharacterEncoding()
null
, then the system's default encoding is used.protected abstract void retrieveCall(XdrAble call) throws OncRpcException, java.io.IOException
XdrDecodingStream.endDecoding()
to free any
pending resources from the decoding stage.
OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully deserialized.
java.io.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.protected abstract XdrDecodingStream getXdrDecodingStream()
protected abstract void endDecoding() throws OncRpcException, java.io.IOException
getXdrDecodingStream()
must not be used any more.
This method belongs to the lower-level access pattern when handling
ONC/RPC calls.
OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully deserialized.
java.io.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.protected abstract XdrEncodingStream getXdrEncodingStream()
protected abstract void beginEncoding(OncRpcCallInformation callInfo, OncRpcServerReplyMessage state) throws OncRpcException, java.io.IOException
callInfo
- Information about ONC/RPC call for which we are about
to send back the reply.state
- ONC/RPC reply header indicating success or failure.
OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully serialized.
java.io.IOException
- if an I/O exception occurs, like transmissionprotected abstract void endEncoding() throws OncRpcException, java.io.IOException
getXdrEncodingStream()
any
longer.
OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully serialized.
java.io.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.protected abstract void reply(OncRpcCallInformation callInfo, OncRpcServerReplyMessage state, XdrAble reply) throws OncRpcException, java.io.IOException
OncRpcCallInformation.reply(XdrAble)
method instead on the
call object supplied to the handler.
An appropriate implementation has to be provided in derived classes as it is dependent on the type of transport (whether UDP/IP or TCP/IP) used.
callInfo
- information about the original call, which are necessary
to send back the reply to the appropriate caller.state
- ONC/RPC reply message header indicating success or failure
and containing associated state information.reply
- If not null
, then this parameter references
the reply to be serialized after the reply message header.
OncRpcException
- if an ONC/RPC exception occurs, like the data
could not be successfully serialized.
java.io.IOException
- if an I/O exception occurs, like transmission
failures over the network, etc.OncRpcCallInformation
,
OncRpcDispatchable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |