325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.ws.developer;
325N/A
325N/Aimport com.sun.istack.internal.NotNull;
325N/Aimport com.sun.xml.internal.ws.api.message.Header;
325N/Aimport com.sun.xml.internal.ws.api.message.Headers;
325N/A
325N/Aimport javax.xml.transform.Source;
325N/Aimport javax.xml.ws.EndpointReference;
325N/Aimport javax.xml.ws.wsaddressing.W3CEndpointReference;
325N/Aimport java.util.ArrayList;
325N/Aimport java.util.List;
325N/A
325N/A/**
325N/A * Represents additional data to be added to EPRs
325N/A * created from {@link StatefulWebServiceManager} (for advanced users).
325N/A *
325N/A * <p>
325N/A * Occasionally it is convenient to be able to control the data to be
325N/A * present on {@link EndpointReference}s created by {@link StatefulWebServiceManager}.
325N/A * You can do so by using this class like this:
325N/A *
325N/A * <pre>
325N/A * statefulWebServiceManager.export({@link W3CEndpointReference}.class,myObject,
325N/A * new EPRRecipe().addReferenceParameter({@link Headers}.create(...))
325N/A * .addReferenceParameter({@link Headers}.create(...)));
325N/A * </pre>
325N/A *
325N/A * <p>
325N/A * The methods on this class follows <a href="http://www.martinfowler.com/bliki/FluentInterface.html">
325N/A * the fluent interface design</a> to allow construction without using a variable.
325N/A *
325N/A *
325N/A * <p>
325N/A * See <a href="http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/#eprinfomodel">
325N/A * WS-Addressing EPR information model</a> for more details.
325N/A *
325N/A * @author Kohsuke Kawaguchi
325N/A * @since 2.1.1
325N/A * @see StatefulWebServiceManager
325N/A * @see Headers
325N/A */
325N/Apublic final class EPRRecipe {
325N/A private final List<Header> referenceParameters = new ArrayList<Header>();
325N/A private final List<Source> metadata = new ArrayList<Source>();
325N/A
325N/A /**
325N/A * Gets all the reference parameters added so far.
325N/A */
325N/A public @NotNull List<Header> getReferenceParameters() {
325N/A return referenceParameters;
325N/A }
325N/A
325N/A /**
325N/A * Gets all the metadata added so far.
325N/A */
325N/A public @NotNull List<Source> getMetadata() {
325N/A return metadata;
325N/A }
325N/A
325N/A /**
325N/A * Adds a new reference parameter.
325N/A */
325N/A public EPRRecipe addReferenceParameter(Header h) {
325N/A if(h==null) throw new IllegalArgumentException();
325N/A referenceParameters.add(h);
325N/A return this;
325N/A }
325N/A
325N/A /**
325N/A * Adds all the headers as reference parameters.
325N/A */
325N/A public EPRRecipe addReferenceParameters(Header... headers) {
325N/A for (Header h : headers)
325N/A addReferenceParameter(h);
325N/A return this;
325N/A }
325N/A
325N/A /**
325N/A * Adds all the headers as reference parameters.
325N/A */
325N/A public EPRRecipe addReferenceParameters(Iterable<? extends Header> headers) {
325N/A for (Header h : headers)
325N/A addReferenceParameter(h);
325N/A return this;
325N/A }
325N/A
325N/A /**
325N/A * Adds a new metadata.
325N/A */
325N/A public EPRRecipe addMetadata(Source source) {
325N/A if(source==null) throw new IllegalArgumentException();
325N/A metadata.add(source);
325N/A return this;
325N/A }
325N/A
325N/A public EPRRecipe addMetadata(Source... sources) {
325N/A for (Source s : sources)
325N/A addMetadata(s);
325N/A return this;
325N/A }
325N/A
325N/A public EPRRecipe addMetadata(Iterable<? extends Source> sources) {
325N/A for (Source s : sources)
325N/A addMetadata(s);
325N/A return this;
325N/A }
325N/A}