*/
public void onEvent(WebAppEvent event)
{
if (event instanceof WebAppLifeCycleEvent && !stopping.get())
{
WebAppLifeCycleEvent waEvent = (WebAppLifeCycleEvent)event;
if (waEvent.getType() == WebAppLifeCycleEvent.REMOVED)
{
String contextName = ContainerUtil.getServletContextName(event.getWebApp().getServletContext());
boolean updated = false;
for (Entry<String, ConcurrentMap<String, Queue<PortalContainerInitTaskContext>>> entry : initTasks.entrySet())
{
String portalContainer = entry.getKey();
ConcurrentMap<String, Queue<PortalContainerInitTaskContext>> queues = entry.getValue();
for (Queue<PortalContainerInitTaskContext> queue : queues.values())
{
for (Iterator<PortalContainerInitTaskContext> it = queue.iterator(); it.hasNext();)
{
PortalContainerInitTaskContext context = it.next();
if (context.getServletContextName().equals(contextName))
{
it.remove();
updated = true;
if (portalContainer2Reload.contains(portalContainer))
{
// The current portal container is already part of the portal containers to be reloaded to so need to continue
// at that point.
lastUpdateTime.set(System.currentTimeMillis());
continue;
}
final PortalContainer container = getPortalContainer(portalContainer);
if (container != null)
{
Set<WebAppInitContext> contexts = container.getWebAppInitContexts();
for (WebAppInitContext webappctx : contexts)
{
ServletContext ctx = webappctx.getServletContext();
if (context.getServletContextName().equals(ContainerUtil.getServletContextName(ctx)))
{
// We found a matching servlet context which means that the current servlet context is defined as a
// PortalContainerConfigOwner
portalContainer2Reload.add(portalContainer);
lastUpdateTime.set(System.currentTimeMillis());
// We already found the corresponding servlet context no need to continue
break;
}
}
}
}
}
}
}
if (updated)
{
LOG.info("The webapp '" + contextName + "' has been undeployed, the related init tasks have been removed");
}
}
else if (waEvent.getType() == WebAppLifeCycleEvent.ADDED && lastUpdateTime.get() > 0 && reloadingThread == null)
{
// Reloading thread used to reload asynchronously the containers
reloadingThread = new Thread("Reloading")
{
@Override