Package jfun.yan.spring

Source Code of jfun.yan.spring.SpringUtils

package jfun.yan.spring;

import jfun.yan.Components;
import jfun.yan.PropertyBinder;
import jfun.yan.etc.FilteredPropertyBinder;
import jfun.yan.etc.PropertyPredicate;
import jfun.yan.etc.TypeFilteredPropertyPredicate;

import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.Advisor;
import org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.ResourceLoaderAware;



/**
* Some common spring related utility functions.
* <p>
* @author Ben Yu
* Nov 20, 2005 10:28:50 PM
*/
public class SpringUtils{
  /**
   * Is this type part of the Spring infrastructure that
   * needs special care?
   * @param type the type.
   * @return true if this is a special Spring infrastructure type
   * (one of those marker interfaces.)
   */
  public static boolean isSpringInfrastructureClass(Class type){
    return Advisor.class.isAssignableFrom(type) ||
    MethodInterceptor.class.isAssignableFrom(type) ||
    AbstractAutoProxyCreator.class.isAssignableFrom(type);
  }
  /**
   * Get the PropertyPredicate object that filters all Spring
   * XXXAware marker interfaces we know so far.
   */
  public static TypeFilteredPropertyPredicate getSpringAwareMarkerInterfaceFilter(){
    final TypeFilteredPropertyPredicate tfpp = new TypeFilteredPropertyPredicate();
    return tfpp.addType(ApplicationContextAware.class)
    .addType(BeanNameAware.class)
    .addType(BeanFactoryAware.class)
    .addType(ResourceLoaderAware.class)
    .addType(MessageSourceAware.class)
    .addType(ApplicationEventPublisherAware.class);
  }
  private static final TypeFilteredPropertyPredicate aware_marker_interfaces =
    getSpringAwareMarkerInterfaceFilter();
  /**
   * Decorate an autowiring mode by filtering out Spring
   * XXXAware marker interfaces.
   * @param binder the autowiring mode.
   * @return the new autowiring mode.
   */
  public static PropertyBinder getAutowireWithoutAwareMarkerInterfaces(
      PropertyBinder binder){
    return new FilteredPropertyBinder(aware_marker_interfaces,
        Components.useDefault(), binder);
  }
}
TOP

Related Classes of jfun.yan.spring.SpringUtils

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.