Skip to content

Commit f1c95fa

Browse files
committed
Refactor FeignClientSpecification post-processor
Replace raw BeanPostProcessor implementation with GenericBeanPostProcessorAdapter<FeignClientSpecification> to enable type-safe post-processing. Remove AOP target-class lookup and cast, simplify the hook to processAfterInitialization(FeignClientSpecification, String), and tighten the bean-name check to start with "default.". Update imports and JavaDoc accordingly.
1 parent 19962bb commit f1c95fa

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

microsphere-spring-cloud-openfeign/src/main/java/io/microsphere/spring/cloud/openfeign/autoconfigure/FeignClientSpecificationPostProcessor.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.microsphere.spring.cloud.openfeign.autoconfigure;
22

33
import io.microsphere.logging.Logger;
4+
import io.microsphere.spring.beans.factory.config.GenericBeanPostProcessorAdapter;
45
import io.microsphere.spring.cloud.openfeign.autorefresh.AutoRefreshCapability;
56
import org.springframework.beans.BeansException;
67
import org.springframework.beans.factory.config.BeanPostProcessor;
@@ -9,7 +10,6 @@
910
import static io.microsphere.logging.LoggerFactory.getLogger;
1011
import static io.microsphere.util.ArrayUtils.arrayToString;
1112
import static io.microsphere.util.ArrayUtils.combine;
12-
import static org.springframework.aop.support.AopUtils.getTargetClass;
1313

1414
/**
1515
* {@link BeanPostProcessor} for {@link FeignClientSpecification}
@@ -19,7 +19,7 @@
1919
* @see org.springframework.cloud.openfeign.FeignClientSpecification
2020
* @since 0.0.1
2121
*/
22-
public class FeignClientSpecificationPostProcessor implements BeanPostProcessor {
22+
public class FeignClientSpecificationPostProcessor extends GenericBeanPostProcessorAdapter<FeignClientSpecification> {
2323

2424
private static final Logger logger = getLogger(FeignClientSpecificationPostProcessor.class);
2525

@@ -31,24 +31,16 @@ public class FeignClientSpecificationPostProcessor implements BeanPostProcessor
3131
* Injects the {@link AutoRefreshCapability} into default {@link FeignClientSpecification}
3232
* beans after initialization.
3333
*
34-
* <p>Example Usage:
35-
* <pre>{@code
36-
* // Invoked automatically by the Spring container during bean post-processing
37-
* Object processed = postProcessAfterInitialization(bean, "default.my-client");
38-
* }</pre>
39-
*
40-
* @param bean the bean instance that has been initialized
34+
* @param bean {@link FeignClientSpecification}
4135
* @param beanName the name of the bean in the Spring context
4236
* @return the (possibly modified) bean instance
4337
* @throws BeansException if post-processing fails
4438
*/
4539
@Override
46-
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
47-
Class<?> beanType = getTargetClass(bean);
48-
if (FEIGN_CLIENT_SPECIFICATION_CLASS.isAssignableFrom(beanType) && beanName.startsWith("default")) {
49-
injectAutoRefreshCapability((FeignClientSpecification) bean);
40+
protected void processAfterInitialization(FeignClientSpecification bean, String beanName) throws BeansException {
41+
if (beanName.startsWith("default.")) {
42+
injectAutoRefreshCapability(bean);
5043
}
51-
return bean;
5244
}
5345

5446
void injectAutoRefreshCapability(FeignClientSpecification specification) {

0 commit comments

Comments
 (0)