Skip to content

Commit

Permalink
LDEV-4356 - caching RHExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Jul 17, 2024
1 parent 0612a3a commit 609a5a3
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 90 deletions.
18 changes: 9 additions & 9 deletions core/src/main/java/lucee/runtime/config/ConfigAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4001,7 +4001,7 @@ public void updateUpdateAdminMode(String mode, boolean merge, boolean keep) thro
for (ConfigWeb cw: webs) {
try {
for (RHExtension ext: ((ConfigPro) cw).getRHExtensions()) {
ext.addToAvailable();
ext.addToAvailable(cw);
}
}
catch (Exception e) {
Expand Down Expand Up @@ -4412,7 +4412,7 @@ public void removeRHExtension(String id) throws PageException {
if (child == null) continue;

try {
rhe = new RHExtension(config, Caster.toString(child.get(KeyConstants._id), null), Caster.toString(child.get(KeyConstants._version), null));
rhe = RHExtension.getInstance(config, Caster.toString(child.get(KeyConstants._id), null), Caster.toString(child.get(KeyConstants._version), null));
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
Expand Down Expand Up @@ -4571,10 +4571,10 @@ public static RHExtension _updateRHExtension(ConfigPro config, Resource ext, boo
public RHExtension updateRHExtension(Config config, Resource ext, boolean reload, boolean force, short action) throws PageException {
RHExtension rhext;
try {
rhext = new RHExtension(config, ext);
if (RHExtension.ACTION_COPY == action) rhext.copyToInstalled();
else if (RHExtension.ACTION_MOVE == action) rhext.moveToInstalled();
rhext.validate();
rhext = RHExtension.getInstance(config, ext);
if (RHExtension.ACTION_COPY == action) rhext.copyToInstalled(config);
else if (RHExtension.ACTION_MOVE == action) rhext.moveToInstalled(config);
rhext.validate(config);
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
Expand Down Expand Up @@ -6370,7 +6370,7 @@ public BundleDefinition[] _updateExtension(ConfigPro config, RHExtension ext) th
Resource r;
if (!StringUtil.isEmpty(res) && (r = ResourceUtil.toResourceExisting(config, res, null)) != null) {
try {
RHExtension _ext = new RHExtension(config, r);// TODO not load it again!
RHExtension _ext = RHExtension.getInstance(config, r);// TODO not load it again!
if (_ext != null && _ext.getId().equalsIgnoreCase(ext.getId())) {
old = RHExtension.toBundleDefinitions(ConfigWebUtil.getAsString("bundles", el, null)); // get existing bundles before populate new ones
ext.populate(el, false);
Expand Down Expand Up @@ -6426,7 +6426,7 @@ private RHExtension getRHExtension(final ConfigPro config, final String id, fina
if (!id.equals(_id)) continue;

try {
return new RHExtension(config, _id, Caster.toString(tmp.get(KeyConstants._version), null));
return RHExtension.getInstance(config, _id, Caster.toString(tmp.get(KeyConstants._version), null));
}
catch (Exception e) {
return defaultValue;
Expand Down Expand Up @@ -6465,7 +6465,7 @@ private RHExtension _hasRHExtensionInstalled(ConfigPro config, ExtensionDefintio
v = Caster.toString(sct.get(KeyConstants._version, null), null);
if (!RHExtension.isInstalled(config, id, v)) continue;

if (ed.equals(new ExtensionDefintion(id, v))) return new RHExtension(config, id, v);
if (ed.equals(new ExtensionDefintion(id, v))) return RHExtension.getInstance(config, id, v);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ public List<ExtensionDefintion> loadLocalExtensions(boolean validate) {
}
if (ed == null) {
try {
ext = new RHExtension(this, locReses[i]);
ext = RHExtension.getInstance(this, locReses[i]);
ed = new ExtensionDefintion(ext.getId(), ext.getVersion());
ed.setSource(ext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4982,7 +4982,7 @@ private static void _loadExtensionBundles(ConfigServerImpl cs, ConfigImpl config
if (!installedFiles.contains(r)) {

// is maybe a diff version installed?
RHExtension ext = new RHExtension(config, r);
RHExtension ext = RHExtension.getInstance(config, r);
if (!installedIds.contains(ext.getId())) {
if (log != null) log.info("extension",
"Found the extension [" + ext + "] in the installed folder that is not present in the configuration in any version, so we will uninstall it");
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/engine/CFMLEngineImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ private int deployBundledExtension(ConfigServerImpl cs, boolean validate) {
log.info("extract-extension", "Copy extension [" + name + "] to temp directory [" + temp + "]");
ResourceUtil.touch(temp);
Util.copy(is, temp.getOutputStream(), false, true);
rhe = new RHExtension(cs, temp);
rhe.validate();
rhe = RHExtension.getInstance(cs, temp);
rhe.validate(cs);
ExtensionDefintion alreadyExists = null;
it = existing.iterator();
while (it.hasNext()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public RHExtension toRHExtension() throws PageException, IOException, BundleExce
// MUST try to load the Extension
throw new ApplicationException("ExtensionDefinition does not contain the necessary data to create the requested object.");
}
rhe = new RHExtension(config, source);
rhe = RHExtension.getInstance(config, source);
return rhe;
}

Expand Down
Loading

0 comments on commit 609a5a3

Please sign in to comment.