X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static WebArchive deploy() {
create(JavaArchive.class)
.addClasses(CdiExtension.class, MyBean.class, MyBeanImpl.class)
.addAsResource("META-INF/services/javax.enterprise.inject.spi.Extension"))
.addAsManifestResource("beans.xml");
.addAsWebInfResource("beans.xml");
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<jboss-deployment-structure>
<deployment>
<dependencies>
<!-- https://issues.jboss.org/browse/WFLY-11629 -->
<module name="org.jboss.jts" services="export"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import java.io.File;

import javax.inject.Inject;

import org.hamcrest.Matchers;
Expand Down Expand Up @@ -36,7 +38,8 @@ public static WebArchive createDeployment() {
.addPackage(
TransactionLiteral.class.getPackage())
.addAsResource(
"META-INF/persistence.xml");
"META-INF/persistence.xml")
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/jboss-deployment-structure.xml"));
}

@Test
Expand Down
13 changes: 12 additions & 1 deletion jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,15 @@
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
<profiles>
<profile>
<id>thorntail</id>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,47 @@

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

import java.util.Map;

import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
import javax.faces.webapp.FacesServlet;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;

/**
*
* @author Arjan Tijms
*/
@WebListener
public class MappingInit implements ServletContextListener {
public class MappingInit implements SystemEventListener {

@Override
public void contextInitialized(ServletContextEvent sce) {
FacesContext context = FacesContext.getCurrentInstance();

@Override
public void processEvent(SystemEvent event) throws AbortProcessingException {

FacesContext facesContext = event.getFacesContext();
ServletContext sc = (ServletContext) facesContext.getExternalContext().getContext();

if (Boolean.valueOf((String) sc.getAttribute("mappingsAdded"))) {
return;
}

Map<String, ? extends ServletRegistration> servletRegistrations = (Map<String, ? extends ServletRegistration>) sc.getAttribute("mappings");

sce.getServletContext()
.getServletRegistrations()
.values()
.stream()
.filter(e -> e.getClassName().equals(FacesServlet.class.getName()))
.findAny()
.ifPresent(
reg -> context.getApplication()
.getViewHandler()
.getViews(context, "/", RETURN_AS_MINIMAL_IMPLICIT_OUTCOME)
.forEach(e -> reg.addMapping(e)));
if (servletRegistrations == null) {
return;
}

MappingServletContextListener.addServletMappings(servletRegistrations, facesContext);
}


@Override
public boolean isListenerForSource(Object source) {
return source instanceof Application;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.javaee8.cdi.dynamic.bean;

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

import java.util.Map;

import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import javax.faces.webapp.FacesServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletRegistration;
import javax.servlet.annotation.WebListener;

@WebListener
public class MappingServletContextListener implements ServletContextListener {

@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext sc = sce.getServletContext();

sc.setAttribute("mappings", sce.getServletContext().getServletRegistrations());

FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext == null) {
//It 's possible that JSF isn't available at this time depending on JSF implementation and Java server container
return;
}

addServletMappings(sc.getServletRegistrations(), facesContext);

//Add a flag to not add the mappings again later in MappingInit
sc.setAttribute("mappingsAdded", "true");
}

public static void addServletMappings(Map<String, ? extends ServletRegistration> servletRegistrations, FacesContext facesContext) {
servletRegistrations.values().stream().filter(e -> e.getClassName().equals(FacesServlet.class.getName()))
.findAny()
.ifPresent(reg -> facesContext.getApplication().getViewHandler().getViews(
facesContext, "/", RETURN_AS_MINIMAL_IMPLICIT_OUTCOME).forEach(e -> reg.addMapping(e)));
}

}
12 changes: 12 additions & 0 deletions jsf/extensionless-mapping/src/main/webapp/WEB-INF/faces-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_3.xsd"
version="2.3">

<application>
<system-event-listener>
<system-event-listener-class>org.javaee8.cdi.dynamic.bean.MappingInit</system-event-listener-class>
<system-event-class>javax.faces.event.PostConstructApplicationEvent</system-event-class>
</system-event-listener>
</application>
</faces-config>
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public void teardown() {
public static WebArchive deploy() {
WebArchive war =
create(WebArchive.class)
.addClasses(MappingInit.class, ApplicationInit.class)
.addClasses(MappingInit.class, ApplicationInit.class, MappingServletContextListener.class)
.addAsWebResource(new File("src/main/webapp/foo.xhtml"))
.addAsWebResource(new File("src/main/webapp/bar.xhtml"))
.addAsWebResource(new File("src/main/webapp/sub/bar.xhtml"), "/sub/bar.xhtml")
.addAsManifestResource("beans.xml");
.addAsWebInfResource("beans.xml")
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/faces-config.xml"));

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import org.javaee8.jsonb.mapping.domain.Person;
import java.util.Arrays;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;

import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
/**
*
* @author Gaurav Gupta
Expand All @@ -20,6 +22,7 @@ public class PersonController {
*
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Person> getAllPeople() {
Person person1 = new Person();
person1.setName("Ondrej");
Expand Down
55 changes: 50 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<payara.micro.version>5.183</payara.micro.version>
<glassfish.version>5.0</glassfish.version>
<tomcat.version>9.0.12</tomcat.version>
<thorntail.version>2.3.0.Final</thorntail.version>
</properties>

<repositories>
Expand Down Expand Up @@ -323,11 +324,6 @@
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>1.0.2.Final</version>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -843,6 +839,55 @@
</build>
</profile>

<!-- ### THORNTAIL ### -->

<profile>
<id>thorntail</id>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.thorntail</groupId>
<artifactId>bom</artifactId>
<version>${thorntail.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<!-- Java EE based client dependencies to contact a server via
WebSocket or REST -->
<dependency>
<groupId>fish.payara.arquillian</groupId>
<artifactId>payara-client-ee8</artifactId>
</dependency>

<dependency>
<groupId>io.thorntail</groupId>
<artifactId>arquillian</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<!-- Uncomment to debug -->
<!--<thorntail.debug.port>8000</thorntail.debug.port> -->
<arquillian.xml>arquillian-thorntail.xml</arquillian.xml>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>


<!-- Activate this profile to download javadoc and sources jars.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public static WebArchive createDeployment() {
Servlet.class
)
.addPackage(
RememberMeAnnotationLiteral.class.getPackage());
RememberMeAnnotationLiteral.class.getPackage())
.addAsWebInfResource("jboss-web.xml");
}

@Before
Expand Down
6 changes: 6 additions & 0 deletions security/dynamic-rememberme/src/test/resources/jboss-web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<jboss-web>
<!-- JASPIC activation for Wildfly. -->
<!-- See https://arjan-tijms.omnifaces.org/2015/08/activating-jaspic-in-jboss-wildfly.html -->
<security-domain>jaspitest</security-domain>
</jboss-web>
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public static WebArchive createDeployment() {
.addPackage(JWTCredential.class.getPackage())
.addAsLibraries(jjwtFiles)
.setWebXML("web.xml")
.addAsWebInfResource("beans.xml");
.addAsWebInfResource("beans.xml")
.addAsWebInfResource("jboss-web.xml");
}

@Before
Expand Down
6 changes: 6 additions & 0 deletions security/jwt/src/test/resources/jboss-web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0"?>
<jboss-web>
<!-- JASPIC activation for Wildfly. -->
<!-- See https://arjan-tijms.omnifaces.org/2015/08/activating-jaspic-in-jboss-wildfly.html -->
<security-domain>jaspitest</security-domain>
</jboss-web>
4 changes: 2 additions & 2 deletions security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<name>Java EE 8 Samples: Security</name>

<modules>
<module>dynamic-rememberme</module>
<module>jwt</module>
<module>dynamic-rememberme</module>
<module>jwt</module>
</modules>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions servlet/http2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
<jdk>1.8</jdk>
</activation>
<properties>
<!-- default is the newest possible, supports 8u161 to 8u181 -->
<alpn.version>8.1.12.v20180117</alpn.version>
<!-- default is the newest possible, supports 8u161 to 8u191 -->
<alpn.version>8.1.13.v20181017</alpn.version>
<bootclasspathPrefix>
${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn.version}/alpn-boot-${alpn.version}.jar
</bootclasspathPrefix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ public class Http2Test {

@Deployment
public static WebArchive createDeployment() {
final WebArchive war = create(WebArchive.class).addPackages(true, "org.javaee8.servlet.http2")
final WebArchive war = create(WebArchive.class).addClasses(Servlet.class)
.addAsWebResource(new File("src/main/webapp/images/payara-logo.jpg"), "images/payara-logo.jpg")
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"));
.addAsWebInfResource(new File("src/main/webapp/WEB-INF/web.xml"))
.addAsResource("project-defaults.yml"); // only for Thormtail;
System.out.println("War file content: \n" + war.toString(true));
return war;
}
Expand Down
8 changes: 8 additions & 0 deletions servlet/http2/src/test/resources/project-defaults.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
thorntail:
undertow:
servers:
default-server:
http-listeners:
default:
# in Thorntail, HTTP/2 is by default only enabled for the HTTPS listener
enable-http2: true
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
.append("Mapping match:")
.append(mapping.getMappingMatch().name())
.append("\n")
.append("Match value:")
.append("Match value:'")
.append(mapping.getMatchValue())
.append("'")
.append("\n")
.append("Pattern:")
.append(mapping.getPattern());
.append("Pattern:'")
.append(mapping.getPattern())
.append("'");
}

}
Loading
X Tutup