org.springframework.beans.factory.config.MethodInvokingFactoryBean Java Examples

The following examples show how to use org.springframework.beans.factory.config.MethodInvokingFactoryBean. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedissonNamespaceParserSupport.java    From redisson with Apache License 2.0 6 votes vote down vote up
private BeanDefinitionBuilder preInvoke(Element element, Object obj, String method, Object[] args, ParserContext parserContext, boolean factory) {
    Class<?> beanClass = BeanMethodInvoker.class;
    if (factory) {
        beanClass = MethodInvokingFactoryBean.class;
    }
    
    BeanDefinitionBuilder builder
            = createBeanDefinitionBuilder(element, parserContext, beanClass);
    if (obj instanceof Class) {
        builder.addPropertyValue("staticMethod",
                ((Class<?>) obj).getName() + "." + method);
    } else {
        builder.addPropertyValue("targetMethod", method);
    }
    builder.addPropertyValue("arguments", args);
    if (element != null) {
        parserContext.getDelegate().parseQualifierElements(element,
                builder.getRawBeanDefinition());
    }
    return builder;
}
 
Example #2
Source File: UtilConfig.java    From distributed-transaction-process with MIT License 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(MessageSource source) {
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setTargetClass(CheckUtil.class);
    bean.setTargetMethod("setSource");
    bean.setArguments(new Object[]{ source });
    return bean;
}
 
Example #3
Source File: EncryptionConfig.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean addProvider()
{
    MethodInvokingFactoryBean methodInvokingFactoryBean = new MethodInvokingFactoryBean();
    methodInvokingFactoryBean.setStaticMethod( "java.security.Security.addProvider" );
    methodInvokingFactoryBean.setArguments( new BouncyCastleProvider() );
    return methodInvokingFactoryBean;
}
 
Example #4
Source File: SecurityConfiguration.java    From java-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean setSecurityManager() {
	MethodInvokingFactoryBean factoryBean = new MethodInvokingFactoryBean();
	factoryBean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
	factoryBean.setArguments(new Object[] { securityManager() });
	return factoryBean;
}
 
Example #5
Source File: AspectJAutoProxyCreatorTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #6
Source File: ShiroConfig.java    From OneBlog with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 修复UnavailableSecurityManagerException(详见issues#IK7C3)
 *
 * @param securityManager
 * @return
 */
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager) {
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
    bean.setArguments(securityManager);
    return bean;
}
 
Example #7
Source File: ShiroConfiguration.java    From watchdog-framework with MIT License 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager){
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
    bean.setArguments(securityManager);
    return bean;
}
 
Example #8
Source File: AspectJAutoProxyCreatorTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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());
}
 
Example #9
Source File: UtilConfig.java    From distributed-transaction-process with MIT License 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(MessageSource source) {
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setTargetClass(CheckUtil.class);
    bean.setTargetMethod("setSource");
    bean.setArguments(new Object[]{ source });
    return bean;
}
 
Example #10
Source File: UtilConfig.java    From distributed-transaction-process with MIT License 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(MessageSource source) {
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setTargetClass(CheckUtil.class);
    bean.setTargetMethod("setSource");
    bean.setArguments(new Object[]{ source });
    return bean;
}
 
Example #11
Source File: ShiroConfig.java    From springboot-shiro with MIT License 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager){
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
    bean.setArguments(securityManager);
    return bean;
}
 
Example #12
Source File: AspectJAutoProxyCreatorTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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());
}
 
Example #13
Source File: ShiroConfig.java    From WebStack-Guns with MIT License 5 votes vote down vote up
/**
 * 在方法中 注入 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;
}
 
Example #14
Source File: ShiroConfig.java    From MeetingFilm with Apache License 2.0 5 votes vote down vote up
/**
 * 在方法中 注入 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;
}
 
Example #15
Source File: ShiroAuthConfig.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean(SecurityManager securityManager){
    MethodInvokingFactoryBean bean = new MethodInvokingFactoryBean();
    bean.setStaticMethod("org.apache.shiro.SecurityUtils.setSecurityManager");
    bean.setArguments(securityManager);
    return bean;
}
 
Example #16
Source File: RedissonRPCClientDefinitionParser.java    From redisson with Apache License 2.0 4 votes vote down vote up
@Override
protected Class<?> getBeanClass(Element element) {
    return MethodInvokingFactoryBean.class;
}
 
Example #17
Source File: RedissonLiveObjectDefinitionParser.java    From redisson with Apache License 2.0 4 votes vote down vote up
@Override
protected Class<?> getBeanClass(Element element) {
    return MethodInvokingFactoryBean.class;
}