use of lucee.runtime.config.ConfigWeb in project Lucee by lucee.
the class GatewayEngineImpl method getCFC.
private Component getCFC(PageContextImpl pc, String requestURI) throws PageException {
HttpServletRequest req = pc.getHttpServletRequest();
try {
String ext = ResourceUtil.getExtension(requestURI, "");
ConfigWeb config = (ConfigWeb) ThreadLocalPageContext.getConfig(pc);
int dialect = config.getFactory().toDialect(ext);
req.setAttribute("client", "lucee-gateway-1-0");
req.setAttribute("call-type", "store-only");
if (dialect == CFMLEngine.DIALECT_LUCEE)
pc.execute(requestURI, true, false);
else
pc.executeCFML(requestURI, true, false);
return (Component) req.getAttribute("component");
} finally {
req.removeAttribute("call-type");
req.removeAttribute("component");
}
}
use of lucee.runtime.config.ConfigWeb 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.ConfigWeb in project Lucee by lucee.
the class Log4jUtil method getLogger.
public static final Logger getLogger(Config config, Appender appender, String name, Level level) {
// fullname
String fullname = name;
if (config instanceof ConfigWeb) {
ConfigWeb cw = (ConfigWeb) config;
fullname = "web." + cw.getLabel() + "." + name;
} else
fullname = "server." + name;
Logger l = LogManager.exists(fullname);
if (l != null)
l.removeAllAppenders();
else
l = LogManager.getLogger(fullname);
l.setAdditivity(false);
l.addAppender(appender);
l.setLevel(level);
return l;
}
use of lucee.runtime.config.ConfigWeb 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);
}
Aggregations