Search in sources :

Example 11 with PageRuntimeException

use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.

the class RWWrap method lock.

public Lock lock(K token, long timeout, boolean readOnly) throws LockException, LockInterruptedException {
    if (timeout <= 0)
        throw new LockException("timeout must be a postive number");
    RWWrap<K> wrap;
    // K token=key;
    synchronized (locks) {
        RWLock<K> lock;
        lock = locks.get(token);
        if (lock == null) {
            locks.put(token, lock = new RWLock<K>(token));
        }
        lock.inc();
        wrap = new RWWrap<K>(lock, readOnly);
    }
    try {
        wrap.lock(timeout);
    } catch (LockException e) {
        synchronized (locks) {
            wrap.getLock().dec();
        }
        throw e;
    } catch (LockInterruptedException e) {
        synchronized (locks) {
            wrap.getLock().dec();
        }
        throw e;
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        synchronized (locks) {
            wrap.getLock().dec();
        }
        throw new PageRuntimeException(Caster.toPageException(t));
    }
    return wrap;
}
Also used : LockException(lucee.commons.lock.LockException) LockInterruptedException(lucee.commons.lock.LockInterruptedException) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 12 with PageRuntimeException

use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.

the class ASMUtil method createBif.

public static BIF createBif(ExprData data, FunctionLibFunction flf) {
    BIF bif = new BIF(data.factory, data.settings, flf);
    data.ep.add(flf, bif, data.srcCode);
    bif.setArgType(flf.getArgType());
    try {
        bif.setClassDefinition(flf.getFunctionClassDefinition());
    } catch (Throwable t) {
        ExceptionUtil.rethrowIfNecessary(t);
        throw new PageRuntimeException(t);
    }
    bif.setReturnType(flf.getReturnTypeAsString());
    return bif;
}
Also used : PageRuntimeException(lucee.runtime.exp.PageRuntimeException) BIF(lucee.transformer.bytecode.expression.var.BIF)

Example 13 with PageRuntimeException

use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.

the class QueryUtil method duplicate2QueryColumnImpl.

public static QueryColumnImpl duplicate2QueryColumnImpl(QueryImpl targetQuery, QueryColumn col, boolean deepCopy) {
    if (col instanceof QueryColumnImpl)
        return ((QueryColumnImpl) col).cloneColumnImpl(deepCopy);
    // fill array for column
    Array content = new ArrayImpl();
    int len = col.size();
    for (int i = 1; i <= len; i++) {
        content.setEL(i, col.get(i, null));
    }
    // create and return column
    try {
        return new QueryColumnImpl(targetQuery, col.getKey(), content, col.getType());
    } catch (PageException e) {
        throw new PageRuntimeException(e);
    }
}
Also used : Array(lucee.runtime.type.Array) PageException(lucee.runtime.exp.PageException) QueryColumnImpl(lucee.runtime.type.QueryColumnImpl) ArrayImpl(lucee.runtime.type.ArrayImpl) PageRuntimeException(lucee.runtime.exp.PageRuntimeException)

Example 14 with PageRuntimeException

use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.

the class DBUtilImpl method releaseDatasourceConnection.

public void releaseDatasourceConnection(PageContext pc, DatasourceConnection dc, boolean managed) {
    pc = ThreadLocalPageContext.get(pc);
    if (managed) {
        if (pc == null)
            throw new PageRuntimeException(new ApplicationException("missing PageContext to access the Database Connection Manager"));
        DatasourceManagerImpl manager = (DatasourceManagerImpl) pc.getDataSourceManager();
        manager.releaseConnection(pc, dc);
        return;
    }
    releaseDatasourceConnection(ThreadLocalPageContext.getConfig(pc), dc);
}
Also used : ApplicationException(lucee.runtime.exp.ApplicationException) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) DatasourceManagerImpl(lucee.runtime.db.DatasourceManagerImpl)

Example 15 with PageRuntimeException

use of lucee.runtime.exp.PageRuntimeException in project Lucee by lucee.

the class TagLib method duplicate.

/**
 * duplcate a hashmap with TagLibTag's
 * @param tags
 * @param deepCopy
 * @return cloned map
 */
private HashMap<String, TagLibTag> duplicate(HashMap<String, TagLibTag> tags, boolean deepCopy) {
    if (deepCopy)
        throw new PageRuntimeException(new ExpressionException("deep copy not supported"));
    Iterator<Entry<String, TagLibTag>> it = tags.entrySet().iterator();
    HashMap<String, TagLibTag> cm = new HashMap<String, TagLibTag>();
    Entry<String, TagLibTag> entry;
    while (it.hasNext()) {
        entry = it.next();
        cm.put(entry.getKey(), deepCopy ? // TODO add support for deepcopy ((TagLibTag)entry.getValue()).duplicate(deepCopy):
        entry.getValue() : entry.getValue());
    }
    return cm;
}
Also used : Entry(java.util.Map.Entry) HashMap(java.util.HashMap) PageRuntimeException(lucee.runtime.exp.PageRuntimeException) ExpressionException(lucee.runtime.exp.ExpressionException)

Aggregations

PageRuntimeException (lucee.runtime.exp.PageRuntimeException)37 PageException (lucee.runtime.exp.PageException)17 Method (java.lang.reflect.Method)7 SQLException (java.sql.SQLException)7 DOMException (org.w3c.dom.DOMException)7 IOException (java.io.IOException)4 Entry (java.util.Map.Entry)4 Pair (lucee.commons.lang.Pair)4 DatasourceConnection (lucee.runtime.db.DatasourceConnection)4 DatabaseException (lucee.runtime.exp.DatabaseException)4 DeprecatedException (lucee.runtime.exp.DeprecatedException)4 ORMDatasourceConnection (lucee.runtime.orm.ORMDatasourceConnection)4 HashMap (java.util.HashMap)3 ApplicationException (lucee.runtime.exp.ApplicationException)3 TemplateException (lucee.runtime.exp.TemplateException)3 Array (lucee.runtime.type.Array)3 Struct (lucee.runtime.type.Struct)3 BIF (lucee.transformer.bytecode.expression.var.BIF)3 Iterator (java.util.Iterator)2 Resource (lucee.commons.io.res.Resource)2