[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/ffc6f187 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ffc6f187 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ffc6f187 Branch: refs/heads/karaf-2.x Commit: ffc6f1875b1ecea1a274c0e09262dda68b0452ec Parents: b728335 Author: Guillaume Nodet <[email protected]> Authored: Sat Feb 28 14:00:14 2015 +0100 Committer: Guillaume Nodet <[email protected]> Committed: Mon Mar 2 09:12:51 2015 +0100 ---------------------------------------------------------------------- .../security/impl/SecuredCommandConfigTransformer.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/ffc6f187/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 1b1c69b..ba9cd91 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 @@ -74,8 +74,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 = ""; @@ -104,7 +106,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 @@ -160,8 +162,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())); - refreshTheAffectedShellCommandBundle(event, configAdmin.getConfiguration(event.getPid())); + Configuration config = configAdmin.getConfiguration(event.getPid()); + generateServiceGuardConfig(config); + refreshTheAffectedShellCommandBundle(event, config); break; } } catch (Exception e) {
