Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 62534 invoked from network); 22 Jul 2010 21:04:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 22 Jul 2010 21:04:19 -0000 Received: (qmail 11015 invoked by uid 500); 22 Jul 2010 21:04:19 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 10944 invoked by uid 500); 22 Jul 2010 21:04:19 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 10937 invoked by uid 99); 22 Jul 2010 21:04:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 21:04:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jul 2010 21:04:17 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3DAF923889E0; Thu, 22 Jul 2010 21:03:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r966856 - in /cxf/branches/2.2.x-fixes: ./ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/spring/ rt/ws/addr/src/main/resources/schemas/ rt/ws/addr/src/test/java/org/apache/cxf/w... Date: Thu, 22 Jul 2010 21:03:25 -0000 To: commits@cxf.apache.org From: dvaleri@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100722210325.3DAF923889E0@eris.apache.org> Author: dvaleri Date: Thu Jul 22 21:03:24 2010 New Revision: 966856 URL: http://svn.apache.org/viewvc?rev=966856&view=rev Log: Merged revisions 966845,966853 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r966845 | dvaleri | 2010-07-22 16:20:36 -0400 (Thu, 22 Jul 2010) | 1 line [CXF-2906] Added cache abstraction and configuration options for WS-A MessageID caching and uniqueness enforcement. ........ r966853 | dvaleri | 2010-07-22 16:44:25 -0400 (Thu, 22 Jul 2010) | 1 line [CXF-2906] Removed accidentally introduced Mina dependency. ........ Added: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/DefaultMessageIdCache.java (with props) cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MessageIdCache.java (with props) Modified: cxf/branches/2.2.x-fixes/ (props changed) cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/WSAddressingFeature.java cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/spring/AddressingBeanDefinitionParser.java cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/resources/schemas/ws-addr-conf.xsd cxf/branches/2.2.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/WSAFeatureXmlTest.java cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/spring.xml Propchange: cxf/branches/2.2.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jul 22 21:03:24 2010 @@ -1 +1 @@ -/cxf/trunk:965966,966026,966762 +/cxf/trunk:965966,966026,966762,966845-966853 Propchange: cxf/branches/2.2.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Added: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/DefaultMessageIdCache.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/DefaultMessageIdCache.java?rev=966856&view=auto ============================================================================== --- cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/DefaultMessageIdCache.java (added) +++ cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/DefaultMessageIdCache.java Thu Jul 22 21:03:24 2010 @@ -0,0 +1,45 @@ +/** + * 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.cxf.ws.addressing; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +/** + * An implementation that uses a simple set to store received message IDs. + * Note that this implementation does not make any attempt to flush older + * message IDs or to persist the message IDs outside of this instance. + */ +public class DefaultMessageIdCache implements MessageIdCache { + + /** + * The set of message IDs. + */ + private final Map messageIdSet = + new ConcurrentHashMap(); + + public boolean checkUniquenessAndCacheId(String messageId) { + return this.messageIdSet.put(messageId, Boolean.TRUE) == null; + } + + protected Set getMessageIdSet() { + return this.messageIdSet.keySet(); + } +} Propchange: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/DefaultMessageIdCache.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=966856&r1=966855&r2=966856&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original) +++ cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Thu Jul 22 21:03:24 2010 @@ -25,7 +25,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.ResourceBundle; -import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -81,11 +80,9 @@ public class MAPAggregator extends Abstr /** - * REVISIT: map usage implies that the *same* interceptor instance - * is used in all chains. + * The cache to use for enforcing uniqueness. Defaults to {@link DefaultMessageIdCache}. */ - protected final Map messageIDs = - new ConcurrentHashMap(); + private MessageIdCache messageIdCache = new DefaultMessageIdCache(); private boolean usingAddressingAdvisory = true; private boolean addressingRequired; @@ -156,7 +153,31 @@ public class MAPAggregator extends Abstr addressingRequired = required; } - + /** + * Returns the cache used to enforce duplicate message IDs when + * {@link #allowDuplicates()} returns {@code false}. + * + * @return the cache used to enforce duplicate message IDs + */ + public MessageIdCache getMessageIdCache() { + return messageIdCache; + } + + /** + * Sets the cache used to enforce duplicate message IDs when + * {@link #allowDuplicates()} returns {@code false}. + * + * @param messageIdCache the cache to use + * + * @throws NullPointerException if {@code messageIdCache} is {@code null} + */ + public void setMessageIdCache(MessageIdCache messageIdCache) { + if (messageIdCache == null) { + throw new NullPointerException("messageIdCache cannot be null."); + } + this.messageIdCache = messageIdCache; + } + /** * Invoked for normal processing of inbound and outbound messages. * @@ -954,8 +975,7 @@ public class MAPAggregator extends Abstr if (!allowDuplicates) { AttributedURIType messageID = maps.getMessageID(); if (messageID != null - && messageIDs.put(messageID.getValue(), - messageID.getValue()) != null) { + && !messageIdCache.checkUniquenessAndCacheId(messageID.getValue())) { LOG.log(Level.WARNING, "DUPLICATE_MESSAGE_ID_MSG", messageID.getValue()); Added: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MessageIdCache.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MessageIdCache.java?rev=966856&view=auto ============================================================================== --- cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MessageIdCache.java (added) +++ cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MessageIdCache.java Thu Jul 22 21:03:24 2010 @@ -0,0 +1,38 @@ +/** + * 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.cxf.ws.addressing; + +/** + * Interface abstracting various ID caches for enforcement of ID uniqueness. + */ +public interface MessageIdCache { + + /** + * Check {@code messageId} for uniqueness against previously + * encountered values and cache the ID. Note that the retention + * policy for previously encountered values is implementation specific. + * + * @param messageId the message ID to check for uniqueness and cache for + * future comparison + * + * @return true if and only if {@code messageId} is not already in the + * cache + */ + boolean checkUniquenessAndCacheId(String messageId); +} Propchange: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MessageIdCache.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/WSAddressingFeature.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/WSAddressingFeature.java?rev=966856&r1=966855&r2=966856&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/WSAddressingFeature.java (original) +++ cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/WSAddressingFeature.java Thu Jul 22 21:03:24 2010 @@ -67,5 +67,25 @@ public class WSAddressingFeature extends mapAggregator.setAddressingRequired(required); } - + /** + * Returns the cache used to enforce duplicate message IDs when + * {@link #isAllowDuplicates()} returns {@code false}. + * + * @return the cache used to enforce duplicate message IDs + */ + public MessageIdCache getMessageIdCache() { + return mapAggregator.getMessageIdCache(); + } + + /** + * Sets the cache used to enforce duplicate message IDs when + * {@link #isAllowDuplicates()} returns {@code false}. + * + * @param messageIdCache the cache to use + * + * @throws NullPointerException if {@code messageIdCache} is {@code null} + */ + public void setMessageIdCache(MessageIdCache messageIdCache) { + mapAggregator.setMessageIdCache(messageIdCache); + } } Modified: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/spring/AddressingBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/spring/AddressingBeanDefinitionParser.java?rev=966856&r1=966855&r2=966856&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/spring/AddressingBeanDefinitionParser.java (original) +++ cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/spring/AddressingBeanDefinitionParser.java Thu Jul 22 21:03:24 2010 @@ -20,14 +20,13 @@ package org.apache.cxf.ws.addressing.spr import org.w3c.dom.Element; +import org.apache.cxf.configuration.spring.AbstractBeanDefinitionParser; import org.apache.cxf.ws.addressing.WSAddressingFeature; -import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; -public class AddressingBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { +public class AddressingBeanDefinitionParser extends AbstractBeanDefinitionParser { @Override protected Class getBeanClass(Element arg0) { return WSAddressingFeature.class; } - } Modified: cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/resources/schemas/ws-addr-conf.xsd URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/resources/schemas/ws-addr-conf.xsd?rev=966856&r1=966855&r2=966856&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/resources/schemas/ws-addr-conf.xsd (original) +++ cxf/branches/2.2.x-fixes/rt/ws/addr/src/main/resources/schemas/ws-addr-conf.xsd Thu Jul 22 21:03:24 2010 @@ -30,6 +30,7 @@ + Modified: cxf/branches/2.2.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java?rev=966856&r1=966855&r2=966856&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java (original) +++ cxf/branches/2.2.x-fixes/rt/ws/addr/src/test/java/org/apache/cxf/ws/addressing/MAPAggregatorTest.java Thu Jul 22 21:03:24 2010 @@ -253,7 +253,7 @@ public class MAPAggregatorTest extends A @Test(expected = SoapFault.class) public void testResponderInboundInvalidMAPs() throws Exception { - aggregator.messageIDs.put("urn:uuid:12345", "urn:uuid:12345"); + aggregator.getMessageIdCache().checkUniquenessAndCacheId("urn:uuid:12345"); Message message = setUpMessage(false, false, false, false, false, false, true); aggregator.setAllowDuplicates(false); aggregator.mediate(message, false); @@ -263,7 +263,7 @@ public class MAPAggregatorTest extends A @Test(expected = SoapFault.class) public void testResponderInboundInvalidMAPsFault() throws Exception { - aggregator.messageIDs.put("urn:uuid:12345", "urn:uuid:12345"); + aggregator.getMessageIdCache().checkUniquenessAndCacheId("urn:uuid:12345"); Message message = setUpMessage(false, false, false, false, false, false, true); aggregator.setAllowDuplicates(false); aggregator.mediate(message, true); @@ -574,7 +574,8 @@ public class MAPAggregatorTest extends A setUpRebase(message, exchange); } } - if (outbound || aggregator.messageIDs.size() > 0) { + if (outbound || ((DefaultMessageIdCache) aggregator.getMessageIdCache()) + .getMessageIdSet().size() > 0) { if (!zeroLengthAction) { Method method = SEI.class.getMethod("op", new Class[0]); setUpMethod(message, exchange, method); Modified: cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/WSAFeatureXmlTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/WSAFeatureXmlTest.java?rev=966856&r1=966855&r2=966856&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/WSAFeatureXmlTest.java (original) +++ cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/WSAFeatureXmlTest.java Thu Jul 22 21:03:24 2010 @@ -33,6 +33,7 @@ import org.apache.cxf.jaxws.JaxWsProxyFa import org.apache.cxf.jaxws.JaxWsServerFactoryBean; import org.apache.cxf.test.AbstractCXFTest; import org.apache.cxf.testutil.common.TestUtil; +import org.apache.cxf.ws.addressing.DefaultMessageIdCache; import org.apache.cxf.ws.addressing.MAPAggregator; import org.apache.cxf.ws.addressing.soap.MAPCodec; import org.apache.hello_world_soap_http.Greeter; @@ -82,15 +83,22 @@ public class WSAFeatureXmlTest extends A private void checkAddressInterceptors(List interceptors) { boolean hasAg = false; boolean hasCodec = false; + Object cache = null; for (Interceptor i : interceptors) { if (i instanceof MAPAggregator) { hasAg = true; + cache = ((MAPAggregator) i).getMessageIdCache(); } else if (i instanceof MAPCodec) { hasCodec = true; } } + + assertTrue(cache instanceof TestCache); assertTrue(hasAg); assertTrue(hasCodec); } + + public static class TestCache extends DefaultMessageIdCache { + } } Modified: cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/spring.xml URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/spring.xml?rev=966856&r1=966855&r2=966856&view=diff ============================================================================== --- cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/spring.xml (original) +++ cxf/branches/2.2.x-fixes/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addressing/spring/spring.xml Thu Jul 22 21:03:24 2010 @@ -30,14 +30,16 @@ http://www.springframework.org/schema/be - + - + +