Search in sources :

Example 1 with ImportDefintion

use of lucee.runtime.component.ImportDefintion in project Lucee by lucee.

the class SourceLastModifiedClassAdapter method getImports.

private static void getImports(List<String> list, Body body) throws TransformerException {
    if (ASMUtil.isEmpty(body))
        return;
    Statement stat;
    List stats = body.getStatements();
    int len = stats.size();
    for (int i = 0; i < len; i++) {
        stat = (Statement) stats.get(i);
        // IFunction
        if (stat instanceof TagImport && !StringUtil.isEmpty(((TagImport) stat).getPath(), true)) {
            ImportDefintion id = ImportDefintionImpl.getInstance(((TagImport) stat).getPath(), null);
            if (id != null && (!list.contains(id.toString()) && !list.contains(id.getPackage() + ".*"))) {
                list.add(id.toString());
            }
            stats.remove(i);
            len--;
            i--;
        } else if (stat instanceof HasBody)
            getImports(list, ((HasBody) stat).getBody());
        else if (stat instanceof HasBodies) {
            Body[] bodies = ((HasBodies) stat).getBodies();
            for (int y = 0; y < bodies.length; y++) {
                getImports(list, bodies[y]);
            }
        }
    }
}
Also used : ImportDefintion(lucee.runtime.component.ImportDefintion) TagImport(lucee.transformer.bytecode.statement.tag.TagImport) HasBodies(lucee.transformer.bytecode.statement.HasBodies) HasBody(lucee.transformer.bytecode.statement.HasBody) List(java.util.List) ArrayList(java.util.ArrayList) HasBody(lucee.transformer.bytecode.statement.HasBody)

Example 2 with ImportDefintion

use of lucee.runtime.component.ImportDefintion in project Lucee by lucee.

the class XMLConfigWebFactory method createContextFilesPost.

private static void createContextFilesPost(Resource configDir, ConfigImpl config, ServletConfig servletConfig, boolean isEventGatewayContext, boolean doNew) {
    Resource contextDir = configDir.getRealResource("context");
    if (!contextDir.exists())
        contextDir.mkdirs();
    Resource adminDir = contextDir.getRealResource("admin");
    if (!adminDir.exists())
        adminDir.mkdirs();
    // Plugin
    Resource pluginDir = adminDir.getRealResource("plugin");
    if (!pluginDir.exists())
        pluginDir.mkdirs();
    // deploy org.lucee.cfml components
    if (config instanceof ConfigWeb) {
        ImportDefintion _import = config.getComponentDefaultImport();
        String path = _import.getPackageAsPath();
        Resource components = config.getConfigDir().getRealResource("components");
        Resource dir = components.getRealResource(path);
        dir.mkdirs();
        // print.o(dir);
        ComponentFactory.deploy(dir, doNew);
    }
}
Also used : ImportDefintion(lucee.runtime.component.ImportDefintion) Resource(lucee.commons.io.res.Resource)

Aggregations

ImportDefintion (lucee.runtime.component.ImportDefintion)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Resource (lucee.commons.io.res.Resource)1 HasBodies (lucee.transformer.bytecode.statement.HasBodies)1 HasBody (lucee.transformer.bytecode.statement.HasBody)1 TagImport (lucee.transformer.bytecode.statement.tag.TagImport)1