采用有参数的构造方法来解决注入你要的属性例如:
public MyInvocationSecurityMetadataSource(RoleService roleService) {
this.roleService = roleService;
loadResourceDefine();
}
RoleService 是可以获得资源列表的组件.
在xml配置文件中采用构造函数注入的方式把RoleService 注入到MyInvocationSecurityMetadataSource中.例如
<beans:bean id="securityMetadataSource"
class="com.shoesishow.security.MyInvocationSecurityMetadataSource">
<beans:constructor-arg><beans:ref bean="roleService"/></beans:constructor-arg>
</beans:bean>