Search in sources :

Example 11 with RefBooleanImpl

use of lucee.commons.lang.types.RefBooleanImpl in project Lucee by lucee.

the class SelectParser method column.

private Expression column(ParserString raw) throws SQLParserException {
    RefBoolean hb = new RefBooleanImpl(false);
    String name = identifier(raw, hb);
    if (name == null)
        return null;
    if (!hb.toBooleanValue()) {
        if ("true".equalsIgnoreCase(name))
            return ValueBoolean.TRUE;
        if ("false".equalsIgnoreCase(name))
            return ValueBoolean.FALSE;
        if ("null".equalsIgnoreCase(name))
            return ValueNull.NULL;
    }
    ColumnExpression column = new ColumnExpression(name, name.equals("?") ? columnIndex++ : 0);
    raw.removeSpace();
    while (raw.forwardIfCurrent(".")) {
        raw.removeSpace();
        String sub = identifier(raw, hb);
        if (sub == null)
            throw new SQLParserException("invalid column definition");
        column.setSub(sub);
    }
    raw.removeSpace();
    if (raw.forwardIfCurrent('(')) {
        return new OperationN(column.getFullName(), readArguments(raw));
    }
    return column;
}
Also used : RefBoolean(lucee.commons.lang.types.RefBoolean) ColumnExpression(lucee.runtime.sql.exp.ColumnExpression) OperationN(lucee.runtime.sql.exp.op.OperationN) ParserString(lucee.commons.lang.ParserString) ValueString(lucee.runtime.sql.exp.value.ValueString) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl)

Example 12 with RefBooleanImpl

use of lucee.commons.lang.types.RefBooleanImpl in project Lucee by lucee.

the class ComponentImpl method getMetaData.

protected static Struct getMetaData(int access, PageContext pc, ComponentImpl comp, boolean ignoreCache) throws PageException {
    // Cache
    final Page page = MetadataUtil.getPageWhenMetaDataStillValid(pc, comp, ignoreCache);
    if (page != null && page.metaData != null && page.metaData.get() != null) {
        return page.metaData.get();
    }
    long creationTime = System.currentTimeMillis();
    StructImpl sct = new StructImpl();
    // fill udfs
    metaUDFs(pc, comp, sct, access);
    // meta
    if (comp.properties.meta != null)
        StructUtil.copy(comp.properties.meta, sct, true);
    String hint = comp.properties.hint;
    String displayname = comp.properties.dspName;
    if (!StringUtil.isEmpty(hint))
        sct.set(KeyConstants._hint, hint);
    if (!StringUtil.isEmpty(displayname))
        sct.set(KeyConstants._displayname, displayname);
    sct.set(KeyConstants._persistent, comp.properties.persistent);
    sct.set(KeyConstants._hashCode, comp.hashCode());
    sct.set(KeyConstants._accessors, comp.properties.accessors);
    sct.set(KeyConstants._synchronized, comp.properties._synchronized);
    if (comp.properties.output != null)
        sct.set(KeyConstants._output, comp.properties.output);
    // extends
    Struct ex = null;
    if (comp.base != null)
        ex = getMetaData(access, pc, comp.base, true);
    if (ex != null)
        sct.set(KeyConstants._extends, ex);
    // implements
    if (comp.absFin != null) {
        Set<String> set = ListUtil.listToSet(comp.properties.implement, ",", true);
        if (comp.absFin.hasInterfaces()) {
            Iterator<InterfaceImpl> it = comp.absFin.getInterfaceIt();
            Struct imp = new StructImpl();
            InterfaceImpl inter;
            while (it.hasNext()) {
                inter = it.next();
                if (!set.contains(inter.getCallPath()))
                    continue;
                imp.setEL(KeyImpl.init(inter.getCallPath()), inter.getMetaData(pc, true));
            }
            sct.set(KeyConstants._implements, imp);
        }
    }
    // PageSource
    PageSource ps = comp.pageSource;
    sct.set(KeyConstants._fullname, ps.getComponentName());
    sct.set(KeyConstants._name, ps.getComponentName());
    sct.set(KeyConstants._path, ps.getDisplayPath());
    sct.set(KeyConstants._type, "component");
    int dialect = comp.getPageSource().getDialect();
    boolean supressWSBeforeArg = dialect != CFMLEngine.DIALECT_CFML || pc.getConfig().getSuppressWSBeforeArg();
    Class<?> skeleton = comp.getJavaAccessClass(pc, new RefBooleanImpl(false), ((ConfigImpl) pc.getConfig()).getExecutionLogEnabled(), false, false, supressWSBeforeArg);
    if (skeleton != null)
        sct.set(KeyConstants._skeleton, skeleton);
    HttpServletRequest req = pc.getHttpServletRequest();
    try {
        // MUST better impl !!!
        String path = ContractPath.call(pc, ps.getDisplayPath());
        sct.set("remoteAddress", "" + new URL(req.getScheme(), req.getServerName(), req.getServerPort(), req.getContextPath() + path + "?wsdl"));
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
    }
    // Properties
    if (comp.properties.properties != null) {
        ArrayImpl parr = new ArrayImpl();
        Property p;
        Iterator<Entry<String, Property>> pit = comp.properties.properties.entrySet().iterator();
        while (pit.hasNext()) {
            p = pit.next().getValue();
            parr.append(p.getMetaData());
        }
        parr.sortIt(new ArrayOfStructComparator(KeyConstants._name));
        sct.set(KeyConstants._properties, parr);
    }
    if (page != null)
        page.metaData = new MetaDataSoftReference<Struct>(sct, creationTime);
    return sct;
}
Also used : ArrayOfStructComparator(lucee.runtime.type.comparator.ArrayOfStructComparator) ArrayImpl(lucee.runtime.type.ArrayImpl) URL(java.net.URL) Struct(lucee.runtime.type.Struct) HttpServletRequest(javax.servlet.http.HttpServletRequest) StructImpl(lucee.runtime.type.StructImpl) MetaDataSoftReference(lucee.runtime.component.MetaDataSoftReference) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl) UDFGSProperty(lucee.runtime.type.UDFGSProperty) Property(lucee.runtime.component.Property)

Example 13 with RefBooleanImpl

use of lucee.commons.lang.types.RefBooleanImpl in project Lucee by lucee.

the class CFMLEngineImpl method loadJSPFactory.

private CFMLFactoryImpl loadJSPFactory(ConfigServerImpl configServer, ServletConfig sg, int countExistingContextes) throws ServletException {
    try {
        if (XMLConfigWebFactory.LOG)
            SystemOut.printDate("load Context");
        // Load Config
        RefBoolean isCustomSetting = new RefBooleanImpl();
        Resource configDir = getConfigDirectory(sg, configServer, countExistingContextes, isCustomSetting);
        if (XMLConfigWebFactory.LOG)
            SystemOut.printDate("got context directory");
        CFMLFactoryImpl factory = new CFMLFactoryImpl(this, sg);
        if (XMLConfigWebFactory.LOG)
            SystemOut.printDate("init factory");
        ConfigWebImpl config = XMLConfigWebFactory.newInstance(this, factory, configServer, configDir, isCustomSetting.toBooleanValue(), sg);
        if (XMLConfigWebFactory.LOG)
            SystemOut.printDate("loaded config");
        factory.setConfig(config);
        return factory;
    } catch (Exception e) {
        ServletException se = new ServletException(e.getMessage());
        se.setStackTrace(e.getStackTrace());
        throw se;
    }
}
Also used : ServletException(javax.servlet.ServletException) PageServletException(lucee.runtime.exp.PageServletException) ConfigWebImpl(lucee.runtime.config.ConfigWebImpl) RefBoolean(lucee.commons.lang.types.RefBoolean) CFMLFactoryImpl(lucee.runtime.CFMLFactoryImpl) Resource(lucee.commons.io.res.Resource) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) PageException(lucee.runtime.exp.PageException) JspException(javax.servlet.jsp.JspException) NativeException(lucee.runtime.exp.NativeException) IOException(java.io.IOException) ServletException(javax.servlet.ServletException) URISyntaxException(java.net.URISyntaxException) PageServletException(lucee.runtime.exp.PageServletException) MalformedURLException(java.net.MalformedURLException) RequestTimeoutException(lucee.runtime.exp.RequestTimeoutException) ApplicationException(lucee.runtime.exp.ApplicationException)

Example 14 with RefBooleanImpl

use of lucee.commons.lang.types.RefBooleanImpl in project Lucee by lucee.

the class PageContextImpl method initApplicationContext.

/**
 * @return return  value of method "onApplicationStart" or true
 * @throws PageException
 */
public boolean initApplicationContext(ApplicationListener listener) throws PageException {
    boolean initSession = false;
    // AppListenerSupport listener = (AppListenerSupport) config.get ApplicationListener();
    KeyLock<String> lock = config.getContextLock();
    String name = StringUtil.emptyIfNull(applicationContext.getName());
    String token = name + ":" + getCFID();
    Lock tokenLock = lock.lock(token, getRequestTimeout());
    // print.o("outer-lock  :"+token);
    try {
        // check session before executing any code
        initSession = applicationContext.isSetSessionManagement() && listener.hasOnSessionStart(this) && !scopeContext.hasExistingSessionScope(this);
        // init application
        Lock nameLock = lock.lock(name, getRequestTimeout());
        // print.o("inner-lock  :"+token);
        try {
            RefBoolean isNew = new RefBooleanImpl(false);
            // this is needed that the application scope is initilized
            application = scopeContext.getApplicationScope(this, isNew);
            if (isNew.toBooleanValue()) {
                try {
                    if (!listener.onApplicationStart(this)) {
                        scopeContext.removeApplicationScope(this);
                        return false;
                    }
                } catch (PageException pe) {
                    scopeContext.removeApplicationScope(this);
                    throw pe;
                }
            }
        } finally {
            // print.o("inner-unlock:"+token);
            lock.unlock(nameLock);
        }
        // init session
        if (initSession) {
            // this is needed that the session scope is initilized
            scopeContext.getSessionScope(this, DUMMY_BOOL);
            listener.onSessionStart(this);
        }
    } finally {
        // print.o("outer-unlock:"+token);
        lock.unlock(tokenLock);
    }
    return true;
}
Also used : PageException(lucee.runtime.exp.PageException) RefBoolean(lucee.commons.lang.types.RefBoolean) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl) KeyLock(lucee.commons.lock.KeyLock) ActiveLock(lucee.runtime.debug.ActiveLock) Lock(lucee.commons.lock.Lock)

Example 15 with RefBooleanImpl

use of lucee.commons.lang.types.RefBooleanImpl in project Lucee by lucee.

the class CFMLTransformer method attribute.

/**
 * Liest ein einzelnes Atribut eines tag ein (nicht NONAME).
 * <br />
 * EBNF:<br />
 * <code>attribute-name  spaces "=" spaces attribute-value;</code>
 * @param tag Definition des Tag das dieses Attribut enthaelt.
 * @param args Container zum Speichern einzelner Attribute Namen zum nachtraeglichen Prufen gegen die Tag-Lib.
 * @return Element Attribute Element.
 * @throws TemplateException
 */
private static Attribute attribute(TagData data, TagLibTag tag, ArrayList<String> args, RefBoolean allowDefaultValue) throws TemplateException {
    Expression value = null;
    // Name
    StringBuffer sbType = new StringBuffer();
    RefBoolean dynamic = new RefBooleanImpl(false);
    boolean isDefaultValue = false;
    boolean[] parseExpression = new boolean[2];
    parseExpression[0] = true;
    parseExpression[1] = false;
    String name = attributeName(data.srcCode, dynamic, args, tag, sbType, parseExpression, allowDefaultValue.toBooleanValue());
    // mixed in a noname attribute
    if (StringUtil.isEmpty(name)) {
        allowDefaultValue.setValue(false);
        TagLibTagAttr attr = tag.getDefaultAttribute();
        if (attr == null)
            throw new TemplateException(data.srcCode, "Invalid Identifier.");
        name = attr.getName();
        sbType.append(attr.getType());
        isDefaultValue = true;
    }
    comment(data.srcCode, true);
    if (isDefaultValue || data.srcCode.forwardIfCurrent('=')) {
        comment(data.srcCode, true);
        // Value
        value = attributeValue(data, tag, sbType.toString(), parseExpression[0], false, data.factory.createLitString(""));
    } else // default value boolean true
    {
        TagLibTagAttr attr = tag.getAttribute(name);
        if (attr != null)
            value = attr.getUndefinedValue(data.factory);
        else
            value = tag.getAttributeUndefinedValue(data.factory);
        if (sbType.toString().length() > 0) {
            value = CastOther.toExpression(value, sbType.toString());
        }
    }
    comment(data.srcCode, true);
    return new Attribute(dynamic.toBooleanValue(), name, value, sbType.toString());
}
Also used : TagLibTagAttr(lucee.transformer.library.tag.TagLibTagAttr) RefBoolean(lucee.commons.lang.types.RefBoolean) Expression(lucee.transformer.expression.Expression) ComponentTemplateException(lucee.transformer.cfml.script.AbstrCFMLScriptTransformer.ComponentTemplateException) TemplateException(lucee.runtime.exp.TemplateException) Attribute(lucee.transformer.bytecode.statement.tag.Attribute) LitString(lucee.transformer.expression.literal.LitString) RefBooleanImpl(lucee.commons.lang.types.RefBooleanImpl)

Aggregations

RefBooleanImpl (lucee.commons.lang.types.RefBooleanImpl)19 RefBoolean (lucee.commons.lang.types.RefBoolean)16 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)4 Expression (lucee.transformer.expression.Expression)4 TagLibTagAttr (lucee.transformer.library.tag.TagLibTagAttr)4 IOException (java.io.IOException)3 ParserString (lucee.commons.lang.ParserString)3 PageException (lucee.runtime.exp.PageException)3 Struct (lucee.runtime.type.Struct)3 ArrayList (java.util.ArrayList)2 Entry (java.util.Map.Entry)2 Resource (lucee.commons.io.res.Resource)2 Component (lucee.runtime.Component)2 PageSource (lucee.runtime.PageSource)2 ApplicationException (lucee.runtime.exp.ApplicationException)2 PageRuntimeException (lucee.runtime.exp.PageRuntimeException)2 ApplicationContext (lucee.runtime.listener.ApplicationContext)2 ColumnExpression (lucee.runtime.sql.exp.ColumnExpression)2 Expression (lucee.runtime.sql.exp.Expression)2 ValueString (lucee.runtime.sql.exp.value.ValueString)2