Added a html cache feature.
This commit is contained in:
parent
ac1527f2c4
commit
df19b3b732
3 changed files with 38 additions and 17 deletions
|
@ -106,7 +106,7 @@ public class CrawlCacheChecker implements ServletContextListener
|
|||
@Override
|
||||
public void contextDestroyed(ServletContextEvent event)
|
||||
{
|
||||
logger.info("Stopping checker thread.");
|
||||
logger.info("Stopping checker thread…");
|
||||
this.checker.interrupt();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
import fr.devinsy.kiss4web.EnvironmentInformation;
|
||||
import fr.devinsy.kiss4web.HtmlCache;
|
||||
import fr.devinsy.kiss4web.Kiss4web;
|
||||
import fr.devinsy.kiss4web.Kiss4web.Mode;
|
||||
import fr.devinsy.kiss4web.dispatcher.KissDispatcher;
|
||||
|
@ -69,6 +70,7 @@ public class StatoolInfosWeb
|
|||
private File configurationFile;
|
||||
private BuildInformation buildInformation;
|
||||
private StatoolInfosContext context;
|
||||
private HtmlCache htmlCache;
|
||||
|
||||
/**
|
||||
* Instantiates a new manager.
|
||||
|
@ -81,6 +83,9 @@ public class StatoolInfosWeb
|
|||
//
|
||||
try
|
||||
{
|
||||
//
|
||||
this.htmlCache = new HtmlCache();
|
||||
|
||||
//
|
||||
currentLog = "StatoolInfosWeb";
|
||||
logger.info("StatoolInfosWeb initializing...");
|
||||
|
@ -189,14 +194,14 @@ public class StatoolInfosWeb
|
|||
{
|
||||
if (this.context.isExpired())
|
||||
{
|
||||
logger.info("Context expired, reloading context…");
|
||||
logger.info("Context expiration: KO, reloading context…");
|
||||
StatoolInfosContext newContext = new StatoolInfosContext(this.configurationFile);
|
||||
this.context = newContext;
|
||||
clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info("Context expiration not detected.");
|
||||
logger.info("Context expiration: OK.");
|
||||
}
|
||||
}
|
||||
catch (StatoolInfosException | IOException exception)
|
||||
|
@ -212,6 +217,17 @@ public class StatoolInfosWeb
|
|||
public void clear()
|
||||
{
|
||||
KissDispatcher.instance().clear();
|
||||
this.htmlCache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the html cache.
|
||||
*
|
||||
* @return the html cache
|
||||
*/
|
||||
public HtmlCache getHtmlCache()
|
||||
{
|
||||
return this.htmlCache;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -52,24 +52,29 @@ public class IndexPage extends HttpServlet
|
|||
{
|
||||
try
|
||||
{
|
||||
// Get parameters.
|
||||
// ===============
|
||||
String html = StatoolInfosWeb.instance().getHtmlCache().get(IndexPage.class.getCanonicalName());
|
||||
if (html == null)
|
||||
{
|
||||
// Get parameters.
|
||||
// ===============
|
||||
|
||||
// Use parameters.
|
||||
// ===============
|
||||
Federation federation = StatoolInfosWeb.instance().getFederation();
|
||||
UptimeJournal uptimes = StatoolInfosWeb.instance().getUptimeJournal();
|
||||
// Use parameters.
|
||||
// ===============
|
||||
Federation federation = StatoolInfosWeb.instance().getFederation();
|
||||
UptimeJournal uptimes = StatoolInfosWeb.instance().getUptimeJournal();
|
||||
|
||||
// Send response.
|
||||
// ==============
|
||||
String headerView = FederationHeaderView.htmlize(federation, uptimes);
|
||||
String contentView = OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations());
|
||||
// Send response.
|
||||
// ==============
|
||||
String headerView = FederationHeaderView.htmlize(federation, uptimes);
|
||||
String contentView = OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations());
|
||||
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add(federation.getName(), "/federation/organizations/");
|
||||
trail.add("Organisations", "/federation/organizations/");
|
||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||
trail.add(federation.getName(), "/federation/organizations/");
|
||||
trail.add("Organisations", "/federation/organizations/");
|
||||
|
||||
String html = WebCharterView.build(headerView, contentView, trail);
|
||||
html = WebCharterView.build(headerView, contentView, trail);
|
||||
StatoolInfosWeb.instance().getHtmlCache().put(IndexPage.class.getCanonicalName(), html);
|
||||
}
|
||||
|
||||
// Display page.
|
||||
response.setContentType("application/xhtml+xml; charset=UTF-8");
|
||||
|
|
Loading…
Reference in a new issue