Search in sources :

Example 6 with BundleDefinition

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();
    }
}
Also used : BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) ApplicationException(lucee.runtime.exp.ApplicationException) Resource(lucee.commons.io.res.Resource) BundleFile(lucee.runtime.osgi.BundleFile)

Example 7 with BundleDefinition

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;
}
Also used : BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) BundleException(org.osgi.framework.BundleException) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 8 with BundleDefinition

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);
    }
}
Also used : BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) VersionDefinition(lucee.runtime.osgi.OSGiUtil.VersionDefinition)

Example 9 with BundleDefinition

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();
}
Also used : BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) HashMap(java.util.HashMap)

Example 10 with BundleDefinition

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;
}
Also used : Array(lucee.runtime.type.Array) BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) VersionDefinition(lucee.runtime.osgi.OSGiUtil.VersionDefinition) StructImpl(lucee.runtime.type.StructImpl) ArrayImpl(lucee.runtime.type.ArrayImpl) Struct(lucee.runtime.type.Struct)

Aggregations

BundleDefinition (lucee.runtime.osgi.OSGiUtil.BundleDefinition)15 HashMap (java.util.HashMap)4 BundleFile (lucee.runtime.osgi.BundleFile)4 Struct (lucee.runtime.type.Struct)4 Bundle (org.osgi.framework.Bundle)4 BundleException (org.osgi.framework.BundleException)4 IOException (java.io.IOException)3 Resource (lucee.commons.io.res.Resource)3 BundleCollection (lucee.loader.osgi.BundleCollection)3 RHExtension (lucee.runtime.extension.RHExtension)3 BundleInfo (lucee.runtime.osgi.BundleInfo)3 StructImpl (lucee.runtime.type.StructImpl)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ZipEntry (java.util.zip.ZipEntry)2 ZipInputStream (java.util.zip.ZipInputStream)2 Log (lucee.commons.io.log.Log)2 CFMLEngine (lucee.loader.engine.CFMLEngine)2 ClassDefinition (lucee.runtime.db.ClassDefinition)2 ApplicationException (lucee.runtime.exp.ApplicationException)2