Skip to content

Commit 1d7cf59

Browse files
committed
Add Thorntail support
1 parent adff40a commit 1d7cf59

File tree

21 files changed

+234
-51
lines changed

21 files changed

+234
-51
lines changed

cdi/dynamic-bean/src/test/java/org/javaee8/cdi/dynamic/bean/DynamicBeanTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static WebArchive deploy() {
2929
create(JavaArchive.class)
3030
.addClasses(CdiExtension.class, MyBean.class, MyBeanImpl.class)
3131
.addAsResource("META-INF/services/javax.enterprise.inject.spi.Extension"))
32-
.addAsManifestResource("beans.xml");
32+
.addAsWebInfResource("beans.xml");
3333
}
3434

3535
@Inject
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<jboss-deployment-structure>
2+
<deployment>
3+
<dependencies>
4+
<!-- https://issues.jboss.org/browse/WFLY-11629 -->
5+
<module name="org.jboss.jts" services="export"/>
6+
</dependencies>
7+
</deployment>
8+
</jboss-deployment-structure>

jpa/dynamic-tx/src/test/java/org/javaee8/jpa/dynamic/tx/DynamicTXTest.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import static org.junit.Assert.assertEquals;
55
import static org.junit.Assert.assertThat;
66

7+
import java.io.File;
8+
79
import javax.inject.Inject;
810

911
import org.hamcrest.Matchers;
@@ -36,7 +38,8 @@ public static WebArchive createDeployment() {
3638
.addPackage(
3739
TransactionLiteral.class.getPackage())
3840
.addAsResource(
39-
"META-INF/persistence.xml");
41+
"META-INF/persistence.xml")
42+
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/jboss-deployment-structure.xml"));
4043
}
4144

4245
@Test

jpa/pom.xml

+12-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,15 @@
2323
<version>${project.version}</version>
2424
</dependency>
2525
</dependencies>
26-
</project>
26+
<profiles>
27+
<profile>
28+
<id>thorntail</id>
29+
<dependencies>
30+
<dependency>
31+
<groupId>com.h2database</groupId>
32+
<artifactId>h2</artifactId>
33+
</dependency>
34+
</dependencies>
35+
</profile>
36+
</profiles>
37+
</project>

jsf/extensionless-mapping/src/main/java/org/javaee8/cdi/dynamic/bean/MappingInit.java

+32-19
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,47 @@
22

33
import static javax.faces.application.ViewVisitOption.RETURN_AS_MINIMAL_IMPLICIT_OUTCOME;
44

5+
import java.util.Map;
6+
7+
import javax.faces.application.Application;
58
import javax.faces.context.FacesContext;
9+
import javax.faces.event.AbortProcessingException;
10+
import javax.faces.event.SystemEvent;
11+
import javax.faces.event.SystemEventListener;
612
import javax.faces.webapp.FacesServlet;
7-
import javax.servlet.ServletContextEvent;
8-
import javax.servlet.ServletContextListener;
9-
import javax.servlet.annotation.WebListener;
13+
import javax.servlet.ServletContext;
14+
import javax.servlet.ServletRegistration;
1015

1116
/**
1217
*
1318
* @author Arjan Tijms
1419
*/
15-
@WebListener
16-
public class MappingInit implements ServletContextListener {
20+
public class MappingInit implements SystemEventListener {
1721

18-
@Override
19-
public void contextInitialized(ServletContextEvent sce) {
20-
FacesContext context = FacesContext.getCurrentInstance();
22+
23+
@Override
24+
public void processEvent(SystemEvent event) throws AbortProcessingException {
25+
26+
FacesContext facesContext = event.getFacesContext();
27+
ServletContext sc = (ServletContext) facesContext.getExternalContext().getContext();
28+
29+
if (Boolean.valueOf((String) sc.getAttribute("mappingsAdded"))) {
30+
return;
31+
}
32+
33+
Map<String, ? extends ServletRegistration> servletRegistrations = (Map<String, ? extends ServletRegistration>) sc.getAttribute("mappings");
2134

22-
sce.getServletContext()
23-
.getServletRegistrations()
24-
.values()
25-
.stream()
26-
.filter(e -> e.getClassName().equals(FacesServlet.class.getName()))
27-
.findAny()
28-
.ifPresent(
29-
reg -> context.getApplication()
30-
.getViewHandler()
31-
.getViews(context, "/", RETURN_AS_MINIMAL_IMPLICIT_OUTCOME)
32-
.forEach(e -> reg.addMapping(e)));
35+
if (servletRegistrations == null) {
36+
return;
37+
}
38+
39+
MappingServletContextListener.addServletMappings(servletRegistrations, facesContext);
3340
}
41+
42+
43+
@Override
44+
public boolean isListenerForSource(Object source) {
45+
return source instanceof Application;
46+
}
3447

3548
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.javaee8.cdi.dynamic.bean;
2+
3+
import static javax.faces.application.ViewVisitOption.RETURN_AS_MINIMAL_IMPLICIT_OUTCOME;
4+
5+
import java.util.Map;
6+
7+
import javax.faces.application.Application;
8+
import javax.faces.context.FacesContext;
9+
import javax.faces.webapp.FacesServlet;
10+
import javax.servlet.ServletContext;
11+
import javax.servlet.ServletContextEvent;
12+
import javax.servlet.ServletContextListener;
13+
import javax.servlet.ServletRegistration;
14+
import javax.servlet.annotation.WebListener;
15+
16+
@WebListener
17+
public class MappingServletContextListener implements ServletContextListener {
18+
19+
@Override
20+
public void contextInitialized(ServletContextEvent sce) {
21+
ServletContext sc = sce.getServletContext();
22+
23+
sc.setAttribute("mappings", sce.getServletContext().getServletRegistrations());
24+
25+
FacesContext facesContext = FacesContext.getCurrentInstance();
26+
if (facesContext == null) {
27+
//It 's possible that JSF isn't available at this time depending on JSF implementation and Java server container
28+
return;
29+
}
30+
31+
addServletMappings(sc.getServletRegistrations(), facesContext);
32+
33+
//Add a flag to not add the mappings again later in MappingInit
34+
sc.setAttribute("mappingsAdded", "true");
35+
}
36+
37+
public static void addServletMappings(Map<String, ? extends ServletRegistration> servletRegistrations, FacesContext facesContext) {
38+
servletRegistrations.values().stream().filter(e -> e.getClassName().equals(FacesServlet.class.getName()))
39+
.findAny()
40+
.ifPresent(reg -> facesContext.getApplication().getViewHandler().getViews(
41+
facesContext, "/", RETURN_AS_MINIMAL_IMPLICIT_OUTCOME).forEach(e -> reg.addMapping(e)));
42+
}
43+
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
4+
version="2.3">
5+
6+
<application>
7+
<system-event-listener>
8+
<system-event-listener-class>org.javaee8.cdi.dynamic.bean.MappingInit</system-event-listener-class>
9+
<system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
10+
</system-event-listener>
11+
</application>
12+
</faces-config>

jsf/extensionless-mapping/src/test/java/org/javaee8/cdi/dynamic/bean/ExtensionlessMappingTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ public void teardown() {
4747
public static WebArchive deploy() {
4848
WebArchive war =
4949
create(WebArchive.class)
50-
.addClasses(MappingInit.class, ApplicationInit.class)
50+
.addClasses(MappingInit.class, ApplicationInit.class, MappingServletContextListener.class)
5151
.addAsWebResource(new File("src/main/webapp/foo.xhtml"))
5252
.addAsWebResource(new File("src/main/webapp/bar.xhtml"))
5353
.addAsWebResource(new File("src/main/webapp/sub/bar.xhtml"), "/sub/bar.xhtml")
54-
.addAsManifestResource("beans.xml");
54+
.addAsWebInfResource("beans.xml")
55+
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"));
5556

5657
System.out.println("War to be deployed contains: \n" + war.toString(true));
5758

jsonb/mapping/src/main/java/org/javaee8/jsonb/mapping/controller/PersonController.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import org.javaee8.jsonb.mapping.domain.Person;
44
import java.util.Arrays;
55
import java.util.List;
6+
67
import javax.ws.rs.GET;
78
import javax.ws.rs.Path;
8-
9+
import javax.ws.rs.Produces;
10+
import javax.ws.rs.core.MediaType;
911
/**
1012
*
1113
* @author Gaurav Gupta
@@ -20,6 +22,7 @@ public class PersonController {
2022
*
2123
*/
2224
@GET
25+
@Produces(MediaType.APPLICATION_JSON)
2326
public List<Person> getAllPeople() {
2427
Person person1 = new Person();
2528
person1.setName("Ondrej");

pom.xml

+50-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<payara.micro.version>5.183</payara.micro.version>
3030
<glassfish.version>5.0</glassfish.version>
3131
<tomcat.version>9.0.12</tomcat.version>
32+
<thorntail.version>2.3.0.Final</thorntail.version>
3233
</properties>
3334

3435
<repositories>
@@ -323,11 +324,6 @@
323324
<artifactId>maven-resources-plugin</artifactId>
324325
<version>3.0.2</version>
325326
</plugin>
326-
<plugin>
327-
<groupId>org.wildfly.plugins</groupId>
328-
<artifactId>wildfly-maven-plugin</artifactId>
329-
<version>1.0.2.Final</version>
330-
</plugin>
331327
</plugins>
332328
</build>
333329

@@ -843,6 +839,55 @@
843839
</build>
844840
</profile>
845841

842+
<!-- ### THORNTAIL ### -->
843+
844+
<profile>
845+
<id>thorntail</id>
846+
847+
<dependencyManagement>
848+
<dependencies>
849+
<dependency>
850+
<groupId>io.thorntail</groupId>
851+
<artifactId>bom</artifactId>
852+
<version>${thorntail.version}</version>
853+
<scope>import</scope>
854+
<type>pom</type>
855+
</dependency>
856+
</dependencies>
857+
</dependencyManagement>
858+
859+
<dependencies>
860+
861+
<!-- Java EE based client dependencies to contact a server via
862+
WebSocket or REST -->
863+
<dependency>
864+
<groupId>fish.payara.arquillian</groupId>
865+
<artifactId>payara-client-ee8</artifactId>
866+
</dependency>
867+
868+
<dependency>
869+
<groupId>io.thorntail</groupId>
870+
<artifactId>arquillian</artifactId>
871+
<scope>test</scope>
872+
</dependency>
873+
874+
</dependencies>
875+
876+
<build>
877+
<plugins>
878+
<plugin>
879+
<artifactId>maven-surefire-plugin</artifactId>
880+
<configuration>
881+
<systemPropertyVariables>
882+
<!-- Uncomment to debug -->
883+
<!--<thorntail.debug.port>8000</thorntail.debug.port> -->
884+
<arquillian.xml>arquillian-thorntail.xml</arquillian.xml>
885+
</systemPropertyVariables>
886+
</configuration>
887+
</plugin>
888+
</plugins>
889+
</build>
890+
</profile>
846891

847892

848893
<!-- Activate this profile to download javadoc and sources jars.

security/dynamic-rememberme/src/test/java/org/javaee8/security/dynamic/rememberme/DynamicRemembermeTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public static WebArchive createDeployment() {
4747
Servlet.class
4848
)
4949
.addPackage(
50-
RememberMeAnnotationLiteral.class.getPackage());
50+
RememberMeAnnotationLiteral.class.getPackage())
51+
.addAsWebInfResource("jboss-web.xml");
5152
}
5253

5354
@Before
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<jboss-web>
3+
<!-- JASPIC activation for Wildfly. -->
4+
<!-- See https://arjan-tijms.omnifaces.org/2015/08/activating-jaspic-in-jboss-wildfly.html -->
5+
<security-domain>jaspitest</security-domain>
6+
</jboss-web>

security/jwt/src/test/java/org/javaee8/security/jwt/JwtTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public static WebArchive createDeployment() {
8383
.addPackage(JWTCredential.class.getPackage())
8484
.addAsLibraries(jjwtFiles)
8585
.setWebXML("web.xml")
86-
.addAsWebInfResource("beans.xml");
86+
.addAsWebInfResource("beans.xml")
87+
.addAsWebInfResource("jboss-web.xml");
8788
}
8889

8990
@Before
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<jboss-web>
3+
<!-- JASPIC activation for Wildfly. -->
4+
<!-- See https://arjan-tijms.omnifaces.org/2015/08/activating-jaspic-in-jboss-wildfly.html -->
5+
<security-domain>jaspitest</security-domain>
6+
</jboss-web>

security/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<name>Java EE 8 Samples: Security</name>
1414

1515
<modules>
16-
<module>dynamic-rememberme</module>
17-
<module>jwt</module>
16+
<module>dynamic-rememberme</module>
17+
<module>jwt</module>
1818
</modules>
1919

2020
<dependencies>

servlet/http2/pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
<jdk>1.8</jdk>
5454
</activation>
5555
<properties>
56-
<!-- default is the newest possible, supports 8u161 to 8u181 -->
57-
<alpn.version>8.1.12.v20180117</alpn.version>
56+
<!-- default is the newest possible, supports 8u161 to 8u191 -->
57+
<alpn.version>8.1.13.v20181017</alpn.version>
5858
<bootclasspathPrefix>
5959
${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn.version}/alpn-boot-${alpn.version}.jar
6060
</bootclasspathPrefix>

servlet/http2/src/test/java/org/javaee8/servlet/http2/Http2Test.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ public class Http2Test {
3838

3939
@Deployment
4040
public static WebArchive createDeployment() {
41-
final WebArchive war = create(WebArchive.class).addPackages(true, "org.javaee8.servlet.http2")
41+
final WebArchive war = create(WebArchive.class).addClasses(Servlet.class)
4242
.addAsWebResource(new File("src/main/webapp/images/payara-logo.jpg"), "images/payara-logo.jpg")
43-
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"));
43+
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"))
44+
.addAsResource("project-defaults.yml"); // only for Thormtail;
4445
System.out.println("War file content: \n" + war.toString(true));
4546
return war;
4647
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
thorntail:
2+
undertow:
3+
servers:
4+
default-server:
5+
http-listeners:
6+
default:
7+
# in Thorntail, HTTP/2 is by default only enabled for the HTTPS listener
8+
enable-http2: true

servlet/mapping/src/main/java/org/javaee8/servlet/mapping/Servlet.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
2828
.append("Mapping match:")
2929
.append(mapping.getMappingMatch().name())
3030
.append("\n")
31-
.append("Match value:")
31+
.append("Match value:'")
3232
.append(mapping.getMatchValue())
33+
.append("'")
3334
.append("\n")
34-
.append("Pattern:")
35-
.append(mapping.getPattern());
35+
.append("Pattern:'")
36+
.append(mapping.getPattern())
37+
.append("'");
3638
}
3739

3840
}

0 commit comments

Comments
 (0)