[KARAF-3577] Optimize SecuredCommandConfigTransformer#generateServiceGuardConfig
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/5bf287ec Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/5bf287ec Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/5bf287ec Branch: refs/heads/master Commit: 5bf287ec9c7919aad1e5e73ee7f7b0f566d9c1c0 Parents: 301f3f7 Author: Guillaume Nodet <[email protected]> Authored: Sat Feb 28 14:00:14 2015 +0100 Committer: Guillaume Nodet <[email protected]> Committed: Mon Mar 2 09:59:47 2015 +0100 ---------------------------------------------------------------------- .../security/impl/SecuredCommandConfigTransformer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/5bf287ec/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandConfigTransformer.java ---------------------------------------------------------------------- diff --git a/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandConfigTransformer.java b/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandConfigTransformer.java index b7fa517..d0be93d 100644 --- a/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandConfigTransformer.java +++ b/shell/console/src/main/java/org/apache/karaf/shell/security/impl/SecuredCommandConfigTransformer.java @@ -75,8 +75,10 @@ public class SecuredCommandConfigTransformer implements ConfigurationListener { } scopeName = scopeName.trim(); + Dictionary<String, Object> configProps = config.getProperties(); + Map<String, Dictionary<String, Object>> configMaps = new HashMap<String, Dictionary<String, Object>>(); - for (Enumeration<String> e = config.getProperties().keys(); e.hasMoreElements(); ) { + for (Enumeration<String> e = configProps.keys(); e.hasMoreElements(); ) { String key = e.nextElement(); String bareCommand = key; String arguments = ""; @@ -105,7 +107,7 @@ public class SecuredCommandConfigTransformer implements ConfigurationListener { // put rules on the map twice, once for commands that 'execute' (implement Function) and // once for commands that are invoked directly - Object roleString = config.getProperties().get(key); + Object roleString = configProps.get(key); map.put("execute" + arguments, roleString); map.put(key, roleString); map.put("*", "*"); // any other method may be invoked by anyone @@ -161,8 +163,9 @@ public class SecuredCommandConfigTransformer implements ConfigurationListener { deleteServiceGuardConfig(event.getPid(), event.getPid().substring(PROXY_COMMAND_ACL_PID_PREFIX.length())); break; case ConfigurationEvent.CM_UPDATED: - generateServiceGuardConfig(configAdmin.getConfiguration(event.getPid(), null)); - refreshTheAffectedShellCommandBundle(event, configAdmin.getConfiguration(event.getPid(), null)); + Configuration config = configAdmin.getConfiguration(event.getPid(), null); + generateServiceGuardConfig(config); + refreshTheAffectedShellCommandBundle(event, config); break; } } catch (Exception e) {
