geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r559301 - in /geronimo/server/trunk/modules: geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
Date Wed, 25 Jul 2007 03:25:15 GMT
Author: gawor
Date: Tue Jul 24 20:25:14 2007
New Revision: 559301

URL: http://svn.apache.org/viewvc?view=rev&rev=559301
Log:
cache generated classes for service-refs - should reduce perm gen OOM errors (jaxrpc needs
one more fix)

Modified:
    geronimo/server/trunk/modules/geronimo-axis/src/main/java/org/apache/geronimo/axis/client/AxisServiceReference.java
    geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.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=559301&r1=559300&r2=559301
==============================================================================
--- 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 20:25:14 2007
@@ -44,6 +44,10 @@
     private Map seiClassNameToFactoryMap;
     private ClassLoader classLoader;
 
+    private FastConstructor serviceConstructor;
+    private Callback[] methodInterceptors;
+    private Class enhancedServiceClass;
+
     public AxisServiceReference(String serviceInterfaceClassName, Map seiPortNameToFactoryMap,
Map seiClassNameToFactoryMap) {
         this.serviceInterfaceClassName = serviceInterfaceClassName;
         this.seiPortNameToFactoryMap = seiPortNameToFactoryMap;
@@ -75,24 +79,35 @@
     }
 
     private Object createServiceInterfaceProxy(Class serviceInterface, Map seiPortNameToFactoryMap,
Map seiClassNameToFactoryMap, ClassLoader classLoader) throws NamingException {
-
-        Callback callback = new ServiceMethodInterceptor(seiPortNameToFactoryMap);
-        Callback[] methodInterceptors = new Callback[]{SerializableNoOp.INSTANCE, callback};
-
-        Enhancer enhancer = new Enhancer();
-        enhancer.setClassLoader(classLoader);
-        enhancer.setSuperclass(ServiceImpl.class);
-        enhancer.setInterfaces(new Class[]{serviceInterface});
-        enhancer.setCallbackFilter(new NoOverrideCallbackFilter(Service.class));
-        enhancer.setCallbackTypes(new Class[]{NoOp.class, MethodInterceptor.class});
-        enhancer.setUseFactory(false);
-        enhancer.setUseCache(false);
-        Class serviceClass = enhancer.createClass();
-
-        Enhancer.registerCallbacks(serviceClass, methodInterceptors);
-        FastConstructor constructor = FastClass.create(serviceClass).getConstructor(SERVICE_CONSTRUCTOR_TYPES);
+        if (this.serviceConstructor == null) {
+            // 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);
+            enhancer.setSuperclass(ServiceImpl.class);
+            enhancer.setInterfaces(new Class[]{serviceInterface});
+            enhancer.setCallbackFilter(new NoOverrideCallbackFilter(Service.class));
+            enhancer.setCallbackTypes(new Class[]{NoOp.class, MethodInterceptor.class});
+            enhancer.setUseFactory(false);
+            enhancer.setUseCache(false);
+            this.enhancedServiceClass = enhancer.createClass();
+
+            // get constructor
+            this.serviceConstructor = 
+                FastClass.create(this.enhancedServiceClass).getConstructor(SERVICE_CONSTRUCTOR_TYPES);
+        }
+        
+        // associate the method interceptors with the generated service class on the current
thread
+        Enhancer.registerCallbacks(this.enhancedServiceClass, this.methodInterceptors);
+        
+        Object[] arguments =
+            new Object[] {seiPortNameToFactoryMap, seiClassNameToFactoryMap};
+        
         try {
-            return constructor.newInstance(new Object[]{seiPortNameToFactoryMap, seiClassNameToFactoryMap});
+            return this.serviceConstructor.newInstance(arguments);
         } catch (InvocationTargetException e) {
             throw (NamingException)new NamingException("Could not construct service instance").initCause(e.getTargetException());
         }

Modified: geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java?view=diff&rev=559301&r1=559300&r2=559301
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jaxws/src/main/java/org/apache/geronimo/jaxws/client/JAXWSServiceReference.java
Tue Jul 24 20:25:14 2007
@@ -46,6 +46,7 @@
     private static final Log LOG = LogFactory.getLog(JAXWSServiceReference.class);
     private static final Class[] URL_SERVICE_NAME_CONSTRUCTOR =
         new Class[] { URL.class, QName.class };
+    
     protected String serviceClassName;
     protected ClassLoader classLoader;
     protected AbstractName moduleName;
@@ -55,17 +56,21 @@
     protected String handlerChainsXML;
     protected Map<Object, EndpointInfo> seiInfoMap;
     protected String referenceClassName;
+    
+    protected Class enhancedServiceClass;
+    protected Callback[] methodInterceptors;
+    protected FastConstructor serviceConstructor;
 
     public JAXWSServiceReference(String handlerChainsXML, Map<Object, EndpointInfo>
seiInfoMap, AbstractName name, QName serviceQName, URI wsdlURI, String referenceClassName,
String serviceClassName) {
         this.handlerChainsXML = handlerChainsXML;
         this.seiInfoMap = seiInfoMap;
-        moduleName = name;
+        this.moduleName = name;
         this.serviceQName = serviceQName;
         this.wsdlURI = wsdlURI;
         this.referenceClassName = referenceClassName;
         this.serviceClassName = serviceClassName;
     }
-
+    
     public void setClassLoader(ClassLoader classLoader) {
         this.classLoader = classLoader;
     }
@@ -149,29 +154,35 @@
     }
     
     private Service createServiceProxy(Class superClass, ClassLoader classLoader, QName serviceName,
URL wsdlLocation) throws NamingException {
-        Callback callback = getPortMethodInterceptor();
-        Callback[] methodInterceptors = new Callback[]{NoOp.INSTANCE, callback};
-
-        Enhancer enhancer = new Enhancer();
-        enhancer.setClassLoader(classLoader);
-        enhancer.setSuperclass(superClass);
-        enhancer.setCallbackFilter(new PortMethodFilter());
-        enhancer.setCallbackTypes(new Class[]{NoOp.class, MethodInterceptor.class});
-        enhancer.setUseFactory(false);
-        enhancer.setUseCache(false);
-        Class serviceClass = enhancer.createClass();
-
-        Enhancer.registerCallbacks(serviceClass, methodInterceptors);
-
-        FastConstructor constructor =
-            FastClass.create(serviceClass).getConstructor(URL_SERVICE_NAME_CONSTRUCTOR);
-        Object[] arguments =
-            new Object[]{wsdlLocation, serviceName};
-
+        if (this.serviceConstructor == null) {            
+            // create method interceptors
+            Callback callback = getPortMethodInterceptor();
+            this.methodInterceptors = new Callback[] {NoOp.INSTANCE, callback};
+
+            // create service class
+            Enhancer enhancer = new Enhancer();
+            enhancer.setClassLoader(classLoader);
+            enhancer.setSuperclass(superClass);
+            enhancer.setCallbackFilter(new PortMethodFilter());
+            enhancer.setCallbackTypes(new Class[] { NoOp.class, MethodInterceptor.class });
+            enhancer.setUseFactory(false);
+            enhancer.setUseCache(false);
+            this.enhancedServiceClass = enhancer.createClass(); 
+
+            // get constructor
+            this.serviceConstructor = 
+                FastClass.create(this.enhancedServiceClass).getConstructor(URL_SERVICE_NAME_CONSTRUCTOR);
+        }
+        
         LOG.debug("Initializing service with: " + wsdlLocation + " " + serviceName);
 
+        // associate the method interceptors with the generated service class on the current
thread
+        Enhancer.registerCallbacks(this.enhancedServiceClass, this.methodInterceptors);
+        
+        Object[] arguments = new Object[] {wsdlLocation, serviceName};
+        
         try {
-            return (Service)constructor.newInstance(arguments);
+            return (Service)this.serviceConstructor.newInstance(arguments);
         } catch (InvocationTargetException e) {
             NamingException exception = new NamingException("Could not construct service
proxy");
             exception.initCause(e.getTargetException());



Mime
View raw message