package com.example.demo.component;
import javassist.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;
import java.lang.reflect.InvocationTargetException;
/**
* @author xianmingyuan
*/
@Slf4j
@Component
public class RabbitTemplateBeanPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof RabbitTemplate) {
try {
return generateProxyObject((RabbitTemplate) bean);
} catch (CannotCompileException e) {
throw new GenerateProxyBeansException("CannotCompileException", e);
} catch (ClassNotFoundException e) {
throw new GenerateProx
Spring内基于Javasist生成子类反射生成代理对象
最新推荐文章于 2023-03-05 15:57:22 发布
本文详细介绍了在Spring框架中如何使用Javasist库动态生成子类,并通过反射创建代理对象的过程。内容涵盖Javasist的基本用法,以及在实际应用中的关键步骤和技术细节。
摘要由CSDN通过智能技术生成