jaxws/src/share/jaxws_classes/javax/xml/ws/FaultAction.java
changeset 12009 4abb694f273a
child 22678 ac1ea46be942
equal deleted inserted replaced
11943:16ba58282d11 12009:4abb694f273a
       
     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  */
       
    25 
       
    26 package javax.xml.ws;
       
    27 
       
    28 import java.lang.annotation.Documented;
       
    29 import java.lang.annotation.ElementType;
       
    30 import java.lang.annotation.Retention;
       
    31 import java.lang.annotation.RetentionPolicy;
       
    32 import java.lang.annotation.Target;
       
    33 
       
    34 /**
       
    35  * The <code>FaultAction</code> annotation is used inside an {@link Action}
       
    36  * annotation to allow an explicit association of a WS-Addressing
       
    37  * <code>Action</code> message addressing property with the <code>fault</code>
       
    38  * messages of the WSDL operation mapped from the exception class.
       
    39  * <p>
       
    40  * The <code>wsam:Action</code> attribute value in the <code>fault</code>
       
    41  * message in the generated WSDL operation mapped for <code>className</code>
       
    42  * class is equal to the corresponding value in the <code>FaultAction</code>.
       
    43  * For the exact computation of <code>wsam:Action</code> values for the
       
    44  * fault messages, refer to the algorithm in the JAX-WS specification.
       
    45  *
       
    46  * <p>
       
    47  * <b>Example 1</b>: Specify explicit values for <code>Action</code> message addressing
       
    48  * property for the <code>input</code>, <code>output</code> and <code>fault</code> message
       
    49  * if the Java method throws only one service specific exception.
       
    50  *
       
    51  * <pre>
       
    52  * &#64;WebService(targetNamespace="http://example.com/numbers")
       
    53  * public class AddNumbersImpl {
       
    54  *     &#64;Action(
       
    55  *         fault = {
       
    56  *             <b>&#64;FaultAction(className=AddNumbersException.class, value="http://example.com/faultAction")</b>
       
    57  *         })
       
    58  *     public int addNumbers(int number1, int number2)
       
    59  *         throws AddNumbersException {
       
    60  *         return number1 + number2;
       
    61  *     }
       
    62  * }
       
    63  * </pre>
       
    64  *
       
    65  * The generated WSDL looks like:
       
    66  *
       
    67  * <pre>
       
    68  *   &lt;definitions targetNamespace="http://example.com/numbers" ...>
       
    69  *     ...
       
    70  *     &lt;portType name="AddNumbersPortType">
       
    71  *       &lt;operation name="AddNumbers">
       
    72  *         ...
       
    73  *         &lt;fault message="tns:AddNumbersException" name="AddNumbersException"
       
    74  *           <b>wsam:Action="http://example.com/faultAction"</b>/>
       
    75  *       &lt;/operation>
       
    76  *     &lt;/portType>
       
    77  *     ...
       
    78  *   &lt;/definitions>
       
    79  * </pre>
       
    80  *
       
    81  * <p>
       
    82  * Example 2: Here is an example that shows if the explicit value for <code>Action</code>
       
    83  * message addressing property for the service specific exception is not present.
       
    84  *
       
    85  * <pre>
       
    86  * &#64;WebService(targetNamespace="http://example.com/numbers")
       
    87  * public class AddNumbersImpl {
       
    88  *     public int addNumbers(int number1, int number2)
       
    89  *         throws AddNumbersException {
       
    90  *         return number1 + number2;
       
    91  *     }
       
    92  * }
       
    93  * </pre>
       
    94  *
       
    95  * The generated WSDL looks like:
       
    96  *
       
    97  * <pre>
       
    98  *   &lt;definitions targetNamespace="http://example.com/numbers" ...>
       
    99  *     ...
       
   100  *     &lt;portType name="AddNumbersPortType">
       
   101  *       &lt;operation name="AddNumbers">
       
   102  *         ...
       
   103  *         &lt;fault message="tns:addNumbersFault" name="InvalidNumbers"
       
   104  *           <b>wsam:Action="http://example.com/numbers/AddNumbersPortType/AddNumbers/Fault/AddNumbersException"</b>/>
       
   105  *       &lt;/operation>
       
   106  *     &lt;/portType>
       
   107  *     ...
       
   108  *   &lt;/definitions>
       
   109  * </pre>
       
   110  *
       
   111  * <p>
       
   112  * Example 3: Here is an example that shows how to specify explicit values for <code>Action</code>
       
   113  * message addressing property if the Java method throws more than one service specific exception.
       
   114  *
       
   115  * <pre>
       
   116  * &#64;WebService(targetNamespace="http://example.com/numbers")
       
   117  * public class AddNumbersImpl {
       
   118  *     &#64;Action(
       
   119  *         fault = {
       
   120  *             <b>&#64;FaultAction(className=AddNumbersException.class, value="http://example.com/addFaultAction"),
       
   121  *             &#64;FaultAction(className=TooBigNumbersException.class, value="http://example.com/toobigFaultAction")</b>
       
   122  *         })
       
   123  *     public int addNumbers(int number1, int number2)
       
   124  *         throws AddNumbersException, TooBigNumbersException {
       
   125  *         return number1 + number2;
       
   126  *     }
       
   127  * }
       
   128  * </pre>
       
   129  *
       
   130  * The generated WSDL looks like:
       
   131  *
       
   132  * <pre>
       
   133  *   &lt;definitions targetNamespace="http://example.com/numbers" ...>
       
   134  *     ...
       
   135  *     &lt;portType name="AddNumbersPortType">
       
   136  *       &lt;operation name="AddNumbers">
       
   137  *         ...
       
   138  *         &lt;fault message="tns:addNumbersFault" name="AddNumbersException"
       
   139  *           <b>wsam:Action="http://example.com/addFaultAction"</b>/>
       
   140  *         &lt;fault message="tns:tooBigNumbersFault" name="TooBigNumbersException"
       
   141  *           <b>wsam:Action="http://example.com/toobigFaultAction"</b>/>
       
   142  *       &lt;/operation>
       
   143  *     &lt;/portType>
       
   144  *     ...
       
   145  *   &lt;/definitions>
       
   146  * </pre>
       
   147  *
       
   148  * @since JAX-WS 2.1
       
   149  */
       
   150 
       
   151 @Documented
       
   152 @Retention(RetentionPolicy.RUNTIME)
       
   153 @Target(ElementType.METHOD)
       
   154 public @interface FaultAction {
       
   155     /**
       
   156      * Name of the exception class
       
   157      */
       
   158     Class<? extends Exception> className();
       
   159 
       
   160     /**
       
   161      * Value of WS-Addressing <code>Action</code> message addressing property for the exception
       
   162      */
       
   163     String value() default "";
       
   164 }