Search in sources :

Example 1 with ReadOnlyStruct

use of lucee.runtime.type.ReadOnlyStruct in project Lucee by lucee.

the class ServerImpl method reload.

public void reload(PageContext pc, Boolean jsr223) {
    Info info = pc.getConfig().getFactory().getEngine().getInfo();
    ReadOnlyStruct coldfusion = new ReadOnlyStruct();
    coldfusion.setEL(PRODUCT_LEVEL, info.getLevel());
    // coldfusion.setEL(PRODUCT_VERSION,"11,0,07,296330");
    coldfusion.setEL(PRODUCT_VERSION, "2016,0,03,300357");
    coldfusion.setEL(SERIAL_NUMBER, "0");
    coldfusion.setEL(PRODUCT_NAME, "Lucee");
    // TODO scope server missing values
    // Jrun
    coldfusion.setEL(KeyConstants._appserver, "");
    // 
    coldfusion.setEL(EXPIRATION, expired);
    // 
    coldfusion.setEL(INSTALL_KIT, "");
    String rootdir = "";
    try {
        rootdir = ThreadLocalPageContext.getConfig(pc).getRootDirectory().getAbsolutePath();
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    // 
    coldfusion.setEL(ROOT_DIR, rootdir);
    // 
    coldfusion.setEL(SUPPORTED_LOCALES, LocaleFactory.getLocaleList());
    coldfusion.setReadOnly(true);
    super.setEL(KeyConstants._coldfusion, coldfusion);
    ReadOnlyStruct os = new ReadOnlyStruct();
    os.setEL(KeyConstants._name, System.getProperty("os.name"));
    os.setEL(ARCH, System.getProperty("os.arch"));
    os.setEL(MAC_ADDRESS, SystemUtil.getMacAddressAsWrap());
    int arch = SystemUtil.getOSArch();
    if (arch != SystemUtil.ARCH_UNKNOW)
        os.setEL(ARCH_MODEL, new Double(arch));
    os.setEL(KeyConstants._version, System.getProperty("os.version"));
    os.setEL(ADDITIONAL_INFORMATION, "");
    os.setEL(BUILD_NUMBER, "");
    os.setEL(HOST_NAME, SystemUtil.getLocalHostName());
    os.setReadOnly(true);
    super.setEL(KeyConstants._os, os);
    ReadOnlyStruct lucee = new ReadOnlyStruct();
    lucee.setEL(KeyConstants._version, info.getVersion().toString());
    lucee.setEL(VERSION_NAME, info.getVersionName());
    lucee.setEL(VERSION_NAME_EXPLANATION, info.getVersionNameExplanation());
    lucee.setEL(KeyConstants._state, getStateAsString(info.getVersion()));
    lucee.setEL(RELEASE_DATE, new DateTimeImpl(info.getRealeaseTime(), false));
    lucee.setEL(LOADER_VERSION, Caster.toDouble(SystemUtil.getLoaderVersion()));
    lucee.setEL(LOADER_PATH, ClassUtil.getSourcePathForClass("lucee.loader.servlet.CFMLServlet", ""));
    lucee.setEL(ENVIRONMENT, jsr223 != null && jsr223.booleanValue() ? "jsr223" : "servlet");
    lucee.setReadOnly(true);
    super.setEL(KeyConstants._lucee, lucee);
    ReadOnlyStruct separator = new ReadOnlyStruct();
    separator.setEL(KeyConstants._path, System.getProperty("path.separator"));
    separator.setEL(KeyConstants._file, System.getProperty("file.separator"));
    separator.setEL(KeyConstants._line, System.getProperty("line.separator"));
    separator.setReadOnly(true);
    super.setEL(KeyConstants._separator, separator);
    ReadOnlyStruct java = new ReadOnlyStruct();
    java.setEL(KeyConstants._version, System.getProperty("java.version"));
    java.setEL(VENDOR, System.getProperty("java.vendor"));
    arch = SystemUtil.getJREArch();
    if (arch != SystemUtil.ARCH_UNKNOW)
        java.setEL(ARCH_MODEL, new Double(arch));
    Runtime rt = Runtime.getRuntime();
    java.setEL(FREE_MEMORY, new Double(rt.freeMemory()));
    java.setEL(TOTAL_MEMORY, new Double(rt.totalMemory()));
    java.setEL(MAX_MEMORY, new Double(rt.maxMemory()));
    java.setEL(JAVA_AGENT_SUPPORTED, Boolean.TRUE);
    if (jep == null) {
        String temp = System.getProperty("user.dir", "");
        if (!StringUtil.isEmpty(temp) && !temp.endsWith(File.separator))
            temp = temp + File.separator;
        jep = temp;
    }
    java.setEL(JAVA_EXECUTION_PATH, jep);
    java.setReadOnly(true);
    super.setEL(KeyConstants._java, java);
    ReadOnlyStruct servlet = new ReadOnlyStruct();
    String name = "";
    try {
        name = pc.getServletContext().getServerInfo();
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    servlet.setEL(KeyConstants._name, name);
    servlet.setReadOnly(true);
    super.setEL(KeyConstants._servlet, servlet);
    ReadOnlyStruct system = new ReadOnlyStruct();
    system.setEL(KeyConstants._properties, SystemPropStruct.getInstance());
    system.setEL(KeyConstants._environment, EnvStruct.getInstance());
    system.setReadOnly(true);
    super.setEL(KeyConstants._system, system);
}
Also used : ReadOnlyStruct(lucee.runtime.type.ReadOnlyStruct) DateTimeImpl(lucee.runtime.type.dt.DateTimeImpl) Info(lucee.Info)

Aggregations

Info (lucee.Info)1 ReadOnlyStruct (lucee.runtime.type.ReadOnlyStruct)1 DateTimeImpl (lucee.runtime.type.dt.DateTimeImpl)1