org.rhq.enterprise.communications.command.impl.stream
Class RemoteInputStreamCommandResponse

java.lang.Object
  extended by org.rhq.enterprise.communications.command.AbstractCommandResponse
      extended by org.rhq.enterprise.communications.command.impl.stream.RemoteInputStreamCommandResponse
All Implemented Interfaces:
Serializable, CommandResponse

public class RemoteInputStreamCommandResponse
extends AbstractCommandResponse

Encapsulates the results of a remote stream invocation.

Author:
John Mazzitelli
See Also:
Serialized Form

Constructor Summary
RemoteInputStreamCommandResponse(Command cmd, Object results)
          Constructor for RemoteInputStreamCommandResponse that defines a successfully invoked remote stream method.
RemoteInputStreamCommandResponse(CommandResponse responseToTransform)
          Constructor for RemoteInputStreamCommandResponse.
RemoteInputStreamCommandResponse(Command cmd, Throwable exception)
          Constructor for RemoteInputStreamCommandResponse that defines a failed remote stream invocation.
 
Method Summary
 byte[] getBytesReadFromStream()
          Returns the actual bytes that were read off of the stream.
 
Methods inherited from class org.rhq.enterprise.communications.command.AbstractCommandResponse
getCommand, getException, getResults, isSuccessful, setCommand, setException, setResults, setSuccessful, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteInputStreamCommandResponse

public RemoteInputStreamCommandResponse(Command cmd,
                                        Object results)
Constructor for RemoteInputStreamCommandResponse that defines a successfully invoked remote stream method. It is expected that when a read() method call has succeeded, this constructor is used with the actual command that was executed. This is because the command contains the byte array parameter that was used to store the read bytes. In order to simulate pass-by-reference, the command must be stored in this response so that byte array can be sent back with the response.

Parameters:
cmd - the command that was executed (may be null)
results - the results of the InputStream method call

RemoteInputStreamCommandResponse

public RemoteInputStreamCommandResponse(Command cmd,
                                        Throwable exception)
Constructor for RemoteInputStreamCommandResponse that defines a failed remote stream invocation.

Parameters:
cmd - the command that was executed (may be null)
exception - the exception that describes the failure, if available (may be null)

RemoteInputStreamCommandResponse

public RemoteInputStreamCommandResponse(CommandResponse responseToTransform)
Constructor for RemoteInputStreamCommandResponse.

See Also:
AbstractCommandResponse.AbstractCommandResponse(CommandResponse)
Method Detail

getBytesReadFromStream

public byte[] getBytesReadFromStream()
Returns the actual bytes that were read off of the stream. This method only returns non-null if the command was successful and it executed one of the InputStream read methods that resulted in the read bytes stored in the byte[] parameter passed to that method.

Returns:
the bytes read from the stream or null if the command was not a "read" method invocation


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.