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;
}
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;
}
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);
}
}
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);
}
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;
}
Aggregations