Search in sources :

Example 1 with MethodInvokingFactoryBean

use of org.springframework.beans.factory.config.MethodInvokingFactoryBean in project vip by guangdada.

the class ShiroConfig method methodInvokingFactoryBean.

/**
 * 在方法中 注入 securityManager,进行代理控制
 */
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(DefaultWebSecurityManager securityManager) {
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
    bean.setArguments(new Object[] { securityManager });
    return bean;
}
Also used : MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) ShiroFilterFactoryBean(org.apache.shiro.spring.web.ShiroFilterFactoryBean) MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) EhCacheManagerFactoryBean(org.springframework.cache.ehcache.EhCacheManagerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with MethodInvokingFactoryBean

use of org.springframework.beans.factory.config.MethodInvokingFactoryBean in project spring-framework by spring-projects.

the class ProxyTargetClassTrueConfig method testAspectsAreApplied.

@Test
public void testAspectsAreApplied() {
    ClassPathXmlApplicationContext bf = newContext("aspects.xml");
    ITestBean tb = (ITestBean) bf.getBean("adrian");
    assertThat(tb.getAge()).isEqualTo(68);
    MethodInvokingFactoryBean factoryBean = (MethodInvokingFactoryBean) bf.getBean("&factoryBean");
    assertThat(AopUtils.isAopProxy(factoryBean.getTargetObject())).isTrue();
    assertThat(((ITestBean) factoryBean.getTargetObject()).getAge()).isEqualTo(68);
}
Also used : ITestBean(org.springframework.beans.testfixture.beans.ITestBean) MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with MethodInvokingFactoryBean

use of org.springframework.beans.factory.config.MethodInvokingFactoryBean in project zhcet-web by zhcet-amu.

the class SecurityBeans method methodInvokingFactoryBean.

/**
 * Spring Security Context is limited to local thread and hence every asynchronous method gets
 * null logged in user info. We modify the SecurityContextHolder here to leverage auditing capabilities
 * in asynchronous methods as well by enabling MODE_INHERITABLETHREADLOCAL
 * @return MethodInvokingFactoryBean
 */
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean() {
    MethodInvokingFactoryBean methodInvokingFactoryBean = new MethodInvokingFactoryBean();
    methodInvokingFactoryBean.setTargetClass(SecurityContextHolder.class);
    methodInvokingFactoryBean.setTargetMethod("setStrategyName");
    methodInvokingFactoryBean.setArguments((Object[]) new String[] { SecurityContextHolder.MODE_INHERITABLETHREADLOCAL });
    return methodInvokingFactoryBean;
}
Also used : MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 4 with MethodInvokingFactoryBean

use of org.springframework.beans.factory.config.MethodInvokingFactoryBean in project spring-framework by spring-projects.

the class TestBeanAdvisor method testAspectsAreApplied.

@Test
public void testAspectsAreApplied() {
    ClassPathXmlApplicationContext bf = newContext("aspects.xml");
    ITestBean tb = (ITestBean) bf.getBean("adrian");
    assertEquals(68, tb.getAge());
    MethodInvokingFactoryBean factoryBean = (MethodInvokingFactoryBean) bf.getBean("&factoryBean");
    assertTrue(AopUtils.isAopProxy(factoryBean.getTargetObject()));
    assertEquals(68, ((ITestBean) factoryBean.getTargetObject()).getAge());
}
Also used : ITestBean(org.springframework.tests.sample.beans.ITestBean) MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Test(org.junit.Test)

Example 5 with MethodInvokingFactoryBean

use of org.springframework.beans.factory.config.MethodInvokingFactoryBean in project dhis2-core by dhis2.

the class HibernateEncryptionConfig method addProvider.

@Bean
public MethodInvokingFactoryBean addProvider() {
    MethodInvokingFactoryBean methodInvokingFactoryBean = new MethodInvokingFactoryBean();
    methodInvokingFactoryBean.setStaticMethod("java.security.Security.addProvider");
    methodInvokingFactoryBean.setArguments(new BouncyCastleProvider());
    return methodInvokingFactoryBean;
}
Also used : MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) MethodInvokingFactoryBean(org.springframework.beans.factory.config.MethodInvokingFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

MethodInvokingFactoryBean (org.springframework.beans.factory.config.MethodInvokingFactoryBean)6 Bean (org.springframework.context.annotation.Bean)4 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 ShiroFilterFactoryBean (org.apache.shiro.spring.web.ShiroFilterFactoryBean)1 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)1 EhCacheManagerFactoryBean (org.springframework.cache.ehcache.EhCacheManagerFactoryBean)1 ITestBean (org.springframework.tests.sample.beans.ITestBean)1