org.rhq.enterprise.communications.command.impl.stream.server
Class RemoteOutputStreamCommandService

java.lang.Object
  extended by org.rhq.enterprise.communications.command.server.CommandMBean
      extended by org.rhq.enterprise.communications.command.server.CommandService
          extended by org.rhq.enterprise.communications.command.impl.stream.server.RemoteOutputStreamCommandService
All Implemented Interfaces:
MBeanRegistration, CommandExecutor, CommandServiceMBean

public class RemoteOutputStreamCommandService
extends CommandService

Processes client requests to write remoted output streams.

Author:
John Mazzitelli

Constructor Summary
RemoteOutputStreamCommandService()
          Constructor for RemoteOutputStreamCommandService.
 
Method Summary
 Long addOutputStream(OutputStream stream)
          Adds the given output stream to this service, effectively allowing remote clients to access this stream.
 CommandResponse execute(Command command, InputStream in, OutputStream out)
          Takes the remote stream access request, which has the NameBasedInvocation parameter, and convert that to a method call on the target stream (using reflection).
 CommandType[] getSupportedCommandTypes()
          Supports remote output stream commands.
 boolean removeOutputStream(Long stream_id)
          Removes the stream associated with the given ID from this service, effectively making this stream inaccessible to remote clients.
 void startService()
          Configures the max idle time taken from this service's container configuration.
 void stopService()
          This is called when the MBean is being deregistered from the MBeanServer.
 
Methods inherited from class org.rhq.enterprise.communications.command.server.CommandService
getCommandServiceId, getConnector, getServiceContainer, getSubsystem, prepareRemoteInputStream, prepareRemoteOutputStream, preRegister, setServiceContainer
 
Methods inherited from class org.rhq.enterprise.communications.command.server.CommandMBean
getLog, getMBeanServer, getObjectName, postDeregister, postRegister, preDeregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteOutputStreamCommandService

public RemoteOutputStreamCommandService()
Constructor for RemoteOutputStreamCommandService.

Method Detail

addOutputStream

public Long addOutputStream(OutputStream stream)
Adds the given output stream to this service, effectively allowing remote clients to access this stream. The returned value is the ID that clients need to use to identify this stream as the one the client wants to access (see RemoteOutputStreamCommand.setStreamId(Long)).

Parameters:
stream - the new stream to remote
Returns:
the stream's ID

removeOutputStream

public boolean removeOutputStream(Long stream_id)
Removes the stream associated with the given ID from this service, effectively making this stream inaccessible to remote clients. This method also ensures the output stream is closed.

Parameters:
stream_id - identifies the stream to remove
Returns:
true if the stream ID was valid and a stream was removed; false if the ID referred to a non-existent stream (which could mean either the stream was never registered at all or it was registered but has already been removed)

startService

public void startService()
Configures the max idle time taken from this service's container configuration.

Overrides:
startService in class CommandMBean
See Also:
CommandMBean.startService()

stopService

public void stopService()
Description copied from class: CommandMBean
This is called when the MBean is being deregistered from the MBeanServer. This implementation is a no-op that subclasses are free to override.

Overrides:
stopService in class CommandMBean
See Also:
CommandMBean.stopService()

execute

public CommandResponse execute(Command command,
                               InputStream in,
                               OutputStream out)
Takes the remote stream access request, which has the NameBasedInvocation parameter, and convert that to a method call on the target stream (using reflection). Then return the Object returned from the method call on the target stream in the response. Note that the invocation signature must match one of the methods on OutputStream.

Parameters:
command - the command to execute
in - input stream should the executor want to get streamed data from the client
out - output stream should the executor want to stream data to the client
Returns:
the results of the command execution
See Also:
CommandExecutor.execute(Command, InputStream, OutputStream)

getSupportedCommandTypes

public CommandType[] getSupportedCommandTypes()
Supports remote output stream commands.

Returns:
array of supported command types
See Also:
CommandServiceMBean.getSupportedCommandTypes()


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