return new ServletContextLocator((ServletContext)ctx, path);
throw new UnsupportedOperationException("Unknown context: "+ctx);
}
private static final ResourceCache getCache(WebApp wapp) {
ResourceCache cache = (ResourceCache)wapp.getAttribute(ATTR_PAGE_CACHE);
if (cache == null) {
synchronized (PageDefinitions.class) {
cache = (ResourceCache)wapp.getAttribute(ATTR_PAGE_CACHE);
if (cache == null) {
Loader loader = null;
final String clsnm = Library.getProperty("org.zkoss.zk.ui.metainfo.page.Loader.class");
if (clsnm != null) {
try {
final Object o = Classes.newInstanceByThread(clsnm,
new Class[] {WebApp.class},
new Object[] {wapp});
if (o instanceof Loader)
loader = (Loader)o;
else
log.warning(clsnm + " must implement " + Loader.class.getName());
} catch (Throwable ex) {
log.warningBriefly("Unable to instantiate "+clsnm, ex);
}
}
if (loader == null)
loader = new MyLoader(wapp);
cache = new ResourceCache(loader, 167);
cache.setMaxSize(1024);
cache.setLifetime(60*60000); //1hr
wapp.setAttribute(ATTR_PAGE_CACHE, cache);
}
}
}
return cache;