Package org.codehaus.cargo.tools.daemon
Class DaemonClient
- java.lang.Object
-
- org.codehaus.cargo.util.log.LoggedObject
-
- org.codehaus.cargo.tools.daemon.DaemonClient
-
- All Implemented Interfaces:
Loggable
public class DaemonClient extends LoggedObject
Client for the Cargo daemon
-
-
Constructor Summary
Constructors Constructor Description DaemonClient(URL url)
Creates a Cargo daemon wrapper for the specified URL which has public access (no username nor password required).DaemonClient(URL url, String username, String password)
Creates a Cargo daemon wrapper for the specified URL, username and password that uses UTF-8 URL encoding.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>
getHandles()
Get details of the handles in the Cargo Daemon.String
getPassword()
Gets the password to use when authenticating with Cargo daemon.URL
getURL()
Gets the full URL of the Cargo daemon instance.String
getUserAgent()
Gets the user agent name to use when communicating with Cargo daemon.String
getUserName()
Gets the username to use when authenticating with Cargo daemon.protected String
invoke(String path, DaemonParameters parameters)
Invokes Cargo daemon with a specified command and content data.void
setLogger(Logger logger)
Overriden in order to set the logger on ancillary components.void
setUserAgent(String userAgent)
Sets the user agent name to use when communicating with Cargo daemon.void
start(DaemonStart start)
Starts a container specified by the start request.void
stop(String handleId)
Stops the container with the specified handle identifier.-
Methods inherited from class org.codehaus.cargo.util.log.LoggedObject
getLogger
-
-
-
-
Constructor Detail
-
DaemonClient
public DaemonClient(URL url)
Creates a Cargo daemon wrapper for the specified URL which has public access (no username nor password required).- Parameters:
url
- the full URL of the Cargo daemon instance to use
-
DaemonClient
public DaemonClient(URL url, String username, String password)
Creates a Cargo daemon wrapper for the specified URL, username and password that uses UTF-8 URL encoding.- Parameters:
url
- the full URL of the Cargo daemon instance to useusername
- the username to use when authenticating with Cargo daemonpassword
- the password to use when authenticating with Cargo daemon
-
-
Method Detail
-
setLogger
public void setLogger(Logger logger)
Overriden in order to set the logger on ancillary components.- Specified by:
setLogger
in interfaceLoggable
- Overrides:
setLogger
in classLoggedObject
- Parameters:
logger
- the logger to set and set in the ancillary objects
-
getURL
public URL getURL()
Gets the full URL of the Cargo daemon instance.- Returns:
- the full URL of the Cargo daemon instance
-
getUserName
public String getUserName()
Gets the username to use when authenticating with Cargo daemon.- Returns:
- the username to use when authenticating with Cargo daemon
-
getPassword
public String getPassword()
Gets the password to use when authenticating with Cargo daemon.- Returns:
- the password to use when authenticating with Cargo daemon
-
getUserAgent
public String getUserAgent()
Gets the user agent name to use when communicating with Cargo daemon.- Returns:
- the user agent name to use when communicating with Cargo daemon
-
setUserAgent
public void setUserAgent(String userAgent)
Sets the user agent name to use when communicating with Cargo daemon.- Parameters:
userAgent
- the user agent name to use when communicating with Cargo daemon
-
start
public void start(DaemonStart start) throws DaemonException, IOException
Starts a container specified by the start request.- Parameters:
start
- The unique identifier of the container- Throws:
DaemonException
- if the Cargo daemon request failsIOException
- if an i/o error occurs
-
stop
public void stop(String handleId) throws DaemonException, IOException
Stops the container with the specified handle identifier.- Parameters:
handleId
- The unique identifier of the container- Throws:
DaemonException
- if the Cargo daemon request failsIOException
- if an i/o error occurs
-
getHandles
public Map<String,String> getHandles() throws DaemonException, IOException
Get details of the handles in the Cargo Daemon.- Returns:
- Handle details, where the key is the handle identifier and the value the status
- Throws:
DaemonException
- if the Cargo daemon request failsIOException
- if an i/o error occurs
-
invoke
protected String invoke(String path, DaemonParameters parameters) throws DaemonException, IOException
Invokes Cargo daemon with a specified command and content data.- Parameters:
path
- the Cargo daemon command to invokeparameters
- an input stream to the content data- Returns:
- the result of the invoking command, as returned by the Cargo daemon application
- Throws:
DaemonException
- if the Cargo daemon request failsIOException
- if an i/o error occurs
-
-