Skip to content

Commit

Permalink
Merge pull request #713 from volosied/MYFACES-4665-5.0
Browse files Browse the repository at this point in the history
MYFACES-4665: Implement BeforeDestroyed [5.0]
  • Loading branch information
volosied committed May 9, 2024
2 parents 397eeed + 2689c3d commit fbf9b8a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.myfaces.cdi.view;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.BeforeDestroyed;
import jakarta.enterprise.context.Destroyed;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.event.Event;
Expand All @@ -37,6 +38,10 @@ public class ViewScopeEventListenerBridge
@Initialized(ViewScoped.class)
private Event<UIViewRoot> viewScopeInitializedEvent;

@Inject
@BeforeDestroyed(ViewScoped.class)
private Event<UIViewRoot> viewScopeBeforeDestroyedEvent;

@Inject
@Destroyed(ViewScoped.class)
private Event<UIViewRoot> viewScopeDestroyedEvent;
Expand All @@ -50,6 +55,7 @@ public void processEvent(SystemEvent event) throws AbortProcessingException

if (event instanceof PreDestroyViewMapEvent)
{
viewScopeBeforeDestroyedEvent.fire((UIViewRoot) event.getSource());
viewScopeDestroyedEvent.fire((UIViewRoot) event.getSource());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.BeforeDestroyed;
import jakarta.enterprise.context.Destroyed;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.context.SessionScoped;
Expand Down Expand Up @@ -63,6 +64,10 @@ public class FlowScopeContextualStorageHolder
@Initialized(FlowScoped.class)
private Event<Flow> flowInitializedEvent;

@Inject
@BeforeDestroyed(FlowScoped.class)
private Event<Flow> flowBeforeDestroyedEvent;

@Inject
@Destroyed(FlowScoped.class)
private Event<Flow> flowDestroyedEvent;
Expand Down Expand Up @@ -212,6 +217,7 @@ public void destroyCurrentFlowScope(FacesContext facesContext)
activeFlowKeys.remove(flowMapKey);
}

flowBeforeDestroyedEvent.fire(flow);
flowDestroyedEvent.fire(flow);
}

Expand Down

0 comments on commit fbf9b8a

Please sign in to comment.