1 package jfun.yan.spring; 2 3 import jfun.yan.Components; 4 import jfun.yan.PropertyBinder; 5 import jfun.yan.etc.FilteredPropertyBinder; 6 import jfun.yan.etc.PropertyPredicate; 7 import jfun.yan.etc.TypeFilteredPropertyPredicate; 8 9 import org.aopalliance.intercept.MethodInterceptor; 10 import org.springframework.aop.Advisor; 11 import org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator; 12 import org.springframework.beans.factory.BeanFactoryAware; 13 import org.springframework.beans.factory.BeanNameAware; 14 import org.springframework.context.ApplicationContextAware; 15 import org.springframework.context.ApplicationEventPublisherAware; 16 import org.springframework.context.MessageSourceAware; 17 import org.springframework.context.ResourceLoaderAware; 18 19 20 21 27 public class SpringUtils{ 28 35 public static boolean isSpringInfrastructureClass(Class type){ 36 return Advisor.class.isAssignableFrom(type) || 37 MethodInterceptor.class.isAssignableFrom(type) || 38 AbstractAutoProxyCreator.class.isAssignableFrom(type); 39 } 40 44 public static TypeFilteredPropertyPredicate getSpringAwareMarkerInterfaceFilter(){ 45 final TypeFilteredPropertyPredicate tfpp = new TypeFilteredPropertyPredicate(); 46 return tfpp.addType(ApplicationContextAware.class) 47 .addType(BeanNameAware.class) 48 .addType(BeanFactoryAware.class) 49 .addType(ResourceLoaderAware.class) 50 .addType(MessageSourceAware.class) 51 .addType(ApplicationEventPublisherAware.class); 52 } 53 private static final TypeFilteredPropertyPredicate aware_marker_interfaces = 54 getSpringAwareMarkerInterfaceFilter(); 55 61 public static PropertyBinder getAutowireWithoutAwareMarkerInterfaces( 62 PropertyBinder binder){ 63 return new FilteredPropertyBinder(aware_marker_interfaces, 64 Components.useDefault(), binder); 65 } 66 } 67 | Popular Tags |