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
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent event)
|
public void contextDestroyed(ServletContextEvent event)
|
||||||
{
|
{
|
||||||
logger.info("Stopping checker thread.");
|
logger.info("Stopping checker thread…");
|
||||||
this.checker.interrupt();
|
this.checker.interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
|
|
||||||
import fr.devinsy.kiss4web.EnvironmentInformation;
|
import fr.devinsy.kiss4web.EnvironmentInformation;
|
||||||
|
import fr.devinsy.kiss4web.HtmlCache;
|
||||||
import fr.devinsy.kiss4web.Kiss4web;
|
import fr.devinsy.kiss4web.Kiss4web;
|
||||||
import fr.devinsy.kiss4web.Kiss4web.Mode;
|
import fr.devinsy.kiss4web.Kiss4web.Mode;
|
||||||
import fr.devinsy.kiss4web.dispatcher.KissDispatcher;
|
import fr.devinsy.kiss4web.dispatcher.KissDispatcher;
|
||||||
|
@ -69,6 +70,7 @@ public class StatoolInfosWeb
|
||||||
private File configurationFile;
|
private File configurationFile;
|
||||||
private BuildInformation buildInformation;
|
private BuildInformation buildInformation;
|
||||||
private StatoolInfosContext context;
|
private StatoolInfosContext context;
|
||||||
|
private HtmlCache htmlCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new manager.
|
* Instantiates a new manager.
|
||||||
|
@ -81,6 +83,9 @@ public class StatoolInfosWeb
|
||||||
//
|
//
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
this.htmlCache = new HtmlCache();
|
||||||
|
|
||||||
//
|
//
|
||||||
currentLog = "StatoolInfosWeb";
|
currentLog = "StatoolInfosWeb";
|
||||||
logger.info("StatoolInfosWeb initializing...");
|
logger.info("StatoolInfosWeb initializing...");
|
||||||
|
@ -189,14 +194,14 @@ public class StatoolInfosWeb
|
||||||
{
|
{
|
||||||
if (this.context.isExpired())
|
if (this.context.isExpired())
|
||||||
{
|
{
|
||||||
logger.info("Context expired, reloading context…");
|
logger.info("Context expiration: KO, reloading context…");
|
||||||
StatoolInfosContext newContext = new StatoolInfosContext(this.configurationFile);
|
StatoolInfosContext newContext = new StatoolInfosContext(this.configurationFile);
|
||||||
this.context = newContext;
|
this.context = newContext;
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
logger.info("Context expiration not detected.");
|
logger.info("Context expiration: OK.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (StatoolInfosException | IOException exception)
|
catch (StatoolInfosException | IOException exception)
|
||||||
|
@ -212,6 +217,17 @@ public class StatoolInfosWeb
|
||||||
public void clear()
|
public void clear()
|
||||||
{
|
{
|
||||||
KissDispatcher.instance().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
|
try
|
||||||
{
|
{
|
||||||
// Get parameters.
|
String html = StatoolInfosWeb.instance().getHtmlCache().get(IndexPage.class.getCanonicalName());
|
||||||
// ===============
|
if (html == null)
|
||||||
|
{
|
||||||
|
// Get parameters.
|
||||||
|
// ===============
|
||||||
|
|
||||||
// Use parameters.
|
// Use parameters.
|
||||||
// ===============
|
// ===============
|
||||||
Federation federation = StatoolInfosWeb.instance().getFederation();
|
Federation federation = StatoolInfosWeb.instance().getFederation();
|
||||||
UptimeJournal uptimes = StatoolInfosWeb.instance().getUptimeJournal();
|
UptimeJournal uptimes = StatoolInfosWeb.instance().getUptimeJournal();
|
||||||
|
|
||||||
// Send response.
|
// Send response.
|
||||||
// ==============
|
// ==============
|
||||||
String headerView = FederationHeaderView.htmlize(federation, uptimes);
|
String headerView = FederationHeaderView.htmlize(federation, uptimes);
|
||||||
String contentView = OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations());
|
String contentView = OrganizationListView.htmlize(federation.getMemberOrganizations(), federation.getAwayOrganizations());
|
||||||
|
|
||||||
BreadcrumbTrail trail = new BreadcrumbTrail();
|
BreadcrumbTrail trail = new BreadcrumbTrail();
|
||||||
trail.add(federation.getName(), "/federation/organizations/");
|
trail.add(federation.getName(), "/federation/organizations/");
|
||||||
trail.add("Organisations", "/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.
|
// Display page.
|
||||||
response.setContentType("application/xhtml+xml; charset=UTF-8");
|
response.setContentType("application/xhtml+xml; charset=UTF-8");
|
||||||
|
|
Loading…
Reference in a new issue