[webbeans-commits] Webbeans SVN: r1705 - in ri/trunk: webbeans-ri/src/main/java/org/jboss/webbeans/mock and 3 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Feb 25 10:22:10 EST 2009


Author: pete.muir at jboss.org
Date: 2009-02-25 10:22:09 -0500 (Wed, 25 Feb 2009)
New Revision: 1705

Added:
   ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/context/api/helpers/
   ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/ConcurrentHashMapBeanStore.java
Removed:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractBeanStore.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/SimpleBeanStore.java
Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.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/ServletLifecycle2.java
Log:
Expose MapBackedBeanStore in SPI and rename stuff

Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java (from rev 1701, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractBeanStore.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractAttributeBackedBeanStore.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -0,0 +1,181 @@
+/*
+ * 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.context.beanstore;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.context.Contextual;
+
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.EnumerationIterable;
+import org.jboss.webbeans.util.Names;
+
+/**
+ * Provides common BeanStore operations
+ * 
+ * @author Nicklas Karlsson
+ * 
+ */
+public abstract class AbstractAttributeBackedBeanStore implements BeanStore
+{
+   // The log provider
+   private static LogProvider log = Logging.getLogProvider(AbstractAttributeBackedBeanStore.class);
+
+   /**
+    * Gets a bean from the store
+    * 
+    * @param contextual The bean to get
+    * @return The instance
+    */
+   @SuppressWarnings("unchecked")
+   public <T> T get(Contextual<? extends T> contextual)
+   {
+      String key = getNamingScheme().getContextualKey(contextual);
+      T instance = (T) getAttribute(key);
+      log.trace("Looked for " + key + " and got " + instance);
+      return instance;
+   }
+
+   /**
+    * Removes an instance from the store
+    * 
+    * @param contextual The bean of the instance to remove
+    * @return The removed instance
+    */
+   public <T> T remove(Contextual<? extends T> contextual)
+   {
+      T instance = get(contextual);
+      String key = getNamingScheme().getContextualKey(contextual);
+      removeAttribute(key);
+      log.trace("Removed bean under key " + key);
+      return instance;
+   }
+
+   /**
+    * Clears the bean store
+    */
+   public void clear()
+   {
+      for (String attributeName : getFilteredAttributeNames())
+      {
+         removeAttribute(attributeName);
+      }
+      log.trace("Bean store cleared");
+   }
+
+   /**
+    * Returns the beans present in the store
+    * 
+    * @return The beans
+    */
+   public Iterable<Contextual<? extends Object>> getBeans()
+   {
+      List<Contextual<?>> contextuals = new ArrayList<Contextual<?>>();
+      BeanStoreNamingScheme namingScheme = getNamingScheme();
+      for (String attributeName : getFilteredAttributeNames())
+      {
+         int beanIndex = namingScheme.getBeanIndexFromKey(attributeName);
+         Contextual<?> contextual = CurrentManager.rootManager().getBeans().get(beanIndex);
+         contextuals.add(contextual);
+      }
+      return contextuals;
+   }
+
+   /**
+    * Gets the list of attribute names that is held by the bean store
+    * 
+    * @return The list of attribute names
+    */
+   private List<String> getFilteredAttributeNames()
+   {
+      List<String> attributeNames = new ArrayList<String>();
+      BeanStoreNamingScheme namingScheme = getNamingScheme();
+      for (String attributeName : new EnumerationIterable<String>(getAttributeNames()))
+      {
+         if (namingScheme.acceptKey(attributeName))
+         {
+            attributeNames.add(attributeName);
+         }
+      }
+      return attributeNames;
+   }
+
+   /**
+    * Puts an instance of a bean in the store
+    * 
+    * @param bean The key bean
+    * @param instance The instance
+    * @return The instance added
+    */
+   public <T> void put(Contextual<? extends T> bean, T instance)
+   {
+      String key = getNamingScheme().getContextualKey(bean);
+      setAttribute(key, instance);
+      log.trace("Added bean " + bean + " under key " + key);
+   }
+
+   /**
+    * Gets an attribute from the underlying storage
+    * 
+    * @param key The key of the attribute
+    * @return The data
+    */
+   protected abstract Object getAttribute(String key);
+
+   /**
+    * Removes an attribute from the underlying storage
+    * 
+    * @param key The attribute to remove
+    */
+   protected abstract void removeAttribute(String key);
+
+   /**
+    * Gets an enumeration of the attribute names present in the underlying
+    * storage
+    * 
+    * @return The attribute names
+    */
+   protected abstract Enumeration<String> getAttributeNames();
+
+   /**
+    * Sets an instance under a key in the underlying storage
+    * 
+    * @param key The key
+    * @param instance The instance
+    */
+   protected abstract void setAttribute(String key, Object instance);
+
+   /**
+    * Gets an naming scheme for handling keys in a bean store
+    * 
+    * @return The naming scheme
+    */
+   protected abstract BeanStoreNamingScheme getNamingScheme();
+
+
+   @Override
+   public String toString()
+   {
+      return "holding " + Names.count(getBeans()) + " instances";
+   }
+}

Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractBeanStore.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractBeanStore.java	2009-02-25 13:55:06 UTC (rev 1704)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/AbstractBeanStore.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -1,181 +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.context.beanstore;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-
-import javax.context.Contextual;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.util.EnumerationIterable;
-import org.jboss.webbeans.util.Names;
-
-/**
- * Provides common BeanStore operations
- * 
- * @author Nicklas Karlsson
- * 
- */
-public abstract class AbstractBeanStore implements BeanStore
-{
-   // The log provider
-   private static LogProvider log = Logging.getLogProvider(AbstractBeanStore.class);
-
-   /**
-    * Gets a bean from the store
-    * 
-    * @param contextual The bean to get
-    * @return The instance
-    */
-   @SuppressWarnings("unchecked")
-   public <T> T get(Contextual<? extends T> contextual)
-   {
-      String key = getNamingScheme().getContextualKey(contextual);
-      T instance = (T) getAttribute(key);
-      log.trace("Looked for " + key + " and got " + instance);
-      return instance;
-   }
-
-   /**
-    * Removes an instance from the store
-    * 
-    * @param contextual The bean of the instance to remove
-    * @return The removed instance
-    */
-   public <T> T remove(Contextual<? extends T> contextual)
-   {
-      T instance = get(contextual);
-      String key = getNamingScheme().getContextualKey(contextual);
-      removeAttribute(key);
-      log.trace("Removed bean under key " + key);
-      return instance;
-   }
-
-   /**
-    * Clears the bean store
-    */
-   public void clear()
-   {
-      for (String attributeName : getFilteredAttributeNames())
-      {
-         removeAttribute(attributeName);
-      }
-      log.trace("Bean store cleared");
-   }
-
-   /**
-    * Returns the beans present in the store
-    * 
-    * @return The beans
-    */
-   public Iterable<Contextual<? extends Object>> getBeans()
-   {
-      List<Contextual<?>> contextuals = new ArrayList<Contextual<?>>();
-      BeanStoreNamingScheme namingScheme = getNamingScheme();
-      for (String attributeName : getFilteredAttributeNames())
-      {
-         int beanIndex = namingScheme.getBeanIndexFromKey(attributeName);
-         Contextual<?> contextual = CurrentManager.rootManager().getBeans().get(beanIndex);
-         contextuals.add(contextual);
-      }
-      return contextuals;
-   }
-
-   /**
-    * Gets the list of attribute names that is held by the bean store
-    * 
-    * @return The list of attribute names
-    */
-   private List<String> getFilteredAttributeNames()
-   {
-      List<String> attributeNames = new ArrayList<String>();
-      BeanStoreNamingScheme namingScheme = getNamingScheme();
-      for (String attributeName : new EnumerationIterable<String>(getAttributeNames()))
-      {
-         if (namingScheme.acceptKey(attributeName))
-         {
-            attributeNames.add(attributeName);
-         }
-      }
-      return attributeNames;
-   }
-
-   /**
-    * Puts an instance of a bean in the store
-    * 
-    * @param bean The key bean
-    * @param instance The instance
-    * @return The instance added
-    */
-   public <T> void put(Contextual<? extends T> bean, T instance)
-   {
-      String key = getNamingScheme().getContextualKey(bean);
-      setAttribute(key, instance);
-      log.trace("Added bean " + bean + " under key " + key);
-   }
-
-   /**
-    * Gets an attribute from the underlying storage
-    * 
-    * @param key The key of the attribute
-    * @return The data
-    */
-   protected abstract Object getAttribute(String key);
-
-   /**
-    * Removes an attribute from the underlying storage
-    * 
-    * @param key The attribute to remove
-    */
-   protected abstract void removeAttribute(String key);
-
-   /**
-    * Gets an enumeration of the attribute names present in the underlying
-    * storage
-    * 
-    * @return The attribute names
-    */
-   protected abstract Enumeration<String> getAttributeNames();
-
-   /**
-    * Sets an instance under a key in the underlying storage
-    * 
-    * @param key The key
-    * @param instance The instance
-    */
-   protected abstract void setAttribute(String key, Object instance);
-
-   /**
-    * Gets an naming scheme for handling keys in a bean store
-    * 
-    * @return The naming scheme
-    */
-   protected abstract BeanStoreNamingScheme getNamingScheme();
-
-
-   @Override
-   public String toString()
-   {
-      return "holding " + Names.count(getBeans()) + " instances";
-   }
-}

Copied: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/ConcurrentHashMapBeanStore.java (from rev 1701, ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/SimpleBeanStore.java)
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/ConcurrentHashMapBeanStore.java	                        (rev 0)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/ConcurrentHashMapBeanStore.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -0,0 +1,61 @@
+/*
+ * 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.context.beanstore;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.context.Contextual;
+
+import org.jboss.webbeans.context.api.BeanStore;
+import org.jboss.webbeans.context.api.helpers.AbstractMapBackedBeanStore;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * A BeanStore that uses a HashMap as backing storage
+ * 
+ * @author Nicklas Karlsson
+ */
+public class ConcurrentHashMapBeanStore extends AbstractMapBackedBeanStore implements BeanStore
+{
+   private static LogProvider log = Logging.getLogProvider(ConcurrentHashMapBeanStore.class);
+   
+   // The backing map
+   protected Map<Contextual<? extends Object>, Object> delegate;
+
+   /**
+    * Constructor
+    */
+   public ConcurrentHashMapBeanStore()
+   {
+      delegate = new ConcurrentHashMap<Contextual<? extends Object>, Object>();
+   }
+
+   /**
+    * Gets the delegate for the store
+    * 
+    * @return The delegate
+    */
+   @Override
+   public Map<Contextual<? extends Object>, Object> delegate()
+   {
+      return delegate;
+   }
+
+}
\ No newline at end of file


Property changes on: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/ConcurrentHashMapBeanStore.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/SimpleBeanStore.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/SimpleBeanStore.java	2009-02-25 13:55:06 UTC (rev 1704)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/context/beanstore/SimpleBeanStore.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -1,139 +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.context.beanstore;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.context.Contextual;
-import javax.inject.manager.Bean;
-
-import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.log.LogProvider;
-import org.jboss.webbeans.log.Logging;
-
-import com.google.common.collect.ForwardingMap;
-
-/**
- * A BeanStore that uses a simple forwarding HashMap as backing storage
- * 
- * @author Nicklas Karlsson
- */
-public class SimpleBeanStore extends ForwardingMap<Contextual<? extends Object>, Object> implements BeanStore
-{
-   private static LogProvider log = Logging.getLogProvider(SimpleBeanStore.class);
-   
-   // The backing map
-   protected Map<Contextual<? extends Object>, Object> delegate;
-
-   /**
-    * Constructor
-    */
-   public SimpleBeanStore()
-   {
-      delegate = new ConcurrentHashMap<Contextual<? extends Object>, Object>();
-   }
-
-   /**
-    * Gets an instance from the store
-    * 
-    * @param The bean to look for
-    * @return An instance, if found
-    * 
-    * @see org.jboss.webbeans.context.api.BeanStore#get(Bean)
-    */
-   public <T extends Object> T get(Contextual<? extends T> bean)
-   {
-      @SuppressWarnings("unchecked")
-      T instance = (T) super.get(bean);
-      log.trace("Searched bean store for " + bean + " and got " + instance);
-      return instance;
-   }
-
-   /**
-    * Gets the delegate for the store
-    * 
-    * @return The delegate
-    */
-   @Override
-   public Map<Contextual<? extends Object>, Object> delegate()
-   {
-      return delegate;
-   }
-
-   /**
-    * Removed a instance from the store
-    * 
-    * @param bean the bean to remove
-    * @return The instance removed
-    *
-    * @see org.jboss.webbeans.context.api.BeanStore#remove(Bean)
-    */
-   public <T extends Object> T remove(Contextual<? extends T> bean)
-   {
-      @SuppressWarnings("unchecked")
-      T instance = (T) super.remove(bean);
-      log.trace("Removed instace " + instance + " for bean " + bean + " from the bean store");
-      return instance;
-   }
-
-   /**
-    * Clears the store
-    * 
-    * @see org.jboss.webbeans.context.api.BeanStore#clear()
-    */
-   public void clear()
-   {
-      delegate.clear();
-      log.trace("Bean store cleared");
-   }
-
-   /**
-    * Returns the beans contained in the store
-    * 
-    * @return The beans present
-    * 
-    * @see org.jboss.webbeans.context.api.BeanStore#getBeans()
-    */
-   public Set<Contextual<? extends Object>> getBeans()
-   {
-      return delegate.keySet();
-   }
-
-   /**
-    * Puts a bean instance under the bean key in the store
-    * 
-    * @param bean The bean
-    * @param instance the instance
-    * 
-    * @see org.jboss.webbeans.context.api.BeanStore#put(Bean, Object)
-    */
-   public <T> void put(Contextual<? extends T> bean, T instance)
-   {
-      delegate.put(bean, instance);
-      log.trace("Stored instance " + instance + " for bean " + bean + " in bean store");
-   }
-
-   @Override
-   public String toString()
-   {
-      return "holding " + delegate.size() + " instances";
-   }
-
-}
\ No newline at end of file

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java	2009-02-25 13:55:06 UTC (rev 1704)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/mock/MockLifecycle.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -20,7 +20,7 @@
 
 import org.jboss.webbeans.bootstrap.WebBeansBootstrap;
 import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.beanstore.SimpleBeanStore;
+import org.jboss.webbeans.context.beanstore.ConcurrentHashMapBeanStore;
 import org.jboss.webbeans.ejb.spi.EjbResolver;
 import org.jboss.webbeans.resources.spi.ResourceLoader;
 import org.jboss.webbeans.servlet.AbstractLifecycle;
@@ -33,9 +33,9 @@
    
    private final WebBeansBootstrap bootstrap;
    private final MockWebBeanDiscovery webBeanDiscovery;
-   private BeanStore applicationBeanStore = new SimpleBeanStore();
-   private BeanStore sessionBeanStore = new SimpleBeanStore();
-   private BeanStore requestBeanStore = new SimpleBeanStore();
+   private BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
+   private BeanStore sessionBeanStore = new ConcurrentHashMapBeanStore();
+   private BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
    
    public MockLifecycle()
    {
@@ -76,7 +76,7 @@
    public void beginApplication()
    {
       super.beginApplication("Mock", applicationBeanStore);
-      BeanStore requestBeanStore = new SimpleBeanStore();
+      BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
       super.beginDeploy(requestBeanStore);
       bootstrap.setEjbDiscovery(new MockEjbDiscovery(webBeanDiscovery.discoverWebBeanClasses()));
       bootstrap.boot();

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java	2009-02-25 13:55:06 UTC (rev 1704)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ApplicationBeanStore.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -22,7 +22,7 @@
 import javax.servlet.ServletContext;
 
 import org.jboss.webbeans.context.ApplicationContext;
-import org.jboss.webbeans.context.beanstore.AbstractBeanStore;
+import org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore;
 import org.jboss.webbeans.context.beanstore.BeanStoreNamingScheme;
 import org.jboss.webbeans.context.beanstore.PrefixBeanStoreNamingScheme;
 
@@ -33,7 +33,7 @@
  * 
  * @see org.jboss.webbeans.context.ApplicationContext
  */
-public class ApplicationBeanStore extends AbstractBeanStore
+public class ApplicationBeanStore extends AbstractAttributeBackedBeanStore
 {
    // The servlet context to use as backing map
    private ServletContext context;
@@ -50,7 +50,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#getAttribute()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#getAttribute()
     */
    @Override
    protected Object getAttribute(String key)
@@ -59,7 +59,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#getAttributeNames()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#getAttributeNames()
     */
    @SuppressWarnings("unchecked")
    @Override
@@ -69,7 +69,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#removeAttributes()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#removeAttributes()
     */
    @Override
    protected void removeAttribute(String key)
@@ -78,7 +78,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#setAttribute()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#setAttribute()
     */
    @Override
    protected void setAttribute(String key, Object instance)

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.java	2009-02-25 13:55:06 UTC (rev 1704)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/HttpSessionBeanStore.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -21,7 +21,7 @@
 import javax.servlet.http.HttpSession;
 
 import org.jboss.webbeans.context.SessionContext;
-import org.jboss.webbeans.context.beanstore.AbstractBeanStore;
+import org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore;
 import org.jboss.webbeans.context.beanstore.BeanStoreNamingScheme;
 import org.jboss.webbeans.context.beanstore.PrefixBeanStoreNamingScheme;
 
@@ -32,7 +32,7 @@
  * 
  * @see org.jboss.webbeans.context.ApplicationContext
  */
-public class HttpSessionBeanStore extends AbstractBeanStore
+public class HttpSessionBeanStore extends AbstractAttributeBackedBeanStore
 {
    // The HTTP session context to use as backing map
    private HttpSession session;
@@ -49,7 +49,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#getAttribute()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#getAttribute()
     */
    @Override
    protected Object getAttribute(String key)
@@ -58,7 +58,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#getAttributeNames()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#getAttributeNames()
     */
    @SuppressWarnings("unchecked")
    @Override
@@ -68,7 +68,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#removeAttributes()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#removeAttributes()
     */
    @Override
    protected void removeAttribute(String key)
@@ -77,7 +77,7 @@
    }
 
    /**
-    * @see org.jboss.webbeans.context.beanstore.AbstractBeanStore#setAttribute()
+    * @see org.jboss.webbeans.context.beanstore.AbstractAttributeBackedBeanStore#setAttribute()
     */
    @Override
    protected void setAttribute(String key, Object instance)

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-25 13:55:06 UTC (rev 1704)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -24,7 +24,7 @@
 import org.jboss.webbeans.CurrentManager;
 import org.jboss.webbeans.context.SessionContext;
 import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.beanstore.SimpleBeanStore;
+import org.jboss.webbeans.context.beanstore.ConcurrentHashMapBeanStore;
 import org.jboss.webbeans.log.LogProvider;
 import org.jboss.webbeans.log.Logging;
 
@@ -72,7 +72,7 @@
       ServletInitialization servletInitialization = new ServletInitialization(servletContext).initialize();
       super.initialize();
       super.beginApplication(servletContext.getServletContextName(), new ApplicationBeanStore(servletContext));
-      BeanStore requestBeanStore = new SimpleBeanStore();
+      BeanStore requestBeanStore = new ConcurrentHashMapBeanStore();
       super.beginDeploy(requestBeanStore);
       servletInitialization.start();
       super.endDeploy(requestBeanStore);
@@ -103,7 +103,7 @@
     */
    public void endSession(HttpSession session)
    {
-      BeanStore mockRequest = new SimpleBeanStore();
+      BeanStore mockRequest = new ConcurrentHashMapBeanStore();
       super.beginRequest("endSession-" + session.getId(), mockRequest);
       super.endSession(session.getId(), restoreSessionContext(session));
       super.endRequest("endSession-" + session.getId(), mockRequest);
@@ -133,7 +133,7 @@
     */
    public void beginRequest(HttpServletRequest request)
    {
-      BeanStore beanStore = new SimpleBeanStore();
+      BeanStore beanStore = new ConcurrentHashMapBeanStore();
       request.setAttribute(REQUEST_ATTRIBUTE_NAME, beanStore);
       super.beginRequest(request.getRequestURI(), beanStore);
       restoreSessionContext(request.getSession());

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle2.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle2.java	2009-02-25 13:55:06 UTC (rev 1704)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/servlet/ServletLifecycle2.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -24,7 +24,7 @@
 import org.jboss.webbeans.CurrentManager;
 import org.jboss.webbeans.context.SessionContext;
 import org.jboss.webbeans.context.api.BeanStore;
-import org.jboss.webbeans.context.beanstore.SimpleBeanStore;
+import org.jboss.webbeans.context.beanstore.ConcurrentHashMapBeanStore;
 
 /**
  * Implementation of the Web Beans lifecycle that can react to servlet events.
@@ -114,7 +114,7 @@
    public void beginRequest(HttpServletRequest request)
    {
       restoreSessionContext(request.getSession());
-      BeanStore beanStore = new SimpleBeanStore();
+      BeanStore beanStore = new ConcurrentHashMapBeanStore();
       request.setAttribute(REQUEST_ATTRIBUTE_NAME, beanStore);
       super.beginRequest(request.getRequestURI(), beanStore);
    }

Added: ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java
===================================================================
--- ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java	                        (rev 0)
+++ ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java	2009-02-25 15:22:09 UTC (rev 1705)
@@ -0,0 +1,90 @@
+package org.jboss.webbeans.context.api.helpers;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.context.Contextual;
+import javax.inject.manager.Bean;
+
+public abstract class AbstractMapBackedBeanStore
+{
+   
+   public AbstractMapBackedBeanStore()
+   {
+      super();
+   }
+
+   public abstract Map<Contextual<? extends Object>, Object> delegate();
+
+   /**
+    * Gets an instance from the store
+    * 
+    * @param The bean to look for
+    * @return An instance, if found
+    * 
+    * @see org.jboss.webbeans.context.api.BeanStore#get(Bean)
+    */
+   public <T extends Object> T get(Contextual<? extends T> bean)
+   {
+      @SuppressWarnings("unchecked")
+      T instance = (T) delegate().get(bean);
+      return instance;
+   }
+
+   /**
+    * Removed a instance from the store
+    * 
+    * @param bean the bean to remove
+    * @return The instance removed
+    *
+    * @see org.jboss.webbeans.context.api.BeanStore#remove(Bean)
+    */
+   public <T extends Object> T remove(Contextual<? extends T> bean)
+   {
+      @SuppressWarnings("unchecked")
+      T instance = (T) delegate().remove(bean);
+      return instance;
+   }
+
+   /**
+    * Clears the store
+    * 
+    * @see org.jboss.webbeans.context.api.BeanStore#clear()
+    */
+   public void clear()
+   {
+      delegate().clear();
+   }
+
+   /**
+    * Returns the beans contained in the store
+    * 
+    * @return The beans present
+    * 
+    * @see org.jboss.webbeans.context.api.BeanStore#getBeans()
+    */
+   public Set<Contextual<? extends Object>> getBeans()
+   {
+      return delegate().keySet();
+   }
+
+   /**
+    * Puts a bean instance under the bean key in the store
+    * 
+    * @param bean The bean
+    * @param instance the instance
+    * 
+    * @see org.jboss.webbeans.context.api.BeanStore#put(Bean, Object)
+    */
+   public <T> void put(Contextual<? extends T> bean, T instance)
+   {
+      delegate().put(bean, instance);
+   }
+
+   @Override
+   public String toString()
+   {
+      return "holding " + delegate().size() + " instances";
+   }
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/context/api/helpers/AbstractMapBackedBeanStore.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list