use of lucee.runtime.config.Config in project Lucee by lucee.
the class CreationImpl method createPageContext.
@Override
public PageContext createPageContext(HttpServletRequest req, HttpServletResponse rsp, OutputStream out) {
Config config = ThreadLocalPageContext.getConfig();
if (!(config instanceof ConfigWeb))
throw new RuntimeException("need a web context to create a PageContext");
CFMLFactory factory = ((ConfigWeb) config).getFactory();
return (PageContext) factory.getPageContext(factory.getServlet(), req, rsp, null, false, -1, false);
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class Compress method load.
private synchronized void load(boolean caseSensitive) throws IOException {
long actLastMod = ffile.lastModified();
lastMod = actLastMod;
lastCheck = System.currentTimeMillis();
Map<String, Boolean> args = new HashMap<String, Boolean>();
args.put("case-sensitive", Caster.toBoolean(caseSensitive));
if (temp == null) {
String cid = "";
Config config = ThreadLocalPageContext.getConfig();
if (config != null) {
cid = config.getIdentification().getId();
temp = config.getTempDirectory();
}
if (temp == null)
temp = SystemUtil.getTempDirectory();
temp = temp.getRealResource("compress");
temp = temp.getRealResource(MD5.getDigestAsString(cid + "-" + ffile.getAbsolutePath()));
if (!temp.exists())
temp.mkdirs();
}
if (temp != null) {
String name = Caster.toString(actLastMod) + ":" + Caster.toString(ffile.length());
name = MD5.getDigestAsString(name, name);
root = temp.getRealResource(name);
if (actLastMod > 0 && root.exists())
return;
ResourceUtil.removeChildrenEL(temp);
// if(root!=null)ResourceUtil.removeChildrenEL(root);
// String name=CreateUUID.invoke();
// root=temp.getRealResource(name);
root.mkdirs();
} else {
ResourceProvider ramProvider = new RamResourceProviderOld().init("ram", args);
root = ramProvider.getResource("/");
}
_load();
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class DatasourceResourceProvider method getManager.
private DatasourceManagerImpl getManager() {
if (_manager == null) {
Config config = ThreadLocalPageContext.getConfig();
_manager = new DatasourceManagerImpl((ConfigImpl) config);
}
return _manager;
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class ResourceLockImpl method _read.
private void _read(String path) {
long start = -1, now;
Thread t;
do {
if ((t = resources.get(path)) == null) {
// print.ln("read ok");
return;
}
if (t == Thread.currentThread()) {
// aprint.err(path);
Config config = ThreadLocalPageContext.getConfig();
if (config != null)
SystemOut.printDate(config.getErrWriter(), "conflict in same thread: on " + path);
// SystemOut.printDate(config.getErrWriter(),"conflict in same thread: on "+path+"\nStacktrace:\n"+StringUtil.replace(ExceptionUtil.getStacktrace(new Throwable(), false),"java.lang.Throwable\n","",true));
return;
}
// bugfix when lock von totem thread, wird es ignoriert
if (!t.isAlive()) {
resources.remove(path);
return;
}
if (start == -1)
start = System.currentTimeMillis();
try {
token.wait(lockTimeout);
now = System.currentTimeMillis();
if ((start + lockTimeout) <= now) {
Config config = ThreadLocalPageContext.getConfig();
if (config != null) {
PageContextImpl pc = null;
String add = "";
if (config instanceof ConfigWeb) {
CFMLFactory factory = ((ConfigWeb) config).getFactory();
if (factory instanceof CFMLFactoryImpl) {
Map<Integer, PageContextImpl> pcs = ((CFMLFactoryImpl) factory).getActivePageContexts();
Iterator<PageContextImpl> it = pcs.values().iterator();
PageContextImpl tmp;
while (it.hasNext()) {
tmp = it.next();
if (t == tmp.getThread()) {
pc = tmp;
break;
}
}
}
}
if (pc != null) {
add = " The file is locked by a request on the following URL " + ReqRspUtil.getRequestURL(pc.getHttpServletRequest(), true) + ", that request started " + (System.currentTimeMillis() - pc.getStartTime()) + "ms ago.";
}
SystemOut.printDate(config.getErrWriter(), "timeout after " + (now - start) + " ms (" + (lockTimeout) + " ms) occured while accessing file [" + path + "]." + add);
} else
SystemOut.printDate("timeout (" + (lockTimeout) + " ms) occured while accessing file [" + path + "].");
return;
}
} catch (InterruptedException e) {
}
} while (true);
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class CharsetUtil method getWebCharset.
public static Charset getWebCharset() {
PageContext pc = ThreadLocalPageContext.get();
if (pc != null)
return pc.getWebCharset();
Config config = ThreadLocalPageContext.getConfig();
if (config != null)
return config.getWebCharset();
return CharsetUtil.ISO88591;
}
Aggregations