geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r559321 - /geronimo/server/trunk/modules/geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java
Date Wed, 25 Jul 2007 05:52:56 GMT
Author: gawor
Date: Tue Jul 24 22:52:54 2007
New Revision: 559321

URL: http://svn.apache.org/viewvc?view=rev&rev=559321
Log:
initialize SEIFactory once. This should help even more with perm gen problem and reduces heap
usage. Daytrader also seems much happier in the webservices mode too.

Modified:
    geronimo/server/trunk/modules/geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java

Modified: geronimo/server/trunk/modules/geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java?view=diff&rev=559321&r1=559320&r2=559321
==============================================================================
--- geronimo/server/trunk/modules/geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java
(original)
+++ geronimo/server/trunk/modules/geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java
Tue Jul 24 22:52:54 2007
@@ -59,31 +59,25 @@
     }
 
     public Object getContent() throws NamingException {
-        Class serviceInterface;
-        try {
-            serviceInterface = classLoader.loadClass(serviceInterfaceClassName);
-        } catch (ClassNotFoundException e) {
-            throw (NamingException)new NamingException("Could not load service interface
class " + serviceInterfaceClassName).initCause(e);
-        }
-        Object serviceInstance = createServiceInterfaceProxy(serviceInterface, seiPortNameToFactoryMap,
seiClassNameToFactoryMap, classLoader);
-        for (Iterator iterator = seiPortNameToFactoryMap.values().iterator(); iterator.hasNext();)
{
-            SEIFactoryImpl seiFactory = (SEIFactoryImpl) iterator.next();
-            try {
-                seiFactory.initialize(serviceInstance, classLoader);
-            } catch (ClassNotFoundException e) {
-                throw (NamingException)new NamingException("Could not load service interface
class; " + e.getMessage()).initCause(e);
-            }
-        }
-
+        Object serviceInstance = createServiceInterfaceProxy(serviceInterfaceClassName, seiPortNameToFactoryMap,
seiClassNameToFactoryMap, classLoader);
         return serviceInstance;
     }
 
-    private Object createServiceInterfaceProxy(Class serviceInterface, Map seiPortNameToFactoryMap,
Map seiClassNameToFactoryMap, ClassLoader classLoader) throws NamingException {
-        if (this.serviceConstructor == null) {
+    private Object createServiceInterfaceProxy(String serviceInterfaceClassName, Map seiPortNameToFactoryMap,
Map seiClassNameToFactoryMap, ClassLoader classLoader) throws NamingException {
+        boolean initialize = (this.serviceConstructor == null);
+        
+        if (initialize) {  
+            Class serviceInterface;
+            try {
+                serviceInterface = classLoader.loadClass(serviceInterfaceClassName);
+            } catch (ClassNotFoundException e) {
+                throw (NamingException)new NamingException("Could not load service interface
class " + serviceInterfaceClassName).initCause(e);
+            }
+                
             // create method interceptors
             Callback callback = new ServiceMethodInterceptor(seiPortNameToFactoryMap);
             this.methodInterceptors = new Callback[]{SerializableNoOp.INSTANCE, callback};
-
+         
             // create service class
             Enhancer enhancer = new Enhancer();
             enhancer.setClassLoader(classLoader);
@@ -106,11 +100,26 @@
         Object[] arguments =
             new Object[] {seiPortNameToFactoryMap, seiClassNameToFactoryMap};
         
+        Object serviceInstance = null;
+        
         try {
-            return this.serviceConstructor.newInstance(arguments);
+            serviceInstance = this.serviceConstructor.newInstance(arguments);
         } catch (InvocationTargetException e) {
             throw (NamingException)new NamingException("Could not construct service instance").initCause(e.getTargetException());
         }
+        
+        if (initialize) {
+            for (Iterator iterator = seiPortNameToFactoryMap.values().iterator(); iterator.hasNext();)
{
+                SEIFactoryImpl seiFactory = (SEIFactoryImpl) iterator.next();
+                try {
+                    seiFactory.initialize(serviceInstance, classLoader);
+                } catch (ClassNotFoundException e) {
+                    throw (NamingException)new NamingException("Could not load service interface
class; " + e.getMessage()).initCause(e);
+                }
+            }
+        }
+        
+        return serviceInstance;
     }
 
 }



Mime
View raw message