Rename client annotations
This commit is contained in:
@@ -21,7 +21,6 @@ import org.springframework.experimental.boot.server.exec.MavenClasspathEntry;
|
||||
import org.springframework.experimental.boot.test.context.EnableDynamicProperty;
|
||||
import org.springframework.experimental.boot.test.context.OAuth2ClientProviderIssuerUri;
|
||||
import org.springframework.grpc.client.ChannelBuilderOptions;
|
||||
import org.springframework.grpc.client.EnableGrpcClients;
|
||||
import org.springframework.grpc.client.GrpcClient;
|
||||
import org.springframework.grpc.client.GrpcClientRegistryCustomizer;
|
||||
import org.springframework.grpc.client.interceptor.security.BearerTokenAuthenticationInterceptor;
|
||||
@@ -114,8 +113,8 @@ public class GrpcServerApplicationTests {
|
||||
|
||||
@TestConfiguration(proxyBeanMethods = false)
|
||||
@EnableDynamicProperty
|
||||
@EnableGrpcClients(@GrpcClient(target = "stub",
|
||||
types = { SimpleGrpc.SimpleBlockingStub.class, ServerReflectionGrpc.ServerReflectionStub.class }))
|
||||
@GrpcClient(target = "stub",
|
||||
types = { SimpleGrpc.SimpleBlockingStub.class, ServerReflectionGrpc.ServerReflectionStub.class })
|
||||
static class ExtraConfiguration {
|
||||
|
||||
private String token;
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.grpc.client.EnableGrpcClients;
|
||||
import org.springframework.grpc.client.GrpcClient;
|
||||
import org.springframework.grpc.sample.proto.HelloReply;
|
||||
import org.springframework.grpc.sample.proto.HelloRequest;
|
||||
@@ -47,7 +46,7 @@ public class GrpcServerApplicationTests {
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@EnableGrpcClients(@GrpcClient(types = ReactorSimpleGrpc.ReactorSimpleStub.class))
|
||||
@GrpcClient(types = ReactorSimpleGrpc.ReactorSimpleStub.class)
|
||||
static class ExtraConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.grpc.client.BlockingStubFactory;
|
||||
import org.springframework.grpc.client.ChannelBuilderOptions;
|
||||
import org.springframework.grpc.client.EnableGrpcClients;
|
||||
import org.springframework.grpc.client.GrpcClient;
|
||||
import org.springframework.grpc.client.GrpcClientRegistryCustomizer;
|
||||
import org.springframework.grpc.client.interceptor.security.BasicAuthenticationInterceptor;
|
||||
@@ -109,8 +108,8 @@ public class GrpcServerApplicationTests {
|
||||
}
|
||||
|
||||
@TestConfiguration
|
||||
@EnableGrpcClients(@GrpcClient(target = "stub", prefix = "unsecured",
|
||||
types = { SimpleGrpc.SimpleBlockingStub.class, ServerReflectionGrpc.ServerReflectionStub.class }))
|
||||
@GrpcClient(target = "stub", prefix = "unsecured",
|
||||
types = { SimpleGrpc.SimpleBlockingStub.class, ServerReflectionGrpc.ServerReflectionStub.class })
|
||||
static class ExtraConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024-2024 the original author or authors.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
package org.springframework.grpc.client;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Documented
|
||||
@Import(GrpcClientConfiguration.class)
|
||||
public @interface EnableGrpcClients {
|
||||
|
||||
GrpcClient[] value() default {};
|
||||
|
||||
}
|
||||
@@ -17,10 +17,13 @@ package org.springframework.grpc.client;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Repeatable;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import io.grpc.stub.AbstractStub;
|
||||
|
||||
/**
|
||||
@@ -33,6 +36,8 @@ import io.grpc.stub.AbstractStub;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@Documented
|
||||
@Import(GrpcClientConfiguration.class)
|
||||
@Repeatable(GrpcClient.Container.class)
|
||||
public @interface GrpcClient {
|
||||
|
||||
/**
|
||||
@@ -77,4 +82,13 @@ public @interface GrpcClient {
|
||||
*/
|
||||
String[] basePackages() default {};
|
||||
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@interface Container {
|
||||
|
||||
GrpcClient[] value() default {};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class GrpcClientConfiguration implements ImportBeanDefinitionRegistrar {
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata meta, BeanDefinitionRegistry registry) {
|
||||
Set<AnnotationAttributes> attrs = meta.getMergedRepeatableAnnotationAttributes(GrpcClient.class,
|
||||
EnableGrpcClients.class, false);
|
||||
GrpcClient.Container.class, false);
|
||||
for (AnnotationAttributes attr : attrs) {
|
||||
register(registry, meta, attr, meta.getClassName() + ".");
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ReactiveStubBeanDefinitionRegistrarTests {
|
||||
registry.registerSingleton("exceptionHandler", GrpcExceptionHandler.class);
|
||||
registrar.registerBeanDefinitions(metadata, registry);
|
||||
processor = (ReactiveStubBeanDefinitionRegistrar.ReactiveStubBeanFactoryPostProcessor) registry
|
||||
.getBean(BEAN_NAME);
|
||||
.getBean(BEAN_NAME);
|
||||
processor.setApplicationContext(registry);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.grpc.autoconfigure.client.GrpcClientProperties.ChannelConfig;
|
||||
import org.springframework.grpc.client.BlockingStubFactory;
|
||||
import org.springframework.grpc.client.EnableGrpcClients;
|
||||
import org.springframework.grpc.client.GrpcClient;
|
||||
import org.springframework.grpc.client.GrpcClientRegistryCustomizer;
|
||||
import org.springframework.grpc.client.GrpcClientRegistryPostProcessor;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnMissingBean(GrpcClientRegistryPostProcessor.class)
|
||||
@EnableGrpcClients
|
||||
@GrpcClient
|
||||
public class ClientScanConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
Reference in New Issue
Block a user