Search in sources :

Example 1 with UndefinedImpl

use of lucee.runtime.type.scope.UndefinedImpl in project Lucee by lucee.

the class PageContextImpl method copyStateTo.

public synchronized void copyStateTo(PageContextImpl other) {
    // cfid (we do this that way, otherwise we only have the same cfid if the current pc has defined cfid in cookie or url)
    getCFID();
    other.cfid = cfid;
    other.cftoken = cftoken;
    // private Debugger debugger=new DebuggerImpl();
    other.requestTimeout = requestTimeout;
    other.locale = locale;
    other.timeZone = timeZone;
    other.fdEnabled = fdEnabled;
    other.useSpecialMappings = useSpecialMappings;
    other.serverPassword = serverPassword;
    other.requestDialect = requestDialect;
    other.currentTemplateDialect = currentTemplateDialect;
    hasFamily = true;
    other.hasFamily = true;
    other.parent = this;
    if (children == null)
        children = new ArrayList<PageContext>();
    children.add(other);
    other.applicationContext = applicationContext;
    other.thread = Thread.currentThread();
    other.startTime = System.currentTimeMillis();
    // path
    other.base = base;
    java.util.Iterator<PageSource> it = includePathList.iterator();
    while (it.hasNext()) {
        other.includePathList.add(it.next());
    }
    it = pathList.iterator();
    while (it.hasNext()) {
        other.pathList.add(it.next());
    }
    // scopes
    other.req = req;
    other.request = request;
    other.form = form;
    other.url = url;
    other.urlForm = urlForm;
    other._url = _url;
    other._form = _form;
    other.variables = variables;
    other.undefined = new UndefinedImpl(other, (short) other.undefined.getType());
    // writers
    other.bodyContentStack.init(config.getCFMLWriter(this, other.req, other.rsp));
    // other.bodyContentStack.init(other.req,other.rsp,other.config.isSuppressWhitespace(),other.config.closeConnection(), other.config.isShowVersion(),config.contentLength(),config.allowCompression());
    other.writer = other.bodyContentStack.getWriter();
    other.forceWriter = other.writer;
    other.psq = psq;
    other.gatewayContext = gatewayContext;
    // initialize stuff
    other.undefined.initialize(other);
}
Also used : UndefinedImpl(lucee.runtime.type.scope.UndefinedImpl) ArrayList(java.util.ArrayList)

Example 2 with UndefinedImpl

use of lucee.runtime.type.scope.UndefinedImpl in project Lucee by lucee.

the class ModernAppListener method initApplicationContext.

private ModernApplicationContext initApplicationContext(PageContextImpl pc, Component app) throws PageException {
    // use existing app context
    RefBoolean throwsErrorWhileInit = new RefBooleanImpl(false);
    ModernApplicationContext appContext = new ModernApplicationContext(pc, app, throwsErrorWhileInit);
    pc.setApplicationContext(appContext);
    // scope cascading
    if (pc.getRequestDialect() == CFMLEngine.DIALECT_CFML && ((UndefinedImpl) pc.undefinedScope()).getScopeCascadingType() != appContext.getScopeCascading()) {
        pc.undefinedScope().initialize(pc);
    }
    // ORM
    if (appContext.isORMEnabled()) {
        boolean hasError = throwsErrorWhileInit.toBooleanValue();
        if (hasError)
            pc.addPageSource(app.getPageSource(), true);
        try {
            ORMUtil.resetEngine(pc, false);
        } finally {
            if (hasError)
                pc.removeLastPageSource(true);
        }
    }
    return appContext;
}
Also used : UndefinedImpl(lucee.runtime.type.scope.UndefinedImpl) RefBoolean(lucee.commons.lang.types.RefBoolean) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl)

Example 3 with UndefinedImpl

use of lucee.runtime.type.scope.UndefinedImpl in project Lucee by lucee.

the class PageContextImpl method initialize.

/**
 * initialize a existing page context
 * @param servlet
 * @param req
 * @param rsp
 * @param errorPageURL
 * @param needsSession
 * @param bufferSize
 * @param autoFlush
 */
public PageContextImpl initialize(HttpServlet servlet, HttpServletRequest req, HttpServletResponse rsp, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush, boolean isChild, boolean ignoreScopes) {
    parent = null;
    appListenerType = ApplicationListener.TYPE_NONE;
    this.ignoreScopes = ignoreScopes;
    requestId = counter++;
    ReqRspUtil.setContentType(rsp, "text/html; charset=" + config.getWebCharset().name());
    this.isChild = isChild;
    applicationContext = defaultApplicationContext;
    startTime = System.currentTimeMillis();
    thread = Thread.currentThread();
    this.req = new HTTPServletRequestWrap(req);
    this.rsp = rsp;
    this.servlet = servlet;
    // Writers
    if (config.debugLogOutput()) {
        CFMLWriter w = config.getCFMLWriter(this, req, rsp);
        w.setAllowCompression(false);
        DebugCFMLWriter dcw = new DebugCFMLWriter(w);
        bodyContentStack.init(dcw);
        debugger.setOutputLog(dcw);
    } else {
        bodyContentStack.init(config.getCFMLWriter(this, req, rsp));
    }
    writer = bodyContentStack.getWriter();
    forceWriter = writer;
    // Scopes
    server = ScopeContext.getServerScope(this, ignoreScopes);
    if (hasFamily) {
        variablesRoot = new VariablesImpl();
        variables = variablesRoot;
        request = new RequestImpl();
        _url = new URLImpl();
        _form = new FormImpl();
        urlForm = new UrlFormImpl(_form, _url);
        undefined = new UndefinedImpl(this, getScopeCascadingType());
        hasFamily = false;
    } else if (variables == null) {
        variablesRoot = new VariablesImpl();
        variables = variablesRoot;
    }
    request.initialize(this);
    if (config.mergeFormAndURL()) {
        url = urlForm;
        form = urlForm;
    } else {
        url = _url;
        form = _form;
    }
    // url.initialize(this);
    // form.initialize(this);
    // undefined.initialize(this);
    psq = config.getPSQL();
    fdEnabled = !config.allowRequestTimeout();
    if (config.getExecutionLogEnabled())
        this.execLog = config.getExecutionLogFactory().getInstance(this);
    if (debugger != null)
        debugger.init(config);
    undefined.initialize(this);
    timeoutStacktrace = null;
    return this;
}
Also used : UrlFormImpl(lucee.runtime.type.scope.UrlFormImpl) UndefinedImpl(lucee.runtime.type.scope.UndefinedImpl) HTTPServletRequestWrap(lucee.runtime.net.http.HTTPServletRequestWrap) DebugCFMLWriter(lucee.runtime.debug.DebugCFMLWriter) CFMLWriter(lucee.runtime.writer.CFMLWriter) UrlFormImpl(lucee.runtime.type.scope.UrlFormImpl) FormImpl(lucee.runtime.type.scope.FormImpl) VariablesImpl(lucee.runtime.type.scope.VariablesImpl) DebugCFMLWriter(lucee.runtime.debug.DebugCFMLWriter) RequestImpl(lucee.runtime.type.scope.RequestImpl) URLImpl(lucee.runtime.type.scope.URLImpl)

Example 4 with UndefinedImpl

use of lucee.runtime.type.scope.UndefinedImpl in project Lucee by lucee.

the class VariableInterpreter method getVariableReference.

public static VariableReference getVariableReference(PageContext pc, Collection.Key[] keys, boolean keepScope) throws PageException {
    if (keys.length == 1) {
        if (keepScope) {
            Collection coll = ((UndefinedImpl) pc.undefinedScope()).getScopeFor(keys[0], null);
            if (coll != null)
                return new VariableReference(coll, keys[0]);
        }
        return new VariableReference(pc.undefinedScope(), keys[0]);
    }
    int scope = scopeKey2Int(keys[0]);
    Object coll;
    if (scope == Scope.SCOPE_UNDEFINED) {
        coll = pc.touch(pc.undefinedScope(), keys[0]);
    } else {
        coll = VariableInterpreter.scope(pc, scope, keys.length > 1);
    }
    for (int i = 1; i < (keys.length - 1); i++) {
        coll = pc.touch(coll, keys[i]);
    }
    if (!(coll instanceof Collection))
        throw new InterpreterException("invalid variable [" + ListUtil.arrayToList(keys, ".") + "]");
    return new VariableReference((Collection) coll, keys[keys.length - 1]);
}
Also used : UndefinedImpl(lucee.runtime.type.scope.UndefinedImpl) VariableReference(lucee.runtime.type.ref.VariableReference) Collection(lucee.runtime.type.Collection)

Aggregations

UndefinedImpl (lucee.runtime.type.scope.UndefinedImpl)4 ArrayList (java.util.ArrayList)1 RefBoolean (lucee.commons.lang.types.RefBoolean)1 RefBooleanImpl (lucee.commons.lang.types.RefBooleanImpl)1 DebugCFMLWriter (lucee.runtime.debug.DebugCFMLWriter)1 HTTPServletRequestWrap (lucee.runtime.net.http.HTTPServletRequestWrap)1 Collection (lucee.runtime.type.Collection)1 VariableReference (lucee.runtime.type.ref.VariableReference)1 FormImpl (lucee.runtime.type.scope.FormImpl)1 RequestImpl (lucee.runtime.type.scope.RequestImpl)1 URLImpl (lucee.runtime.type.scope.URLImpl)1 UrlFormImpl (lucee.runtime.type.scope.UrlFormImpl)1 VariablesImpl (lucee.runtime.type.scope.VariablesImpl)1 CFMLWriter (lucee.runtime.writer.CFMLWriter)1