src/share/jaxws_classes/com/sun/xml/internal/ws/developer/StreamingAttachmentFeature.java

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

author
mkos
date
Fri, 14 Feb 2014 11:13:45 +0100
changeset 515
6cd506508147
parent 368
0989ad8c0860
child 637
9c07ef4934dd
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.developer;
    28 import com.sun.xml.internal.ws.api.FeatureConstructor;
    29 import com.sun.istack.internal.Nullable;
    31 import javax.xml.ws.WebServiceFeature;
    33 import com.sun.xml.internal.org.jvnet.mimepull.MIMEConfig;
    35 import com.sun.org.glassfish.gmbal.ManagedAttribute;
    36 import com.sun.org.glassfish.gmbal.ManagedData;
    38 /**
    39  * Proxy needs to be created with this feature to configure StreamingAttachment
    40  * attachments behaviour.
    41  *
    42  * <pre>
    43  * for e.g.: To configure all StreamingAttachment attachments to be kept in memory
    44  * <p>
    45  *
    46  * StreamingAttachmentFeature feature = new StreamingAttachmentFeature();
    47  * feature.setAllMemory(true);
    48  *
    49  * proxy = HelloService().getHelloPort(feature);
    50  *
    51  * </pre>
    52  *
    53  * @author Jitendra Kotamraju
    54  */
    55 @ManagedData
    56 public final class StreamingAttachmentFeature extends WebServiceFeature {
    57     /**
    58      * Constant value identifying the {@link StreamingAttachment} feature.
    59      */
    60     public static final String ID = "http://jax-ws.dev.java.net/features/mime";
    62     private MIMEConfig config;
    64     private String dir;
    65     private boolean parseEagerly;
    66     private long memoryThreshold;
    68     public StreamingAttachmentFeature() {
    69     }
    71     @FeatureConstructor({"dir","parseEagerly","memoryThreshold"})
    72     public StreamingAttachmentFeature(@Nullable String dir, boolean parseEagerly, long memoryThreshold) {
    73         this.enabled = true;
    74         this.dir = dir;
    75         this.parseEagerly = parseEagerly;
    76         this.memoryThreshold = memoryThreshold;
    77     }
    79     @ManagedAttribute
    80     public String getID() {
    81         return ID;
    82     }
    84     /**
    85      * Returns the configuration object. Once this is called, you cannot
    86      * change the configuration.
    87      *
    88      * @return
    89      */
    90     @ManagedAttribute
    91     public MIMEConfig getConfig() {
    92         if (config == null) {
    93             config = new MIMEConfig();
    94             config.setDir(dir);
    95             config.setParseEagerly(parseEagerly);
    96             config.setMemoryThreshold(memoryThreshold);
    97             config.validate();
    98         }
    99         return config;
   100     }
   102     /**
   103      * Directory in which large attachments are stored
   104      */
   105     public void setDir(String dir) {
   106         this.dir = dir;
   107     }
   109     /**
   110      * StreamingAttachment message is parsed eagerly
   111      */
   112     public void setParseEagerly(boolean parseEagerly) {
   113         this.parseEagerly = parseEagerly;
   114     }
   116     /**
   117      * After this threshold(no of bytes), large attachments are
   118      * written to file system
   119      */
   120     public void setMemoryThreshold(long memoryThreshold) {
   121         this.memoryThreshold = memoryThreshold;
   122     }
   124 }

mercurial