diff options
author | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2010-01-26 17:23:06 +0000 |
---|---|---|
committer | clemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2010-01-26 17:23:06 +0000 |
commit | 615cf8bb11a1253e36aaf2f01082ed6429836358 (patch) | |
tree | e7047e07a004f22eeb209835cb5620a5e2819fc9 /bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java | |
parent | 7af237ef102514aa817e567861dc25ab39b6dac0 (diff) | |
parent | b184b9e753daee529a2996832286fbaf3bf3a696 (diff) | |
download | mocca-615cf8bb11a1253e36aaf2f01082ed6429836358.tar.gz mocca-615cf8bb11a1253e36aaf2f01082ed6429836358.tar.bz2 mocca-615cf8bb11a1253e36aaf2f01082ed6429836358.zip |
[maven-release-plugin] copy for branch mocca-1.2.11-sha2
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/branches/mocca-1.2.11-sha2@606 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java')
-rw-r--r-- | bkucommon/src/main/java/at/gv/egiz/bku/slcommands/SLCommandFactory.java | 54 |
1 files changed, 29 insertions, 25 deletions
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 6e84867e..8e3f6ece 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 @@ -88,11 +88,6 @@ public class SLCommandFactory { private Map<String, Class<? extends SLCommand>> slRequestTypeMap = new HashMap<String, Class<? extends SLCommand>>(); /** - * The mapping of a requests's qualified name to a concrete command factories. - */ - private Map<QName, AbstractSLCommandFactory> slCommandFactories = new HashMap<QName, AbstractSLCommandFactory>(); - - /** * Configures the singleton instance with command implementations * @param commandImplMap * @throws ClassNotFoundException @@ -106,19 +101,7 @@ public class SLCommandFactory { slRequestTypeMap.put(key, impl); } } - - public void setConcreteFactories(Map<QName, AbstractSLCommandFactory> 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 <code>namespaceUri</code> and <code>localname</code> @@ -380,16 +363,37 @@ public class SLCommandFactory { log.info("Unsupported security layer request version : " + qName.getNamespaceURI()); throw new SLVersionException(qName.getNamespaceURI()); } + + Class<? extends SLCommand> 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()}); + } - 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()}); + + + // 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); } - return concreteFactory.createSLCommand(context, (JAXBElement<?>) object); + slCommand.init(context, (JAXBElement) object); + + return slCommand; } }
\ No newline at end of file |