Search in sources :

Example 1 with BundleInfo

use of lucee.runtime.osgi.BundleInfo in project Lucee by lucee.

the class XMLConfigAdmin method updateRHExtension.

public void updateRHExtension(Config config, RHExtension rhext, boolean reload) throws PageException {
    ConfigImpl ci = (ConfigImpl) config;
    Log logger = ci.getLog("deploy");
    String type = ci instanceof ConfigWeb ? "web" : "server";
    // load already installed previous version and uninstall the parts no longer needed
    RHExtension existingRH = getRHExtension(ci, rhext.getId(), null);
    if (existingRH != null) {
        // same version
        if (existingRH.getVersion().compareTo(rhext.getVersion()) == 0) {
            removeRHExtension(config, existingRH, rhext, false);
        } else
            removeRHExtension(config, existingRH, rhext, true);
    }
    // INSTALL
    try {
        // boolean clearTags=false,clearFunction=false;
        boolean reloadNecessary = false;
        // store to xml
        BundleDefinition[] existing = _updateExtension(ci, rhext);
        // _storeAndReload();
        // this must happen after "store"
        // clean after populating the new ones
        cleanBundles(rhext, ci, existing);
        // ConfigWebAdmin.updateRHExtension(ci,rhext);
        ZipInputStream zis = new ZipInputStream(IOUtil.toBufferedInputStream(rhext.getExtensionFile().getInputStream()));
        ZipEntry entry;
        String path;
        String fileName;
        while ((entry = zis.getNextEntry()) != null) {
            path = entry.getName();
            fileName = fileName(entry);
            // jars
            if (!entry.isDirectory() && (startsWith(path, type, "jars") || startsWith(path, type, "jar") || startsWith(path, type, "bundles") || startsWith(path, type, "bundle") || startsWith(path, type, "lib") || startsWith(path, type, "libs")) && StringUtil.endsWithIgnoreCase(path, ".jar")) {
                Object obj = XMLConfigAdmin.installBundle(config, zis, fileName, rhext.getVersion(), false, false);
                // jar is not a bundle, only a regular jar
                if (!(obj instanceof BundleFile)) {
                    Resource tmp = (Resource) obj;
                    Resource tmpJar = tmp.getParentResource().getRealResource(ListUtil.last(path, "\\/"));
                    tmp.moveTo(tmpJar);
                    XMLConfigAdmin.updateJar(config, tmpJar, false);
                }
            }
            // flds
            if (!entry.isDirectory() && startsWith(path, type, "flds") && (StringUtil.endsWithIgnoreCase(path, ".fld") || StringUtil.endsWithIgnoreCase(path, ".fldx"))) {
                logger.log(Log.LEVEL_INFO, "extension", "deploy fld " + fileName);
                updateFLD(zis, fileName, false);
                reloadNecessary = true;
            }
            // tlds
            if (!entry.isDirectory() && startsWith(path, type, "tlds") && (StringUtil.endsWithIgnoreCase(path, ".tld") || StringUtil.endsWithIgnoreCase(path, ".tldx"))) {
                logger.log(Log.LEVEL_INFO, "extension", "deploy tld/tldx " + fileName);
                updateTLD(zis, fileName, false);
                reloadNecessary = true;
            }
            // tags
            if (!entry.isDirectory() && startsWith(path, type, "tags")) {
                String sub = subFolder(entry);
                logger.log(Log.LEVEL_INFO, "extension", "deploy tag " + sub);
                updateTag(zis, sub, false);
                // clearTags=true;
                reloadNecessary = true;
            }
            // functions
            if (!entry.isDirectory() && startsWith(path, type, "functions")) {
                String sub = subFolder(entry);
                logger.log(Log.LEVEL_INFO, "extension", "deploy function " + sub);
                updateFunction(zis, sub, false);
                // clearFunction=true;
                reloadNecessary = true;
            }
            // mappings
            if (!entry.isDirectory() && (startsWith(path, type, "archives") || startsWith(path, type, "mappings"))) {
                String sub = subFolder(entry);
                logger.log(Log.LEVEL_INFO, "extension", "deploy mapping " + sub);
                updateArchive(zis, sub, false);
                reloadNecessary = true;
            // clearFunction=true;
            }
            // event-gateway
            if (!entry.isDirectory() && (startsWith(path, type, "event-gateways") || startsWith(path, type, "eventGateways")) && (StringUtil.endsWithIgnoreCase(path, "." + Constants.getCFMLComponentExtension()) || StringUtil.endsWithIgnoreCase(path, "." + Constants.getLuceeComponentExtension()))) {
                String sub = subFolder(entry);
                logger.log(Log.LEVEL_INFO, "extension", "deploy event-gateway " + sub);
                updateEventGateway(zis, sub, false);
            }
            // context
            String realpath;
            if (!entry.isDirectory() && startsWith(path, type, "context") && !StringUtil.startsWith(fileName(entry), '.')) {
                realpath = path.substring(8);
                logger.log(Log.LEVEL_INFO, "extension", "deploy context " + realpath);
                updateContext(zis, realpath, false, false);
            }
            // web contextS
            boolean first;
            if (!entry.isDirectory() && ((first = startsWith(path, type, "webcontexts")) || startsWith(path, type, "web.contexts")) && !StringUtil.startsWith(fileName(entry), '.')) {
                realpath = path.substring(first ? 12 : 13);
                logger.log(Log.LEVEL_INFO, "extension", "deploy webcontext " + realpath);
                updateWebContexts(zis, realpath, false, false);
            }
            // applications
            if (!entry.isDirectory() && (startsWith(path, type, "applications") || startsWith(path, type, "web.applications") || startsWith(path, type, "web")) && !StringUtil.startsWith(fileName(entry), '.')) {
                int index;
                if (startsWith(path, type, "applications"))
                    index = 13;
                else if (startsWith(path, type, "web.applications"))
                    index = 17;
                else
                    // web
                    index = 4;
                realpath = path.substring(index);
                logger.log(Log.LEVEL_INFO, "extension", "deploy application " + realpath);
                updateApplication(zis, realpath, false);
            }
            // configs
            if (!entry.isDirectory() && (startsWith(path, type, "config")) && !StringUtil.startsWith(fileName(entry), '.')) {
                realpath = path.substring(7);
                logger.log(Log.LEVEL_INFO, "extension", "deploy config " + realpath);
                updateConfigs(zis, realpath, false, false);
            }
            // components
            if (!entry.isDirectory() && (startsWith(path, type, "components")) && !StringUtil.startsWith(fileName(entry), '.')) {
                realpath = path.substring(11);
                logger.log(Log.LEVEL_INFO, "extension", "deploy component " + realpath);
                updateComponent(zis, realpath, false, false);
            }
            // plugins
            if (!entry.isDirectory() && (startsWith(path, type, "plugins")) && !StringUtil.startsWith(fileName(entry), '.')) {
                realpath = path.substring(8);
                logger.log(Log.LEVEL_INFO, "extension", "deploy plugin " + realpath);
                updatePlugin(zis, realpath, false);
            }
            zis.closeEntry();
        }
        // load the bundles
        if (rhext.getStartBundles()) {
            rhext.deployBundles(ci);
            BundleInfo[] bfs = rhext.getBundles();
            for (BundleInfo bf : bfs) {
                OSGiUtil.loadBundleFromLocal(bf.getSymbolicName(), bf.getVersion(), false, null);
            }
        }
        // update cache
        if (!ArrayUtil.isEmpty(rhext.getCaches())) {
            Iterator<Map<String, String>> itl = rhext.getCaches().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                if (cd != null && cd.isBundle()) {
                    _updateCache(cd);
                    reloadNecessary = true;
                }
                logger.info("extension", "update cache [" + cd + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update cache handler
        if (!ArrayUtil.isEmpty(rhext.getCacheHandlers())) {
            Iterator<Map<String, String>> itl = rhext.getCacheHandlers().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                String _id = map.get("id");
                if (!StringUtil.isEmpty(_id) && cd != null && cd.hasClass()) {
                    _updateCacheHandler(_id, cd);
                    reloadNecessary = true;
                }
                logger.info("extension", "update cache handler [" + cd + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update AMF
        if (!ArrayUtil.isEmpty(rhext.getAMFs())) {
            Iterator<Map<String, String>> itl = rhext.getAMFs().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                if (cd != null && cd.hasClass()) {
                    _updateAMFEngine(cd, map.get("caster"), map.get("configuration"));
                    reloadNecessary = true;
                }
                logger.info("extension", "update AMF engine [" + cd + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update Search
        if (!ArrayUtil.isEmpty(rhext.getSearchs())) {
            Iterator<Map<String, String>> itl = rhext.getSearchs().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                if (cd != null && cd.hasClass()) {
                    _updateSearchEngine(cd);
                    reloadNecessary = true;
                }
                logger.info("extension", "update search engine [" + cd + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update Resource
        if (!ArrayUtil.isEmpty(rhext.getResources())) {
            Iterator<Map<String, String>> itl = rhext.getResources().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                String scheme = map.get("scheme");
                if (cd != null && cd.hasClass() && !StringUtil.isEmpty(scheme)) {
                    Struct args = new StructImpl();
                    copyButIgnoreClassDef(map, args);
                    args.remove("scheme");
                    _updateResourceProvider(scheme, cd, args);
                    reloadNecessary = true;
                }
                logger.info("extension", "update resource provider [" + scheme + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update orm
        if (!ArrayUtil.isEmpty(rhext.getOrms())) {
            Iterator<Map<String, String>> itl = rhext.getOrms().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                if (cd != null && cd.hasClass()) {
                    _updateORMEngine(cd);
                    reloadNecessary = true;
                }
                logger.info("extension", "update orm engine [" + cd + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update monitor
        if (!ArrayUtil.isEmpty(rhext.getMonitors())) {
            Iterator<Map<String, String>> itl = rhext.getMonitors().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                if (cd != null && cd.hasClass()) {
                    _updateMonitorEnabled(true);
                    _updateMonitor(cd, map.get("type"), map.get("name"), true);
                    reloadNecessary = true;
                }
                logger.info("extension", "update monitor engine [" + cd + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update jdbc
        if (!ArrayUtil.isEmpty(rhext.getJdbcs())) {
            Iterator<Map<String, String>> itl = rhext.getJdbcs().iterator();
            Map<String, String> map;
            while (itl.hasNext()) {
                map = itl.next();
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                String _label = map.get("label");
                if (cd != null && cd.isBundle()) {
                    _updateJDBCDriver(_label, cd);
                    reloadNecessary = true;
                }
                logger.info("extension", "update JDBC Driver [" + _label + ":" + cd + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // update mapping
        if (!ArrayUtil.isEmpty(rhext.getMappings())) {
            Iterator<Map<String, String>> itl = rhext.getMappings().iterator();
            Map<String, String> map;
            String virtual, physical, archive, primary;
            short inspect;
            int lmode, ltype;
            boolean toplevel, readonly;
            while (itl.hasNext()) {
                map = itl.next();
                virtual = map.get("virtual");
                physical = map.get("physical");
                archive = map.get("archive");
                primary = map.get("primary");
                inspect = ConfigWebUtil.inspectTemplate(map.get("inspect"), Config.INSPECT_UNDEFINED);
                lmode = ConfigWebUtil.toListenerMode(map.get("listener-mode"), -1);
                ltype = ConfigWebUtil.toListenerType(map.get("listener-type"), -1);
                toplevel = Caster.toBooleanValue(map.get("toplevel"), false);
                readonly = Caster.toBooleanValue(map.get("readonly"), false);
                _updateMapping(virtual, physical, archive, primary, inspect, toplevel, lmode, ltype, readonly);
                reloadNecessary = true;
                logger.info("extension", "update Mapping [" + virtual + "]");
            }
        }
        if (!ArrayUtil.isEmpty(rhext.getEventGatewayInstances())) {
            Iterator<Map<String, Object>> itl = rhext.getEventGatewayInstances().iterator();
            Map<String, Object> map;
            while (itl.hasNext()) {
                map = itl.next();
                // id
                String id = Caster.toString(map.get("id"), null);
                // class
                ClassDefinition cd = RHExtension.toClassDefinition(config, map, null);
                // component path
                String cfcPath = Caster.toString(map.get("cfc-path"), null);
                if (StringUtil.isEmpty(cfcPath))
                    cfcPath = Caster.toString(map.get("component-path"), null);
                // listener component path
                String listenerCfcPath = Caster.toString(map.get("listener-cfc-path"), null);
                if (StringUtil.isEmpty(listenerCfcPath))
                    listenerCfcPath = Caster.toString(map.get("listener-component-path"), null);
                // startup mode
                String strStartupMode = Caster.toString(map.get("startup-mode"), "automatic");
                int startupMode = GatewayEntryImpl.toStartup(strStartupMode, GatewayEntryImpl.STARTUP_MODE_AUTOMATIC);
                // read only
                boolean readOnly = Caster.toBooleanValue(map.get("read-only"), false);
                // custom
                Struct custom = Caster.toStruct(map.get("custom"), null);
                if (!StringUtil.isEmpty(id) && (!StringUtil.isEmpty(cfcPath) || (cd != null && cd.hasClass()))) {
                    _updateGatewayEntry(id, cd, cfcPath, listenerCfcPath, startupMode, custom, readOnly);
                }
                logger.info("extension", "update event gateway entry [" + id + "] from extension [" + rhext.getName() + ":" + rhext.getVersion() + "]");
            }
        }
        // reload
        // if(reloadNecessary){
        reloadNecessary = true;
        if (reload && reloadNecessary)
            _storeAndReload();
        else
            _store();
    // }
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        DeployHandler.moveToFailedFolder(rhext.getExtensionFile().getParentResource(), rhext.getExtensionFile());
        try {
            XMLConfigAdmin.removeRHExtension((ConfigImpl) config, rhext.getId(), false);
        } catch (Throwable t2) {
            ExceptionUtil.rethrowIfNecessary(t2);
        }
        throw Caster.toPageException(t);
    }
}
Also used : ZipEntry(java.util.zip.ZipEntry) ClassDefinition(lucee.runtime.db.ClassDefinition) Struct(lucee.runtime.type.Struct) BundleInfo(lucee.runtime.osgi.BundleInfo) BundleFile(lucee.runtime.osgi.BundleFile) Log(lucee.commons.io.log.Log) Resource(lucee.commons.io.res.Resource) BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) RHExtension(lucee.runtime.extension.RHExtension) ZipInputStream(java.util.zip.ZipInputStream) StructImpl(lucee.runtime.type.StructImpl) CreateObject(lucee.runtime.functions.other.CreateObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with BundleInfo

use of lucee.runtime.osgi.BundleInfo in project Lucee by lucee.

the class XMLConfigWebFactory method loadExtensionBundles.

/**
 * loads the bundles defined in the extensions
 * @param cs
 * @param config
 * @param doc
 * @param log
 */
private static void loadExtensionBundles(ConfigServerImpl cs, ConfigImpl config, Document doc, Log log) {
    Element parent = getChildByName(doc.getDocumentElement(), "extensions");
    Element[] children = getChildren(parent, "rhextension");
    String strBundles;
    List<RHExtension> extensions = new ArrayList<RHExtension>();
    RHExtension rhe;
    for (Element child : children) {
        BundleInfo[] bfsq;
        try {
            rhe = new RHExtension(config, child);
            if (rhe.getStartBundles())
                rhe.deployBundles(config);
            extensions.add(rhe);
        } catch (Exception e) {
            log.error("load-extension", e);
            continue;
        }
    }
    config.setExtensions(extensions.toArray(new RHExtension[extensions.size()]));
}
Also used : RHExtension(lucee.runtime.extension.RHExtension) BundleInfo(lucee.runtime.osgi.BundleInfo) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) FunctionLibException(lucee.transformer.library.function.FunctionLibException) PageException(lucee.runtime.exp.PageException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SecurityException(lucee.runtime.exp.SecurityException) TagLibException(lucee.transformer.library.tag.TagLibException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SQLException(java.sql.SQLException) IOException(java.io.IOException) BundleException(org.osgi.framework.BundleException) SAXException(org.xml.sax.SAXException) ClassException(lucee.commons.lang.ClassException) MalformedURLException(java.net.MalformedURLException) ExpressionException(lucee.runtime.exp.ExpressionException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 3 with BundleInfo

use of lucee.runtime.osgi.BundleInfo in project Lucee by lucee.

the class RHExtension method populate.

private void populate(Query qry) throws PageException, IOException, BundleException {
    int row = qry.addRow();
    qry.setAt(KeyConstants._id, row, getId());
    qry.setAt(KeyConstants._name, row, name);
    qry.setAt(KeyConstants._image, row, getImage());
    qry.setAt(KeyConstants._description, row, description);
    qry.setAt(KeyConstants._version, row, getVersion() == null ? null : getVersion().toString());
    qry.setAt(TRIAL, row, isTrial());
    qry.setAt(RELEASE_TYPE, row, toReleaseType(getReleaseType(), "all"));
    // qry.setAt(JARS, row,Caster.toArray(getJars()));
    qry.setAt(FLDS, row, Caster.toArray(getFlds()));
    qry.setAt(TLDS, row, Caster.toArray(getTlds()));
    qry.setAt(FUNCTIONS, row, Caster.toArray(getFunctions()));
    qry.setAt(ARCHIVES, row, Caster.toArray(getArchives()));
    qry.setAt(TAGS, row, Caster.toArray(getTags()));
    qry.setAt(CONTEXTS, row, Caster.toArray(getContexts()));
    qry.setAt(WEBCONTEXTS, row, Caster.toArray(getWebContexts()));
    qry.setAt(CONFIG, row, Caster.toArray(getConfigs()));
    qry.setAt(EVENT_GATEWAYS, row, Caster.toArray(getEventGateways()));
    qry.setAt(CATEGORIES, row, Caster.toArray(getCategories()));
    qry.setAt(APPLICATIONS, row, Caster.toArray(getApplications()));
    qry.setAt(COMPONENTS, row, Caster.toArray(getComponents()));
    qry.setAt(PLUGINS, row, Caster.toArray(getPlugins()));
    qry.setAt(START_BUNDLES, row, Caster.toBoolean(getStartBundles()));
    BundleInfo[] bfs = getBundles();
    Query qryBundles = new QueryImpl(new Key[] { KeyConstants._name, KeyConstants._version }, bfs.length, "bundles");
    for (int i = 0; i < bfs.length; i++) {
        qryBundles.setAt(KeyConstants._name, i + 1, bfs[i].getSymbolicName());
        if (bfs[i].getVersion() != null)
            qryBundles.setAt(KeyConstants._version, i + 1, bfs[i].getVersionAsString());
    }
    qry.setAt(BUNDLES, row, qryBundles);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) BundleInfo(lucee.runtime.osgi.BundleInfo) Query(lucee.runtime.type.Query)

Example 4 with BundleInfo

use of lucee.runtime.osgi.BundleInfo in project Lucee by lucee.

the class RHExtension method load.

private void load(Resource ext) throws IOException, BundleException, ApplicationException {
    // print.ds(ext.getAbsolutePath());
    loaded = true;
    // no we read the content of the zip
    ZipInputStream zis = new ZipInputStream(IOUtil.toBufferedInputStream(ext.getInputStream()));
    ZipEntry entry;
    Manifest manifest = null;
    String _img = null;
    String path;
    String fileName, sub;
    List<BundleInfo> bundles = new ArrayList<BundleInfo>();
    List<String> jars = new ArrayList<String>();
    List<String> flds = new ArrayList<String>();
    List<String> tlds = new ArrayList<String>();
    List<String> tags = new ArrayList<String>();
    List<String> functions = new ArrayList<String>();
    List<String> contexts = new ArrayList<String>();
    List<String> configs = new ArrayList<String>();
    List<String> webContexts = new ArrayList<String>();
    List<String> applications = new ArrayList<String>();
    List<String> components = new ArrayList<String>();
    List<String> plugins = new ArrayList<String>();
    List<String> gateways = new ArrayList<String>();
    List<String> archives = new ArrayList<String>();
    try {
        while ((entry = zis.getNextEntry()) != null) {
            path = entry.getName();
            fileName = fileName(entry);
            sub = subFolder(entry);
            if (!entry.isDirectory() && path.equalsIgnoreCase("META-INF/MANIFEST.MF")) {
                manifest = toManifest(config, zis, null);
            } else if (!entry.isDirectory() && path.equalsIgnoreCase("META-INF/logo.png")) {
                _img = toBase64(zis, null);
            } else // jars
            if (!entry.isDirectory() && (startsWith(path, type, "jars") || startsWith(path, type, "jar") || startsWith(path, type, "bundles") || startsWith(path, type, "bundle") || startsWith(path, type, "lib") || startsWith(path, type, "libs")) && StringUtil.endsWithIgnoreCase(path, ".jar")) {
                // print.e("xxxxxx-------- "+fileName+" -------xxxxxx");
                jars.add(fileName);
                BundleInfo bi = BundleInfo.getInstance(fileName, zis, false);
                if (bi.isBundle())
                    bundles.add(bi);
            } else // flds
            if (!entry.isDirectory() && startsWith(path, type, "flds") && (StringUtil.endsWithIgnoreCase(path, ".fld") || StringUtil.endsWithIgnoreCase(path, ".fldx")))
                flds.add(fileName);
            else // tlds
            if (!entry.isDirectory() && startsWith(path, type, "tlds") && (StringUtil.endsWithIgnoreCase(path, ".tld") || StringUtil.endsWithIgnoreCase(path, ".tldx")))
                tlds.add(fileName);
            else // archives
            if (!entry.isDirectory() && (startsWith(path, type, "archives") || startsWith(path, type, "mappings")) && StringUtil.endsWithIgnoreCase(path, ".lar"))
                archives.add(fileName);
            else // event-gateway
            if (!entry.isDirectory() && (startsWith(path, type, "event-gateways") || startsWith(path, type, "eventGateways")) && (StringUtil.endsWithIgnoreCase(path, "." + Constants.getCFMLComponentExtension()) || StringUtil.endsWithIgnoreCase(path, "." + Constants.getLuceeComponentExtension())))
                gateways.add(sub);
            else // tags
            if (!entry.isDirectory() && startsWith(path, type, "tags"))
                tags.add(sub);
            else // functions
            if (!entry.isDirectory() && startsWith(path, type, "functions"))
                functions.add(sub);
            else // context
            if (!entry.isDirectory() && startsWith(path, type, "context") && !StringUtil.startsWith(fileName(entry), '.'))
                contexts.add(sub);
            else // web contextS
            if (!entry.isDirectory() && (startsWith(path, type, "webcontexts") || startsWith(path, type, "web.contexts")) && !StringUtil.startsWith(fileName(entry), '.'))
                webContexts.add(sub);
            else // config
            if (!entry.isDirectory() && startsWith(path, type, "config") && !StringUtil.startsWith(fileName(entry), '.'))
                configs.add(sub);
            else // applications
            if (!entry.isDirectory() && (startsWith(path, type, "web.applications") || startsWith(path, type, "applications") || startsWith(path, type, "web")) && !StringUtil.startsWith(fileName(entry), '.'))
                applications.add(sub);
            else // components
            if (!entry.isDirectory() && (startsWith(path, type, "components")) && !StringUtil.startsWith(fileName(entry), '.'))
                components.add(sub);
            else // plugins
            if (!entry.isDirectory() && (startsWith(path, type, "plugins")) && !StringUtil.startsWith(fileName(entry), '.'))
                plugins.add(sub);
            zis.closeEntry();
        }
    } finally {
        IOUtil.closeEL(zis);
    }
    // read the manifest
    if (manifest == null)
        throw new ApplicationException("The Extension [" + ext + "] is invalid,no Manifest file was found at [META-INF/MANIFEST.MF].");
    readManifestConfig(manifest, ext.getAbsolutePath(), _img);
    this.jars = jars.toArray(new String[jars.size()]);
    this.flds = flds.toArray(new String[flds.size()]);
    this.tlds = tlds.toArray(new String[tlds.size()]);
    this.tags = tags.toArray(new String[tags.size()]);
    this.gateways = gateways.toArray(new String[gateways.size()]);
    this.functions = functions.toArray(new String[functions.size()]);
    this.archives = archives.toArray(new String[archives.size()]);
    this.contexts = contexts.toArray(new String[contexts.size()]);
    this.configs = configs.toArray(new String[configs.size()]);
    this.webContexts = webContexts.toArray(new String[webContexts.size()]);
    this.applications = applications.toArray(new String[applications.size()]);
    this.components = components.toArray(new String[components.size()]);
    this.plugins = plugins.toArray(new String[plugins.size()]);
    this.bundles = bundles.toArray(new BundleInfo[bundles.size()]);
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) BundleInfo(lucee.runtime.osgi.BundleInfo) ApplicationException(lucee.runtime.exp.ApplicationException) ZipEntry(java.util.zip.ZipEntry) ArrayList(java.util.ArrayList) Manifest(java.util.jar.Manifest)

Example 5 with BundleInfo

use of lucee.runtime.osgi.BundleInfo in project Lucee by lucee.

the class XMLConfigAdmin method cleanBundles.

public static void cleanBundles(RHExtension rhe, ConfigImpl config, BundleDefinition[] candiatesToRemove) throws BundleException, ApplicationException, IOException {
    if (ArrayUtil.isEmpty(candiatesToRemove))
        return;
    BundleCollection coreBundles = ConfigWebUtil.getEngine(config).getBundleCollection();
    // core master
    _cleanBundles(candiatesToRemove, coreBundles.core.getSymbolicName(), coreBundles.core.getVersion());
    // core slaves
    Iterator<Bundle> it = coreBundles.getSlaves();
    Bundle b;
    while (it.hasNext()) {
        b = it.next();
        _cleanBundles(candiatesToRemove, b.getSymbolicName(), b.getVersion());
    }
    // all extension
    Iterator<RHExtension> itt = config.getAllRHExtensions().iterator();
    RHExtension _rhe;
    while (itt.hasNext()) {
        _rhe = itt.next();
        if (rhe != null && rhe.equals(_rhe))
            continue;
        BundleInfo[] bundles = _rhe.getBundles();
        for (BundleInfo bi : bundles) {
            _cleanBundles(candiatesToRemove, bi.getSymbolicName(), bi.getVersion());
        }
    }
    // now we only have BundlesDefs in the array no longer used
    for (BundleDefinition ctr : candiatesToRemove) {
        if (ctr != null)
            OSGiUtil.removeLocalBundleSilently(ctr.getName(), ctr.getVersion(), true);
    }
}
Also used : BundleDefinition(lucee.runtime.osgi.OSGiUtil.BundleDefinition) BundleCollection(lucee.loader.osgi.BundleCollection) RHExtension(lucee.runtime.extension.RHExtension) BundleInfo(lucee.runtime.osgi.BundleInfo) Bundle(org.osgi.framework.Bundle)

Aggregations

BundleInfo (lucee.runtime.osgi.BundleInfo)6 RHExtension (lucee.runtime.extension.RHExtension)4 ApplicationException (lucee.runtime.exp.ApplicationException)3 BundleDefinition (lucee.runtime.osgi.OSGiUtil.BundleDefinition)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ZipEntry (java.util.zip.ZipEntry)2 ZipInputStream (java.util.zip.ZipInputStream)2 ClassException (lucee.commons.lang.ClassException)2 ExpressionException (lucee.runtime.exp.ExpressionException)2 PageException (lucee.runtime.exp.PageException)2 SecurityException (lucee.runtime.exp.SecurityException)2 FunctionLibException (lucee.transformer.library.function.FunctionLibException)2 TagLibException (lucee.transformer.library.tag.TagLibException)2 BundleException (org.osgi.framework.BundleException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 SQLException (java.sql.SQLException)1