class Pipe<T>
extends java.lang.Object
| Modifier and Type | Class and Description | 
|---|---|
private class  | 
Pipe.Receiver
Waits until a message is received from the other side of the pipe. 
 | 
private class  | 
Pipe.Sender
Mainly consists of a queue for messages. 
 | 
private class  | 
Pipe.Worker
Worker class for both the receiver and sender of the pipe. 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static int | 
ERROR_MESSAGE  | 
private java.util.concurrent.locks.ReentrantLock | 
listenerLock  | 
private java.util.LinkedList<PipeListener<T>> | 
listeners  | 
private java.lang.String[] | 
messageDelimiters
The delimiters of the messages, i.e. strings that indicate the end of a message. 
 | 
static int | 
NORMAL_MESSAGE  | 
private java.util.concurrent.locks.Condition | 
postMessages
The sender goes to sleep when there are no messages to be sent. 
 | 
private java.util.LinkedList<java.lang.String> | 
queue
Stores messages that are to be sent in the next cycle of the worker responsible for sending messages. 
 | 
private java.util.concurrent.locks.ReentrantLock | 
queueLock  | 
private T | 
session
User specific data. 
 | 
private java.util.concurrent.locks.ReentrantLock | 
workerLock  | 
private java.util.List<Pipe.Worker> | 
workers
The workers of the pipe. 
 | 
| Constructor and Description | 
|---|
Pipe(T session,
    java.lang.String[] messageDelimiters)  | 
| Modifier and Type | Method and Description | 
|---|---|
(package private) void | 
addListener(PipeListener<T> listener)  | 
void | 
close()  | 
(package private) void | 
closeSendingPipe()
Closes the pipe for sending, signalling the end of the input to the target process. 
 | 
T | 
getSession()  | 
(package private) void | 
sendMessage(java.lang.String message)
sends a message to the external process. 
 | 
void | 
start(java.io.InputStream input,
     java.io.OutputStream output,
     java.io.InputStream error,
     PipeListener<T> listener)  | 
void | 
waitForPipe()
Wait until the output of the target process has been read completely. 
 | 
private final java.util.concurrent.locks.ReentrantLock listenerLock
private final java.util.LinkedList<PipeListener<T>> listeners
private java.util.List<Pipe.Worker> workers
private final java.util.concurrent.locks.ReentrantLock workerLock
private java.util.LinkedList<java.lang.String> queue
private final java.util.concurrent.locks.ReentrantLock queueLock
private final java.util.concurrent.locks.Condition postMessages
private final java.lang.String[] messageDelimiters
public static final int NORMAL_MESSAGE
public static final int ERROR_MESSAGE
private final T session
public Pipe(T session, java.lang.String[] messageDelimiters)
public void start(java.io.InputStream input,
                  java.io.OutputStream output,
                  java.io.InputStream error,
                  PipeListener<T> listener)
public void close()
void sendMessage(java.lang.String message)
void closeSendingPipe()
void addListener(PipeListener<T> listener)
public T getSession()
public void waitForPipe()
                 throws java.lang.InterruptedException
java.lang.InterruptedException