use of lucee.runtime.config.Config in project Lucee by lucee.
the class SessionEndCacheEvent method onExpires.
@Override
public void onExpires(CacheEntry entry) {
String key = entry.getKey();
// type
int index = key.indexOf(':'), last;
// String type=key.substring(0,index);
// cfid
last = index + 1;
index = key.indexOf(':', last);
String cfid = key.substring(last, index);
// appName
last = index + 1;
index = key.indexOf(':', last);
String appName = key.substring(last);
Config config = ThreadLocalPageContext.getConfig();
_doEnd((CFMLFactoryImpl) (((ConfigWeb) config).getFactory()), appName, cfid);
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class CFMLResourceProvider method getPageContext.
private PageContext getPageContext(PageContext pc) {
ThreadLocalPageContext.get(pc);
if (pc != null)
return pc;
Config c = ThreadLocalPageContext.getConfig();
if (c instanceof ConfigWeb) {
return ThreadUtil.createPageContext((ConfigWeb) c, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, "localhost", "/", "", new Cookie[0], new Pair[0], null, new Pair[0], new StructImpl(), false, -1);
}
try {
return CFMLEngineFactory.getInstance().createPageContext(new File("."), "localhost", "/", "", new Cookie[0], null, null, null, DevNullOutputStream.DEV_NULL_OUTPUT_STREAM, -1, false);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class FormatUtil method addCustom.
private static void addCustom(List<DateFormat> list, Locale locale, short formatType) {
// get custom formats from file
Config config = ThreadLocalPageContext.getConfig();
Resource dir = config != null ? config.getConfigDir().getRealResource("locales") : null;
if (dir != null && dir.isDirectory()) {
String appendix = "-datetime";
if (formatType == FORMAT_TYPE_DATE)
appendix = "-date";
if (formatType == FORMAT_TYPE_TIME)
appendix = "-time";
Resource file = dir.getRealResource(locale.getLanguage() + "-" + locale.getCountry() + appendix + ".df");
if (file.isFile()) {
try {
String content = IOUtil.toString(file, (Charset) null);
String[] arr = lucee.runtime.type.util.ListUtil.listToStringArray(content, '\n');
String line;
SimpleDateFormat sdf;
for (int i = 0; i < arr.length; i++) {
line = arr[i].trim();
if (StringUtil.isEmpty(line))
continue;
sdf = new SimpleDateFormat(line, locale);
if (!list.contains(sdf))
list.add(sdf);
}
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
}
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class DBUtilImpl method getDatasourceConnection.
public DatasourceConnection getDatasourceConnection(PageContext pc, String datasourceName, String user, String pass, boolean managed) throws PageException {
DataSource datasource = null;
pc = ThreadLocalPageContext.get(pc);
if (pc != null) {
// default datasource
if ("__default__".equalsIgnoreCase(datasourceName)) {
Object obj = pc.getApplicationContext().getDefDataSource();
if (obj instanceof String)
datasourceName = (String) obj;
else
datasource = (DataSource) obj;
}
// get datasource from application context
if (datasource == null)
datasource = pc.getApplicationContext().getDataSource(datasourceName, null);
}
// get datasource from config
if (datasource == null) {
Config config = ThreadLocalPageContext.getConfig(pc);
datasource = config.getDataSource(datasourceName);
}
return getDatasourceConnection(pc, datasource, user, pass, managed);
}
use of lucee.runtime.config.Config in project Lucee by lucee.
the class ThreadUtil method cloneHttpServletRequest.
public static HttpServletRequest cloneHttpServletRequest(PageContext pc) {
Config config = pc.getConfig();
HttpServletRequest req = pc.getHttpServletRequest();
HttpServletRequestDummy dest = HttpServletRequestDummy.clone(config, config.getRootDirectory(), req);
return dest;
}
Aggregations