X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2FCommandThread.java;h=678e4a65011be986c9e5c5eafc4ed0c96d5254ac;hb=86f289cd42ba95846c80d22129ed565e4e9d6dde;hp=e3169b9cbe0617095979703d6d794c2d79e56099;hpb=249aba186bb25b673bc701f4614cfe1981cd6767;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/CommandThread.java b/src/main/java/com/indexdata/mkjsf/pazpar2/CommandThread.java index e3169b9..678e4a6 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/CommandThread.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/CommandThread.java @@ -3,45 +3,42 @@ package com.indexdata.mkjsf.pazpar2; import org.apache.log4j.Logger; import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command; +import com.indexdata.mkjsf.pazpar2.data.Responses; +/** + * Helper class for running multiple concurrent Pazpar2 commands. Basically + * used for updating display data (show,stat,bytarget,termlist) together. + * + * @author Niels Erik + * + */ public class CommandThread extends Thread { private static Logger logger = Logger.getLogger(CommandThread.class); Pazpar2Command command; SearchClient client; - CommandResponse commandResponse = null; + Responses pzresp; + HttpResponseWrapper commandResponse = null; - public CommandThread (Pazpar2Command command, SearchClient client) { + public CommandThread (Pazpar2Command command, SearchClient client, Responses pzresp) { this.command = command; this.client = client; + this.pzresp = pzresp; } /** - * Runs the specified command using the specified Pazpar2 client - * Sets the Pazpar2 response as an XML response string to be retrieved by - * getResponse(). - * - * In case of an exception, an error response is generated, the document - * element being the same as it would have been if successful (named after - * the command, that is). - * + * Executes the specified command using the specified Pazpar2 client */ - public void run() { - - if (command.getCommandName().equals("search")) { - client.setSearchCommand(command); - } - long start = System.currentTimeMillis(); - commandResponse = client.executeCommand(command); - long end = System.currentTimeMillis(); - logger.debug("Executed " + command.getCommandName() + " in " + (end-start) + " ms." ); + public void run() { + logger.debug(command.getCommandName() + " executing asynchronously"); + command.run(client,pzresp); } /** * * @return Pazpar2 response as an XML string, possibly a generated error XML */ - public CommandResponse getCommandResponse () { + public HttpResponseWrapper getCommandResponse () { return commandResponse; }