Rename client annotations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user