This is an output stream that actually sends the stream data to a remote server. Note that this extends
OutputStream
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 output streams are remoted. First, an input stream must be {@link ServiceContainer#addRemoteOutputStream(OutputStream) assigned a server-side service component}. At that point, your server is ready to begin accepting remote commands to write the output 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 output stream was registered. Note that, for convienence, the constructor {@link RemoteOutputStream#RemoteOutputStream(OutputStream,ServiceContainer)} is provided to both add the outputstream to the server-side services container and instantiate this object with the appropriate stream ID. This {@link RemoteOutputStream} object can then be passed to a remote client in some way (typically by serializing it aspart of a {@link Command}). The remote endpoint must then tell this object (after its been deserialized) which {@link #setClientCommandSender(ClientCommandSender) client sender} to use when communicating back to the server(which it needs to do when writing 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 {@link #getServerEndpoint() server endpoint} as its target. After the remote endpoint sets upits sender in this object, it is free to operate on this object as if it were a "normal" OutputStream
. Note that remote output streams should be {@link #close() closed} in order to clean up server-side resources in atimely manner.
@author John Mazzitelli