From ef8dc449ddc60008bce9264c73b4162cc487c174 Mon Sep 17 00:00:00 2001 From: wbauer Date: Thu, 16 Oct 2008 07:51:13 +0000 Subject: Changed STAL Handler from static registration to one Object per STAL instance git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@121 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java | 21 +++++++++------------ .../bku/smccstal/InfoBoxReadRequestHandler.java | 5 ----- .../egiz/bku/smccstal/SMCCSTALRequestHandler.java | 2 -- 3 files changed, 9 insertions(+), 19 deletions(-) (limited to 'smccSTAL/src') diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java index b48388db..cf524737 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/AbstractSMCCSTAL.java @@ -37,19 +37,17 @@ import at.gv.egiz.stal.SignRequest; public abstract class AbstractSMCCSTAL implements STAL { private static Log log = LogFactory.getLog(AbstractSMCCSTAL.class); - + public final static int DEFAULT_MAX_RETRIES = 3; protected Locale locale = Locale.getDefault(); - // protected SMCCHelper smccHelper = new SMCCHelper(); protected SignatureCard signatureCard = null; - protected static Map handlerMap = new HashMap(); - + protected Map handlerMap = new HashMap(); + protected int maxRetries = DEFAULT_MAX_RETRIES; - static { + protected AbstractSMCCSTAL() { addRequestHandler(InfoboxReadRequest.class, new InfoBoxReadRequestHandler()); - // addRequestHandler(SignRequest.class, new SignRequestHandler()); } /** @@ -72,7 +70,7 @@ public abstract class AbstractSMCCSTAL implements STAL { log.info("Processing: " + request.getClass()); int retryCounter = 0; while (retryCounter < maxRetries) { - log.info("Number of retries: "+retryCounter); + log.info("Number of retries: " + retryCounter); SMCCSTALRequestHandler handler = null; handler = handlerMap.get(request.getClass().getSimpleName()); if (handler != null) { @@ -83,7 +81,6 @@ public abstract class AbstractSMCCSTAL implements STAL { } } try { - handler = handler.newInstance(); handler.init(signatureCard, getGUI()); STALResponse response = handler.handleRequest(request); if (response != null) { @@ -91,7 +88,7 @@ public abstract class AbstractSMCCSTAL implements STAL { log.info("Got an error response"); ErrorResponse err = (ErrorResponse) response; if (err.getErrorCode() == 6001) { - retryCounter = Integer.MAX_VALUE-1; + retryCounter = Integer.MAX_VALUE - 1; } if (++retryCounter < maxRetries) { log.info("Retrying"); @@ -128,13 +125,13 @@ public abstract class AbstractSMCCSTAL implements STAL { return responseList; } - public static void addRequestHandler(Class id, + public void addRequestHandler(Class id, SMCCSTALRequestHandler handler) { log.debug("Registering STAL request handler: " + id.getSimpleName()); handlerMap.put(id.getSimpleName(), handler); } - public static SMCCSTALRequestHandler getRequestHandler( + public SMCCSTALRequestHandler getRequestHandler( Class request) { return handlerMap.get(request.getSimpleName()); } @@ -150,5 +147,5 @@ public abstract class AbstractSMCCSTAL implements STAL { public void setMaxRetries(int maxRetries) { this.maxRetries = maxRetries; } - + } diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java index 25085b16..b48d6d50 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/InfoBoxReadRequestHandler.java @@ -133,9 +133,4 @@ public class InfoBoxReadRequestHandler extends AbstractRequestHandler implements } return new String(gui.getPin()); } - - @Override - public SMCCSTALRequestHandler newInstance() { - return new InfoBoxReadRequestHandler(); - } } diff --git a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java index 6f303f76..94ab7a5b 100644 --- a/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java +++ b/smccSTAL/src/main/java/at/gv/egiz/bku/smccstal/SMCCSTALRequestHandler.java @@ -30,6 +30,4 @@ public interface SMCCSTALRequestHandler { public boolean requireCard(); - public SMCCSTALRequestHandler newInstance(); - } -- cgit v1.2.3