From 4a334069beb85654e3cb35aef7e4508e04127036 Mon Sep 17 00:00:00 2001 From: mcentner Date: Tue, 26 Jan 2010 16:22:56 +0000 Subject: MOCCA 1.2.11 with SHA-2 enabled. git-svn-id: https://joinup.ec.europa.eu/svn/mocca/branches/mocca-1.2.11-sha2/mocca-1.2.11@599 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../gv/egiz/bku/slcommands/SLCommandFactory.java | 54 ++++++++++------------ 1 file changed, 25 insertions(+), 29 deletions(-) (limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java') diff --git a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java index 8e3f6ece..6e84867e 100644 --- a/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java +++ b/bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java @@ -87,6 +87,11 @@ public class SLCommandFactory { */ private Map> slRequestTypeMap = new HashMap>(); + /** + * The mapping of a requests's qualified name to a concrete command factories. + */ + private Map slCommandFactories = new HashMap(); + /** * Configures the singleton instance with command implementations * @param commandImplMap @@ -101,7 +106,19 @@ public class SLCommandFactory { slRequestTypeMap.put(key, impl); } } - + + public void setConcreteFactories(Map factories) { + if (log.isDebugEnabled()) { + StringBuilder sb = new StringBuilder(); + sb.append("Registered sl command factory for"); + for (QName qname : factories.keySet()) { + sb.append("\n " + qname + " : " + factories.get(qname).getClass()); + } + log.debug(sb); + } + slCommandFactories = factories; + } + /** * Register an {@link SLCommand} implementation class of a Security Layer * command with the given namespaceUri and localname @@ -363,37 +380,16 @@ public class SLCommandFactory { log.info("Unsupported security layer request version : " + qName.getNamespaceURI()); throw new SLVersionException(qName.getNamespaceURI()); } - - Class implClass = getImplClass(qName); - if (implClass == null) { - // command not supported - log.info("Unsupported command received: " + qName.toString()); - throw new SLCommandException(4011, - SLExceptionMessages.EC4011_NOTIMPLEMENTED, new Object[]{qName.toString()}); - } - - - // try to instantiate - SLCommand slCommand; - try { - slCommand = implClass.newInstance(); - log.debug("SLCommand " + slCommand.getName() + " created."); - } catch (InstantiationException e) { - // unexpected error - log.error("Failed to instantiate security layer command implementation.", - e); - throw new SLRuntimeException(e); - } catch (IllegalAccessException e) { - // unexpected error - log.error("Failed to instantiate security layer command implementation.", - e); - throw new SLRuntimeException(e); + AbstractSLCommandFactory concreteFactory = slCommandFactories.get(qName); + if (concreteFactory == null) { + // command not supported + log.info("Unsupported command received: " + qName.toString()); + throw new SLCommandException(4011, + SLExceptionMessages.EC4011_NOTIMPLEMENTED, new Object[]{qName.toString()}); } - slCommand.init(context, (JAXBElement) object); - - return slCommand; + return concreteFactory.createSLCommand(context, (JAXBElement) object); } } \ No newline at end of file -- cgit v1.2.3