Skip to content

Commit

Permalink
load core tag and function libraries on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Dec 12, 2024
1 parent fab71e6 commit 90fa84c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
45 changes: 25 additions & 20 deletions core/src/main/java/lucee/runtime/config/ConfigFactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2146,7 +2146,7 @@ public static void loadTag(ConfigImpl config, Struct root, boolean doNew) {

// init TLDS
{
config.setTLDs(ConfigUtil.duplicate(new TagLib[] { ConfigUtil.getConfigServerImpl(config).coreTLDs }, false));
config.setTLDs(ConfigUtil.duplicate(new TagLib[] { ConfigUtil.getConfigServerImpl(config).getCoreTLDs() }, false)); // MUST duplicate needed?
}

// TLD Dir
Expand Down Expand Up @@ -2222,7 +2222,7 @@ public static void loadFunctions(ConfigImpl config, Struct root, boolean doNew)

// Init flds
{
config.setFLDs(ConfigUtil.getConfigServerImpl(config).coreFLDs.duplicate(false));
config.setFLDs(ConfigUtil.getConfigServerImpl(config).getCoreFLDs().duplicate(false)); // MUST duplicate needed?

}

Expand Down Expand Up @@ -3296,24 +3296,7 @@ private static void _loadExtensionBundles(ConfigServerImpl config, Struct root)
// we force a new installation if we have switched from single to multi mode, because extension can
// act completely different if that is the case
rhe = RHExtension.installExtension(config, id, Caster.toString(child.get(KeyConstants._version, null), null), res, false);
if (rhe.getMetadata().isStartBundles()) {
if (!firstLoad) {
rhe.deployBundles(config, true);
}
else {
try {
BundleInfo[] bundles = rhe.getMetadata().getBundles();
if (bundles != null) {
for (BundleInfo bi: bundles) {
OSGiUtil.loadBundleFromLocal(bi.getSymbolicName(), bi.getVersion(), null, false, null);
}
}
}
catch (Exception ex) {
rhe.deployBundles(config, true);
}
}
}
startBundles(config, rhe, firstLoad);

extensions.add(rhe);
installedFiles.add(rhe.getExtensionFile());
Expand Down Expand Up @@ -3358,6 +3341,28 @@ private static void _loadExtensionBundles(ConfigServerImpl config, Struct root)
}
}

private static void startBundles(ConfigServerImpl config, RHExtension rhe, boolean firstLoad) throws IOException, BundleException {
if (rhe.getMetadata().isStartBundles()) {
if (!firstLoad) {
rhe.deployBundles(config, true);
}
else {
try {
BundleInfo[] bundles = rhe.getMetadata().getBundles();
if (bundles != null) {
for (BundleInfo bi: bundles) {
OSGiUtil.loadBundleFromLocal(bi.getSymbolicName(), bi.getVersion(), null, false, null);
}
}
}
catch (Exception ex) {
rhe.deployBundles(config, true);
}
}
}

}

public static List<ExtensionDefintion> loadExtensionDefinition(ConfigImpl config, Struct root) {
List<ExtensionDefintion> extensions = new ArrayList<>();

Expand Down
28 changes: 24 additions & 4 deletions core/src/main/java/lucee/runtime/config/ConfigServerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public final class ConfigServerImpl extends ConfigImpl implements ConfigServer {

private int permGenCleanUpThreshold = 60;

final TagLib coreTLDs;
final FunctionLib coreFLDs;
private TagLib coreTLDs;
private FunctionLib coreFLDs;

private final UpdateInfo updateInfo;

Expand Down Expand Up @@ -166,8 +166,6 @@ public final class ConfigServerImpl extends ConfigImpl implements ConfigServer {
protected ConfigServerImpl(CFMLEngineImpl engine, Map<String, CFMLFactory> initContextes, Map<String, CFMLFactory> contextes, Resource configDir, Resource configFile,
UpdateInfo updateInfo, boolean essentialOnly, boolean newVersion) throws TagLibException, FunctionLibException {
super(configDir, configFile, newVersion);
this.coreTLDs = TagLibFactory.loadFromSystem(id);
this.coreFLDs = FunctionLibFactory.loadFromSystem(id);

this.engine = engine;
if (!essentialOnly) engine.setConfigServerImpl(this);
Expand All @@ -178,6 +176,28 @@ protected ConfigServerImpl(CFMLEngineImpl engine, Map<String, CFMLFactory> initC
this.updateInfo = updateInfo;
}

FunctionLib getCoreFLDs() throws FunctionLibException {
if (coreFLDs == null) {
synchronized (SystemUtil.createToken("ConfigServerImpl", "getCoreFLDs")) {
if (coreFLDs == null) {
this.coreFLDs = FunctionLibFactory.loadFromSystem(id);
}
}
}
return coreFLDs;
}

TagLib getCoreTLDs() throws TagLibException {
if (coreTLDs == null) {
synchronized (SystemUtil.createToken("ConfigServerImpl", "getCoreTLDs")) {
if (coreTLDs == null) {
this.coreTLDs = TagLibFactory.loadFromSystem(id);
}
}
}
return coreTLDs;
}

public void setRoot(Struct root) {
this.root = root;
}
Expand Down
2 changes: 1 addition & 1 deletion loader/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project default="core" basedir="." name="Lucee"
xmlns:resolver="antlib:org.apache.maven.resolver.ant">

<property name="version" value="7.0.0.69-SNAPSHOT"/>
<property name="version" value="7.0.0.70-SNAPSHOT"/>

<taskdef uri="antlib:org.apache.maven.resolver.ant" resource="org/apache/maven/resolver/ant/antlib.xml">
<classpath>
Expand Down
2 changes: 1 addition & 1 deletion loader/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.lucee</groupId>
<artifactId>lucee</artifactId>
<version>7.0.0.69-SNAPSHOT</version>
<version>7.0.0.70-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Lucee Loader Build</name>
Expand Down

0 comments on commit 90fa84c

Please sign in to comment.