axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barre...@apache.org
Subject svn commit: r649660 - in /webservices/axis2/trunk/java/modules/metadata: src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java test/org/apache/axis2/jaxws/description/ReleaseAxisResourcesTests.java
Date Fri, 18 Apr 2008 19:13:41 GMT
Author: barrettj
Date: Fri Apr 18 12:13:36 2008
New Revision: 649660

URL: http://svn.apache.org/viewvc?rev=649660&view=rev
Log:
Fix for changed commited to 649213.  Those changes break ?xsd since the schemaList has been
released.
Added config property control to whether the AxisService resources will be released.  Default
is that they will not be released.
Added tests to verify the default and enabled behavior.

Added:
    webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/ReleaseAxisResourcesTests.java
Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=649660&r1=649659&r2=649660&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
Fri Apr 18 12:13:36 2008
@@ -20,6 +20,7 @@
 package org.apache.axis2.jaxws.description.impl;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
 import org.apache.axis2.Constants.Configuration;
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.context.ConfigurationContext;
@@ -98,6 +99,9 @@
         implements EndpointDescription, EndpointDescriptionJava, EndpointDescriptionWSDL
{
     private ServiceDescriptionImpl parentServiceDescription;
     private AxisService axisService;
+    // In some environments some of the resources on an AxisService can lead to OOMs.
+    // However, releasing these resources can have other implications.  
+    private boolean releaseAxisServiceResources = false;
 
     private QName portQName;
     private QName serviceQName;
@@ -251,6 +255,7 @@
         // TODO: Refactor this with the consideration of no WSDL/Generic Service/Annotated
SEI
         setupAxisService();
         addToAxisService();
+        setupReleaseResources(getServiceDescription().getAxisConfigContext());
 
         buildDescriptionHierachy();
         addAnonymousAxisOperations();
@@ -270,6 +275,23 @@
         
     }
     
+    private void setupReleaseResources(ConfigurationContext configurationContext) {
+        if (configurationContext != null) {
+            AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration();
+            if (axisConfiguration != null) {
+                Parameter param = 
+                    axisConfiguration.getParameter(Constants.Configuration.REDUCE_WSDL_MEMORY_CACHE);
+                if (param != null) {
+                    releaseAxisServiceResources = ((String) param.getValue()).equalsIgnoreCase("true");
+                    if (log.isDebugEnabled()) {
+                        log.debug("EndpointDescription configured to release AxisService
resources via "
+                                  + Constants.Configuration.REDUCE_WSDL_MEMORY_CACHE);
+                    }
+                }
+            }
+        }
+        
+    }
     EndpointDescriptionImpl(ServiceDescriptionImpl parent, String serviceImplName) {
         this(parent, serviceImplName, null);
     }
@@ -540,6 +562,7 @@
         configureWebServiceFeatures();
         
         // REVIEW: there are some throws above that won't cause the release
+        setupReleaseResources(composite.getConfigurationContext());
         releaseAxisServiceResources();
     }
 
@@ -576,8 +599,8 @@
         buildEndpointDescriptionFromAnnotations();
         
         configureWebServiceFeatures();
-        
-        releaseAxisServiceResources();
+        // This constructor isn't used anymore, so there's no need to do this
+//        releaseAxisServiceResources();
 
         // The anonymous AxisOperations are currently NOT added here.  The reason 
         // is that (for now) this is a SERVER-SIDE code path, and the anonymous operations
@@ -1021,7 +1044,7 @@
 
     private void releaseAxisServiceResources() {
         // release the schema list in the AxisService
-        if (axisService != null) {
+        if (releaseAxisServiceResources && axisService != null) {
             axisService.releaseSchemaList();
         }
     }

Added: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/ReleaseAxisResourcesTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/ReleaseAxisResourcesTests.java?rev=649660&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/ReleaseAxisResourcesTests.java
(added)
+++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/ReleaseAxisResourcesTests.java
Fri Apr 18 12:13:36 2008
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.apache.axis2.jaxws.description;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.MethodDescriptionComposite;
+import org.apache.axis2.jaxws.description.builder.ParameterDescriptionComposite;
+import org.apache.axis2.jaxws.description.builder.WebServiceAnnot;
+import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
+
+import javax.jws.WebService;
+import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import java.io.File;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Test that with the configuration property set in axis2.xml, the AxisService
+ * resources are released after they are no longer needed.  The configuation
+ * value in axis2.xml is:
+ *     <parameter name="reduceWSDLMemoryCache">true</parameter>
+ * 
+ * NOTE: the tests currently use the axis2.xml from modules/kernel/conf (see
+ * build.xml).  There is an axis2.xml in the test-resource directory which
+ * enables the necessary property.  This axis2.xml is used by explicitly creating a
+ * configuration context to point to it.
+ * 
+ * ALSO NOTE: The default behavior should be OFF!  When the resources are cleaned from
+ * the AxisService, ?xsd will not work.
+ * 
+ * This test is based heavily on modules/metadata/test/org/apache/axis2/jaxws/description/DBCwithReduceWSDLMemoryParmsTests.java
+ */
+public class ReleaseAxisResourcesTests extends TestCase {
+    private static String basedir;
+    
+    static {
+        basedir = System.getProperty("basedir");
+        if (basedir == null) {
+            basedir = new File(".").getAbsolutePath();
+        }
+    }
+
+    /**
+     * Test that the default behavior is to NOT clenup AxisService resources.  The axis2.xml
+     * file used will be the default one, in target/repository/conf.  The propery should
not
+     * be set in that file.
+     */
+    public void testServerSideRelease_Default_OFF() {
+
+        // Since we aren't expliclty creating a ConfigurationContext using a differetn axis2.xml,
+        // the file target/repository/conf/axis2.xml will be used.  This one
+        // will not have the property set which causes AxisService resources to be cleaned
up.
+        
+        String wsdlRelativeLocation = "test-resources/wsdl/";
+        String wsdlFileName = "BindingNamespace.wsdl";
+        String targetNamespace = "http://nonanonymous.complextype.test.org";
+        String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
+
+        // Build up a DBC, including the WSDL Definition and the annotation information for

+        // the impl class.
+        DescriptionBuilderComposite dbc = new DescriptionBuilderComposite(/*configContext*/);
+
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
+        Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
+        assertNotNull(wsdlDefn);
+
+        WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
+        assertNotNull(webServiceAnnot);
+        webServiceAnnot.setWsdlLocation(wsdlLocation);
+        webServiceAnnot.setTargetNamespace(targetNamespace);
+        webServiceAnnot.setServiceName("EchoMessageService");
+        webServiceAnnot.setPortName("EchoMessagePort");
+
+        MethodDescriptionComposite mdc = new MethodDescriptionComposite();
+        mdc.setMethodName("echoMessage");
+        mdc.setReturnType("java.lang.String");
+
+        ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
+        pdc1.setParameterType("java.lang.String");
+
+        mdc.addParameterDescriptionComposite(pdc1);
+
+        dbc.addMethodDescriptionComposite(mdc);
+        dbc.setWebServiceAnnot(webServiceAnnot);
+        dbc.setClassName(BindingNSImpl.class.getName());
+        dbc.setwsdlURL(wsdlURL);
+
+        HashMap<String, DescriptionBuilderComposite> dbcMap =
+                new HashMap<String, DescriptionBuilderComposite>();
+        dbcMap.put(dbc.getClassName(), dbc);
+
+        List<ServiceDescription> serviceDescList =
+                DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap /*, configContext*/);
+        assertEquals(1, serviceDescList.size());
+        ServiceDescription serviceDesc = (ServiceDescription) serviceDescList.get(0);
+
+        assertNotNull(serviceDesc);
+        EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions()[0];
+        assertNotNull(endpointDesc);
+        AxisService axisService = endpointDesc.getAxisService();
+        assertNotNull(axisService);
+
+        assertNotNull(axisService.getSchema());
+        assertTrue(axisService.getSchema().size() > 0);
+    }
+    
+    public void testServerSideRelease() {
+        String axis2xml = basedir + "/test-resources/axis2.xml";
+        ConfigurationContext configContext = null;
+        try {
+            configContext =
+                    ConfigurationContextFactory.createConfigurationContextFromFileSystem(null,
+                                                                                        
axis2xml);
+        } catch (AxisFault e) {
+            fail("Got fault trying to create config context" + e);
+        }
+        assertNotNull(configContext);
+        String param =
+                (String) configContext.getAxisConfiguration()
+                                      .getParameterValue("reduceWSDLMemoryCache");
+        assertNotNull(param);
+
+        String wsdlRelativeLocation = "test-resources/wsdl/";
+        String wsdlFileName = "BindingNamespace.wsdl";
+        String targetNamespace = "http://nonanonymous.complextype.test.org";
+        String wsdlLocation = wsdlRelativeLocation + wsdlFileName;
+
+        // Build up a DBC, including the WSDL Definition and the annotation information for

+        // the impl class.
+        DescriptionBuilderComposite dbc = new DescriptionBuilderComposite(configContext);
+
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL(wsdlFileName);
+        Definition wsdlDefn = DescriptionTestUtils.createWSDLDefinition(wsdlURL);
+        assertNotNull(wsdlDefn);
+
+        WebServiceAnnot webServiceAnnot = WebServiceAnnot.createWebServiceAnnotImpl();
+        assertNotNull(webServiceAnnot);
+        webServiceAnnot.setWsdlLocation(wsdlLocation);
+        webServiceAnnot.setTargetNamespace(targetNamespace);
+        webServiceAnnot.setServiceName("EchoMessageService");
+        webServiceAnnot.setPortName("EchoMessagePort");
+
+        MethodDescriptionComposite mdc = new MethodDescriptionComposite();
+        mdc.setMethodName("echoMessage");
+        mdc.setReturnType("java.lang.String");
+
+        ParameterDescriptionComposite pdc1 = new ParameterDescriptionComposite();
+        pdc1.setParameterType("java.lang.String");
+
+        mdc.addParameterDescriptionComposite(pdc1);
+
+        dbc.addMethodDescriptionComposite(mdc);
+        dbc.setWebServiceAnnot(webServiceAnnot);
+        dbc.setClassName(BindingNSImpl.class.getName());
+        dbc.setwsdlURL(wsdlURL);
+
+        HashMap<String, DescriptionBuilderComposite> dbcMap =
+                new HashMap<String, DescriptionBuilderComposite>();
+        dbcMap.put(dbc.getClassName(), dbc);
+        List<ServiceDescription> serviceDescList =
+                DescriptionFactory.createServiceDescriptionFromDBCMap(dbcMap, configContext);
+        assertEquals(1, serviceDescList.size());
+        ServiceDescription serviceDesc = (ServiceDescription) serviceDescList.get(0);
+
+        assertNotNull(serviceDesc);
+        EndpointDescription endpointDesc = serviceDesc.getEndpointDescriptions()[0];
+        assertNotNull(endpointDesc);
+        AxisService axisService = endpointDesc.getAxisService();
+        assertNotNull(axisService);
+
+        assertNotNull(axisService.getSchema());
+        assertTrue(axisService.getSchema().size() == 0);
+    }
+
+    @WebService(serviceName = "EchoMessageService", portName = "EchoMessagePort", targetNamespace
= "http://nonanonymous.complextype.test.org", wsdlLocation = "test-resources/wsdl/BindingNamespace.wsdl")
+    public class BindingNSImpl {
+        public String echoMessage(String arg) {
+            return arg;
+        }
+    }
+}
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message