Author: pete.muir(a)jboss.org
Date: 2008-12-05 05:29:20 -0500 (Fri, 05 Dec 2008)
New Revision: 409
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
Log:
Tidy up lifecycle
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-05
09:50:51 UTC (rev 408)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-05
10:29:20 UTC (rev 409)
@@ -453,6 +453,17 @@
}
return activeContexts.iterator().next();
}
+
+ /**
+ * Direct access to build in contexts for internal use
+ *
+ * @param scopeType
+ * @return
+ */
+ public Context getBuiltInContext(Class<? extends Annotation> scopeType)
+ {
+ return contextMap.getBuiltInContext(scopeType);
+ }
/**
* Returns an instance of a bean
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2008-12-05
09:50:51 UTC (rev 408)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2008-12-05
10:29:20 UTC (rev 409)
@@ -42,8 +42,6 @@
public class ServletLifecycle
{
private static LogProvider log = Logging.getLogProvider(ServletLifecycle.class);
- // Where to find the manager in JNDI
- private static final String MANAGER_JNDI_KEY = "java:comp/Manager";
// The servlet context
private static ServletContext servletContext;
@@ -94,7 +92,7 @@
*/
public static void beginRequest(HttpServletRequest request) {
ManagerImpl manager = ManagerImpl.instance();
- SessionContext sessionContext = (SessionContext)
manager.getContext(SessionScoped.class);
+ SessionContext sessionContext = (SessionContext)
manager.getBuiltInContext(SessionScoped.class);
sessionContext.setSession(request.getSession(true));
}
Deleted:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-12-05
09:50:51 UTC (rev 408)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansFilter.java 2008-12-05
10:29:20 UTC (rev 409)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.webbeans.servlet;
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Filter for handling request-level events
- *
- * Delegates work to the ServletLifecycle
- *
- * @author Pete Muir
- * @author Nicklas Karlsson
- */
-public class WebBeansFilter implements Filter
-{
- /**
- * Called when the filter is initializes
- *
- * @param filterConfig The filter configuration
- * @throws ServletException When things go Wrong(tm)
- */
- public void init(FilterConfig filterConfig) throws ServletException
- {
- }
-
- /**
- * Executes the filter
- *
- * @param request The request
- * @param response The response
- * @param chain The filter chain
- *
- * @throws IOException When things go Wrong(tm)
- * @throws ServletException When things go Wrong(tm)
- */
- public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException, ServletException
- {
- try
- {
- ServletLifecycle.beginRequest((HttpServletRequest) request);
- chain.doFilter(request, response);
- }
- finally
- {
- ServletLifecycle.endRequest((HttpServletRequest) request);
- }
- }
-
- /**
- * Called when the filter is destroyed
- */
- public void destroy()
- {
- }
-}
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java
===================================================================
---
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java 2008-12-05
09:50:51 UTC (rev 408)
+++
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansListener.java 2008-12-05
10:29:20 UTC (rev 409)
@@ -19,6 +19,9 @@
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
@@ -32,7 +35,7 @@
* @author Nicklas Karlsson
*
*/
-public class WebBeansListener implements ServletContextListener, HttpSessionListener
+public class WebBeansListener implements ServletContextListener, HttpSessionListener,
ServletRequestListener
{
/**
@@ -75,4 +78,28 @@
ServletLifecycle.endApplication();
}
+ public void requestDestroyed(ServletRequestEvent sre)
+ {
+ if (sre.getServletRequest() instanceof HttpServletRequest)
+ {
+ ServletLifecycle.endRequest((HttpServletRequest) sre.getServletRequest());
+ }
+ else
+ {
+ throw new IllegalStateException("Non HTTP-Servlet lifecycle not
defined");
+ }
+ }
+
+ public void requestInitialized(ServletRequestEvent sre)
+ {
+ if (sre.getServletRequest() instanceof HttpServletRequest)
+ {
+ ServletLifecycle.beginRequest((HttpServletRequest) sre.getServletRequest());
+ }
+ else
+ {
+ throw new IllegalStateException("Non HTTP-Servlet lifecycle not
defined");
+ }
+ }
+
}