|
1 /* |
|
2 * Copyright (c) 1997, 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 */ |
|
25 |
|
26 package com.sun.xml.internal.ws.developer; |
|
27 |
|
28 import com.sun.xml.internal.ws.server.DraconianValidationErrorHandler; |
|
29 |
|
30 import javax.jws.WebService; |
|
31 import javax.xml.transform.Source; |
|
32 import javax.xml.validation.Schema; |
|
33 import javax.xml.ws.spi.WebServiceFeatureAnnotation; |
|
34 import java.lang.annotation.Documented; |
|
35 import static java.lang.annotation.ElementType.TYPE; |
|
36 import java.lang.annotation.Retention; |
|
37 import static java.lang.annotation.RetentionPolicy.RUNTIME; |
|
38 import java.lang.annotation.Target; |
|
39 import java.lang.annotation.ElementType; |
|
40 |
|
41 /** |
|
42 * Validates all request and response messages payload(SOAP:Body) for a {@link WebService} |
|
43 * against the XML schema. To use this feature, annotate the endpoint class with |
|
44 * this annotation. |
|
45 * |
|
46 * <pre> |
|
47 * for e.g.: |
|
48 * |
|
49 * @WebService |
|
50 * @SchemaValidation |
|
51 * public class HelloImpl { |
|
52 * ... |
|
53 * } |
|
54 * </pre> |
|
55 * |
|
56 * At present, schema validation works for doc/lit web services only. |
|
57 * |
|
58 * @since JAX-WS 2.1.3 |
|
59 * @author Jitendra Kotamraju |
|
60 * @see SchemaValidationFeature |
|
61 */ |
|
62 @Retention(RUNTIME) |
|
63 @Target({TYPE, ElementType.METHOD, ElementType.FIELD}) |
|
64 @Documented |
|
65 @WebServiceFeatureAnnotation(id = SchemaValidationFeature.ID, bean = SchemaValidationFeature.class) |
|
66 public @interface SchemaValidation { |
|
67 |
|
68 /** |
|
69 * Configure the validation behaviour w.r.t error handling. The default handler |
|
70 * just rejects any invalid schema intances. If the application want to change |
|
71 * this default behaviour(say just log the errors), it can do so by providing |
|
72 * a custom implementation of {@link ValidationErrorHandler}. |
|
73 */ |
|
74 Class<? extends ValidationErrorHandler> handler() default DraconianValidationErrorHandler.class; |
|
75 |
|
76 /** |
|
77 * Turns validation on/off for inbound messages |
|
78 * |
|
79 * @since JAX-WS RI 2.2.2 |
|
80 */ |
|
81 boolean inbound() default true; |
|
82 |
|
83 |
|
84 /** |
|
85 * Turns validation on/off for outbound messages |
|
86 * |
|
87 * @since JAX-WS RI 2.2.2 |
|
88 */ |
|
89 boolean outbound() default true; |
|
90 |
|
91 /** |
|
92 * Does validation for bound headers in a SOAP message. |
|
93 * |
|
94 boolean headers() default false; |
|
95 */ |
|
96 |
|
97 /** |
|
98 * Additional schema documents that are used to create {@link Schema} object. Useful |
|
99 * when the application adds additional SOAP headers to the message. This is a list |
|
100 * of system-ids, that are used to create {@link Source} objects and used in creation |
|
101 * of {@link Schema} object |
|
102 * |
|
103 * for e.g.: |
|
104 * @SchemaValidation(schemaLocations={"http://bar.foo/b.xsd", "http://foo.bar/a.xsd"} |
|
105 * |
|
106 String[] schemaLocations() default {}; |
|
107 */ |
|
108 |
|
109 } |