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 * Default request header list. 041 * 042 * <p> 043 * Specifies a supplier of headers to set on all requests. 044 * 045 * <h5 class='section'>Notes:</h5><ul> 046 * <li class='note'> 047 * Supplier class must provide a public no-arg constructor. 048 * </ul> 049 * 050 * @return The annotation value. 051 */ 052 Class<? extends HeaderList> headerList() default HeaderList.Void.class; 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="https://juneau.apache.org/docs/topics/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 * REST service path. 072 * 073 * <ul class='values'> 074 * <li>An absolute URL. 075 * <li>A relative URL interpreted as relative to the root URL defined on the <c>RestClient</c> 076 * <li>No path interpreted as the class name (e.g. <js>"http://localhost/root-url/org.foo.MyInterface"</js>) 077 * </ul> 078 * 079 * <h5 class='section'>Notes:</h5><ul> 080 * <li class='note'> 081 * Supports <a class="doclink" href="https://juneau.apache.org/docs/topics/DefaultVarResolver">VarResolver.DEFAULT</a> 082 * (e.g. <js>"$P{mySystemProperty}"</js>). 083 * </ul> 084 * 085 * @return The annotation value. 086 */ 087 String path() default ""; 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}