public class GrpcClientBeanPostProcessor extends Object implements BeanPostProcessor
BeanPostProcessor
searches for fields and methods in beans that are annotated with GrpcClient
and sets them.Constructor and Description |
---|
GrpcClientBeanPostProcessor(ApplicationContext applicationContext)
Creates a new GrpcClientBeanPostProcessor with the given ApplicationContext.
|
Modifier and Type | Method and Description |
---|---|
protected List<ClientInterceptor> |
interceptorsFromAnnotation(GrpcClient annotation)
Gets or creates the
ClientInterceptor s that are referenced in the given annotation. |
Object |
postProcessBeforeInitialization(Object bean,
String beanName) |
protected <T> T |
processInjectionPoint(Member injectionTarget,
Class<T> injectionType,
GrpcClient annotation)
Processes the given injection point and computes the appropriate value for the injection.
|
protected <T> T |
valueForMember(String name,
Member injectionTarget,
Class<T> injectionType,
Channel channel)
Creates the instance to be injected for the given member.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
postProcessAfterInitialization
public GrpcClientBeanPostProcessor(ApplicationContext applicationContext)
applicationContext
- The application context that will be used to get lazy access to the
GrpcChannelFactory
and StubTransformer
s.public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
postProcessBeforeInitialization
in interface BeanPostProcessor
BeansException
protected <T> T processInjectionPoint(Member injectionTarget, Class<T> injectionType, GrpcClient annotation)
T
- The type of the value to be injected.injectionTarget
- The target of the injection.injectionType
- The class that will be used to compute injection.annotation
- The annotation on the target with the metadata for the injection.protected List<ClientInterceptor> interceptorsFromAnnotation(GrpcClient annotation) throws BeansException
ClientInterceptor
s that are referenced in the given annotation.
Note: This methods return value does not contain the global client interceptors because they are handled
by the GrpcChannelFactory
.
annotation
- The annotation to get the interceptors for.BeansException
- If the referenced interceptors weren't found or could not be created.protected <T> T valueForMember(String name, Member injectionTarget, Class<T> injectionType, Channel channel) throws BeansException
T
- The type of the instance to be injected.name
- The name that was used to create the channel.injectionTarget
- The target member for the injection.injectionType
- The class that should injected.channel
- The channel that should be used to create the instance.BeansException
- If the value of the field could not be created or the type of the field is unsupported.