public class Client
extends java.lang.Object
CommandServlet
over http to modify session properties
and returns the results. The client has support for connecting to multiple servers and sending
the session cookie returned by one server to other servers, to emulate the behavior of a client
talking to the servers through a load balancer.
The client currently only targets servers running on "localhost"
To set the server this client is targeting, use setPort(int)
.Modifier and Type | Class and Description |
---|---|
class |
Client.Response
A response received from the server.
|
Constructor and Description |
---|
Client() |
Modifier and Type | Method and Description |
---|---|
Client.Response |
executionFunction(java.lang.Class<? extends java.util.function.Function<javax.servlet.http.HttpServletRequest,java.lang.String>> functionClass)
Instantiate and execute a function in the server.
|
Client.Response |
get(java.lang.String key)
Get the value of a session attribute on the server
|
Client.Response |
get(java.lang.String key,
boolean storeRespCookie)
Get the value of a session attribute on the server
|
Client.Response |
invalidate()
Invalidate this clients session on the server
|
Client.Response |
invalidate(boolean storeRespCookie)
Invalidate this clients session on the server
|
Client.Response |
remove(java.lang.String key)
Remove the session attribute on the server
|
Client.Response |
remove(java.lang.String key,
boolean storeRespCookie)
Remove the session attribute on the server
|
Client.Response |
set(java.lang.String key,
java.lang.String value)
Set the value of a session attribute on the server
|
Client.Response |
set(java.lang.String key,
java.lang.String value,
boolean storeRespCookie)
Set the value of a session attribute on the server
|
Client.Response |
setMaxInactive(int time)
Set the maximum inactive interval for this client's session on the server.
|
Client.Response |
setMaxInactive(int time,
boolean storeRespCookie)
Set the maximum inactive interval for this client's session on the server.
|
void |
setPort(int port)
Change the server that the client is targeting.
|
public void setPort(int port)
port
- the port that the server is listening onpublic Client.Response get(java.lang.String key) throws java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
public Client.Response get(java.lang.String key, boolean storeRespCookie) throws java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
public Client.Response set(java.lang.String key, java.lang.String value) throws java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
public Client.Response set(java.lang.String key, java.lang.String value, boolean storeRespCookie) throws java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
public Client.Response executionFunction(java.lang.Class<? extends java.util.function.Function<javax.servlet.http.HttpServletRequest,java.lang.String>> functionClass) throws java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
public Client.Response remove(java.lang.String key) throws java.io.IOException, java.net.URISyntaxException
key
- - the session attribute to removejava.io.IOException
java.net.URISyntaxException
public Client.Response remove(java.lang.String key, boolean storeRespCookie) throws java.net.URISyntaxException, java.io.IOException
key
- - the session attribute to removestoreRespCookie
- - whether or not to store the session cookie of this requestjava.net.URISyntaxException
java.io.IOException
public Client.Response invalidate() throws java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
public Client.Response invalidate(boolean storeRespCookie) throws java.io.IOException, java.net.URISyntaxException
java.io.IOException
java.net.URISyntaxException
public Client.Response setMaxInactive(int time) throws java.io.IOException, java.net.URISyntaxException
time
- - Time in seconds until the session should expirejava.io.IOException
java.net.URISyntaxException
public Client.Response setMaxInactive(int time, boolean storeRespCookie) throws java.io.IOException, java.net.URISyntaxException
time
- - Time in seconds until the session should expirejava.io.IOException
java.net.URISyntaxException