1/*
2 * Copyright (c) 1997, 2013, 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
26package com.sun.xml.internal.ws.api.server;
27
28import com.sun.istack.internal.NotNull;
29import com.sun.istack.internal.Nullable;
30
31/**
32 * Resolves relative references among {@link SDDocument}s.
33 *
34 * <p>
35 * This interface is implemented by the caller of
36 * {@link SDDocument#writeTo} method so
37 * that the {@link SDDocument} can correctly produce references
38 * to other documents.
39 *
40 * <p>
41 * This mechanism allows the user of {@link WSEndpoint} to
42 * assign logical URLs to each {@link SDDocument} (which is often
43 * necessarily done in a transport-dependent way), and then
44 * serve description documents.
45 *
46 *
47 *
48 * <h2>Usage Example 1</h2>
49 * <p>
50 * HTTP servlet transport chose to expose those metadata documents
51 * to HTTP GET requests where each {@link SDDocument} is identified
52 * by a simple query string "?<i>ID</i>". (HTTP servlet transport
53 * assigns such IDs by itself.)
54 *
55 * <p>
56 * In this nameing scheme, when {@link SDDocument} X refers to
57 * {@link SDDocument} Y, it can put a reference as "?<i>IDofY</i>".
58 * By implementing {@link DocumentAddressResolver} it can do so.
59 *
60 * @author Kohsuke Kawaguchi
61 */
62public interface DocumentAddressResolver {
63    /**
64     * Produces a relative reference from one document to another.
65     *
66     * @param current
67     *      The document that is being generated.
68     * @param referenced
69     *      The document that is referenced.
70     * @return
71     *      The reference to be put inside {@code current} to refer to
72     *      {@code referenced}. This can be a relative URL as well as
73     *      an absolute. If null is returned, then the {@link SDDocument}
74     *      will produce a "implicit reference" (for example, &lt;xs:import>
75     *      without the @schemaLocation attribute, etc).
76     */
77    @Nullable String getRelativeAddressFor(@NotNull SDDocument current, @NotNull SDDocument referenced);
78}
79