Rename client annotations

This commit is contained in:
Dave Syer
2025-03-26 08:13:21 +00:00
parent 6bb10ab65e
commit 55bd93958a
8 changed files with 23 additions and 46 deletions

View File

@@ -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 {};
}

View File

@@ -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 {};
}
}

View File

@@ -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() + ".");
}

View File

@@ -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);
}