diff --git a/spring/spring6/src/main/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapter.java b/spring/spring6/src/main/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapter.java index 7ef88bc6158..e55338ae6e1 100644 --- a/spring/spring6/src/main/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapter.java +++ b/spring/spring6/src/main/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapter.java @@ -56,6 +56,18 @@ /** * A {@link ReactorHttpExchangeAdapter} implementation for the Armeria {@link WebClient}. + * + *

{@code
+ * import com.linecorp.armeria.client.WebClient;
+ * import org.springframework.web.service.invoker.HttpServiceProxyFactory;
+ *
+ * WebClient webClient = ...;
+ * ArmeriaHttpExchangeAdapter adapter = ArmeriaHttpExchangeAdapter.of(webClient);
+ * MyService service =
+ *   HttpServiceProxyFactory.builderFor(adapter)
+ *                          .build()
+ *                          .createClient(MyService.class);
+ * }
*/ public final class ArmeriaHttpExchangeAdapter extends AbstractReactorHttpExchangeAdapter { @@ -144,13 +156,13 @@ public boolean supportsRequestAttributes() { * Sends the specified {@link HttpRequestValues} to the {@link WebClient} and returns the response. * *

Implementation note

- * In order to encode {@link HttpRequestValues#getBodyValue()} to {@link HttpData}, we - * need to convert the {@link HttpRequestValues} to {@link ClientRequest} first. The serialization process - * is delegated to the {@link ClientRequest}. After that, the request is written to - * {@link ArmeriaClientHttpRequest} to send the request via the {@link WebClient}. + * In order to encode {@link HttpRequestValues#getBodyValue()} to {@link HttpData}, we need to convert + * the {@link HttpRequestValues} to {@link ClientRequest} first. The serialization process is delegated to + * the {@link ClientRequest}. After that, the request is written to {@link ArmeriaClientHttpRequest} to send + * the request via the {@link WebClient}. * - *

The response handling has to be done in the reverse order. Armeria {@link HttpResponse} is converted into - * {@link ArmeriaClientHttpResponse} first and then converted into {@link ClientResponse}. + *

The response handling has to be done in the reverse order. Armeria {@link HttpResponse} is converted + * into {@link ArmeriaClientHttpResponse} first and then converted into {@link ClientResponse}. */ private Mono execute(HttpRequestValues requestValues) { final URI uri; diff --git a/spring/spring6/src/main/java/com/linecorp/armeria/spring/client/package-info.java b/spring/spring6/src/main/java/com/linecorp/armeria/spring/client/package-info.java new file mode 100644 index 00000000000..6535d480e07 --- /dev/null +++ b/spring/spring6/src/main/java/com/linecorp/armeria/spring/client/package-info.java @@ -0,0 +1,24 @@ +/* + * Copyright 2016 LINE Corporation + * + * LINE Corporation 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: + * + * https://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. + */ + +/** + * + * Spring 6 HTTP interface integration. + */ +@NonNullByDefault +package com.linecorp.armeria.spring.client; + +import com.linecorp.armeria.common.annotation.NonNullByDefault; diff --git a/spring/spring6/src/main/java/com/linecorp/armeria/spring/internal/client/package-info.java b/spring/spring6/src/main/java/com/linecorp/armeria/spring/internal/client/package-info.java new file mode 100644 index 00000000000..ba3539a8598 --- /dev/null +++ b/spring/spring6/src/main/java/com/linecorp/armeria/spring/internal/client/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2016 LINE Corporation + * + * LINE Corporation 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: + * + * https://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. + */ + +/** + * Various classes used internally. Anything in this package can be changed or removed at any time. + */ +@NonNullByDefault +package com.linecorp.armeria.spring.internal.client; + +import com.linecorp.armeria.common.annotation.NonNullByDefault; diff --git a/spring/spring6/src/main/java/com/linecorp/armeria/spring/internal/common/package-info.java b/spring/spring6/src/main/java/com/linecorp/armeria/spring/internal/common/package-info.java new file mode 100644 index 00000000000..f5f9f0a729f --- /dev/null +++ b/spring/spring6/src/main/java/com/linecorp/armeria/spring/internal/common/package-info.java @@ -0,0 +1,23 @@ +/* + * Copyright 2016 LINE Corporation + * + * LINE Corporation 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: + * + * https://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. + */ + +/** + * Various classes used internally. Anything in this package can be changed or removed at any time. + */ +@NonNullByDefault +package com.linecorp.armeria.spring.internal.common; + +import com.linecorp.armeria.common.annotation.NonNullByDefault; diff --git a/spring/spring6/src/test/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapterTest.java b/spring/spring6/src/test/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapterTest.java index 8250c6aa6a8..47d5dbc81f1 100644 --- a/spring/spring6/src/test/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapterTest.java +++ b/spring/spring6/src/test/java/com/linecorp/armeria/spring/client/ArmeriaHttpExchangeAdapterTest.java @@ -29,7 +29,6 @@ * limitations under the License. */ - package com.linecorp.armeria.spring.client; import static org.assertj.core.api.Assertions.assertThat; @@ -184,13 +183,13 @@ void uriBuilderFactoryWithPathVariableAndRequestParam() throws Exception { assertThat(server.takeRequest(1, TimeUnit.SECONDS)).isNull(); } - @Test void ignoredUriBuilderFactory() throws Exception { final String expectedResponseBody = "hello"; prepareResponse(response -> response.status(200).content(expectedResponseBody)); final URI dynamicUri = server.httpUri().resolve("/greeting/123"); - final UriBuilderFactory factory = new DefaultUriBuilderFactory(anotherServer.httpUri().resolve("/").toString()); + final UriBuilderFactory factory = new DefaultUriBuilderFactory( + anotherServer.httpUri().resolve("/").toString()); final String actualBody = initService().getWithIgnoredUriBuilderFactory(dynamicUri, factory); @@ -246,6 +245,5 @@ String getWithUriBuilderFactory(UriBuilderFactory uriBuilderFactory, @GetExchange("/greeting") String getWithIgnoredUriBuilderFactory(URI uri, UriBuilderFactory uriBuilderFactory); - } }