public class JslipcPipeServer extends Object implements TimeoutAware
accept()
wait for
an incoming connection request sent by a JslipcPipeClient
.Constructor and Description |
---|
JslipcPipeServer(File connectDirectory,
File pipeDirectory)
Creates a JslipcPipeServer supporting all pipe types.
|
JslipcPipeServer(File connectDirectory,
File pipeDirectory,
Class<? extends JslipcPipe>... supportedTypes)
Creates a JslipcPipeServer working on the given directory.
|
Modifier and Type | Method and Description |
---|---|
JslipcConnection |
accept()
Waits for an incoming request, and creates an appropriate pipe.
|
void |
checkDirectory(File directory,
String name) |
protected JslipcPipe |
createPipe(JslipcRequest request,
JslipcResponse response)
Creates a pipe from the given request and sets up the response.
|
int |
getAcceptTimeout() |
protected Class<? extends JslipcPipe> |
getSuitableType(JslipcRequest request)
Returns an appropriate pipe class for the request.
|
int |
getTimeout()
Returns the time to wait for the client to fulfill it connect request.
|
protected JslipcRequest |
readRequest(InputStream in)
Reads an request from the given stream.
|
protected void |
sendResponse(JslipcResponse response,
OutputStream out)
Sends the response to the given stream.
|
void |
setAcceptTimeout(int timeout)
Sets the
accept() timeout. |
void |
setTimeout(int timeout)
Sets the time to wait for the client to fulfill it connect request.
|
protected void |
sleep(long waitingSince,
int timeout)
Sleeps for the default time and watches for timeouts.
|
String |
toString() |
protected File |
waitForDirectory()
Wait for a not yet served FilePipe directory.
|
public JslipcPipeServer(File connectDirectory, File pipeDirectory) throws IOException
connectDirectory
- the directory the server searches for incoming connection
request.pipeDirectory
- the directory used to set up pipes.IOException
public JslipcPipeServer(File connectDirectory, File pipeDirectory, Class<? extends JslipcPipe>... supportedTypes) throws IOException
connectDirectory
- the directory the server searches for incoming connection
request.pipeDirectory
- the directory used to set up pipes.supportedTypes
- the pipe types supported by the server, the first one is
preferred.IOException
public JslipcConnection accept() throws IOException
IOException
protected JslipcPipe createPipe(JslipcRequest request, JslipcResponse response) throws IOException
request
- response
- IOException
protected Class<? extends JslipcPipe> getSuitableType(JslipcRequest request) throws IOException
request
- IOException
- if none of the accepted types is supported by this server.protected JslipcRequest readRequest(InputStream in) throws IOException
in
- IOException
protected void sendResponse(JslipcResponse response, OutputStream out) throws IOException
response
- out
- IOException
protected File waitForDirectory() throws IOException
IOException
protected void sleep(long waitingSince, int timeout) throws InterruptedIOException
waitingSince
- the timestamp when the operation started to block.InterruptedIOException
public int getAcceptTimeout()
accept()
timeout.public void setAcceptTimeout(int timeout)
accept()
timeout.timeout
- the timeout in ms.public int getTimeout()
getTimeout
in interface TimeoutAware
public void setTimeout(int timeout)
setTimeout
in interface TimeoutAware
timeout
- the timeout in ms.Copyright © 2014. All Rights Reserved.