src/share/jaxws_classes/com/sun/xml/internal/ws/dump/MessageDumpingFeature.java

Fri, 14 Feb 2014 11:13:45 +0100

author
mkos
date
Fri, 14 Feb 2014 11:13:45 +0100
changeset 515
6cd506508147
parent 0
373ffda63c9a
permissions
-rw-r--r--

8026188: Enhance envelope factory
Summary: Avoiding caching data initialized via TCCL in static context; fix also reviewed by Alexander Fomin
Reviewed-by: ahgross, mgrebac, skoivu

     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.xml.internal.ws.dump;
    28 import com.sun.xml.internal.ws.api.FeatureConstructor;
    29 import com.sun.org.glassfish.gmbal.ManagedAttribute;
    30 import com.sun.org.glassfish.gmbal.ManagedData;
    32 import javax.xml.ws.WebServiceFeature;
    33 import java.util.Queue;
    34 import java.util.concurrent.atomic.AtomicBoolean;
    35 import java.util.logging.Level;
    37 /**
    38  *
    39  * @author Marek Potociar (marek.potociar at sun.com)
    40  */
    41 @ManagedData
    42 public final class MessageDumpingFeature extends WebServiceFeature {
    44     public static final String ID = "com.sun.xml.internal.ws.messagedump.MessageDumpingFeature";
    45     //
    46     private static final Level DEFAULT_MSG_LOG_LEVEL = Level.FINE;
    47     //
    48     private final Queue<String> messageQueue;
    49     private final AtomicBoolean messageLoggingStatus;
    50     private final String messageLoggingRoot;
    51     private final Level messageLoggingLevel;
    53     public MessageDumpingFeature() {
    54         this(null, null, true);
    55     }
    57     public MessageDumpingFeature(String msgLogRoot, Level msgLogLevel, boolean storeMessages) {
    58         this.messageQueue =  (storeMessages) ? new java.util.concurrent.ConcurrentLinkedQueue<String>() : null;
    59         this.messageLoggingStatus = new AtomicBoolean(true);
    60         this.messageLoggingRoot = (msgLogRoot != null && msgLogRoot.length() > 0) ? msgLogRoot : MessageDumpingTube.DEFAULT_MSGDUMP_LOGGING_ROOT;
    61         this.messageLoggingLevel = (msgLogLevel != null) ? msgLogLevel : DEFAULT_MSG_LOG_LEVEL;
    63         super.enabled = true;
    64     }
    66     public MessageDumpingFeature(boolean enabled) {
    67         // this constructor is here just to satisfy JAX-WS specification requirements
    68         this();
    69         super.enabled = enabled;
    70     }
    72     @FeatureConstructor({"enabled", "messageLoggingRoot", "messageLoggingLevel", "storeMessages"})
    73     public MessageDumpingFeature(boolean enabled, String msgLogRoot, String msgLogLevel, boolean storeMessages) {
    74         // this constructor is here just to satisfy JAX-WS specification requirements
    75         this(msgLogRoot, Level.parse(msgLogLevel), storeMessages);
    77         super.enabled = enabled;
    78     }
    80     @Override
    81     @ManagedAttribute
    82     public String getID() {
    83         return ID;
    84     }
    86     public String nextMessage() {
    87         return (messageQueue != null) ? messageQueue.poll() : null;
    88     }
    90     public void enableMessageLogging() {
    91         messageLoggingStatus.set(true);
    92     }
    94     public void disableMessageLogging() {
    95         messageLoggingStatus.set(false);
    96     }
    98     @ManagedAttribute
    99     public boolean getMessageLoggingStatus() {
   100         return messageLoggingStatus.get();
   101     }
   103     @ManagedAttribute
   104     public String getMessageLoggingRoot() {
   105         return messageLoggingRoot;
   106     }
   108     @ManagedAttribute
   109     public Level getMessageLoggingLevel() {
   110         return messageLoggingLevel;
   111     }
   113     boolean offerMessage(String message) {
   114         return (messageQueue != null) ? messageQueue.offer(message) : false;
   115     }
   116 }

mercurial