diff --git a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java index 8d3b1c3d7e..866918c867 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigAdmin.java +++ b/core/src/main/java/lucee/runtime/config/ConfigAdmin.java @@ -576,7 +576,7 @@ protected static void updateMapping(ConfigPro config, String virtual, String phy admin._updateMapping(virtual, physical, archive, primary, inspect, inspectTemplateIntervalSlow, inspectTemplateIntervalFast, toplevel, listenerMode, listenerType, readonly); admin._store(); - Admin.getConfigServerImpl(config).resetMappings(); + ConfigUtil.getConfigWebImpl(config).resetMappings(); if (reload) admin._reload(); } @@ -4735,7 +4735,7 @@ public void updateRHExtension(Config config, RHExtension rhext, boolean reload, String sub = subFolder(entry); logger.log(Log.LEVEL_DEBUG, "extension", "deploy mapping " + sub); updateArchive(zis, sub, false); - ConfigUtil.getConfigServerImpl(config).resetMappings(); + ConfigUtil.getConfigWebImpl(config).resetMappings(); reloadNecessary = true; } @@ -5023,7 +5023,7 @@ else if (!StringUtil.isEmpty(cfc, true)) { toplevel = Caster.toBooleanValue(map.get("toplevel"), false); readonly = Caster.toBooleanValue(map.get("readonly"), false); _updateMapping(virtual, physical, archive, primary, inspect, inspectTemplateIntervalSlow, inspectTemplateIntervalFast, toplevel, lmode, ltype, readonly); - ConfigUtil.getConfigServerImpl(config).resetMappings(); + ConfigUtil.getConfigWebImpl(config).resetMappings(); reloadNecessary = true; logger.debug("extension", "Update Mapping [" + virtual + "]"); diff --git a/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java b/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java index 19fc875da8..8b0cb5a064 100644 --- a/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java +++ b/core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java @@ -208,7 +208,7 @@ public static ConfigWebPro newInstanceWeb(CFMLEngine engine, CFMLFactoryImpl fac Resource configDir = configServer.getConfigDir(); double start = SystemUtil.millis(); - ConfigWebPro configWeb = existingToUpdate != null ? existingToUpdate.setInstance(factory, configServer, servletConfig) + ConfigWebPro configWeb = existingToUpdate != null ? existingToUpdate.setInstance(factory, configServer, servletConfig, true) : new ConfigWebImpl(factory, configServer, servletConfig); factory.setConfig(configServer, configWeb); diff --git a/core/src/main/java/lucee/runtime/config/ConfigUtil.java b/core/src/main/java/lucee/runtime/config/ConfigUtil.java index aad6eb40be..faf3cb4883 100755 --- a/core/src/main/java/lucee/runtime/config/ConfigUtil.java +++ b/core/src/main/java/lucee/runtime/config/ConfigUtil.java @@ -1457,4 +1457,13 @@ public static ConfigServerImpl getConfigServerImpl(Config config) { // MUST remove throw new RuntimeException("getConfigServerImpl: " + config.getClass().getName()); } + + public static ConfigWebImpl getConfigWebImpl(Config config) { + if (config instanceof ConfigWebImpl) return ((ConfigWebImpl) config); + Config c = ThreadLocalPageContext.getConfig(); + LogUtil.log(Log.LEVEL_ERROR, "config", "canno convert the following instance to a ConfigWebImpl: " + config.getClass().getName()); + if (c instanceof ConfigWebImpl) return ((ConfigWebImpl) c); + // MUST remove + throw new RuntimeException("getConfigWebImpl: " + config.getClass().getName()); + } } \ No newline at end of file diff --git a/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java b/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java index 9bebc17704..5af63c4956 100644 --- a/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java +++ b/core/src/main/java/lucee/runtime/config/ConfigWebImpl.java @@ -122,17 +122,17 @@ public class ConfigWebImpl extends ConfigBase implements ConfigWebPro { private lucee.runtime.rest.Mapping[] restMappings; public ConfigWebImpl(CFMLFactoryImpl factory, ConfigServerImpl cs, ServletConfig config) { - setInstance(factory, cs, config); + setInstance(factory, cs, config, false); } - public ConfigWebPro setInstance(CFMLFactoryImpl factory, ConfigServerImpl cs, ServletConfig config) { + public ConfigWebPro setInstance(CFMLFactoryImpl factory, ConfigServerImpl cs, ServletConfig config, boolean reload) { this.id = null; this.factory = factory; this.cs = cs; this.config = config; helper = new ConfigWebHelper(cs, this); - reload(); + if (reload) reload(); return this; } @@ -376,16 +376,6 @@ public boolean passwordEqual(Password password) { return cs.passwordEqual(password); } - @Override - public Mapping[] getMappings() { - if (mappings == null) { - synchronized (this) { - if (mappings == null) createMapping(); - } - } - return mappings;// cs.getMappings(); - } - @Override public lucee.runtime.rest.Mapping[] getRestMappings() { if (restMappings == null) { @@ -1810,65 +1800,56 @@ public void reload() { synchronized (this) { if (mappings != null) { ConfigFactoryImpl.flushPageSourcePool(mappings); + // resetMappings(false);// MUST 7 iss that needed? } - - createMapping(); createRestMapping(); } } - private void createMapping() { - Map existing = getExistingMappings(); - - // Mapping - Map mappings = MapFactory.getConcurrentMap(); - Mapping tmp; - boolean finished = false; - Mapping ex; - Mapping[] sm = cs.getMappings(); - if (sm != null) { - for (int i = 0; i < sm.length; i++) { - if (!sm[i].isHidden()) { - if ("/".equals(sm[i].getVirtual())) finished = true; - ex = existing.get(sm[i].getVirtualLowerCase()); - if (ex != null && ex.equals(sm[i])) { - mappings.put(ex.getVirtualLowerCase(), ex); - continue; - } - else if (sm[i] instanceof MappingImpl) { - tmp = ((MappingImpl) sm[i]).cloneReadOnly(this); - mappings.put(tmp.getVirtualLowerCase(), tmp); - - } - else { - tmp = sm[i]; - mappings.put(tmp.getVirtualLowerCase(), tmp); + @Override + public Mapping[] getMappings() { + if (mappings == null) { + synchronized (SystemUtil.createToken("ConfigWebImpl", "getMappings")) { + if (mappings == null) { + Mapping[] existing = cs.getMappings(); + // Mapping + Map mappings = MapFactory.getConcurrentMap(existing.length + 1); + boolean finished = false; + + for (Mapping m: existing) { + if ("/".equals(m.getVirtual())) finished = true; + mappings.put(m.getVirtualLowerCase(), m); } - if (ex instanceof MappingImpl) { - ((MappingImpl) ex).flush(); + if (!finished) { + Mapping m; + if (ResourceUtil.isUNCPath(getRootDirectory().getPath())) { + m = new MappingImpl(this, "/", getRootDirectory().getPath(), null, ConfigPro.INSPECT_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, + ConfigPro.INSPECT_INTERVAL_UNDEFINED, true, true, true, true, false, false, null, -1, -1); + } + else { + m = new MappingImpl(this, "/", "/", null, ConfigPro.INSPECT_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, true, + true, true, true, false, false, null, -1, -1, true, true); + } + mappings.put("/", m); } - + this.mappings = ConfigUtil.sort(mappings.values().toArray(new Mapping[mappings.size()])); } } } - if (!finished) { - Mapping m; - if (ResourceUtil.isUNCPath(getRootDirectory().getPath())) { - m = new MappingImpl(this, "/", getRootDirectory().getPath(), null, ConfigPro.INSPECT_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, - ConfigPro.INSPECT_INTERVAL_UNDEFINED, true, true, true, true, false, false, null, -1, -1); - } - else { - m = new MappingImpl(this, "/", "/", null, ConfigPro.INSPECT_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, ConfigPro.INSPECT_INTERVAL_UNDEFINED, true, true, true, - true, false, false, null, -1, -1, true, true); - } - ex = existing.get("/"); - if (ex != null && ex.equals(m)) { - m = ex; + return mappings; + } + + public ConfigWebImpl resetMappings() { + if (mappings != null) { + synchronized (SystemUtil.createToken("ConfigWebImpl", "getMappings")) { + if (mappings != null) { + mappings = null; + cs.resetMappings(); + } } - mappings.put("/", m); } - this.mappings = ConfigUtil.sort(mappings.values().toArray(new Mapping[mappings.size()])); + return this; } private void createRestMapping() { @@ -1891,17 +1872,6 @@ private void createRestMapping() { this.restMappings = mappings.values().toArray(new lucee.runtime.rest.Mapping[mappings.size()]); } - private Map getExistingMappings() { - Map mappings = MapFactory.getConcurrentMap(); - - if (this.mappings != null) { - for (Mapping m: this.mappings) { - mappings.put(m.getVirtualLowerCase(), m); - } - } - return mappings; - } - @Override public void removeDatasourceConnectionPool(DataSource ds) { cs.removeDatasourceConnectionPool(ds); diff --git a/core/src/main/java/lucee/runtime/tag/Admin.java b/core/src/main/java/lucee/runtime/tag/Admin.java index 718963a225..71585c9b4a 100755 --- a/core/src/main/java/lucee/runtime/tag/Admin.java +++ b/core/src/main/java/lucee/runtime/tag/Admin.java @@ -1023,7 +1023,7 @@ else if (mappingType == MAPPING_CT) { mapping.getInspectTemplateRaw(), mapping.getInspectTemplateAutoIntervalRaw(true), mapping.getInspectTemplateAutoIntervalRaw(false), mapping.isTopLevel(), mapping.getListenerMode(), mapping.getListenerType(), mapping.isReadonly()); store(); - Admin.getConfigServerImpl(config).resetMappings(); + ConfigUtil.getConfigWebImpl(configWeb).resetMappings(); } } @@ -2067,7 +2067,7 @@ private void doGetComponentMappings() throws PageException { private void doRemoveMapping() throws PageException { admin.removeMapping(getString("admin", action, "virtual")); store(); - Admin.getConfigServerImpl(config).resetMappings(); + ConfigUtil.getConfigWebImpl(configWeb).resetMappings(); adminSync.broadcast(attributes, config); } @@ -2101,7 +2101,7 @@ private void doUpdateMapping() throws PageException { ); store(); - Admin.getConfigServerImpl(config).resetMappings(); + ConfigUtil.getConfigWebImpl(configWeb).resetMappings(); adminSync.broadcast(attributes, config); }