cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r1468835 - in /cxf/branches/2.7.x-fixes: ./ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ rt/ws/rm/src/main/resources/schemas/configuration/ systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/
Date Wed, 17 Apr 2013 11:10:50 GMT
Author: ay
Date: Wed Apr 17 11:10:50 2013
New Revision: 1468835

URL: http://svn.apache.org/r1468835
Log:
Merged revisions 1468507 via  svn merge from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1468507 | ay | 2013-04-16 18:54:28 +0200 (Tue, 16 Apr 2013) | 1 line
  
  [CXF-4968] Add an option to limit the number of active sequences created at WS-RM endpoints
........

Added:
    cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/limit-seqs.xml
      - copied unchanged from r1468507, cxf/trunk/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/limit-seqs.xml
Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java
    cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager-types.xsd
    cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java

Propchange: cxf/branches/2.7.x-fixes/
            ('svn:mergeinfo' removed)

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java?rev=1468835&r1=1468834&r2=1468835&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java (original)
+++ cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java Wed
Apr 17 11:10:50 2013
@@ -26,7 +26,9 @@ import java.util.logging.Logger;
 
 import javax.xml.datatype.Duration;
 
+import org.apache.cxf.binding.Binding;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb.DatatypeFactory;
 import org.apache.cxf.message.Exchange;
@@ -75,8 +77,22 @@ public class Servant implements Invoker 
             || RM11Constants.INSTANCE.getCreateSequenceOnewayOperationName().equals(oi.getName()))
{
             try {
                 return Collections.singletonList(createSequence(exchange.getInMessage()));
-            } catch (Exception ex) {
-                throw new Fault(ex);
+            } catch (RuntimeException ex) {
+                LOG.log(Level.WARNING, "Sequence creation rejected", ex);
+                SequenceFault sf = 
+                    new SequenceFaultFactory(protocol.getConstants()).createCreateSequenceRefusedFault();
+                Endpoint e = exchange.get(Endpoint.class);
+                Binding b = null == e ? null : e.getBinding();
+                if (null != b) {
+                    RMManager m = reliableEndpoint.getManager();
+                    LOG.fine("Manager: " + m);
+                    BindingFaultFactory bff = m.getBindingFaultFactory(b);
+                    Fault f = bff.createFault(sf, exchange.getInMessage());
+                    // log with warning instead sever, as this may happen for some delayed
messages
+                    LogUtils.log(LOG, Level.WARNING, "SEQ_FAULT_MSG", bff.toString(f));
+                    throw f;
+                }
+                throw new Fault(sf);
             }
         } else if (RM10Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName())
             || RM11Constants.INSTANCE.getCreateSequenceResponseOnewayOperationName().equals(oi.getName()))
{
@@ -114,6 +130,10 @@ public class Servant implements Invoker 
         createResponse.setIdentifier(destination.generateSequenceIdentifier());
         
         DestinationPolicyType dp = reliableEndpoint.getManager().getDestinationPolicy();
+        if (dp.getMaxSequences() > 0 
+            && destination.getProcessingSequenceCount() >= dp.getMaxSequences())
{
+            throw new RuntimeException("Sequence creation refused");
+        }
         Duration supportedDuration = dp.getSequenceExpiration();
         if (null == supportedDuration) {
             supportedDuration = DatatypeFactory.PT0S;

Modified: cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager-types.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager-types.xsd?rev=1468835&r1=1468834&r2=1468835&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager-types.xsd
(original)
+++ cxf/branches/2.7.x-fixes/rt/ws/rm/src/main/resources/schemas/configuration/wsrm-manager-types.xsd
Wed Apr 17 11:10:50 2013
@@ -78,6 +78,14 @@
                 </xs:documentation>
             </xs:annotation>      
         </xs:attribute>
+        <xs:attribute name="maxSequences" type="xs:int" use="optional" default="0">
+            <xs:annotation>
+                <xs:documentation>
+                    The maximum number of sequences that can be held active. A value of
+                    0 indicates there is no limit.
+                </xs:documentation>
+            </xs:annotation>      
+        </xs:attribute>
     </xs:complexType>
     
     <xs:complexType name="DestinationPolicyType">
@@ -110,6 +118,14 @@
             </xs:annotation>      
         </xs:attribute>
         
+        <xs:attribute name="maxSequences" type="xs:int" use="optional" default="0">
+            <xs:annotation>
+                <xs:documentation>
+                    The maximum number of sequences that can be held active. A value of
+                    0 indicates there is no limit.
+                </xs:documentation>
+            </xs:annotation>      
+        </xs:attribute>
     </xs:complexType>
 
     <xs:complexType name="SequenceTerminationPolicyType">    

Modified: cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java?rev=1468835&r1=1468834&r2=1468835&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/ws-rm/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
Wed Apr 17 11:10:50 2013
@@ -1416,6 +1416,37 @@ public class SequenceTest extends Abstra
         mf.verifyAcknowledgements(new boolean[] {false, true}, false);
         
     }    
+
+    @Test
+    public void testCreateSequenceRefused() throws Exception {
+        init("org/apache/cxf/systest/ws/rm/limit-seqs.xml");
+
+        RMManager manager = greeterBus.getExtension(RMManager.class);
+        assertEquals("Unexpected maximum sequence count.", 1, manager.getDestinationPolicy().getMaxSequences());
+
+        greeter.greetMe("one");
+        // force greeter to be re-initialized so that a new sequence is created
+        ClientProxy.getClient(greeter).getConduit().close();
+        initProxy(false, null);
+
+        try {
+            greeter.greetMe("two");
+            fail("Expected fault.");
+        } catch (WebServiceException ex) {
+            // sequence creation refused
+        }   
+        
+        // the third inbound message has a SequenceFault header
+        MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(),
+            inRecorder.getInboundMessages(), Names200408.WSA_NAMESPACE_NAME, RM10Constants.NAMESPACE_URI);
+        mf.verifySequenceFault(RM10Constants.CREATE_SEQUENCE_REFUSED_FAULT_QNAME, false,
2);
+        String[] expectedActions = new String[3];
+        expectedActions = new String[] {RM10Constants.CREATE_SEQUENCE_RESPONSE_ACTION,
+                                        GREETME_RESPONSE_ACTION,
+                                        RM10_GENERIC_FAULT_ACTION};
+        mf.verifyActions(expectedActions, false);
+    }
+
     // --- test utilities ---
 
     private void init(String cfgResource) {



Mime
View raw message