### Install Implementation and Test Helper
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Installs the Mojarra implementation jar and the base test helper into the local Maven repository.
```bash
mvn -pl impl,test/base -am clean install -DskipTests
```
--------------------------------
### Visit all nodes in the view
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/impl/src/main/javadoc/jakarta/faces/component/visit/package.html
Demonstrates how to traverse every node in the component tree starting from the UIViewRoot.
```java
UIViewRoot root = facesContext.getViewRoot();
root.visitTree(VisitContext.createVisitContext(context),
new VisitCallback() {
public VisitResult visit(VisitContext context,
UIComponent target) {
// take some action on target
return VisitResult.ACCEPT;
}
});
```
--------------------------------
### Create a Facelets view
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/README.md
The hello.xhtml file defines the user interface using Jakarta Faces components.
```xml
Hello, World!
#{hello.message}
```
--------------------------------
### Build and Swap Layer Artifacts
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Commands to prepare a local SNAPSHOT artifact and integrate it into the benchmarking environment.
```bash
mvn clean install
```
```bash
mvn clean package -DskipTests -Dglassfish.version=-SNAPSHOT
```
```bash
target/glassfish8/glassfish/modules/.jar
```
```bash
-Dperf.jvmArguments
```
--------------------------------
### Run Performance Benchmarks
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Execute the integration tests with performance benchmarking enabled.
```bash
mvn failsafe:integration-test failsafe:verify -Dperf=true -Dperf.warmup=20 -Dperf.runs=200
```
--------------------------------
### Run Performance Benchmarks
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Executes performance benchmarks against different application servers using specific Maven profiles.
```bash
mvn clean verify -Dperf=true # GlassFish (default)
mvn clean verify -Dperf=true -Pwildfly # WildFly
mvn clean verify -Dperf=true -Ptomee # TomEE Plume
mvn clean verify -Dperf=true -Ppayara # Payara
mvn clean verify -Dperf=true -Pliberty # OpenLiberty (via facesContainer)
mvn clean verify -Dperf=true -Ptomcat # Tomcat (+ Weld + Hibernate Validator)
# Every server also has a -myfaces twin that runs Apache MyFaces instead of Eclipse Mojarra:
mvn clean verify -Dperf=true -Pglassfish-myfaces # GlassFish (with patched jakarta.faces.jar)
mvn clean verify -Dperf=true -Pwildfly-myfaces # WildFly (via WAR_BUNDLES_JSF_IMPL)
mvn clean verify -Dperf=true -Ptomee-myfaces # TomEE WebProfile
mvn clean verify -Dperf=true -Ppayara-myfaces # Payara (with patched jakarta.faces.jar)
mvn clean verify -Dperf=true -Pliberty-myfaces # OpenLiberty
mvn clean verify -Dperf=true -Ptomcat-myfaces # Tomcat (+ Weld + Hibernate Validator)
# Tune iteration counts (warmup=50, runs=1000 by default):
mvn clean verify -Dperf=true -Dperf.warmup=200 -Dperf.runs=2000
```
--------------------------------
### Build Mojarra 4.1 and 4.0
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/DEVELOPERS.md
Execute these commands from the impl directory to build the project artifacts.
```bash
# under the impl dir of project
mvn clean install
```
--------------------------------
### Create a backing bean
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/README.md
A simple RequestScoped backing bean to handle user input and message generation.
```java
package com.example;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;
@Named
@RequestScoped
public class Hello {
private String name;
private String message;
public void createMessage() {
message = "Hello, " + name + "!";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMessage() {
return message;
}
}
```
--------------------------------
### Run Performance Tests with Custom State Saving
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Executes performance verification with specific state-saving method and serialization settings.
```bash
mvn clean verify -Dperf=true -Dwebapp.stateSavingMethod=client -Dwebapp.serializeServerState=true
```
--------------------------------
### Resolving Components Programmatically
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/impl/src/main/javadoc/jakarta/faces/component/search/package.html
Demonstrates resolving a single component or multiple components using a ContextCallback.
```java
SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
SearchExpressionContext context = SearchExpressionContext.createSearchExpressionContext(facesContext, facesContext.getViewRoot());
handler.resolveComponent(context, ":form:container:@next",
new ContextCallback() {
public void invokeContextCallback(FacesContext context,
UIComponent target) {
// target == the resolved component
}
});
```
```java
SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
SearchExpressionContext context = SearchExpressionContext.createSearchExpressionContext(facesContext, facesContext.getViewRoot());
handler.resolveComponents(context, ":form:container:@next :input1 input2:@parent",
new ContextCallback() {
public void invokeContextCallback(FacesContext context,
UIComponent target) {
// target == the resolved component
}
});
```
--------------------------------
### Compare two released Mojarra versions
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Compares performance statistics between two different released versions without rebuilding.
```bash
cd test/perf
mvn clean verify -Dperf=true -Dmojarra.version=4.1.8 && cp target/perf-stats-*.txt /tmp/a.txt
mvn clean verify -Dperf=true -Dmojarra.version=4.1.9 && cp target/perf-stats-*.txt /tmp/b.txt
diff /tmp/a.txt /tmp/b.txt
```
--------------------------------
### Optional faces-config.xml configuration
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/README.md
The deployment descriptor for Faces configuration is fully optional.
```xml
```
--------------------------------
### Configure Servlet Container Dependencies for Maven
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/README.md
Include these dependencies when deploying to barebones Servlet containers like Tomcat or Jetty. Optional modules for WebSocket and Bean Validation are included.
```xml
org.glassfish
jakarta.faces
org.jboss.weld.servlet
weld-servlet-shaded
org.glassfish
jakarta.json
org.hibernate.validator
hibernate-validator
```
--------------------------------
### Using Search Expressions in Facelets
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/impl/src/main/javadoc/jakarta/faces/component/search/package.html
Demonstrates how to use search expressions within JSF tags like h:outputLabel and f:ajax.
```xml
```
--------------------------------
### Run performance tests with MyFaces profile
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Executes performance tests using a specific MyFaces version and profile.
```bash
mvn clean verify -Dperf=true -Ptomcat-myfaces -Dmyfaces.version=4.1.3
```
--------------------------------
### Visit specific subtrees in the view
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/impl/src/main/javadoc/jakarta/faces/component/visit/package.html
Demonstrates how to restrict the tree traversal to specific subtrees by providing a set of client IDs to the VisitContext.
```java
Set toVisit = getSet("form1:optionsPanel", "form2:detailPanel");
UIViewRoot root = facesContext.getViewRoot();
root.visitTree(VisitContext.createVisitContext(context, toVisit, null),
new VisitCallback() {
public VisitResult visit(VisitContext context,
UIComponent target) {
// take some action on target
return VisitResult.ACCEPT;
}
});
```
--------------------------------
### Generate performance report
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Uses perfreport.py to generate a markdown report comparing two performance dump files.
```bash
python3 perfreport.py /tmp/a.txt /tmp/b.txt \
--a-label Mojarra --b-label MyFaces --title "Tomcat" --out /tmp/report.md
```
--------------------------------
### Compare two branches
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Compares performance between two branches by rebuilding the implementation between runs.
```bash
git checkout && mvn -pl impl,test/base -am clean install -DskipTests
( cd test/perf && mvn clean verify -Dperf=true && cp target/perf-stats-*.txt /tmp/a.txt )
git checkout && mvn -pl impl,test/base -am clean install -DskipTests
( cd test/perf && mvn clean verify -Dperf=true && cp target/perf-stats-*.txt /tmp/b.txt )
diff /tmp/a.txt /tmp/b.txt
```
--------------------------------
### Configure JFR JVM Arguments
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Set the JVM arguments for JFR by appending them to the perf.jvmArguments property.
```bash
-Dperf.jvmArguments="-Xmx1g -XX:StartFlightRecording=filename=/tmp/perf-bench.jfr,settings=profile,name=perf,dumponexit=true -XX:FlightRecorderOptions=stackdepth=256"
```
--------------------------------
### Register FacesServlet in web.xml
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/README.md
Optional configuration for the FacesServlet in a Servlet 6.0+ environment.
```xml
facesServlet
jakarta.faces.webapp.FacesServlet
facesServlet
*.xhtml
```
--------------------------------
### Configure Jakarta EE API Dependency for Maven
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/README.md
Use this dependency for full Jakarta EE containers where the API is provided by the server.
```xml
jakarta.platform
jakarta.jakartaee-api
11.0.0
provided
```
--------------------------------
### Inject Additional Context Parameters
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Uses the additionalContextParams escape hatch to pass custom XML context parameters to the web application.
```bash
mvn clean verify -Dperf=true \
-Dwebapp.additionalContextParams='com.sun.faces.disableIdUniquenessChecktrue'
```
--------------------------------
### Run performance tests with specific Mojarra version
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Executes performance tests using a specific released Mojarra version.
```bash
mvn clean verify -Dperf=true -Dmojarra.version=4.1.9
```
--------------------------------
### Analyze JFR Recordings
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Use the JDK-bundled jfr tool to summarize and view hot methods or allocation data from a recording file.
```bash
jfr summary /tmp/perf-bench.jfr
jfr view --width 200 hot-methods /tmp/perf-bench.jfr
jfr view --width 200 allocation-by-class /tmp/perf-bench.jfr
jfr view --width 200 allocation-by-site /tmp/perf-bench.jfr
```
--------------------------------
### Resolving Client IDs Programmatically
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/impl/src/main/javadoc/jakarta/faces/component/search/package.html
Shows how to resolve a search expression string into a client identifier using the SearchExpressionHandler.
```java
SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
SearchExpressionContext context = SearchExpressionContext.createSearchExpressionContext(facesContext, facesContext.getViewRoot());
String clientId = handler.resolveClientId(context, ":form:container:@next");
```
--------------------------------
### Export JFR Events to JSON
Source: https://github.com/eclipse-ee4j/mojarra/blob/main/test/perf/README.md
Export execution samples to a JSON file for deeper analysis, ensuring the stack-depth is set to capture full request stacks.
```bash
jfr print --json --stack-depth 256 --events jdk.ExecutionSample /tmp/perf-bench.jfr > /tmp/samples.json
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.