public class RemoteInputStream extends InputStream implements Serializable
InputStream so it can be used as any normal stream object; however, all methods are overridden to actually
delegate the methods to the remote stream.
In order to be able to use this object, you should understand how input streams are remoted. First, an input
stream must be assigned a server-side service component.
At that point, your server is ready to begin accepting remote commands to read the input stream. That's where this
object comes in. You instantiate this object by giving its constructor the ID of the stream and the service container
where that input stream was registered. Note that, for convienence, the constructor
RemoteInputStream(InputStream, ServiceContainer) is provided to both add the input stream
to the server-side services container and instantiate this object with the appropriate stream ID. This
RemoteInputStream object can then be passed to a remote client in some way (typically by serializing it as
part of a Command). The remote endpoint must then tell this object (after its been deserialized) which
client sender to use when communicating back to the server
(which it needs to do when pulling the stream data). We need that remote endpoint to give this object a sender
because its the remote endpoint's job to configure that sender with things like its keystore and truststore locations
(when transporting over SSL). In order to configure that client sender, the remote endpoint must create the sender
such that it uses the server endpoint as its target. After the remote endpoint sets up
its sender in this object, it is free to operate on this object as if it were a "normal" InputStream.
Note that remote input streams should be closed in order to clean up server-side resources in a
timely manner.
| Constructor and Description |
|---|
RemoteInputStream(InputStream stream,
ServiceContainer server)
Creates a new
RemoteInputStream object. |
RemoteInputStream(Long id,
ServiceContainer server)
Creates a new
RemoteInputStream object. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
String |
getServerEndpoint()
Returns the endpoint of the server where the remote input stream is actually located.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
protected Object |
sendRequest(Method method,
Object[] args)
Builds the command to execute the method on the remote stream and submit the request.
|
void |
setClientCommandSender(ClientCommandSender sender)
Sets the sender that this input stream object will use to send the remote invocation requests.
|
long |
skip(long n) |
String |
toString() |
public RemoteInputStream(InputStream stream, ServiceContainer server) throws Exception
RemoteInputStream object. This constructor is the same as
RemoteInputStream(Long, ServiceContainer) but additionally adds the stream's
server-side component that is required in order for the stream to be remotely accessible (see
ServiceContainer.addRemoteInputStream(InputStream)).stream - the stream to remoteserver - the server-side container that is responsible for remoting the streamException - if failed to add the remote input stream to the given containerpublic RemoteInputStream(Long id, ServiceContainer server)
RemoteInputStream object. Because the remote input stream needs a server-side component to
be able to serve up the stream data to remote endpoints, the given server is needed so this object
knows that server component's endpoint.id - identifies the stream this object will remotely accessserver - the server where the input stream service is registered and awaiting for the remote endpoint to
begin sending it requestspublic String getServerEndpoint()
client sender.public void setClientCommandSender(ClientCommandSender sender)
getServerEndpoint(). Therefore,
before a caller calls this method, it must ensure that any sender it passes in has been configured to send its
messages to the input stream's server endpoint.sender - object used to send the requests to the remote serverpublic String toString()
toString in class ObjectObject.toString()public int available()
throws IOException
available in class InputStreamIOExceptionInputStream.available()public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionInputStream.close()public void mark(int readlimit)
mark in class InputStreamInputStream.mark(int)public boolean markSupported()
markSupported in class InputStreamInputStream.markSupported()public int read()
throws IOException
read in class InputStreamIOExceptionInputStream.read()public int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionInputStream.read(byte[])public int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionInputStream.read(byte[], int, int)public void reset()
throws IOException
reset in class InputStreamIOExceptionInputStream.reset()public long skip(long n)
throws IOException
skip in class InputStreamIOExceptionInputStream.skip(long)protected Object sendRequest(Method method, Object[] args) throws RemoteIOException
method - the method to invoke on the remote streamargs - the arguments to pass to the invoked method on the remote streamRemoteIOException - if either the sending of the request failed of the remote input stream actually
encountered a problemCopyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.