Sping框架:BeanFactory与FactoryBean的

2019-08-16  本文已影响0人  飞狗未来

BeanFactory 和 FactoryBean 都是spring-beans-*.*.*.jar里面的接口。

接口定义区别

BeanFactory接口

BeanFactory

FactoryBean接口

FactoryBean

功能区别

举例

Shiro在Spring中的配置,实现类ShiroFilterFactoryBean为FactoryBean的一个实现类,它返回的类型为SpringShiroFilter。

<!-- 安全认证过滤器 -->
    <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
        <property name="securityManager" ref="securityManager" /><!-- 
        <property name="loginUrl" value="${adminPath}/login" />
        <property name="successUrl" value="${adminPath}?login" />
        <property name="filters">
            <map>
                <entry key="cas" value-ref="casFilter"/>
                <entry key="authc" value-ref="formAuthenticationFilter"/>
                <entry key="user" value-ref="memberFilter"/>
            </map>
        </property>
        <property name="filterChainDefinitions">
            <ref bean="shiroFilterChainDefinitions"/>
        </property>
    </bean>
上一篇 下一篇

猜你喜欢

热点阅读