still SWF 302 work - phase listener mods and more javadoc
This commit is contained in:
@@ -164,7 +164,8 @@ public class FlowNavigationHandler extends DecoratingNavigationHandler {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// bind the new execution as the 'current execution'
|
// bind the new execution as the 'current execution'
|
||||||
FlowExecutionHolderUtils.setFlowExecutionHolder(new FlowExecutionHolder(flowExecution), facesContext);
|
FlowExecutionHolderUtils.setFlowExecutionHolder(new FlowExecutionHolder(flowExecution),
|
||||||
|
facesContext);
|
||||||
}
|
}
|
||||||
// start the new execution
|
// start the new execution
|
||||||
ViewSelection selectedView = flowExecution.start(createInput(context), context);
|
ViewSelection selectedView = flowExecution.start(createInput(context), context);
|
||||||
@@ -185,6 +186,10 @@ public class FlowNavigationHandler extends DecoratingNavigationHandler {
|
|||||||
holder.setViewSelection(selectedView);
|
holder.setViewSelection(selectedView);
|
||||||
}
|
}
|
||||||
catch (NoMatchingTransitionException e) {
|
catch (NoMatchingTransitionException e) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("No flow state transition found for event '" + eventId
|
||||||
|
+ "'; falling back to standard navigation handler.");
|
||||||
|
}
|
||||||
// not a valid event in the current state: proceed with standard navigation
|
// not a valid event in the current state: proceed with standard navigation
|
||||||
originalNavigationHandler.handleNavigation(facesContext, fromAction, outcome);
|
originalNavigationHandler.handleNavigation(facesContext, fromAction, outcome);
|
||||||
}
|
}
|
||||||
@@ -238,6 +243,9 @@ public class FlowNavigationHandler extends DecoratingNavigationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupResources(FacesContext context) {
|
private void cleanupResources(FacesContext context) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Cleaning up allocated flow system resources");
|
||||||
|
}
|
||||||
FlowExecutionHolderUtils.unlockCurrentFlowExecutionIfNecessary(context);
|
FlowExecutionHolderUtils.unlockCurrentFlowExecutionIfNecessary(context);
|
||||||
ExternalContextHolder.setExternalContext(null);
|
ExternalContextHolder.setExternalContext(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,10 +225,24 @@ public class FlowPhaseListener implements PhaseListener {
|
|||||||
if (event.getPhaseId() == PhaseId.RESTORE_VIEW) {
|
if (event.getPhaseId() == PhaseId.RESTORE_VIEW) {
|
||||||
ExternalContextHolder.setExternalContext(new JsfExternalContext(context));
|
ExternalContextHolder.setExternalContext(new JsfExternalContext(context));
|
||||||
restoreFlowExecution(event.getFacesContext());
|
restoreFlowExecution(event.getFacesContext());
|
||||||
|
// we do not need to worry about clean up here since other phases will continue to run even if an exception
|
||||||
|
// occurs in restoreFlowExecution(FacesContext)
|
||||||
}
|
}
|
||||||
else if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
|
else if (event.getPhaseId() == PhaseId.RENDER_RESPONSE) {
|
||||||
if (FlowExecutionHolderUtils.isFlowExecutionRestored(event.getFacesContext())) {
|
if (FlowExecutionHolderUtils.isFlowExecutionRestored(event.getFacesContext())) {
|
||||||
prepareResponse(getCurrentContext(), FlowExecutionHolderUtils.getFlowExecutionHolder(context));
|
try {
|
||||||
|
prepareResponse(getCurrentContext(), FlowExecutionHolderUtils.getFlowExecutionHolder(context));
|
||||||
|
}
|
||||||
|
catch (RuntimeException e) {
|
||||||
|
// we must cleanup here since this is the render response phase and the after phase callback will
|
||||||
|
// NOT run when an exception occurs (which typically does the cleanup--see below)
|
||||||
|
cleanupResources(context);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
catch (Error e) {
|
||||||
|
cleanupResources(context);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,7 +255,7 @@ public class FlowPhaseListener implements PhaseListener {
|
|||||||
saveFlowExecution(getCurrentContext(), FlowExecutionHolderUtils.getFlowExecutionHolder(context));
|
saveFlowExecution(getCurrentContext(), FlowExecutionHolderUtils.getFlowExecutionHolder(context));
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
// always cleanup after save - done with flow execution request processing
|
// always cleanup after save - we are done with flow execution request processing
|
||||||
cleanupResources(context);
|
cleanupResources(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,7 +427,7 @@ public class FlowPhaseListener implements PhaseListener {
|
|||||||
if (flowExecution.isActive()) {
|
if (flowExecution.isActive()) {
|
||||||
// save the flow execution out to the repository
|
// save the flow execution out to the repository
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Saving continuation to repository with key " + holder.getFlowExecutionKey());
|
logger.debug("Saving execution to repository with key " + holder.getFlowExecutionKey());
|
||||||
}
|
}
|
||||||
repository.putFlowExecution(holder.getFlowExecutionKey(), flowExecution);
|
repository.putFlowExecution(holder.getFlowExecutionKey(), flowExecution);
|
||||||
}
|
}
|
||||||
@@ -435,6 +449,9 @@ public class FlowPhaseListener implements PhaseListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cleanupResources(FacesContext context) {
|
private void cleanupResources(FacesContext context) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("Cleaning up allocated flow system resources");
|
||||||
|
}
|
||||||
FlowExecutionHolderUtils.unlockCurrentFlowExecutionIfNecessary(context);
|
FlowExecutionHolderUtils.unlockCurrentFlowExecutionIfNecessary(context);
|
||||||
ExternalContextHolder.setExternalContext(null);
|
ExternalContextHolder.setExternalContext(null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user