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