You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by sc...@apache.org on 2006/08/02 03:46:35 UTC
svn commit: r427852 - in /shale/sandbox/shale-petstore/src/main:
java/org/apache/shale/petstore/web/DataPopFilter.java
java/org/apache/shale/petstore/web/DataPopListener.java
webapp/WEB-INF/web.xml
Author: schof
Date: Tue Aug 1 18:46:35 2006
New Revision: 427852
URL: http://svn.apache.org/viewvc?rev=427852&view=rev
Log:
Reverted data initialization back to listener (from servlet filter) once it was clear that the hibernate problems i was experiencing had nothing to do with the listener (listener is preferred to filter for this kind of thing.)
Added:
shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopListener.java
- copied, changed from r427827, shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopFilter.java
Removed:
shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopFilter.java
Modified:
shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/web.xml
Copied: shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopListener.java (from r427827, shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopFilter.java)
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopListener.java?p2=shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopListener.java&p1=shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopFilter.java&r1=427827&r2=427852&rev=427852&view=diff
==============================================================================
--- shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopFilter.java (original)
+++ shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/web/DataPopListener.java Tue Aug 1 18:46:35 2006
@@ -29,47 +29,21 @@
*
* @author Sean Schofield
*/
-public class DataPopFilter implements Filter {
+public class DataPopListener implements ServletContextListener {
- ServletContext servletContext;
- boolean ready;
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
- public void init(FilterConfig filterConfig) throws ServletException {
- this.servletContext = filterConfig.getServletContext();
- }
+ // get the service bean
+
+ ApplicationContext applicationContext = (ApplicationContext)servletContextEvent.getServletContext().
+ getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
- // one-time intialization of data
- if (!ready) {
- ApplicationContext applicationContext = (ApplicationContext)servletContext.
- getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
-
- InventoryService inventoryService = (InventoryService)applicationContext.getBean("inventoryService");
- inventoryService.createTestData();
- ready = true;
- }
- filterChain.doFilter(servletRequest, servletResponse);
+ InventoryService inventoryService = (InventoryService)applicationContext.getBean("inventoryService");
+ inventoryService.createTestData();
}
- public void destroy() {
- //To change body of implemented methods use File | Settings | File Templates.
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+
}
+
}
-//public class DataPopFilter implements ServletContextListener {
-//
-// public void contextInitialized(ServletContextEvent servletContextEvent) {
-//
-// // get the service bean
-//
-// ApplicationContext applicationContext = (ApplicationContext)servletContextEvent.getServletContext().
-// getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
-//
-// InventoryService inventoryService = (InventoryService)applicationContext.getBean("inventoryService");
-// inventoryService.createTestData();
-// }
-//
-// public void contextDestroyed(ServletContextEvent servletContextEvent) {
-//
-// }
-//
-//}
Modified: shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/web.xml?rev=427852&r1=427851&r2=427852&view=diff
==============================================================================
--- shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/web.xml (original)
+++ shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/web.xml Tue Aug 1 18:46:35 2006
@@ -151,19 +151,6 @@
<!--
==============================================================================
- PETSTORE
- ==============================================================================
- -->
-
- <filter>
- <filter-name>petstore-data-pop</filter-name>
- <filter-class>
- org.apache.shale.petstore.web.DataPopFilter
- </filter-class>
- </filter>
-
- <!--
- ==============================================================================
MYFACES/TOMAHAWK
==============================================================================
-->
@@ -202,33 +189,33 @@
<!--
==============================================================================
- PETSTORE
+ SHALE
==============================================================================
-->
- <filter-mapping>
- <filter-name>petstore-data-pop</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
+ <listener>
+ <listener-class>org.apache.commons.chain.web.ChainListener</listener-class>
+ </listener>
<!--
==============================================================================
- SHALE
+ SPRING
==============================================================================
-->
<listener>
- <listener-class>org.apache.commons.chain.web.ChainListener</listener-class>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
+
<!--
==============================================================================
- SPRING
+ PETSTORE
==============================================================================
-->
<listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ <listener-class>org.apache.shale.petstore.web.DataPopListener</listener-class>
</listener>
<!--