KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > xml > ws > soap > MTOMFeature


1 /*
2  * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
3  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4  */

5
6 package javax.xml.ws.soap;
7
8 import javax.xml.ws.Binding;
9 import javax.xml.ws.BindingType;
10 import javax.xml.ws.WebServiceFeature;
11 import javax.xml.ws.WebServiceException;
12 import javax.xml.ws.spi.Provider;
13
14
15 /**
16  * This feature represents the use of MTOM with a
17  * web service.
18  *
19  * <p>
20  * The following describes the affects of this feature with respect
21  * to being enabled or disabled:
22  * <ul>
23  * <li> ENABLED: In this Mode, MTOM will be enabled.
24  * <li> DISABLED: In this Mode, MTOM will be disabled
25  * </ul>
26  * <p>
27  * The {@link #threshold} property can be used to set the threshold
28  * value used to determine when binary data should be XOP encoded.
29  *
30  * @since JAX-WS 2.1
31  */

32 public final class MTOMFeature extends WebServiceFeature {
33     /**
34      * Constant value identifying the MTOMFeature
35      */

36     public static final String JavaDoc ID = "http://www.w3.org/2004/08/soap/features/http-optimization";
37   
38    
39     /**
40      * Property for MTOM threshold value. This property serves as a hint when
41      * MTOM is enabled, binary data above this size in bytes SHOULD be sent
42      * as attachment.
43      * The value of this property MUST always be >= 0. Default value is 0.
44      */

45     protected int threshold = 0;
46     
47
48     /**
49      * Create an <code>MTOMFeature</code>.
50      * The instance created will be enabled.
51      */

52     public MTOMFeature() {
53         this.enabled = true;
54     }
55     
56     /**
57      * Creates an <code>MTOMFeature</code>.
58      *
59      * @param enabled specifies if this feature should be enabled or not
60      */

61     public MTOMFeature(boolean enabled) {
62         this.enabled = enabled;
63     }
64
65
66     /**
67      * Creates an <code>MTOMFeature</code>.
68      * The instance created will be enabled.
69      *
70      * @param threshold the size in bytes that binary data SHOULD be before
71      * being sent as an attachment.
72      *
73      * @throws WebServiceException if threshold is < 0
74      */

75     public MTOMFeature(int threshold) {
76         if (threshold < 0)
77             throw new WebServiceException("MTOMFeature.threshold must be >= 0, actual value: "+threshold);
78         this.enabled = true;
79         this.threshold = threshold;
80     }
81     
82     /**
83      * Creates an <code>MTOMFeature</code>.
84      *
85      * @param enabled specifies if this feature should be enabled or not
86      * @param threshold the size in bytes that binary data SHOULD be before
87      * being sent as an attachment.
88      *
89      * @throws WebServiceException if threshold is < 0
90      */

91     public MTOMFeature(boolean enabled, int threshold) {
92         if (threshold < 0)
93             throw new WebServiceException("MTOMFeature.threshold must be >= 0, actual value: "+threshold);
94         this.enabled = enabled;
95         this.threshold = threshold;
96     }
97     
98     /**
99      * {@inheritDoc}
100      */

101     public String JavaDoc getID() {
102         return ID;
103     }
104     
105     /**
106      * Gets the threshold value used to determine when binary data
107      * should be sent as an attachment.
108      *
109      * @return the current threshold size in bytes
110      */

111     public int getThreshold() {
112         return threshold;
113     }
114 }
115
Popular Tags