Skip to content

Commit

Permalink
improve getting BundleInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeloffner committed Dec 12, 2024
1 parent 90fa84c commit a72a6b5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ else if (!entry.isDirectory() && (startsWith(path, type, "jars") || startsWith(p
|| startsWith(path, type, "bundle") || startsWith(path, type, "lib") || startsWith(path, type, "libs")) && (StringUtil.endsWithIgnoreCase(path, ".jar"))) {

jars.add(fileName);
BundleInfo bi = BundleInfo.getInstance(fileName, zis, false);
BundleInfo bi = BundleInfo.getInstance(config, fileName, zis, false);
if (bi.isBundle()) bundles.add(bi);
}

Expand Down
30 changes: 27 additions & 3 deletions core/src/main/java/lucee/runtime/osgi/BundleInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import lucee.commons.io.res.type.file.FileResource;
import lucee.commons.lang.ExceptionUtil;
import lucee.commons.lang.StringUtil;
import lucee.runtime.config.Config;
import lucee.runtime.config.ConfigUtil;
import lucee.runtime.op.Caster;
import lucee.runtime.osgi.OSGiUtil.BundleDefinition;
import lucee.runtime.osgi.OSGiUtil.PackageDefinition;
Expand Down Expand Up @@ -72,12 +74,27 @@ public class BundleInfo implements Serializable {
private Map<String, PackageDefinition> exportPackageAsMap;
private static Map<String, BundleInfo> bundles = new HashMap<String, BundleInfo>();

public static BundleInfo getInstance(String id, InputStream is, boolean closeStream) throws IOException, BundleException {
public static BundleInfo getInstance(Config config, String id, InputStream is, boolean closeStream) throws IOException, BundleException {

// cached ?
BundleInfo bi = bundles.get(id);
if (bi != null) return bi;
if (bi != null) {
return bi;
}

File tmp = File.createTempFile("temp-extension", "lex");
// load file from bundles dir
try {
File bundleFile = new File(ConfigUtil.getCFMLEngine(config).getCFMLEngineFactory().getBundleDirectory(), id);
if (bundleFile.isFile()) {
bundles.put(id, bi = new BundleInfo(bundleFile));
return bi;
}
}
catch (Exception e) {
}

// create a temp file to read data from it (using the stream direclty did not work properly)
File tmp = File.createTempFile("temp-extension", "lex");
try {
FileOutputStream os = new FileOutputStream(tmp);
IOUtil.copy(is, os, closeStream, true);
Expand Down Expand Up @@ -307,4 +324,11 @@ protected static File toFileResource(Resource file) throws IOException {
if (file instanceof FileResource) return (File) file;
throw new IOException("only file resources (local file system) are supported");
}

@Override
public String toString() {
return "name:" + name + ";version:" + version + ";symbolicName:" + symbolicName + ";exportPackage:" + exportPackage + ";importPackage:" + importPackage + ";activator:"
+ activator + ";manifestVersion:" + manifestVersion + ";description:" + description + ";dynamicImportPackage:" + dynamicImportPackage + ";classPath:" + classPath
+ ";requireBundle:" + requireBundle + ";fragmentHost:" + fragementHost;
}
}
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.70-SNAPSHOT"/>
<property name="version" value="7.0.0.71-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.70-SNAPSHOT</version>
<version>7.0.0.71-SNAPSHOT</version>
<packaging>jar</packaging>

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

0 comments on commit a72a6b5

Please sign in to comment.