blob: ab5e5dcd96a2627e0dbc64e4875ab5c98f66d71c [file] [log] [blame]
<!--
/***************************************************************************************************************************
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
***************************************************************************************************************************/
-->
@Response
<p>
The {@link oaj.http.annotation.Response @Response} annotation can be applied to types returned by <ja>@RemoteMethod</ja>-annotated methods.
</p>
<ul class='doctree'>
<li class='ja'>{@link oaj.http.annotation.Response}
<ul>
<li class='jf'>{@link oaj.http.annotation.Response#partParser() partParser} - Override the part parser.
</ul>
</ul>
<p>
The <ja>@Response</ja> annotation can be used to define interfaces for retrieving response parts using a bean-like proxy.
</p>
<h5 class='figure'>Example:</h5>
<p class='bpcode w800'>
<ja>@RemoteResource</ja>
<jk>public interface</jk> PetStore {
<ja>@RemoteMethod</ja>
CreatePetResponse postPet(...);
}
</p>
<p class='bpcode w800'>
<ja>@Response</ja>
<jk>public interface</jk> CreatePetResponse {
<ja>@ResponseBody</ja>
Pet getBody();
<ja>@ResponseHeader</ja>(<js>"E-Tag"</js>)
UUID getUUID();
<ja>@ResponseStatus</ja>
int getStatus();
}
</p>
<p class='bpcode w800'>
PetStore store = restClient.getRemoteResource(PetStore.<jk>class</jk>, <js>"http://localhost:10000"</js>);
CreatePetResponse response = store.postPet(...);
Pet pet = response.getBody();
UUID uuid = response.getUUID();
<jk>int</jk> status = response.getStatus();
</p>
<p>
The annotated methods must be no-arg.
They can be named anything.
</p>
<p>
Any of the following annotations can be used on the methods:
</p>
<ul>
<li class='ja'>{@link oaj.http.annotation.ResponseBody}
<li class='ja'>{@link oaj.http.annotation.ResponseHeader}
<li class='ja'>{@link oaj.http.annotation.ResponseStatus}
</ul>
<p>
The behavior and functionality of all of the annotations are the same as if they were used on method arguments directly. This means full support for OpenAPI serialization and validation.
</p>