Example usage for org.springframework.security.config BeanIds METHOD_SECURITY_METADATA_SOURCE_ADVISOR

List of usage examples for org.springframework.security.config BeanIds METHOD_SECURITY_METADATA_SOURCE_ADVISOR

Introduction

In this page you can find the example usage for org.springframework.security.config BeanIds METHOD_SECURITY_METADATA_SOURCE_ADVISOR.

Prototype

String METHOD_SECURITY_METADATA_SOURCE_ADVISOR

To view the source code for org.springframework.security.config BeanIds METHOD_SECURITY_METADATA_SOURCE_ADVISOR.

Click Source Link

Usage

From source file:org.springframework.security.config.method.GlobalMethodSecurityBeanDefinitionParser.java

private void registerAdvisor(ParserContext parserContext, BeanReference interceptor,
        BeanReference metadataSource, Object source, String adviceOrder) {
    if (parserContext.getRegistry().containsBeanDefinition(BeanIds.METHOD_SECURITY_METADATA_SOURCE_ADVISOR)) {
        parserContext.getReaderContext().error("Duplicate <global-method-security> detected.", source);
    }/*w  w  w .  j  av  a2s.  c  om*/
    RootBeanDefinition advisor = new RootBeanDefinition(MethodSecurityMetadataSourceAdvisor.class);

    if (StringUtils.hasText(adviceOrder)) {
        advisor.getPropertyValues().addPropertyValue("order", adviceOrder);
    }

    // advisor must be an infrastructure bean as Spring's
    // InfrastructureAdvisorAutoProxyCreator will ignore it
    // otherwise
    advisor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    advisor.setSource(source);
    advisor.getConstructorArgumentValues().addGenericArgumentValue(interceptor.getBeanName());
    advisor.getConstructorArgumentValues().addGenericArgumentValue(metadataSource);
    advisor.getConstructorArgumentValues().addGenericArgumentValue(metadataSource.getBeanName());

    parserContext.getRegistry().registerBeanDefinition(BeanIds.METHOD_SECURITY_METADATA_SOURCE_ADVISOR,
            advisor);
}