[webbeans-commits] Webbeans SVN: r1464 - in ri/trunk/webbeans-ri/src/main: java/org/jboss/webbeans/context/beanmap and 3 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Mon Feb 9 02:58:39 EST 2009
Author: nickarls
Date: 2009-02-09 02:58:39 -0500 (Mon, 09 Feb 2009)
New Revision: 1464
Added:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionManager.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java
Removed:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/AbstractBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/BeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
ri/trunk/webbeans-ri/src/main/resources/META-INF/faces-config.xml
Log:
* Some fixes to conversation propagation
* Some renames (Session -> HttpSession)
* Fix for conversation/session removing stuff not in their namespace
* Skeleton of redirect filter
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -17,8 +17,6 @@
package org.jboss.webbeans.bootstrap;
-
-
import org.jboss.webbeans.BeanValidator;
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.ManagerImpl;
@@ -37,7 +35,7 @@
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.resources.spi.ResourceLoader;
-import org.jboss.webbeans.servlet.SessionManager;
+import org.jboss.webbeans.servlet.HttpSessionManager;
import org.jboss.webbeans.transaction.Transaction;
/**
@@ -106,7 +104,7 @@
beanDeployer.addClass(ServletConversationManager.class);
beanDeployer.addClass(JavaSEConversationTerminator.class);
beanDeployer.addClass(NumericConversationIdGenerator.class);
- beanDeployer.addClass(SessionManager.class);
+ beanDeployer.addClass(HttpSessionManager.class);
beanDeployer.deploy();
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/AbstractBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/AbstractBeanMap.java 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/AbstractBeanMap.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -27,13 +27,14 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.servlet.ApplicationBeanMap;
+import org.jboss.webbeans.util.EnumerationIterable;
import org.jboss.webbeans.util.Names;
/**
* Provides common BeanMap operations
*
* @author Nicklas Karlsson
- *
+ *
*/
public abstract class AbstractBeanMap implements BeanMap
{
@@ -75,12 +76,9 @@
*/
public void clear()
{
- Enumeration<String> names = getAttributeNames();
- while (names.hasMoreElements())
+ for (String name : getFilteredAttributeNames())
{
- String name = (String) names.nextElement();
removeAttribute(name);
- log.trace("Cleared " + name);
}
log.trace("Bean Map cleared");
}
@@ -93,18 +91,31 @@
public Iterable<Contextual<? extends Object>> keySet()
{
List<Contextual<?>> beans = new ArrayList<Contextual<?>>();
- Enumeration<String> names = getAttributeNames();
- while (names.hasMoreElements())
+ for (String name : getFilteredAttributeNames())
{
- String name = (String) names.nextElement();
- if (name.startsWith(getKeyPrefix()))
+ String id = name.substring(getKeyPrefix().length() + 1);
+ Contextual<?> bean = CurrentManager.rootManager().getBeans().get(Integer.parseInt(id));
+ beans.add(bean);
+ }
+ return beans;
+ }
+
+ /**
+ * Gets the list of attribute names that is held by the bean map
+ *
+ * @return The list of attribute names
+ */
+ private List<String> getFilteredAttributeNames()
+ {
+ List<String> attributeNames = new ArrayList<String>();
+ for (String attributeName : new EnumerationIterable<String>(getAttributeNames()))
+ {
+ if (attributeName.startsWith(getKeyPrefix()))
{
- String id = name.substring(getKeyPrefix().length() + 1);
- Contextual<?> bean = CurrentManager.rootManager().getBeans().get(Integer.parseInt(id));
- beans.add(bean);
+ attributeNames.add(attributeName);
}
}
- return beans;
+ return attributeNames;
}
/**
@@ -137,9 +148,9 @@
protected abstract void removeAttribute(String key);
/**
- * Gets an enumeration of the beans present in the underlying storage
+ * Gets an enumeration of the attribute names present in the underlying storage
*
- * @return The current beans
+ * @return The attribute names
*/
protected abstract Enumeration<String> getAttributeNames();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/BeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/BeanMap.java 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanmap/BeanMap.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -27,7 +27,7 @@
* @author Nicklas Karlsson
*
* @see org.jboss.webbeans.context.beanmap.SimpleBeanMap
- * @see org.jboss.webbeans.servlet.SessionBeanMap
+ * @see org.jboss.webbeans.servlet.HttpSessionBeanMap
*/
public interface BeanMap
{
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -0,0 +1,146 @@
+/*
+ * 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.jsf;
+
+import javax.context.Conversation;
+import javax.faces.component.UIViewRoot;
+import javax.faces.component.html.HtmlInputHidden;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.conversation.ConversationManager;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.servlet.ServletLifecycle;
+
+/**
+ * A phase listener for propagating conversation id over postbacks through a hidden component
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+public class WebBeansPhaseListener implements PhaseListener
+{
+ // The ID/name of the conversation-propagating component
+ private static final String CONVERSATION_PROPAGATION_COMPONENT = "jboss_org_webbeans_conversation_propagation";
+
+ private static LogProvider log = Logging.getLogProvider(ServletLifecycle.class);
+
+ /**
+ * Indicates if we are in a JSF postback or not
+ *
+ * @return True if postback, false otherwise
+ */
+ private boolean isPostback()
+ {
+ return FacesContext.getCurrentInstance().getRenderKit().getResponseStateManager().isPostback(FacesContext.getCurrentInstance());
+ }
+
+ public void afterPhase(PhaseEvent phaseEvent)
+ {
+ // If we are restoring a view and we are in a postback
+ if (phaseEvent.getPhaseId().equals(PhaseId.RESTORE_VIEW) && isPostback())
+ {
+ log.trace("Processing after RESTORE_VIEW phase");
+ HtmlInputHidden propagationComponent = getPropagationComponent(phaseEvent.getFacesContext().getViewRoot());
+ // Resume the conversation if the propagation component can be found
+ if (propagationComponent != null)
+ {
+ log.trace("Propagation component found");
+ String cid = propagationComponent.getValue().toString();
+ ConversationManager conversationManager = CurrentManager.rootManager().getInstanceByType(ConversationManager.class);
+ conversationManager.beginOrRestoreConversation(cid);
+ }
+ }
+ }
+
+ public void beforePhase(PhaseEvent phaseEvent)
+ {
+ if (phaseEvent.getPhaseId().equals(PhaseId.RENDER_RESPONSE) && isPostback())
+ {
+ // If we are rendering the response from a postback
+ log.trace("Processing after RENDER_RESPONSE phase");
+ Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
+ // If we are in a long-running conversation, create or update the conversation id
+ // in the propagation component in the view root
+ if (conversation.isLongRunning())
+ {
+ log.trace("Updating propagation for " + conversation);
+ createOrUpdatePropagationComponent(phaseEvent.getFacesContext(), conversation.getId());
+ }
+ else
+ {
+ // Otherwise, remove the component from the view root
+ log.trace("Removing propagation for " + conversation);
+ removePropagationComponent(phaseEvent.getFacesContext().getViewRoot());
+ }
+ }
+ }
+
+ /**
+ * Gets the conversation propagation component
+ *
+ * @param viewRoot The view root to search in
+ * @return The component, or null if it's not present
+ */
+ private HtmlInputHidden getPropagationComponent(UIViewRoot viewRoot)
+ {
+ return (HtmlInputHidden) viewRoot.findComponent(CONVERSATION_PROPAGATION_COMPONENT);
+ }
+
+ /**
+ * Creates or updates the conversation propagation component in the view root
+ *
+ * @param facesContext The faces context
+ * @param cid The conversation id to propagate
+ */
+ private void createOrUpdatePropagationComponent(FacesContext facesContext, String cid)
+ {
+ HtmlInputHidden propagationComponent = getPropagationComponent(facesContext.getViewRoot());
+ // Creates the component if it can't be found
+ if (propagationComponent == null)
+ {
+ propagationComponent = (HtmlInputHidden) facesContext.getApplication().createComponent(HtmlInputHidden.COMPONENT_TYPE);
+ propagationComponent.setId(CONVERSATION_PROPAGATION_COMPONENT);
+ facesContext.getViewRoot().getChildren().add(propagationComponent);
+ }
+ propagationComponent.setValue(cid);
+ }
+
+ /**
+ * Removes the conversation propagation from the view root (if present)
+ *
+ * @param viewRoot The view root to remove the component from
+ */
+ private void removePropagationComponent(UIViewRoot viewRoot)
+ {
+ HtmlInputHidden propagationComponent = getPropagationComponent(viewRoot);
+ if (propagationComponent != null)
+ {
+ viewRoot.getChildren().remove(propagationComponent);
+ }
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ConversationBeanMap.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -21,7 +21,7 @@
import org.jboss.webbeans.context.ConversationContext;
-public class ConversationBeanMap extends SessionBeanMap
+public class ConversationBeanMap extends HttpSessionBeanMap
{
private String cid;
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanMap.java (from rev 1449, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanMap.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanMap.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -0,0 +1,95 @@
+/*
+ * 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.util.Enumeration;
+
+import javax.servlet.http.HttpSession;
+
+import org.jboss.webbeans.context.SessionContext;
+import org.jboss.webbeans.context.beanmap.AbstractBeanMap;
+
+/**
+ * A BeanMap that uses a HTTP session as backing map
+ *
+ * @author Nicklas Karlsson
+ *
+ * @see org.jboss.webbeans.context.ApplicationContext
+ */
+public class HttpSessionBeanMap extends AbstractBeanMap
+{
+ // The HTTP session context to use as backing map
+ private HttpSession session;
+
+ /**
+ * Constructor
+ *
+ * @param session The HTTP session
+ */
+ public HttpSessionBeanMap(HttpSession session)
+ {
+ super();
+ this.session = session;
+ }
+
+ /**
+ * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#getKeyPrefix()
+ */
+ @Override
+ protected String getKeyPrefix()
+ {
+ return SessionContext.class.getName();
+ }
+
+ /**
+ * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#getAttribute()
+ */
+ @Override
+ protected Object getAttribute(String key)
+ {
+ return session.getAttribute(key);
+ }
+
+ /**
+ * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#getAttributeNames()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Enumeration<String> getAttributeNames()
+ {
+ return session.getAttributeNames();
+ }
+
+ /**
+ * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#removeAttributes()
+ */
+ @Override
+ protected void removeAttribute(String key)
+ {
+ session.removeAttribute(key);
+ }
+
+ /**
+ * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#setAttribute()
+ */
+ @Override
+ protected void setAttribute(String key, Object instance)
+ {
+ session.setAttribute(key, instance);
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanMap.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionManager.java (from rev 1449, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionManager.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionManager.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -0,0 +1,24 @@
+package org.jboss.webbeans.servlet;
+
+import javax.context.RequestScoped;
+import javax.inject.Produces;
+import javax.servlet.http.HttpSession;
+
+ at RequestScoped
+public class HttpSessionManager
+{
+ private HttpSession session;
+
+ public void setSession(HttpSession session)
+ {
+ this.session = session;
+ }
+
+ @Produces
+ @RequestScoped
+ HttpSession produceSession()
+ {
+ return session;
+ }
+
+}
Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionManager.java
___________________________________________________________________
Name: svn:mergeinfo
+
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 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -51,6 +51,7 @@
*/
public static void beginApplication(ServletContext servletContext)
{
+ log.trace("Application is starting up");
new ServletBootstrap(servletContext).boot();
}
@@ -59,6 +60,7 @@
*/
public static void endApplication()
{
+ log.trace("Application is shutting down");
ApplicationContext.INSTANCE.destroy();
ApplicationContext.INSTANCE.setBeanMap(null);
}
@@ -70,6 +72,7 @@
*/
public static void beginSession(HttpSession session)
{
+ log.trace("Starting session " + session.getId());
}
/**
@@ -79,7 +82,8 @@
*/
public static void endSession(HttpSession session)
{
- SessionContext.INSTANCE.setBeanMap(new SessionBeanMap(session));
+ log.trace("Ending session " + session.getId());
+ SessionContext.INSTANCE.setBeanMap(new HttpSessionBeanMap(session));
SessionContext.INSTANCE.destroy();
SessionContext.INSTANCE.setBeanMap(null);
ConversationManager conversationManager = CurrentManager.rootManager().getInstanceByType(ConversationManager.class);
@@ -95,8 +99,9 @@
*/
public static void beginRequest(HttpServletRequest request)
{
- CurrentManager.rootManager().getInstanceByType(SessionManager.class).setSession(request.getSession());
- SessionContext.INSTANCE.setBeanMap(new SessionBeanMap(request.getSession()));
+ log.trace("Processing HTTP request " + request.getRequestURI() + " begins");
+ CurrentManager.rootManager().getInstanceByType(HttpSessionManager.class).setSession(request.getSession());
+ SessionContext.INSTANCE.setBeanMap(new HttpSessionBeanMap(request.getSession()));
beginConversation(request);
DependentContext.INSTANCE.setActive(true);
}
@@ -116,7 +121,8 @@
*/
public static void endRequest(HttpServletRequest request)
{
- CurrentManager.rootManager().getInstanceByType(SessionManager.class).setSession(null);
+ log.trace("Processing HTTP request " + request.getRequestURI() + " ends");
+ CurrentManager.rootManager().getInstanceByType(HttpSessionManager.class).setSession(null);
CurrentManager.rootManager().getInstanceByType(ConversationManager.class).cleanupConversation();
DependentContext.INSTANCE.setActive(false);
RequestContext.INSTANCE.destroy();
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionBeanMap.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -1,95 +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.util.Enumeration;
-
-import javax.servlet.http.HttpSession;
-
-import org.jboss.webbeans.context.SessionContext;
-import org.jboss.webbeans.context.beanmap.AbstractBeanMap;
-
-/**
- * A BeanMap that uses a HTTP session as backing map
- *
- * @author Nicklas Karlsson
- *
- * @see org.jboss.webbeans.context.ApplicationContext
- */
-public class SessionBeanMap extends AbstractBeanMap
-{
- // The HTTP session context to use as backing map
- private HttpSession session;
-
- /**
- * Constructor
- *
- * @param session The HTTP session
- */
- public SessionBeanMap(HttpSession session)
- {
- super();
- this.session = session;
- }
-
- /**
- * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#getKeyPrefix()
- */
- @Override
- protected String getKeyPrefix()
- {
- return SessionContext.class.getName();
- }
-
- /**
- * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#getAttribute()
- */
- @Override
- protected Object getAttribute(String key)
- {
- return session.getAttribute(key);
- }
-
- /**
- * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#getAttributeNames()
- */
- @SuppressWarnings("unchecked")
- @Override
- protected Enumeration<String> getAttributeNames()
- {
- return session.getAttributeNames();
- }
-
- /**
- * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#removeAttributes()
- */
- @Override
- protected void removeAttribute(String key)
- {
- session.removeAttribute(key);
- }
-
- /**
- * @see org.jboss.webbeans.context.beanmap.AbstractBeanMap#setAttribute()
- */
- @Override
- protected void setAttribute(String key, Object instance)
- {
- session.setAttribute(key, instance);
- }
-
-}
Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/SessionManager.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -1,24 +0,0 @@
-package org.jboss.webbeans.servlet;
-
-import javax.context.RequestScoped;
-import javax.inject.Produces;
-import javax.servlet.http.HttpSession;
-
- at RequestScoped
-public class SessionManager
-{
- private HttpSession session;
-
- public void setSession(HttpSession session)
- {
- this.session = session;
- }
-
- @Produces
- @RequestScoped
- HttpSession produceSession()
- {
- return session;
- }
-
-}
Added: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/WebBeansServletFilter.java 2009-02-09 07:58:39 UTC (rev 1464)
@@ -0,0 +1,77 @@
+/*
+ * 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.context.Conversation;
+import javax.faces.context.FacesContext;
+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.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.jboss.webbeans.CurrentManager;
+
+/**
+ * Filter for handling conversation propagation over redirects
+ *
+ * @author Nicklas Karlsson
+ *
+ */
+// TODO: Quick and dirty, not for actual usage yet ;-)
+public class WebBeansServletFilter implements Filter
+{
+
+ public void destroy()
+ {
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+ {
+ chain.doFilter(request, wrapResponse((HttpServletResponse) response));
+ }
+
+ private ServletResponse wrapResponse(HttpServletResponse response)
+ {
+ return new HttpServletResponseWrapper(response)
+ {
+ @Override
+ public void sendRedirect(String location) throws IOException
+ {
+ FacesContext context = FacesContext.getCurrentInstance();
+ Conversation conversation = CurrentManager.rootManager().getInstanceByType(Conversation.class);
+ if (conversation.isLongRunning())
+ {
+ location = context.getApplication().getViewHandler().getActionURL(context, location);
+ String appendedConversation = "?cid=" + conversation.getId();
+ location = context.getExternalContext().encodeActionURL(location + appendedConversation);
+ }
+ super.sendRedirect(location);
+ }
+ };
+ }
+
+ public void init(FilterConfig config) throws ServletException
+ {
+ }
+
+}
Modified: ri/trunk/webbeans-ri/src/main/resources/META-INF/faces-config.xml
===================================================================
--- ri/trunk/webbeans-ri/src/main/resources/META-INF/faces-config.xml 2009-02-08 22:52:28 UTC (rev 1463)
+++ ri/trunk/webbeans-ri/src/main/resources/META-INF/faces-config.xml 2009-02-09 07:58:39 UTC (rev 1464)
@@ -7,5 +7,8 @@
<application>
<el-resolver>org.jboss.webbeans.el.WebBeansELResolver</el-resolver>
</application>
-
+ <lifecycle>
+ <phase-listener>org.jboss.webbeans.jsf.WebBeansPhaseListener</phase-listener>
+ </lifecycle>
+
</faces-config>
More information about the weld-commits
mailing list