public class

SshMultiplexedConnector

extends Object
implements MuleContextAware
java.lang.Object
   ↳ org.mule.modules.ssh.multiplexer.SshMultiplexedConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

Cloud Connector for ssh that is capable to handle multiple session from different users and reusing the session of any given user if he wants to send multiple messages. Notice that while this connector can handle N sessions for N users, each user can only have 1 active session at a time

Summary

Constants
String SSH_CALLBACK_USER
Fields
private Flow callbackFlow The flow that will receive callback invocations
private String callbackFlowName If not null, a flow with this name will be fetched from the registry and invoked everytime data is received from the other end.
private SshConnectionManager connectionManager Instance of SshConnectionManager to delegate the connection handling
private String host IP address for the target host
private static final Logger logger
private MuleContext muleContext
private int port TCP port in which the host is listening
private Integer receiverBufferSize The size of the receiver buffer in bytes.
private boolean shellMode if true, the connection will be opened in shell mode, meaning that the session context will be maintained from the moment it's stablished until it's closed.
private int timeout message timeout
Public Constructors
SshMultiplexedConnector()
Public Methods
void connect()
Instanciates the connectionManager.
void disconnect()
Releases all the active ssh connections and deallocates org.mule.modules.ssh.multiplexer.SshMultiplexedConnector.connectionManager
Integer getReceiverBufferSize()
void release(String username)
Releases the ssh connection associated with the username (if any).
void send(String username, String password, String content, boolean breakLine)
creates/reuses a ssh connection to the host login in as username.
void setCallbackFlowName(String callbackFlowName)
void setHost(String host)
void setMuleContext(MuleContext context)
void setPort(int port)
void setReceiverBufferSize(Integer receiverBufferSize)
void setShellMode(boolean shellMode)
void setTimeout(int timeout)
Protected Methods
void doCallback(String response, String username)
sends the message to the responseFlow if not null
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.mule.api.context.MuleContextAware

Constants

private static final String SSH_CALLBACK_USER

Constant Value: "SSH_CALLBACK_USER"

Fields

private Flow callbackFlow

The flow that will receive callback invocations

private String callbackFlowName

If not null, a flow with this name will be fetched from the registry and invoked everytime data is received from the other end. Keep in mind that SSH is a full duplex protocol, meaning that you can receive data at any time, not just as a reply to a message you have sent.

private SshConnectionManager connectionManager

Instance of SshConnectionManager to delegate the connection handling

private String host

IP address for the target host

private static final Logger logger

private MuleContext muleContext

private int port

TCP port in which the host is listening

private Integer receiverBufferSize

The size of the receiver buffer in bytes. Defaults to 8192 and must be greater or equal to 1

private boolean shellMode

if true, the connection will be opened in shell mode, meaning that the session context will be maintained from the moment it's stablished until it's closed. If false, then only single commands will be allowed and no context will be passed from one invocation to the next.

private int timeout

message timeout

Public Constructors

public SshMultiplexedConnector ()

Public Methods

public void connect ()

Instanciates the connectionManager. Actual ssh connections are lazily created by org.mule.modules.ssh.multiplexer.SshMultiplexedConnector.connectionManager

Throws
ConnectionException

public void disconnect ()

Releases all the active ssh connections and deallocates org.mule.modules.ssh.multiplexer.SshMultiplexedConnector.connectionManager

public Integer getReceiverBufferSize ()

public void release (String username)

Releases the ssh connection associated with the username (if any). It does so by invoking org.mule.modules.ssh.multiplexer.SshConnectionManager.release(String)

Parameters
username - the username whose connection we want to free
See Also
  • org.mule.modules.ssh.multiplexer.SshConnectionManager.release(String)

public void send (String username, String password, String content, boolean breakLine)

creates/reuses a ssh connection to the host login in as username. Notice that after sending the message the session is kept active. It is up to you to release it. To release a session, the username can send {@org.mule.modules.ssh.multiplexer.SshMultiplexedConnector.DISCONNECT_STRING } as content. This will cause org.mule.modules.ssh.multiplexer.SshMultiplexedConnector.release(String) to be invoked

Parameters
username - the username to use at remote authentication
password - the password to use at remote authentication
content - the content to send
breakLine - if true, then
Returns
  • Accumulates text response from the server until the receiving buffer is empty and then returns all of the content at once.
Throws
Exception
See Also
  • org.mule.modules.ssh.multiplexer.SshMultiplexedConnector.release(String)

public void setCallbackFlowName (String callbackFlowName)

Parameters
callbackFlowName

public void setHost (String host)

Parameters
host

public void setMuleContext (MuleContext context)

Parameters
context

public void setPort (int port)

Parameters
port

public void setReceiverBufferSize (Integer receiverBufferSize)

Parameters
receiverBufferSize

public void setShellMode (boolean shellMode)

Parameters
shellMode

public void setTimeout (int timeout)

Parameters
timeout

Protected Methods

protected void doCallback (String response, String username)

sends the message to the responseFlow if not null

Parameters
response
username