deltaspike doesn't allow that before v1.1.0, however, it's very easy to implement it manually:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SessionScoped | |
@JsfPhaseListener | |
public class WindowQuotaHandler implements PhaseListener | |
{ | |
@Inject | |
private WindowContext windowContext; | |
private Stack<String> windowIdStack = new Stack<String>(); | |
@Override | |
public synchronized /*no issue due to session-scoped instance*/ | |
void afterPhase(PhaseEvent event) | |
{ | |
String currentWindowId = windowContext.getCurrentWindowId(); | |
if (currentWindowId == null) | |
{ | |
return; | |
} | |
if (windowIdStack.contains(currentWindowId)) | |
{ | |
windowIdStack.remove(currentWindowId); | |
windowIdStack.push(currentWindowId); | |
} | |
else | |
{ | |
windowIdStack.push(currentWindowId); | |
if (windowIdStack.size() > 30) //restricted to 30 windows | |
{ | |
String windowIdToRemove = windowIdStack.remove(0); | |
windowContext.closeWindow(windowIdToRemove); | |
} | |
} | |
} | |
@Override | |
public void beforePhase(PhaseEvent event) | |
{ | |
} | |
@Override | |
public PhaseId getPhaseId() | |
{ | |
return PhaseId.RENDER_RESPONSE; | |
} | |
} |