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
Showing
7 changed files
with
196 additions
and
13 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
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
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,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
|
||
<!-- RESTEasy Filter --> | ||
<filter> | ||
<filter-name>Resteasy</filter-name> | ||
<filter-class>org.jboss.resteasy.plugins.server.servlet.FilterDispatcher</filter-class> | ||
<init-param> | ||
<param-name>javax.ws.rs.Application</param-name> | ||
<param-value>org.jboss.seam.rest.examples.exceptions.JaxrsExceptionsApplication</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>resteasy.scan</param-name> | ||
<param-value>true</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>resteasy.servlet.mapping.prefix</param-name> | ||
<param-value>/api</param-value> | ||
</init-param> | ||
<init-param> | ||
<param-name>resteasy.injector.factory</param-name> | ||
<param-value>org.jboss.resteasy.cdi.CdiInjectorFactory</param-value> | ||
</init-param> | ||
</filter> | ||
|
||
<filter-mapping> | ||
<filter-name>Resteasy</filter-name> | ||
<url-pattern>/api/*</url-pattern> | ||
</filter-mapping> | ||
|
||
<!-- Weld Servlet Listener --> | ||
<listener> | ||
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> | ||
</listener> | ||
|
||
<!-- Seam Servlet Bootstrap --> | ||
<!-- We need to Bootstrap using Servlet since weld-servlet does not support injection into Servlet Listeners --> | ||
<servlet> | ||
<display-name>Servlet REST Listener Startup</display-name> | ||
<servlet-class>org.jboss.seam.rest.SeamRestStartupListener</servlet-class> | ||
<load-on-startup>1</load-on-startup> | ||
</servlet> | ||
</web-app> | ||
|
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,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
|
||
</web-app> | ||
|
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
48 changes: 48 additions & 0 deletions
48
impl/src/main/java/org/jboss/seam/rest/SeamRestStartupListener.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,48 @@ | ||
package org.jboss.seam.rest; | ||
|
||
import javax.inject.Inject; | ||
import javax.servlet.ServletConfig; | ||
import javax.servlet.ServletContextEvent; | ||
import javax.servlet.ServletContextListener; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebListener; | ||
import javax.servlet.http.HttpServlet; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
/** | ||
* We also extend HttpServlet so that Seam REST can be bootstrapped by eagerly-loaded Servlet on Tomcat 7, where | ||
* weld-servlet does not support CDI injection into Servlet Listeners. | ||
* | ||
* @author <a href="http://community.jboss.org/people/jharting">Jozef Hartinger</a> | ||
* | ||
*/ | ||
@WebListener | ||
public class SeamRestStartupListener extends HttpServlet implements ServletContextListener { | ||
|
||
private static final Logger log = Logger.getLogger(SeamRestStartupListener.class); | ||
|
||
private static final long serialVersionUID = -3618026329655575903L; | ||
|
||
@Inject | ||
private SeamRestStartup startup; | ||
|
||
@Override | ||
public void init(ServletConfig config) throws ServletException { | ||
super.init(config); | ||
startup.init(config.getServletContext()); | ||
} | ||
|
||
@Override | ||
public void contextInitialized(ServletContextEvent sce) { | ||
if (startup == null) { | ||
log.warn("Listener injection does not work. You are probably running within a Servlet container. Make sure to configure Seam REST to use Servlet bootstrap instead."); | ||
return; | ||
} | ||
startup.init(sce.getServletContext()); | ||
} | ||
|
||
@Override | ||
public void contextDestroyed(ServletContextEvent sce) { | ||
} | ||
} |