Author: fmui
Date: Fri Jan 16 15:47:01 2015
New Revision: 1652440

URL: http://svn.apache.org/r1652440
Log:
Web Services client: added session parameter to control handling of SOAP 
responses (in-memory vs temp file)

Modified:
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java
    
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java
    
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java?rev=1652440&r1=1652439&r2=1652440&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java
 Fri Jan 16 15:47:01 2015
@@ -28,6 +28,7 @@ import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.soap.MTOMFeature;
 
 import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
+import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import 
org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
@@ -44,12 +45,29 @@ import com.sun.xml.internal.ws.developer
 /**
  * Sun JRE JAX-WS implementation.
  */
+@SuppressWarnings("restriction")
 public class SunJREPortProvider extends AbstractPortProvider {
     private static final Logger LOG = 
LoggerFactory.getLogger(SunJREPortProvider.class);
 
+    private int contentThreshold;
+    private int responseThreshold;
+
+    @Override
+    public void setSession(BindingSession session) {
+        super.setSession(session);
+
+        contentThreshold = 
session.get(SessionParameter.WEBSERVICES_MEMORY_THRESHOLD, 4 * 1024 * 1024);
+        responseThreshold = 
session.get(SessionParameter.WEBSERVICES_REPSONSE_MEMORY_THRESHOLD, -1);
+
+        if (responseThreshold > contentThreshold) {
+            contentThreshold = responseThreshold;
+        }
+    }
+
     /**
      * Creates a port object.
      */
+    @SuppressWarnings("restriction")
     protected BindingProvider createPortObject(CmisServiceHolder 
serviceHolder) {
         if (LOG.isDebugEnabled()) {
             LOG.debug("Session {}: Creating Web Service port object of {} 
...", getSession().getSessionId(),
@@ -60,11 +78,15 @@ public class SunJREPortProvider extends
             // prepare features
             WebServiceFeature[] features;
             if (serviceHolder.getService().handlesContent()) {
-                int threshold = 
getSession().get(SessionParameter.WEBSERVICES_MEMORY_THRESHOLD, 4 * 1024 * 
1024);
                 features = new WebServiceFeature[] { new MTOMFeature(),
-                        new StreamingAttachmentFeature(null, true, threshold) 
};
+                        new StreamingAttachmentFeature(null, true, 
contentThreshold) };
             } else {
-                features = new WebServiceFeature[] { new MTOMFeature() };
+                if (responseThreshold > -1) {
+                    features = new WebServiceFeature[] { new MTOMFeature(),
+                            new StreamingAttachmentFeature(null, true, 
responseThreshold) };
+                } else {
+                    features = new WebServiceFeature[] { new MTOMFeature() };
+                }
             }
 
             // create port object

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java?rev=1652440&r1=1652439&r2=1652440&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java
 Fri Jan 16 15:47:01 2015
@@ -28,6 +28,7 @@ import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.soap.MTOMFeature;
 
 import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
+import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import 
org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
@@ -47,6 +48,21 @@ import com.sun.xml.ws.developer.WSBindin
 public class SunRIPortProvider extends AbstractPortProvider {
     private static final Logger LOG = 
LoggerFactory.getLogger(SunRIPortProvider.class);
 
+    private int contentThreshold;
+    private int responseThreshold;
+
+    @Override
+    public void setSession(BindingSession session) {
+        super.setSession(session);
+
+        contentThreshold = 
session.get(SessionParameter.WEBSERVICES_MEMORY_THRESHOLD, 4 * 1024 * 1024);
+        responseThreshold = 
session.get(SessionParameter.WEBSERVICES_REPSONSE_MEMORY_THRESHOLD, -1);
+
+        if (responseThreshold > contentThreshold) {
+            contentThreshold = responseThreshold;
+        }
+    }
+
     /**
      * Creates a port object.
      */
@@ -60,11 +76,15 @@ public class SunRIPortProvider extends A
             // prepare features
             WebServiceFeature[] features;
             if (serviceHolder.getService().handlesContent()) {
-                int threshold = 
getSession().get(SessionParameter.WEBSERVICES_MEMORY_THRESHOLD, 4 * 1024 * 
1024);
                 features = new WebServiceFeature[] { new MTOMFeature(),
-                        new StreamingAttachmentFeature(null, true, threshold) 
};
+                        new StreamingAttachmentFeature(null, true, 
contentThreshold) };
             } else {
-                features = new WebServiceFeature[] { new MTOMFeature() };
+                if (responseThreshold > -1) {
+                    features = new WebServiceFeature[] { new MTOMFeature(),
+                            new StreamingAttachmentFeature(null, true, 
responseThreshold) };
+                } else {
+                    features = new WebServiceFeature[] { new MTOMFeature() };
+                }
             }
 
             // create port object

Modified: 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
URL: 
http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java?rev=1652440&r1=1652439&r2=1652440&view=diff
==============================================================================
--- 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
 (original)
+++ 
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
 Fri Jan 16 15:47:01 2015
@@ -484,6 +484,15 @@ package org.apache.chemistry.opencmis.co
  * <td>4194304 (4MB)</td>
  * </tr>
  * <tr>
+ * <td>{@link #WEBSERVICES_REPSONSE_MEMORY_THRESHOLD}</td>
+ * <td>Web Service responses (XML SOAP parts) smaller than the threshold are
+ * kept in main memory, larger responses are written to a temporary file</td>
+ * <td>Web Services</td>
+ * <td>size in bytes</td>
+ * <td>no</td>
+ * <td>(JAX-WS implementation default)</td>
+ * </tr>
+ * <tr>
  * <td colspan="6"><b>Browser Binding</b></td>
  * </tr>
  * <tr>
@@ -595,6 +604,7 @@ public final class SessionParameter {
     public static final String WEBSERVICES_ACL_SERVICE_ENDPOINT = 
"org.apache.chemistry.opencmis.binding.webservices.ACLService.endpoint";
 
     public static final String WEBSERVICES_MEMORY_THRESHOLD = 
"org.apache.chemistry.opencmis.binding.webservices.memoryThreshold";
+    public static final String WEBSERVICES_REPSONSE_MEMORY_THRESHOLD = 
"org.apache.chemistry.opencmis.binding.webservices.responseMemoryThreshold";
 
     public static final String WEBSERVICES_PORT_PROVIDER_CLASS = 
"org.apache.chemistry.opencmis.binding.webservices.portprovider.classname";
 


Reply via email to