`
<bean class="com.mocent.shiro.captcha.DreamCaptcha"> <property name="cacheManager" ref="shiroSpringCacheManager"/> <!-- 复用半小时缓存 --> <property name="cacheName" value="halfHour"/> </bean>``
<bean id="shiroSpringCacheManager" class="com.mocent.shiro.cash.ShiroSpringCacheManager"> <property name="cacheManager" ref="cacheManager"/> </bean>`` 3.
<property name="cacheManager" ref="ehcacheManager"/> <property name="transactionAware" value="true"/> </bean>``
<bean id="ehcacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> <property name="configLocation" value="classpath:cash/ehcache.xml"/> </bean>``5.
<cache name="halfHour" maxElementsInMemory="10000" maxElementsOnDisk="100000" eternal="false" timeToIdleSeconds="1800" timeToLiveSeconds="1800" overflowToDisk="false" diskPersistent="false" />`
这个bean将要被IOC实例化,通过get set的方式传参数进去,被赋值的属性是cacheManager和cacheName。cacheName是直接赋值为halfHour字符串,而cacheManager属性来自ShiroSpringCacheManager的属性以及方法如下也是使用get set的方式设置值被设值的属性是cacheManager,cacheManager来自经过一系列的传递后发现最终的验证码的缓存管理类是EhCacheCacheManager,它实现了org.springframework.cache.CacheManager接口可以被com.mocent.shiro.captcha.DreamCaptcha使用继续往下看org.springframework.cache.CacheManager的cacheManager参数是来自org.springframework.cache.ehcache.EhCacheManagerFactoryBean他是EhCacheCacheManager的工厂类,生成EhCacheCacheManager的配置文件是cash/ehcache.xml里面有一个名为halfHour的缓存配置这也是验证码生成类com.mocent.shiro.captcha.DreamCaptcha的另外一个属性的来源
相关资源:java验证码识别