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.rest.client.remote; 014 015import static java.lang.annotation.ElementType.*; 016import static java.lang.annotation.RetentionPolicy.*; 017 018import java.io.*; 019import java.lang.annotation.*; 020 021import org.apache.juneau.http.annotation.*; 022 023/** 024 * Annotation applied to Java methods on REST proxy. 025 * 026 * <div class='warn'> 027 * <b>Deprecated</b> - Use {@link org.apache.juneau.http.remote.RemoteMethod} 028 * </div> 029 * 030 * <ul class='seealso'> 031 * <li class='link'>{@doc juneau-rest-client.RestProxies} 032 * </ul> 033 */ 034@Documented 035@Target(METHOD) 036@Retention(RUNTIME) 037@Inherited 038@Deprecated 039public @interface RemoteMethod { 040 041 /** 042 * REST service path. 043 * 044 * <p> 045 * The possible values are: 046 * <ul class='spaced-list'> 047 * <li>An absolute URL. 048 * <li>A relative URL interpreted as relative to the root URL defined on the <c>RestClient</c> and/or {@link RemoteResource#path()}. 049 * <li>No path. 050 * </ul> 051 * 052 * <p> 053 * If you do not specify a path, then the path is inferred from the Java method name. 054 * 055 * <h5 class='figure'>Example:</h5> 056 * <p class='bcode'> 057 * <jc>// POST /pet</jc> 058 * <ja>@RestMethod</ja> 059 * <jk>public void</jk> postPet(...) {...} 060 * </p> 061 */ 062 String path() default ""; 063 064 /** 065 * Defines the HTTP method to use for REST calls. 066 * 067 * <p> 068 * If not specified, then the method is inferred from the Java method name. 069 * 070 * <h5 class='figure'>Example:</h5> 071 * <p class='bcode'> 072 * <jc>// POST /pet</jc> 073 * <ja>@RestMethod</ja> 074 * <jk>public void</jk> postPet(...) {...} 075 * </p> 076 * 077 * <br>If the method cannot be inferred, then the default is <js>"GET"</js>. 078 */ 079 String method() default ""; 080 081 /** 082 * The value the remote method returns. 083 * 084 * <p> 085 * Possible values: 086 * <ul class='spaced-list'> 087 * <li> 088 * {@link RemoteReturn#BODY} (default) - The body of the HTTP response converted to a POJO. 089 * <br>The return type on the Java method can be any of the following: 090 * <ul class='spaced-list'> 091 * <li> 092 * <jk>void</jk> - Don't parse any response. Note that the method will still throw an exception if an 093 * error HTTP status is returned. 094 * <li> 095 * Any parsable POJO - The body of the response will be converted to the POJO using the parser defined 096 * on the <c>RestClient</c>. 097 * <li> 098 * Any POJO annotated with the {@link Response @Response} annotation. 099 * This allows for response beans to be used which also allows for OpenAPI-based parsing and validation. 100 * <li> 101 * <c>HttpResponse</c> - Returns the raw <c>HttpResponse</c> returned by the inner 102 * <c>HttpClient</c>. 103 * <li> 104 * {@link Reader} - Returns access to the raw reader of the response. 105 * <li> 106 * {@link InputStream} - Returns access to the raw input stream of the response. 107 * </ul> 108 * <li> 109 * {@link RemoteReturn#STATUS} - The HTTP status code on the response. 110 * <br>The return type on the Java method can be any of the following: 111 * <ul> 112 * <li><jk>int</jk>/<c>Integer</c> - The HTTP response code. 113 * <li><jk>boolean</jk>/<c>Boolean</c> - <jk>true</jk> if the response code is <c><400</c> 114 * </ul> 115 * </ul> 116 */ 117 RemoteReturn returns() default RemoteReturn.BODY; 118}