[weld-commits] Weld SVN: r5426 - in core/trunk: impl/src/main/java/org/jboss/weld/bootstrap and 2 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Jan 11 17:24:43 EST 2010


Author: pete.muir at jboss.org
Date: 2010-01-11 17:24:42 -0500 (Mon, 11 Jan 2010)
New Revision: 5426

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/serialization/
   core/trunk/impl/src/main/java/org/jboss/weld/serialization/ContextualStoreImpl.java
Removed:
   core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/ContainerState.java
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
Log:
reorg

Modified: core/trunk/impl/src/main/java/org/jboss/weld/ContainerState.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ContainerState.java	2010-01-11 22:19:26 UTC (rev 5425)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ContainerState.java	2010-01-11 22:24:42 UTC (rev 5426)
@@ -1,7 +1,7 @@
 package org.jboss.weld;
 
 /**
- * Container status
+ * Application container instance state
  * @author pmuir
  *
  */

Deleted: core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java	2010-01-11 22:19:26 UTC (rev 5425)
+++ core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java	2010-01-11 22:24:42 UTC (rev 5426)
@@ -1,129 +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.weld;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.PassivationCapable;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.Maps;
-
-import org.jboss.weld.serialization.spi.ContextualStore;
-import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
-import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
-import org.jboss.weld.context.SerializableContextualImpl;
-import org.jboss.weld.context.SerializableContextualInstanceImpl;
-
-/**
- * Implementation of {@link org.jboss.weld.serialization.spi.ContextualStore}
- *
- * @author Pete Muir
- *
- */
-public class ContextualStoreImpl implements ContextualStore
-{
-   
-   private static final String GENERATED_ID_PREFIX = ContextualStoreImpl.class.getName();
-   
-   // The map containing container-local contextuals
-   private final BiMap<Contextual<?>, String> contextuals;
-   
-   // The map containing passivation capable contextuals
-   private final ConcurrentMap<String, Contextual<?>> passivationCapableContextuals;
-   
-   private final AtomicInteger idGenerator;
-   
-   public ContextualStoreImpl()
-   {
-      this.idGenerator = new AtomicInteger(0);
-      BiMap<Contextual<?>, String> map = HashBiMap.create();
-      // TODO Somehow remove this sync if it shows bad in a profiler
-      this.contextuals = Maps.synchronizedBiMap(map);
-      this.passivationCapableContextuals = new ConcurrentHashMap<String, Contextual<?>>();
-   }
-
-   /**
-    * Given a particular id, return the correct contextual. For contextuals
-    * which aren't passivation capable, the contextual can't be found in another
-    * container, and null will be returned.
-    * 
-    * @param id An identifier for the contextual
-    * @return the contextual
-    */
-   @SuppressWarnings("unchecked")
-   public <C extends Contextual<I>, I> C getContextual(String id)
-   {
-      if (id.startsWith(GENERATED_ID_PREFIX))
-      {
-         return (C) contextuals.inverse().get(id);
-      }
-      else
-      {
-         return (C) passivationCapableContextuals.get(id);
-      }
-   }
-   
-   /**
-    * Add a contextual (if not already present) to the store, and return
-    * it's id. If the contextual is passivation capable, it's id will
-    * be used, otherwise an id will be generated
-    * 
-    * @param contextual the contexutal to add
-    * @return the current id for the contextual
-    */
-   public String putIfAbsent(Contextual<?> contextual)
-   {
-      if (contextual instanceof PassivationCapable)
-      {
-         PassivationCapable passivationCapable = (PassivationCapable) contextual;
-         passivationCapableContextuals.putIfAbsent(passivationCapable.getId(), contextual);
-         return passivationCapable.getId();
-      }
-      else if (contextuals.containsKey(contextual))
-      {
-         return contextuals.get(contextual);
-      }
-      else
-      {
-         String id = new StringBuilder().append(GENERATED_ID_PREFIX).append(idGenerator.incrementAndGet()).toString();
-         contextuals.put(contextual, id);
-         return id;
-      }
-   }
-
-   public <C extends Contextual<I>, I> SerializableContextual<C, I> getSerializableContextual(Contextual<I> contextual)
-   {
-      return new SerializableContextualImpl(contextual);
-   }
-
-   public <C extends Contextual<I>, I> SerializableContextualInstance<C, I> getSerializableContextualInstance(Contextual<I> contextual, I instance, CreationalContext<I> creationalContext)
-   {
-      return new SerializableContextualInstanceImpl(contextual, instance, creationalContext);
-   }
-
-   public void cleanup()
-   {
-      contextuals.clear();
-      passivationCapableContextuals.clear();
-   }
-}

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2010-01-11 22:19:26 UTC (rev 5425)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2010-01-11 22:24:42 UTC (rev 5426)
@@ -40,7 +40,6 @@
 
 import org.jboss.weld.Container;
 import org.jboss.weld.ContainerState;
-import org.jboss.weld.ContextualStoreImpl;
 import org.jboss.weld.bean.builtin.BeanManagerBean;
 import org.jboss.weld.bootstrap.api.Bootstrap;
 import org.jboss.weld.bootstrap.api.Environment;
@@ -83,6 +82,7 @@
 import org.jboss.weld.resources.SingleThreadScheduledExecutorServiceFactory;
 import org.jboss.weld.resources.spi.ResourceLoader;
 import org.jboss.weld.resources.spi.ScheduledExecutorServiceFactory;
+import org.jboss.weld.serialization.ContextualStoreImpl;
 import org.jboss.weld.serialization.spi.ContextualStore;
 import org.jboss.weld.servlet.HttpSessionManager;
 import org.jboss.weld.servlet.ServletApiAbstraction;

Copied: core/trunk/impl/src/main/java/org/jboss/weld/serialization/ContextualStoreImpl.java (from rev 5424, core/trunk/impl/src/main/java/org/jboss/weld/ContextualStoreImpl.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/serialization/ContextualStoreImpl.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/serialization/ContextualStoreImpl.java	2010-01-11 22:24:42 UTC (rev 5426)
@@ -0,0 +1,129 @@
+/*
+ * 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.weld.serialization;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.enterprise.context.spi.Contextual;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.PassivationCapable;
+
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Maps;
+
+import org.jboss.weld.serialization.spi.ContextualStore;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.serialization.spi.helpers.SerializableContextualInstance;
+import org.jboss.weld.context.SerializableContextualImpl;
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
+
+/**
+ * Implementation of {@link org.jboss.weld.serialization.spi.ContextualStore}
+ *
+ * @author Pete Muir
+ *
+ */
+public class ContextualStoreImpl implements ContextualStore
+{
+   
+   private static final String GENERATED_ID_PREFIX = ContextualStoreImpl.class.getName();
+   
+   // The map containing container-local contextuals
+   private final BiMap<Contextual<?>, String> contextuals;
+   
+   // The map containing passivation capable contextuals
+   private final ConcurrentMap<String, Contextual<?>> passivationCapableContextuals;
+   
+   private final AtomicInteger idGenerator;
+   
+   public ContextualStoreImpl()
+   {
+      this.idGenerator = new AtomicInteger(0);
+      BiMap<Contextual<?>, String> map = HashBiMap.create();
+      // TODO Somehow remove this sync if it shows bad in a profiler
+      this.contextuals = Maps.synchronizedBiMap(map);
+      this.passivationCapableContextuals = new ConcurrentHashMap<String, Contextual<?>>();
+   }
+
+   /**
+    * Given a particular id, return the correct contextual. For contextuals
+    * which aren't passivation capable, the contextual can't be found in another
+    * container, and null will be returned.
+    * 
+    * @param id An identifier for the contextual
+    * @return the contextual
+    */
+   @SuppressWarnings("unchecked")
+   public <C extends Contextual<I>, I> C getContextual(String id)
+   {
+      if (id.startsWith(GENERATED_ID_PREFIX))
+      {
+         return (C) contextuals.inverse().get(id);
+      }
+      else
+      {
+         return (C) passivationCapableContextuals.get(id);
+      }
+   }
+   
+   /**
+    * Add a contextual (if not already present) to the store, and return
+    * it's id. If the contextual is passivation capable, it's id will
+    * be used, otherwise an id will be generated
+    * 
+    * @param contextual the contexutal to add
+    * @return the current id for the contextual
+    */
+   public String putIfAbsent(Contextual<?> contextual)
+   {
+      if (contextual instanceof PassivationCapable)
+      {
+         PassivationCapable passivationCapable = (PassivationCapable) contextual;
+         passivationCapableContextuals.putIfAbsent(passivationCapable.getId(), contextual);
+         return passivationCapable.getId();
+      }
+      else if (contextuals.containsKey(contextual))
+      {
+         return contextuals.get(contextual);
+      }
+      else
+      {
+         String id = new StringBuilder().append(GENERATED_ID_PREFIX).append(idGenerator.incrementAndGet()).toString();
+         contextuals.put(contextual, id);
+         return id;
+      }
+   }
+
+   public <C extends Contextual<I>, I> SerializableContextual<C, I> getSerializableContextual(Contextual<I> contextual)
+   {
+      return new SerializableContextualImpl(contextual);
+   }
+
+   public <C extends Contextual<I>, I> SerializableContextualInstance<C, I> getSerializableContextualInstance(Contextual<I> contextual, I instance, CreationalContext<I> creationalContext)
+   {
+      return new SerializableContextualInstanceImpl(contextual, instance, creationalContext);
+   }
+
+   public void cleanup()
+   {
+      contextuals.clear();
+      passivationCapableContextuals.clear();
+   }
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/serialization/ContextualStoreImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java	2010-01-11 22:19:26 UTC (rev 5425)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/deployment/structure/resolution/AccessibleManagerResolutionTest.java	2010-01-11 22:24:42 UTC (rev 5426)
@@ -5,7 +5,6 @@
 import javax.enterprise.inject.spi.Bean;
 
 import org.jboss.weld.Container;
-import org.jboss.weld.ContextualStoreImpl;
 import org.jboss.weld.bean.ManagedBean;
 import org.jboss.weld.bean.RIBean;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
@@ -18,6 +17,7 @@
 import org.jboss.weld.metadata.TypeStore;
 import org.jboss.weld.metadata.cache.MetaAnnotationStore;
 import org.jboss.weld.resources.ClassTransformer;
+import org.jboss.weld.serialization.ContextualStoreImpl;
 import org.jboss.weld.serialization.spi.ContextualStore;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;



More information about the weld-commits mailing list