Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 55407 invoked from network); 9 Nov 2007 22:58:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Nov 2007 22:58:09 -0000 Received: (qmail 37343 invoked by uid 500); 9 Nov 2007 22:57:57 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 37229 invoked by uid 500); 9 Nov 2007 22:57:57 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 37220 invoked by uid 99); 9 Nov 2007 22:57:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2007 14:57:57 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Nov 2007 22:58:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B71F81A9832; Fri, 9 Nov 2007 14:57:33 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r593683 - in /incubator/cxf/branches/2.0.x-fixes: ./ api/src/main/java/org/apache/cxf/ws/addressing/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ Date: Fri, 09 Nov 2007 22:57:33 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071109225733.B71F81A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Fri Nov 9 14:57:32 2007 New Revision: 593683 URL: http://svn.apache.org/viewvc?rev=593683&view=rev Log: Merged revisions 593444 via svnmerge from https://svn.apache.org/repos/asf/incubator/cxf/trunk ........ r593444 | mmao | 2007-11-09 02:48:19 -0500 (Fri, 09 Nov 2007) | 6 lines CXF-1186, CXF-1172 * WS-Addressing is working with the API approach * Complete the system tests * Logging interceptors more programmatic ........ Added: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java - copied unchanged from r593444, incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingMessage.java Modified: incubator/cxf/branches/2.0.x-fixes/ (props changed) incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java incubator/cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Propchange: incubator/cxf/branches/2.0.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java?rev=593683&r1=593682&r2=593683&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java (original) +++ incubator/cxf/branches/2.0.x-fixes/api/src/main/java/org/apache/cxf/ws/addressing/WSAContextUtils.java Fri Nov 9 14:57:32 2007 @@ -60,7 +60,7 @@ */ public static boolean retrieveUsingAddressing(Message message) { Boolean override = (Boolean)message.get(USING_PROPERTY); - return override != null && override.booleanValue(); + return override == null || (override != null && override.booleanValue()); } /** Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=593683&r1=593682&r2=593683&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Fri Nov 9 14:57:32 2007 @@ -37,16 +37,29 @@ public class LoggingInInterceptor extends AbstractPhaseInterceptor { private static final Logger LOG = LogUtils.getL7dLogger(LoggingInInterceptor.class); + private final LoggingMessage buffer = new LoggingMessage("Inbound Message\n----------------------------"); private int limit = 100 * 1024; + private boolean enabled; + public LoggingInInterceptor() { super(Phase.RECEIVE); } public LoggingInInterceptor(int lim) { - super(Phase.RECEIVE); + this(); limit = lim; } + + public LoggingInInterceptor(boolean b) { + this(); + this.enabled = b; + } + + public LoggingMessage getBuffer() { + return this.buffer; + } + public void setLimit(int lim) { limit = lim; } @@ -56,52 +69,53 @@ } public void handleMessage(Message message) throws Fault { + if (enabled || LOG.isLoggable(Level.INFO)) { + logging(message); + } + } - if (LOG.isLoggable(Level.INFO)) { - StringBuilder buffer = new StringBuilder(2048); - - buffer.append("Inbound Message\n") - .append("--------------------------------------"); - - String encoding = (String)message.get(Message.ENCODING); - if (encoding != null) { - buffer.append("\nEncoding: " + encoding); - } - Object headers = message.get(Message.PROTOCOL_HEADERS); - if (headers != null) { - buffer.append("\nHeaders: " + headers); - } + private void logging(Message message) throws Fault { + String encoding = (String)message.get(Message.ENCODING); + + if (encoding != null) { + buffer.getEncoding().append(encoding); + } + Object headers = message.get(Message.PROTOCOL_HEADERS); + + if (headers != null) { + buffer.getHeader().append(headers); + } - InputStream is = message.getContent(InputStream.class); - if (is != null) { - CachedOutputStream bos = new CachedOutputStream(); - try { - IOUtils.copy(is, bos); - - bos.flush(); - is.close(); - - message.setContent(InputStream.class, bos.getInputStream()); - if (bos.getTempFile() != null) { - //large thing on disk... - buffer.append("\nMessage (saved to tmp file):\n"); - buffer.append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n"); - } else { - buffer.append("\nMessage:\n"); - } - if (bos.size() > limit) { - buffer.append("(message truncated to " + limit + " bytes)\n"); - } - bos.writeCacheTo(buffer, limit); - - bos.close(); - } catch (IOException e) { - throw new Fault(e); + InputStream is = message.getContent(InputStream.class); + if (is != null) { + CachedOutputStream bos = new CachedOutputStream(); + try { + IOUtils.copy(is, bos); + + bos.flush(); + is.close(); + + message.setContent(InputStream.class, bos.getInputStream()); + if (bos.getTempFile() != null) { + //large thing on disk... + buffer.getMessage().append("\nMessage (saved to tmp file):\n"); + buffer.getMessage().append("Filename: " + bos.getTempFile().getAbsolutePath() + "\n"); + } else { + buffer.getMessage().append("\nMessage:\n"); } + if (bos.size() > limit) { + buffer.getMessage().append("(message truncated to " + limit + " bytes)\n"); + } + bos.writeCacheTo(buffer.getPayload(), limit); + + bos.close(); + } catch (IOException e) { + throw new Fault(e); } - buffer.append("\n--------------------------------------"); + } + + if (LOG.isLoggable(Level.INFO)) { LOG.info(buffer.toString()); } } - } Modified: incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java?rev=593683&r1=593682&r2=593683&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingOutInterceptor.java Fri Nov 9 14:57:32 2007 @@ -37,18 +37,24 @@ public class LoggingOutInterceptor extends AbstractPhaseInterceptor { private static final Logger LOG = LogUtils.getL7dLogger(LoggingOutInterceptor.class); + private final LoggingMessage buffer = new LoggingMessage("Outbound Message\n---------------------------"); private int limit = 100 * 1024; + private boolean enabled; public LoggingOutInterceptor() { super(Phase.PRE_STREAM); addBefore(StaxOutInterceptor.class.getName()); } public LoggingOutInterceptor(int lim) { - super(Phase.PRE_STREAM); - addBefore(StaxOutInterceptor.class.getName()); + this(); limit = lim; } + + public LoggingOutInterceptor(boolean b) { + this(); + this.enabled = b; + } public void setLimit(int lim) { limit = lim; @@ -58,20 +64,22 @@ return limit; } + public LoggingMessage getBuffer() { + return this.buffer; + } public void handleMessage(Message message) throws Fault { final OutputStream os = message.getContent(OutputStream.class); if (os == null) { return; } - if (!LOG.isLoggable(Level.INFO)) { - return; + + if (LOG.isLoggable(Level.INFO) || enabled) { + // Write the output while caching it for the log message + final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(os); + message.setContent(OutputStream.class, newOut); + newOut.registerCallback(new LoggingCallback()); } - - // Write the output while caching it for the log message - final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(os); - message.setContent(OutputStream.class, newOut); - newOut.registerCallback(new LoggingCallback()); } class LoggingCallback implements CachedOutputStreamCallback { @@ -81,31 +89,27 @@ } public void onClose(CachedOutputStream cos) { - - StringBuilder buffer = new StringBuilder(2048); - if (cos.getTempFile() == null) { - buffer.append("Outbound Message:\n"); + //buffer.append("Outbound Message:\n"); if (cos.size() > limit) { - buffer.append("(message truncated to " + limit + " bytes)\n"); + buffer.getMessage().append("(message truncated to " + limit + " bytes)\n"); } - buffer.append("--------------------------------------\n"); } else { - buffer.append("Outbound Message (saved to tmp file):\n"); - buffer.append("Filename: " + cos.getTempFile().getAbsolutePath() + "\n"); + buffer.getMessage().append("Outbound Message (saved to tmp file):\n"); + buffer.getMessage().append("Filename: " + cos.getTempFile().getAbsolutePath() + "\n"); if (cos.size() > limit) { - buffer.append("(message truncated to " + limit + " bytes)\n"); + buffer.getMessage().append("(message truncated to " + limit + " bytes)\n"); } - buffer.append("--------------------------------------\n"); } try { - cos.writeCacheTo(buffer, limit); + cos.writeCacheTo(buffer.getPayload(), limit); } catch (Exception ex) { //ignore } - buffer.append("--------------------------------------\n"); - LOG.info(buffer.toString()); + + if (LOG.isLoggable(Level.INFO)) { + LOG.info(buffer.toString()); + } } - } } Modified: incubator/cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=593683&r1=593682&r2=593683&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Fri Nov 9 14:57:32 2007 @@ -22,7 +22,6 @@ import java.text.MessageFormat; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -65,14 +64,14 @@ * is used in all chains. */ protected final Map messageIDs = - new HashMap(); + new ConcurrentHashMap(); /** * Whether the endpoint supports WS-Addressing. */ - private Map usingAddressing = new ConcurrentHashMap(); - private boolean usingAddressingAdvisory; + private final Map usingAddressing = new ConcurrentHashMap(); + private boolean usingAddressingAdvisory = true; private boolean allowDuplicates = true; @@ -85,7 +84,7 @@ /** * Indicates if duplicate messageIDs are allowed. - * @return true iff duplicate messageIDs are allowed + * @return true if duplicate messageIDs are allowed */ public boolean allowDuplicates() { return allowDuplicates; @@ -147,13 +146,17 @@ * @pre message is outbound */ private boolean usingAddressing(Message message) { - boolean ret = false; + boolean ret = true; if (ContextUtils.isRequestor(message)) { - ret = usingAddressingAdvisory - || WSAContextUtils.retrieveUsingAddressing(message) - || hasUsingAddressing(message) + if (hasUsingAddressing(message) || hasAddressingAssertion(message) - || hasUsingAddressingAssertion(message); + || hasUsingAddressingAssertion(message)) { + return true; + } + if (!usingAddressingAdvisory + || !WSAContextUtils.retrieveUsingAddressing(message)) { + ret = false; + } } else { ret = getMAPs(message, false, false) != null; } @@ -205,8 +208,7 @@ private boolean hasAddressingAssertion(Message message) { AssertionInfoMap aim = message.get(AssertionInfoMap.class); if (null == aim) { - return false; - + return false; } Collection ais = aim.get(MetadataConstants.ADDRESSING_ASSERTION_QNAME); if (null == ais || ais.size() == 0) {