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