001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.http.remote;
014
015import static java.lang.annotation.ElementType.*;
016import static java.lang.annotation.RetentionPolicy.*;
017
018import java.lang.annotation.*;
019
020import org.apache.juneau.http.header.*;
021
022/**
023 * Identifies a proxy against a REST interface.
024 *
025 * <h5 class='section'>See Also:</h5><ul>
026 *    <li class='link'><a class="doclink" href="../../../../../index.html#jrc.Proxies">REST Proxies</a>
027 * </ul>
028 */
029@Documented
030@Target({TYPE})
031@Retention(RUNTIME)
032@Inherited
033public @interface Remote {
034
035   /**
036    * REST service path.
037    *
038    * <ul class='values'>
039    *    <li>An absolute URL.
040    *    <li>A relative URL interpreted as relative to the root URL defined on the <c>RestClient</c>
041    *    <li>No path interpreted as the class name (e.g. <js>"http://localhost/root-url/org.foo.MyInterface"</js>)
042    * </ul>
043    *
044    * <h5 class='section'>Notes:</h5><ul>
045    *    <li class='note'>
046    *       Supports <a class="doclink" href="../../../../../index.html#jm.DefaultVarResolver">VarResolver.DEFAULT</a>
047    *       (e.g. <js>"$P{mySystemProperty}"</js>).
048    * </ul>
049    *
050    * @return The annotation value.
051    */
052   String path() default "";
053
054   /**
055    * Default request headers.
056    *
057    * <p>
058    * Specifies headers to set on all requests.
059    *
060    * <h5 class='section'>Notes:</h5><ul>
061    *    <li class='note'>
062    *       Supports <a class="doclink" href="../../../../../index.html#jm.DefaultVarResolver">VarResolver.DEFAULT</a>
063    *       (e.g. <js>"$P{mySystemProperty}"</js>).
064    * </ul>
065    *
066    * @return The annotation value.
067    */
068   String[] headers() default {};
069
070   /**
071    * Default request header list.
072    *
073    * <p>
074    * Specifies a supplier of headers to set on all requests.
075    *
076    * <h5 class='section'>Notes:</h5><ul>
077    *    <li class='note'>
078    *       Supplier class must provide a public no-arg constructor.
079    * </ul>
080    *
081    * @return The annotation value.
082    */
083   Class<? extends HeaderList> headerList() default HeaderList.Void.class;
084
085   /**
086    * Specifies the client version of this interface.
087    *
088    * <p>
089    * Used to populate the <js>"Client-Version"</js> header that identifies what version of client this is
090    * so that the server side can handle older versions accordingly.
091    *
092    * <p>
093    * The format of this is a string of the format <c>#[.#[.#[...]]</c> (e.g. <js>"1.2.3"</js>).
094    *
095    * <p>
096    * The server side then uses an OSGi-version matching pattern to identify which methods to call:
097    * <p class='bjava'>
098    *    <jc>// Call this method if Client-Version is at least 2.0.
099    *    // Note that this also matches 2.0.1.</jc>
100    *    <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"2.0"</js>)
101    *    <jk>public</jk> Object method1()  {...}
102    *
103    *    <jc>// Call this method if Client-Version is at least 1.1, but less than 2.0.</jc>
104    *    <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[1.1,2.0)"</js>)
105    *    <jk>public</jk> Object method2()  {...}
106    *
107    *    <jc>// Call this method if Client-Version is less than 1.1.</jc>
108    *    <ja>@RestGet</ja>(path=<js>"/foobar"</js>, clientVersion=<js>"[0,1.1)"</js>)
109    *    <jk>public</jk> Object method3()  {...}
110    * </p>
111    *
112    * <h5 class='section'>Notes:</h5><ul>
113    *    <li class='note'>
114    *       Supports <a class="doclink" href="../../../../../index.html#jm.DefaultVarResolver">VarResolver.DEFAULT</a>
115    *       (e.g. <js>"$P{mySystemProperty}"</js>).
116    * </ul>
117    *
118    * @return The annotation value.
119    */
120   String version() default "";
121
122   /**
123    * Specifies the client version header name.
124    *
125    * <p>
126    * The default value is <js>"Client-Version"</js>.
127    *
128    * <h5 class='section'>Notes:</h5><ul>
129    *    <li class='note'>
130    *       Supports <a class="doclink" href="../../../../../index.html#jm.DefaultVarResolver">VarResolver.DEFAULT</a>
131    *       (e.g. <js>"$P{mySystemProperty}"</js>).
132    * </ul>
133    *
134    * @return The annotation value.
135    */
136   String versionHeader() default "";
137}