incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r555333 - in /incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba: CorbaConduit.java TypeMapCache.java utils/CorbaBindingHelper.java
Date Wed, 11 Jul 2007 16:40:59 GMT
Author: bravi
Date: Wed Jul 11 09:40:56 2007
New Revision: 555333

URL: http://svn.apache.org/viewvc?view=rev&rev=555333
Log:
[YOKO-397] - Using a WeakHashMap to cleanup the TypeFactory Cache & moved the ORB shutdown
to the finalize method in CorbaConduit.

Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/TypeMapCache.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaBindingHelper.java

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java?view=diff&rev=555333&r1=555332&r2=555333
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaConduit.java
Wed Jul 11 09:40:56 2007
@@ -80,9 +80,7 @@
         endpointInfo = ei;
         target = getTargetReference(ref);
         orbConfig = config;
-        CorbaBindingHelper.destroyDefaultORB();
         orb = CorbaBindingHelper.getDefaultORB(config);
-        TypeMapCache.clear();
         typeMap = TypeMapCache.get(ei.getService());
     }
 
@@ -130,6 +128,13 @@
                 LOG.log(Level.SEVERE, "Could not build the corba request");
                 throw new CorbaBindingException(ex);
             }
+        }
+    }
+
+    protected void finalize() throws Throwable {
+        super.finalize();
+        if (orb != null) {
+            orb.destroy();
         }
     }
 

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/TypeMapCache.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/TypeMapCache.java?view=diff&rev=555333&r1=555332&r2=555333
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/TypeMapCache.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/TypeMapCache.java
Wed Jul 11 09:40:56 2007
@@ -18,9 +18,9 @@
  */
 package org.apache.yoko.bindings.corba;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.WeakHashMap;
 
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
@@ -29,7 +29,7 @@
 public class TypeMapCache {
 
     private static Map<ServiceInfo, CorbaTypeMap> cache =
-        new HashMap<ServiceInfo, CorbaTypeMap>();
+        new WeakHashMap<ServiceInfo, CorbaTypeMap>();
 
     public static CorbaTypeMap get(ServiceInfo service) {
         if (service != null) {

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaBindingHelper.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaBindingHelper.java?view=diff&rev=555333&r1=555332&r2=555333
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaBindingHelper.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/utils/CorbaBindingHelper.java
Wed Jul 11 09:40:56 2007
@@ -36,34 +36,20 @@
     private static final Logger LOG = LogUtils.getL7dLogger(CorbaBindingHelper.class);
     private static Map<String, ORB> orbList = new HashMap<String, ORB>();
     private static Map<String, Integer> orbUseCount = new HashMap<String, Integer>();
-    private static ORB defaultORB;
     
     public static ORB getDefaultORB(OrbConfig config) {
+        Properties props = System.getProperties();
+        props.put("org.omg.CORBA.ORBClass", config.getOrbClass());
+        props.put("org.omg.CORBA.ORBSingletonClass", config.getOrbSingletonClass());
+        props.put("yoko.orb.id", "Yoko-Binding");
+        List<String> orbArgs = config.getOrbArgs();
+        ORB defaultORB = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
         if (defaultORB == null) {
-            Properties props = System.getProperties();
-            props.put("org.omg.CORBA.ORBClass", config.getOrbClass());
-            props.put("org.omg.CORBA.ORBSingletonClass", config.getOrbSingletonClass());
-            props.put("yoko.orb.id", "Yoko-Binding");
-            List<String> orbArgs = config.getOrbArgs();
-            defaultORB = ORB.init(orbArgs.toArray(new String[orbArgs.size()]), props);
-            if (defaultORB == null) {
-                LOG.severe("Could not create instance of the ORB");
-                throw new CorbaBindingException("Could not create instance of the ORB");
-            }
+            LOG.severe("Could not create instance of the ORB");
+            throw new CorbaBindingException("Could not create instance of the ORB");
         }
         return defaultORB;
-    }
-    
-    public static void destroyDefaultORB() {
-        try {
-            if (defaultORB != null) {
-                defaultORB.shutdown(true);
-                defaultORB = null;
-            }
-        } catch (Exception ex) {
-            throw new CorbaBindingException(ex);
-        }
-    }
+    }    
 
     public static ORB createAddressSpecificORB(String address, OrbConfig config) {
         ORB orb = null;



Mime
View raw message