1 /*
   2  * Copyright (c) 2005, 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  */
  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>Action</code> annotation allows explicit association of a
  36  * WS-Addressing <code>Action</code> message addressing property with
  37  * <code>input</code>, <code>output</code>, and
  38  * <code>fault</code> messages of the mapped WSDL operation.
  39  * <p>
  40  * This annotation can be specified on each method of a service endpoint interface.
  41  * For such a method, the mapped operation in the generated WSDL's
  42  * <code>wsam:Action</code> attribute on the WSDL <code>input</code>,
  43  * <code>output</code> and <code>fault</code> messages of the WSDL <code>operation</code>
  44  * is based upon which attributes of the <code>Action</code> annotation have been specified.
  45  * For the exact computation of <code>wsam:Action</code> values for the messages, refer
  46  * to the algorithm in the JAX-WS specification.
  47  * <p>
  48  * <b>Example 1</b>: Specify explicit values for <code>Action</code> message addressing property
  49  * for <code>input</code> and <code>output</code> messages.
  50  *
  51  * <pre>
  52  * @WebService(targetNamespace="http://example.com/numbers")
  53  * public class AddNumbersImpl {
  54  *     <b>@Action(
  55  *         input="http://example.com/inputAction",
  56  *         output="http://example.com/outputAction")</b>
  57  *     public int addNumbers(int number1, int number2) {
  58  *         return number1 + number2;
  59  *     }
  60  * }
  61  * </pre>
  62  *
  63  * The generated WSDL looks like:
  64  * <pre>
  65  *   &lt;definitions targetNamespace="http://example.com/numbers" ...>
  66  *     ...
  67  *     &lt;portType name="AddNumbersPortType">
  68  *       &lt;operation name="AddNumbers">
  69  *         &lt;input message="tns:AddNumbersInput" name="foo"
  70  *           <b>wsam:Action="http://example.com/inputAction"</b>/>
  71  *         &lt;output message="tns:AddNumbersOutput" name="bar"
  72  *           <b>wsam:Action="http://example.com/outputAction"</b>/>
  73  *       &lt;/operation>
  74  *     &lt;/portType>
  75  *     ...
  76  *   &lt;/definitions>
  77  * </pre>
  78  *
  79  * <p>
  80  * <b>Example 2</b>: Specify explicit value for <code>Action</code> message addressing property
  81  * for only the <code>input</code> message. The <code>wsam:Action</code> values for the
  82  * WSDL <code>output</code> message are computed using the algorithm in the JAX-WS specification.
  83  *
  84  * <pre>
  85  * @WebService(targetNamespace="http://example.com/numbers")
  86  * public class AddNumbersImpl {
  87  *     <b>@Action(input="http://example.com/inputAction")</b>
  88  *     public int addNumbers(int number1, int number2) {
  89  *         return number1 + number2;
  90  *     }
  91  * }
  92  * </pre>
  93  *
  94  * The generated WSDL looks like:
  95  * <pre>
  96  *   &lt;definitions targetNamespace="http://example.com/numbers" ...>
  97  *     ...
  98  *     &lt;portType name="AddNumbersPortType">
  99  *       &lt;operation name="AddNumbers">
 100  *         &lt;input message="tns:AddNumbersInput" name="foo"
 101  *           <b>wsam:Action="http://example.com/inputAction"</b> />
 102  *         &lt;output message="tns:AddNumbersOutput" name="bar"
 103  *           <b>wsam:Action="http://example.com/numbers/AddNumbersPortType/AddNumbersResponse"</b>/>
 104  *       &lt;/operation>
 105  *     &lt;/portType>
 106  *     ...
 107  *   &lt;/definitions>
 108  * </pre>
 109  *
 110  * It is legitimate to specify an explicit value for <code>Action</code> message addressing property for
 111  * <code>output</code> message only. In this case, <code>wsam:Action</code> value for the
 112  * WSDL <code>input</code> message is computed using the algorithm in the JAX-WS specification.
 113  *
 114  * <p>
 115  * <b>Example 3</b>: See {@link FaultAction} annotation for an example of
 116  * how to specify an explicit value for <code>Action</code> message addressing property for the
 117  * <code>fault</code> message.
 118  *
 119  * @see FaultAction
 120  *
 121  * @since 1.6, JAX-WS 2.1
 122  */
 123 
 124 @Documented
 125 @Retention(RetentionPolicy.RUNTIME)
 126 @Target(ElementType.METHOD)
 127 public @interface Action {
 128     /**
 129      * Explicit value of the WS-Addressing <code>Action</code> message addressing property for the <code>input</code>
 130      * message of the operation.
 131      */
 132     String input() default "";
 133 
 134     /**
 135      * Explicit value of the WS-Addressing <code>Action</code> message addressing property for the <code>output</code>
 136      * message of the operation.
 137      */
 138     String output() default "";
 139 
 140     /**
 141      * Explicit value of the WS-Addressing <code>Action</code> message addressing property for the <code>fault</code>
 142      * message(s) of the operation. Each exception that is mapped to a fault and requires an explicit WS-Addressing
 143      * <code>Action</code> message addressing property, needs to be specified as a value in this property
 144      * using {@link FaultAction} annotation.
 145      */
 146     FaultAction[] fault() default { };
 147 }