All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.matrix.registrar.RegistrarFactoryBean Maven / Gradle / Ivy

Go to download

Nepxion Matrix is an AOP framework integrated with Spring AutoProxy, Spring Registrar and Spring Import Selector

There is a newer version: 3.0.0
Show newest version
package com.nepxion.matrix.registrar;

/**
 * 

Title: Nepxion Matrix

*

Description: Nepxion Matrix AOP

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import org.aopalliance.intercept.MethodInterceptor; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; public class RegistrarFactoryBean implements ApplicationContextAware, FactoryBean, InitializingBean, BeanClassLoaderAware { private ApplicationContext applicationContext; private Class interfaze; private MethodInterceptor interceptor; private Object proxy; private ClassLoader classLoader; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } public ApplicationContext getApplicationContext() { return applicationContext; } @Override public Object getObject() throws Exception { return proxy; } @Override public Class getObjectType() { return interfaze; } @Override public boolean isSingleton() { return false; } @Override public void afterPropertiesSet() throws Exception { ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.addInterface(interfaze); proxyFactory.addAdvice(interceptor); proxyFactory.setOptimize(false); proxy = proxyFactory.getProxy(classLoader); } @Override public void setBeanClassLoader(ClassLoader classLoader) { this.classLoader = classLoader; } public Class getInterfaze() { return interfaze; } public void setInterfaze(Class interfaze) { this.interfaze = interfaze; } public MethodInterceptor getInterceptor() { return interceptor; } public void setInterceptor(MethodInterceptor interceptor) { this.interceptor = interceptor; } }