* @Inject - * @GrpcChannel(name = "foo") + * @GrpcChannel("foo") * private Channel channel; ** @@ -45,7 +43,7 @@ * *
* @Inject - * @GrpcChannel(name = "foo") + * @GrpcChannel("foo") * @GrpcProxy * private FooServiceClient client; *@@ -55,7 +53,7 @@ * *
* @Grpc(name = "FooService") - * @GrpcChannel(name = "foo") + * @GrpcChannel("foo") * public interface FooServiceClient { * ... * }; @@ -66,30 +64,11 @@ @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface GrpcChannel { + /** * The name of the configured channel or gRPC server host. * * @return name of the channel */ - @Nonbinding String name(); - - /** - * An {@link jakarta.enterprise.util.AnnotationLiteral} for the - * {@link GrpcChannel} annotation. - */ - class Literal extends AnnotationLiteralimplements GrpcChannel { - - /** - * The singleton instance of {@link io.helidon.microprofile.grpc.client.GrpcChannel.Literal}. - */ - public static final Literal INSTANCE = new Literal(); - - @Serial - private static final long serialVersionUID = 1L; - - @Override - public String name() { - return ""; - } - } + @Nonbinding String value(); } diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcClientBuilder.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcClientBuilder.java index d45db0062a9..572609ed4b4 100644 --- a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcClientBuilder.java +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcClientBuilder.java @@ -21,9 +21,9 @@ import java.util.function.Supplier; import io.helidon.common.Builder; +import io.helidon.grpc.api.GrpcMarshaller; +import io.helidon.grpc.api.GrpcMethod; import io.helidon.grpc.core.MethodHandler; -import io.helidon.microprofile.grpc.api.GrpcMarshaller; -import io.helidon.microprofile.grpc.api.GrpcMethod; import io.helidon.microprofile.grpc.core.AbstractServiceBuilder; import io.helidon.microprofile.grpc.core.AnnotatedMethod; import io.helidon.microprofile.grpc.core.AnnotatedMethodList; @@ -139,7 +139,7 @@ private void addServiceMethod(ClientServiceDescriptor.Builder builder, Annotated Class> responseType = handler.getResponseType(); AnnotatedMethodConfigurer configurer = new AnnotatedMethodConfigurer(method, requestType, responseType, handler); - switch (annotation.type()) { + switch (annotation.value()) { case UNARY: builder.unary(name, configurer); break; @@ -154,7 +154,7 @@ private void addServiceMethod(ClientServiceDescriptor.Builder builder, Annotated break; case UNKNOWN: default: - LOGGER.log(Level.ERROR, () -> "Unrecognized method type " + annotation.type()); + LOGGER.log(Level.ERROR, () -> "Unrecognized method type " + annotation.value()); } } diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxy.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxy.java index 3adc9df56be..45121f8ef15 100644 --- a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxy.java +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxy.java @@ -16,13 +16,11 @@ package io.helidon.microprofile.grpc.client; -import java.io.Serial; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import jakarta.enterprise.util.AnnotationLiteral; import jakarta.inject.Qualifier; /** @@ -33,19 +31,4 @@ @Retention(RetentionPolicy.RUNTIME) @Qualifier public @interface GrpcProxy { - - /** - * An {@link jakarta.enterprise.util.AnnotationLiteral} for the - * {@link io.helidon.microprofile.grpc.client.GrpcProxy} annotation. - */ - class Literal extends AnnotationLiteral implements GrpcProxy { - - /** - * The singleton instance of {@link io.helidon.microprofile.grpc.client.GrpcProxy.Literal}. - */ - public static final Literal INSTANCE = new Literal(); - - @Serial - private static final long serialVersionUID = 1L; - } } diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyBuilder.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyBuilder.java index c1a0eaaae05..f4b516e67c2 100644 --- a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyBuilder.java +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyBuilder.java @@ -46,8 +46,8 @@ private GrpcProxyBuilder(GrpcServiceClient client, Class type) { * for a given gRPC service interface. * * The class passed to this method should be properly annotated with - * {@link io.helidon.microprofile.grpc.api.Grpc} and - * {@link io.helidon.microprofile.grpc.api.GrpcMethod} annotations + * {@link io.helidon.grpc.api.Grpc} and + * {@link io.helidon.grpc.api.GrpcMethod} annotations * so that the proxy can properly route calls to the server. * * @param channel the {@link io.grpc.Channel} to connect to the server diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyProducer.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyProducer.java index 86ab53f2395..1b4722a60a6 100644 --- a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyProducer.java +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcProxyProducer.java @@ -48,16 +48,16 @@ private GrpcProxyProducer() { * @return a gRPC client proxy */ @GrpcProxy - @GrpcChannel(name = GrpcChannelsProvider.DEFAULT_CHANNEL_NAME) + @GrpcChannel(value = GrpcChannelsProvider.DEFAULT_CHANNEL_NAME) static Object proxyUsingNamedChannel(InjectionPoint injectionPoint, ChannelProducer producer) { Class> type = ModelHelper.getGenericType(injectionPoint.getType()); String channelName; if (injectionPoint.getAnnotated().isAnnotationPresent(GrpcChannel.class)) { - channelName = injectionPoint.getAnnotated().getAnnotation(GrpcChannel.class).name(); + channelName = injectionPoint.getAnnotated().getAnnotation(GrpcChannel.class).value(); } else { channelName = type.isAnnotationPresent(GrpcChannel.class) - ? type.getAnnotation(GrpcChannel.class).name() + ? type.getAnnotation(GrpcChannel.class).value() : GrpcChannelsProvider.DEFAULT_CHANNEL_NAME; } diff --git a/microprofile/grpc/client/src/main/java/module-info.java b/microprofile/grpc/client/src/main/java/module-info.java index 2f85ea74a87..02a914828d5 100644 --- a/microprofile/grpc/client/src/main/java/module-info.java +++ b/microprofile/grpc/client/src/main/java/module-info.java @@ -24,7 +24,7 @@ requires io.helidon.tracing; requires io.helidon.config; requires io.helidon.webclient.grpc; - requires io.helidon.microprofile.grpc.api; + requires io.helidon.grpc.api; requires io.helidon.microprofile.grpc.core; requires io.grpc; diff --git a/microprofile/grpc/client/src/test/java/io/helidon/microprofile/grpc/client/EchoServiceTest.java b/microprofile/grpc/client/src/test/java/io/helidon/microprofile/grpc/client/EchoServiceTest.java index d93c23d0b7a..5a72e88ed5d 100644 --- a/microprofile/grpc/client/src/test/java/io/helidon/microprofile/grpc/client/EchoServiceTest.java +++ b/microprofile/grpc/client/src/test/java/io/helidon/microprofile/grpc/client/EchoServiceTest.java @@ -23,9 +23,9 @@ import io.helidon.common.configurable.Resource; import io.helidon.common.tls.Tls; -import io.helidon.microprofile.grpc.api.Grpc; -import io.helidon.microprofile.grpc.api.GrpcMarshaller; -import io.helidon.microprofile.grpc.api.Unary; +import io.helidon.grpc.api.Grpc; +import io.helidon.grpc.api.GrpcMarshaller; +import io.helidon.grpc.api.Unary; import io.helidon.microprofile.grpc.server.GrpcMpCdiExtension; import io.helidon.microprofile.testing.junit5.AddBean; import io.helidon.microprofile.testing.junit5.AddExtension; @@ -120,7 +120,7 @@ public void onCompleted() { @GrpcMarshaller("java") public static class EchoService { - @Unary(name = "Echo") + @Unary("Echo") public void echo(String request, StreamObserver
observer) { try { complete(observer, request); @@ -130,12 +130,12 @@ public void echo(String request, StreamObserver observer) { } } - @Grpc(name = "EchoService") + @Grpc("EchoService") @GrpcMarshaller("java") - @GrpcChannel(name = "echo-channel") + @GrpcChannel(value = "echo-channel") public interface EchoServiceClient { - @Unary(name = "Echo") + @Unary("Echo") void echo(String request, StreamObserver observer); } }