tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r1041646 - in /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi: OWBContext.java ThreadSingletonServiceImpl.java
Date Thu, 02 Dec 2010 23:39:22 GMT
Author: dblevins
Date: Thu Dec  2 23:39:21 2010
New Revision: 1041646

URL: http://svn.apache.org/viewvc?rev=1041646&view=rev
Log:
Related changes for OWB-503: Reduce static synchronized hashmap usage

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContext.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContext.java?rev=1041646&r1=1041645&r2=1041646&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContext.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContext.java
Thu Dec  2 23:39:21 2010
@@ -20,6 +20,8 @@
 
 package org.apache.openejb.cdi;
 
+import org.apache.webbeans.config.WebBeansContext;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -28,17 +30,17 @@ import java.util.Map;
  */
 public class OWBContext {
 
-    private final Map<String, Object> singletons;
+    private WebBeansContext webBeansContext;
 
     public OWBContext() {
-        singletons = new HashMap<String, Object>();
+        webBeansContext = new WebBeansContext();
     }
 
-    public OWBContext(Map<String, Object> singletons) {
-        this.singletons = singletons;
+    public OWBContext(WebBeansContext webBeansContext) {
+        this.webBeansContext = webBeansContext;
     }
 
-    public Map<String, Object> getSingletons() {
-        return singletons;
+    public WebBeansContext getSingletons() {
+        return webBeansContext;
     }
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java?rev=1041646&r1=1041645&r2=1041646&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java
Thu Dec  2 23:39:21 2010
@@ -84,13 +84,6 @@ public class ThreadSingletonServiceImpl 
     }
 
     private void contextMessage(OWBContext newOWBContext, String prefix) {
-        if (logger.isDebugEnabled()) {
-            StringBuilder b = new StringBuilder(" owbContext: " + newOWBContext + "\n");
-            for (Object service : newOWBContext.getSingletons().values()) {
-                b.append("  " + service + "\n");
-            }
-            logger.debug(b.toString());
-        }
     }
 
     @Override
@@ -102,24 +95,7 @@ public class ThreadSingletonServiceImpl 
     @Override
     public Object get(Object key, String singletonClassName) {
         OWBContext context = getContext();
-        contextMessage(context, "ThreadSingletonService looking for " + singletonClassName);
-        Object service = context.getSingletons().get(singletonClassName);
-        if (service == null) {
-            try {
-                Class clazz = classLoader.loadClass(singletonClassName);
-                service = clazz.newInstance();
-            } catch (ClassNotFoundException e) {
-                throw new WebBeansException("Could not locate requested class " + singletonClassName
+ " in classloader " + classLoader, e);
-            } catch (InstantiationException e) {
-                throw new WebBeansException("Could not create instance of class " + singletonClassName,
e);
-            } catch (IllegalAccessException e) {
-                throw new WebBeansException("Could not create instance of class " + singletonClassName,
e);
-            } catch (NoClassDefFoundError e) {
-                throw new WebBeansException("Could not locate requested class " + singletonClassName
+ " in classloader " + classLoader, e);
-            }
-            context.getSingletons().put(singletonClassName, service);
-        }
-        return service;
+        return context.getSingletons().get(singletonClassName);
     }
 
     private OWBContext getContext() {
@@ -138,7 +114,7 @@ public class ThreadSingletonServiceImpl 
 
     @Override
     public boolean isExist(Object key, String singletonClassName) {
-        return getContext().getSingletons().containsKey(singletonClassName);
+        throw new UnsupportedOperationException("isExist is never called");
     }
 
     @Override



Mime
View raw message