use of lucee.runtime.osgi.OSGiUtil.BundleDefinition in project Lucee by lucee.
the class RHExtension method toBundleDefinition.
private static BundleDefinition toBundleDefinition(InputStream is, String name, String extensionVersion, boolean closeStream) throws IOException, BundleException, ApplicationException {
Resource tmp = SystemUtil.getTempDirectory().getRealResource(name);
try {
IOUtil.copy(is, tmp, closeStream);
BundleFile bf = new BundleFile(tmp);
if (bf.isBundle())
throw new ApplicationException("Jar [" + name + "] is not a valid OSGi Bundle");
return new BundleDefinition(bf.getSymbolicName(), bf.getVersion());
} finally {
tmp.delete();
}
}
use of lucee.runtime.osgi.OSGiUtil.BundleDefinition in project Lucee by lucee.
the class RHExtension method toBundleDefinitions.
public static BundleDefinition[] toBundleDefinitions(String strBundles) {
if (StringUtil.isEmpty(strBundles, true))
return EMPTY_BD;
String[] arrStrs = toArray(strBundles);
BundleDefinition[] arrBDs;
if (!ArrayUtil.isEmpty(arrStrs)) {
arrBDs = new BundleDefinition[arrStrs.length];
int index;
for (int i = 0; i < arrStrs.length; i++) {
index = arrStrs[i].indexOf(':');
if (index == -1)
arrBDs[i] = new BundleDefinition(arrStrs[i].trim());
else {
try {
arrBDs[i] = new BundleDefinition(arrStrs[i].substring(0, index).trim(), arrStrs[i].substring(index + 1).trim());
} catch (BundleException e) {
// should not happen
throw new PageRuntimeException(e);
}
}
}
} else
arrBDs = EMPTY_BD;
return arrBDs;
}
use of lucee.runtime.osgi.OSGiUtil.BundleDefinition in project Lucee by lucee.
the class DumpUtil method requiredBundles.
private static void requiredBundles(DumpTable parent, Bundle b) {
try {
List<BundleDefinition> list = OSGiUtil.getRequiredBundles(b);
if (list.isEmpty())
return;
DumpTable dt = new DumpTable("#6289a3", "#dee3e9", "#000000");
dt.appendRow(-1, new SimpleDumpData("name"), new SimpleDumpData("version"), new SimpleDumpData("operator"));
Iterator<BundleDefinition> it = list.iterator();
BundleDefinition bd;
VersionDefinition vd;
String v, op;
while (it.hasNext()) {
bd = it.next();
vd = bd.getVersionDefiniton();
if (vd != null) {
v = vd.getVersionAsString();
op = vd.getOpAsString();
} else {
v = "";
op = "";
}
dt.appendRow(0, new SimpleDumpData(bd.getName()), new SimpleDumpData(v), new SimpleDumpData(op));
}
parent.appendRow(1, new SimpleDumpData("required-bundles"), dt);
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
use of lucee.runtime.osgi.OSGiUtil.BundleDefinition in project Lucee by lucee.
the class ConfigServerImpl method getAllExtensionBundleDefintions.
@Override
public Collection<BundleDefinition> getAllExtensionBundleDefintions() {
Map<String, BundleDefinition> rtn = new HashMap<>();
// server (this)
Iterator<BundleDefinition> itt = getExtensionBundleDefintions().iterator();
BundleDefinition bd;
while (itt.hasNext()) {
bd = itt.next();
rtn.put(bd.getName() + "|" + bd.getVersionAsString(), bd);
}
// webs
ConfigWeb[] cws = getConfigWebs();
for (ConfigWeb cw : cws) {
itt = ((ConfigImpl) cw).getExtensionBundleDefintions().iterator();
while (itt.hasNext()) {
bd = itt.next();
rtn.put(bd.getName() + "|" + bd.getVersionAsString(), bd);
}
}
return rtn.values();
}
use of lucee.runtime.osgi.OSGiUtil.BundleDefinition in project Lucee by lucee.
the class BundleInfo method toArray1.
private static Array toArray1(List<BundleDefinition> list) {
Struct sct;
Array arr = new ArrayImpl();
Iterator<BundleDefinition> it = list.iterator();
BundleDefinition bd;
VersionDefinition vd;
while (it.hasNext()) {
bd = it.next();
sct = new StructImpl();
sct.setEL(KeyConstants._bundleName, bd.getName());
vd = bd.getVersionDefiniton();
if (vd != null) {
sct.setEL(KeyConstants._bundleVersion, vd.getVersionAsString());
sct.setEL("operator", vd.getOpAsString());
}
arr.appendEL(sct);
}
return arr;
}
Aggregations