Tue, 06 Mar 2012 16:09:35 -0800
7150322: Stop using drop source bundles in jaxws
Reviewed-by: darcy, ohrstrom
1 /*
2 * Copyright (c) 2005, 2010, 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 javax.xml.ws.soap;
28 import javax.xml.ws.WebServiceFeature;
29 import javax.xml.ws.WebServiceException;
30 import javax.xml.ws.Dispatch;
31 import javax.xml.ws.Endpoint;
32 import javax.xml.ws.Service;
34 /**
35 * This feature represents the use of MTOM with a
36 * web service.
37 *
38 * This feature can be used during the creation of SEI proxy, and
39 * {@link Dispatch} instances on the client side and {@link Endpoint}
40 * instances on the server side. This feature cannot be used for {@link Service}
41 * instance creation on the client side.
42 *
43 * <p>
44 * The following describes the affects of this feature with respect
45 * to being enabled or disabled:
46 * <ul>
47 * <li> ENABLED: In this Mode, MTOM will be enabled. A receiver MUST accept
48 * both a non-optimized and an optimized message, and a sender MAY send an
49 * optimized message, or a non-optimized message. The heuristics used by a
50 * sender to determine whether to use optimization or not are
51 * implementation-specific.
52 * <li> DISABLED: In this Mode, MTOM will be disabled
53 * </ul>
54 * <p>
55 * The {@link #threshold} property can be used to set the threshold
56 * value used to determine when binary data should be XOP encoded.
57 *
58 * @since JAX-WS 2.1
59 */
60 public final class MTOMFeature extends WebServiceFeature {
61 /**
62 * Constant value identifying the MTOMFeature
63 */
64 public static final String ID = "http://www.w3.org/2004/08/soap/features/http-optimization";
67 /**
68 * Property for MTOM threshold value. This property serves as a hint when
69 * MTOM is enabled, binary data above this size in bytes SHOULD be sent
70 * as attachment.
71 * The value of this property MUST always be >= 0. Default value is 0.
72 */
73 protected int threshold = 0;
76 /**
77 * Create an <code>MTOMFeature</code>.
78 * The instance created will be enabled.
79 */
80 public MTOMFeature() {
81 this.enabled = true;
82 }
84 /**
85 * Creates an <code>MTOMFeature</code>.
86 *
87 * @param enabled specifies if this feature should be enabled or not
88 */
89 public MTOMFeature(boolean enabled) {
90 this.enabled = enabled;
91 }
94 /**
95 * Creates an <code>MTOMFeature</code>.
96 * The instance created will be enabled.
97 *
98 * @param threshold the size in bytes that binary data SHOULD be before
99 * being sent as an attachment.
100 *
101 * @throws WebServiceException if threshold is < 0
102 */
103 public MTOMFeature(int threshold) {
104 if (threshold < 0)
105 throw new WebServiceException("MTOMFeature.threshold must be >= 0, actual value: "+threshold);
106 this.enabled = true;
107 this.threshold = threshold;
108 }
110 /**
111 * Creates an <code>MTOMFeature</code>.
112 *
113 * @param enabled specifies if this feature should be enabled or not
114 * @param threshold the size in bytes that binary data SHOULD be before
115 * being sent as an attachment.
116 *
117 * @throws WebServiceException if threshold is < 0
118 */
119 public MTOMFeature(boolean enabled, int threshold) {
120 if (threshold < 0)
121 throw new WebServiceException("MTOMFeature.threshold must be >= 0, actual value: "+threshold);
122 this.enabled = enabled;
123 this.threshold = threshold;
124 }
126 /**
127 * {@inheritDoc}
128 */
129 public String getID() {
130 return ID;
131 }
133 /**
134 * Gets the threshold value used to determine when binary data
135 * should be sent as an attachment.
136 *
137 * @return the current threshold size in bytes
138 */
139 public int getThreshold() {
140 return threshold;
141 }
142 }