forked from apache/myfaces
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3689580
commit 63a3fe8
Showing
5 changed files
with
149 additions
and
57 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package jakarta.faces.event; | ||
|
||
import jakarta.enterprise.util.AnnotationLiteral; | ||
import jakarta.inject.Qualifier; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Target({ ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Qualifier | ||
public @interface AfterPhase | ||
{ | ||
PhaseId value(); | ||
|
||
public final static class Literal extends AnnotationLiteral<AfterPhase> implements AfterPhase | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
private final PhaseId value; | ||
|
||
public static Literal of(PhaseId value) | ||
{ | ||
return new Literal(value); | ||
} | ||
|
||
private Literal(PhaseId value) | ||
{ | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public PhaseId value() | ||
{ | ||
return value; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package jakarta.faces.event; | ||
|
||
import jakarta.enterprise.util.AnnotationLiteral; | ||
import jakarta.inject.Qualifier; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Target({ ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Qualifier | ||
public @interface BeforePhase | ||
{ | ||
PhaseId value(); | ||
|
||
public final static class Literal extends AnnotationLiteral<BeforePhase> implements BeforePhase | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
private final PhaseId value; | ||
|
||
public static Literal of(PhaseId value) | ||
{ | ||
return new Literal(value); | ||
} | ||
|
||
private Literal(PhaseId value) | ||
{ | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public PhaseId value() | ||
{ | ||
return value; | ||
} | ||
} | ||
} |
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
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
47 changes: 47 additions & 0 deletions
47
impl/src/main/java/org/apache/myfaces/cdi/PhaseBroadcaster.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.apache.myfaces.cdi; | ||
|
||
import jakarta.enterprise.event.Event; | ||
import jakarta.enterprise.inject.spi.BeanManager; | ||
import jakarta.faces.event.*; | ||
import org.apache.myfaces.cdi.util.CDIUtils; | ||
|
||
public class PhaseBroadcaster implements PhaseListener | ||
{ | ||
@Override | ||
public void beforePhase(PhaseEvent phaseEvent) | ||
{ | ||
BeanManager beanManager = CDIUtils.getBeanManager(phaseEvent.getFacesContext()); | ||
if (beanManager == null) | ||
{ | ||
return; | ||
} | ||
|
||
Event<Object> event = beanManager.getEvent(); | ||
|
||
event.select(BeforePhase.Literal.of(phaseEvent.getPhaseId())).fire(event); | ||
|
||
event.select(BeforePhase.Literal.of(PhaseId.ANY_PHASE)).fire(event); | ||
} | ||
|
||
@Override | ||
public void afterPhase(PhaseEvent phaseEvent) | ||
{ | ||
BeanManager beanManager = CDIUtils.getBeanManager(phaseEvent.getFacesContext()); | ||
if (beanManager == null) | ||
{ | ||
return; | ||
} | ||
|
||
Event<Object> event = beanManager.getEvent(); | ||
|
||
event.select(AfterPhase.Literal.of(phaseEvent.getPhaseId())).fire(event); | ||
|
||
event.select(AfterPhase.Literal.of(PhaseId.ANY_PHASE)).fire(event); | ||
} | ||
|
||
@Override | ||
public PhaseId getPhaseId() | ||
{ | ||
return PhaseId.ANY_PHASE; | ||
} | ||
} |