[webbeans-commits] Webbeans SVN: r326 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: servlet and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Tue Nov 18 06:32:55 EST 2008
Author: nickarls
Date: 2008-11-18 06:32:55 -0500 (Tue, 18 Nov 2008)
New Revision: 326
Modified:
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java
Log:
Minor, make SessionBeanMap more general
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java 2008-11-18 11:13:38 UTC (rev 325)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionBeanMap.java 2008-11-18 11:32:55 UTC (rev 326)
@@ -35,18 +35,18 @@
*/
public class SessionBeanMap implements BeanMap
{
- private static final String KEY_PREFIX = "SessionScoped#";
-
private HttpSession session;
private ManagerImpl manager;
private BeanMap cache;
+ private String keyPrefix;
- public SessionBeanMap(ManagerImpl manager)
+ public SessionBeanMap(ManagerImpl manager, String keyPrefix)
{
super();
this.manager = manager;
// A "normal" BeanMap is used as cache
cache = new SimpleBeanMap();
+ this.keyPrefix = keyPrefix;
}
/**
@@ -80,7 +80,7 @@
@SuppressWarnings("unused")
private String getBeanKey(Bean<?> bean) {
// TODO Append scope to in order to make class usable by multiple contexts
- return KEY_PREFIX + manager.getBeans().indexOf(bean);
+ return keyPrefix + manager.getBeans().indexOf(bean);
}
/**
@@ -169,8 +169,8 @@
Enumeration names = session.getAttributeNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
- if (name.startsWith(KEY_PREFIX)) {
- String id = name.substring(KEY_PREFIX.length());
+ if (name.startsWith(keyPrefix)) {
+ String id = name.substring(keyPrefix.length());
Bean<?> bean = manager.getBeans().get(Integer.parseInt(id));
beans.add(bean);
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-11-18 11:13:38 UTC (rev 325)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/contexts/SessionContext.java 2008-11-18 11:32:55 UTC (rev 326)
@@ -33,7 +33,7 @@
{
super(SessionScoped.class);
// Replaces the BeanMap implementation with a session-based one
- beans.set(new SessionBeanMap(manager));
+ beans.set(new SessionBeanMap(manager, getScopeType().getName() + "#"));
}
@Override
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-11-18 11:13:38 UTC (rev 325)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java 2008-11-18 11:32:55 UTC (rev 326)
@@ -6,7 +6,6 @@
import javax.webbeans.SessionScoped;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.contexts.SessionBeanMap;
import org.jboss.webbeans.contexts.SessionContext;
import org.jboss.webbeans.util.JNDI;
More information about the weld-commits
mailing list