src/share/jaxws_classes/com/sun/xml/internal/ws/developer/EPRRecipe.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
1 /*
2 * Copyright (c) 1997, 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 com.sun.xml.internal.ws.developer;
27
28 import com.sun.istack.internal.NotNull;
29 import com.sun.xml.internal.ws.api.message.Header;
30 import com.sun.xml.internal.ws.api.message.Headers;
31
32 import javax.xml.transform.Source;
33 import javax.xml.ws.EndpointReference;
34 import javax.xml.ws.wsaddressing.W3CEndpointReference;
35 import java.util.ArrayList;
36 import java.util.List;
37
38 /**
39 * Represents additional data to be added to EPRs
40 * created from {@link StatefulWebServiceManager} (for advanced users).
41 *
42 * <p>
43 * Occasionally it is convenient to be able to control the data to be
44 * present on {@link EndpointReference}s created by {@link StatefulWebServiceManager}.
45 * You can do so by using this class like this:
46 *
47 * <pre>
48 * statefulWebServiceManager.export({@link W3CEndpointReference}.class,myObject,
49 * new EPRRecipe().addReferenceParameter({@link Headers}.create(...))
50 * .addReferenceParameter({@link Headers}.create(...)));
51 * </pre>
52 *
53 * <p>
54 * The methods on this class follows <a href="http://www.martinfowler.com/bliki/FluentInterface.html">
55 * the fluent interface design</a> to allow construction without using a variable.
56 *
57 *
58 * <p>
59 * See <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/#eprinfomodel">
60 * WS-Addressing EPR information model</a> for more details.
61 *
62 * @author Kohsuke Kawaguchi
63 * @since 2.1.1
64 * @see StatefulWebServiceManager
65 * @see Headers
66 */
67 public final class EPRRecipe {
68 private final List<Header> referenceParameters = new ArrayList<Header>();
69 private final List<Source> metadata = new ArrayList<Source>();
70
71 /**
72 * Gets all the reference parameters added so far.
73 */
74 public @NotNull List<Header> getReferenceParameters() {
75 return referenceParameters;
76 }
77
78 /**
79 * Gets all the metadata added so far.
80 */
81 public @NotNull List<Source> getMetadata() {
82 return metadata;
83 }
84
85 /**
86 * Adds a new reference parameter.
87 */
88 public EPRRecipe addReferenceParameter(Header h) {
89 if(h==null) throw new IllegalArgumentException();
90 referenceParameters.add(h);
91 return this;
92 }
93
94 /**
95 * Adds all the headers as reference parameters.
96 */
97 public EPRRecipe addReferenceParameters(Header... headers) {
98 for (Header h : headers)
99 addReferenceParameter(h);
100 return this;
101 }
102
103 /**
104 * Adds all the headers as reference parameters.
105 */
106 public EPRRecipe addReferenceParameters(Iterable<? extends Header> headers) {
107 for (Header h : headers)
108 addReferenceParameter(h);
109 return this;
110 }
111
112 /**
113 * Adds a new metadata.
114 */
115 public EPRRecipe addMetadata(Source source) {
116 if(source==null) throw new IllegalArgumentException();
117 metadata.add(source);
118 return this;
119 }
120
121 public EPRRecipe addMetadata(Source... sources) {
122 for (Source s : sources)
123 addMetadata(s);
124 return this;
125 }
126
127 public EPRRecipe addMetadata(Iterable<? extends Source> sources) {
128 for (Source s : sources)
129 addMetadata(s);
130 return this;
131 }
132 }

mercurial