@Override public Object getTargetObject() { return this.beanFactory.getBean(this.targetBeanName); }
private Object createInterfaceProxyForFactoryBean(final Object factoryBean, Class<?> interfaceType, final ConfigurableBeanFactory beanFactory, final String beanName) { return Proxy.newProxyInstance( factoryBean.getClass().getClassLoader(), new Class<?>[] {interfaceType}, (proxy, method, args) -> { if (method.getName().equals("getObject") && args == null) { return beanFactory.getBean(beanName); } return ReflectionUtils.invokeMethod(method, factoryBean, args); }); }
private Object createInterfaceProxyForFactoryBean(final Object factoryBean, Class<?> interfaceType, final ConfigurableBeanFactory beanFactory, final String beanName) { return Proxy.newProxyInstance( factoryBean.getClass().getClassLoader(), new Class<?>[] {interfaceType}, (proxy, method, args) -> { if (method.getName().equals("getObject") && args == null) { return beanFactory.getBean(beanName); } return ReflectionUtils.invokeMethod(method, factoryBean, args); }); }
@Nullable public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null) { return this.scope.resolveContextualObject(key); } else { return null; } }
@Nullable public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null) { return this.scope.resolveContextualObject(key); } else { return null; } }
Object factoryBean = beanFactory.getBean(BeanFactory.FACTORY_BEAN_PREFIX + beanName); if (factoryBean instanceof ScopedProxyFactoryBean) {
parentContext = (ApplicationContext) factory.getBean("red5.common");
return beanFactory.getBean(beanName);
Object factoryBean = beanFactory.getBean(BeanFactory.FACTORY_BEAN_PREFIX + beanName); if (factoryBean instanceof ScopedProxyFactoryBean) {
return beanFactory.getBean(beanName);
@Override public void beforeTestClass(TestContext testContext) throws Exception { ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) testContext .getApplicationContext().getAutowireCapableBeanFactory(); if (!beanFactory.containsBean("mockMvcClientHttpRequestFactory")) { this.factory = new MockMvcClientHttpRequestFactory( beanFactory.getBean(MockMvc.class)); beanFactory.registerSingleton("mockMvcClientHttpRequestFactory", this.factory); } else { this.factory = beanFactory.getBean("mockMvcClientHttpRequestFactory", MockMvcClientHttpRequestFactory.class); } }
@Test public void aliasing() { BeanFactory bf = getBeanFactory(); if (!(bf instanceof ConfigurableBeanFactory)) { return; } ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) bf; String alias = "rods alias"; try { cbf.getBean(alias); fail("Shouldn't permit factory get on normal bean"); } catch (NoSuchBeanDefinitionException ex) { // Ok assertTrue(alias.equals(ex.getBeanName())); } // Create alias cbf.registerAlias("rod", alias); Object rod = getBeanFactory().getBean("rod"); Object aliasRod = getBeanFactory().getBean(alias); assertTrue(rod == aliasRod); }
public void registerSubContext(String webAppKey) { // get the sub contexts - servlet context ServletContext ctx = servletContext.getContext(webAppKey); if (ctx == null) { ctx = servletContext; } ContextLoader loader = new ContextLoader(); ConfigurableWebApplicationContext appCtx = (ConfigurableWebApplicationContext) loader.initWebApplicationContext(ctx); appCtx.setParent(applicationContext); appCtx.refresh(); ctx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, appCtx); ConfigurableBeanFactory appFactory = appCtx.getBeanFactory(); logger.debug("About to grab Webcontext bean for {}", webAppKey); Context webContext = (Context) appCtx.getBean("web.context"); webContext.setCoreBeanFactory(parentFactory); webContext.setClientRegistry(clientRegistry); webContext.setServiceInvoker(globalInvoker); webContext.setScopeResolver(globalResolver); webContext.setMappingStrategy(globalStrategy); WebScope scope = (WebScope) appFactory.getBean("web.scope"); scope.setServer(server); scope.setParent(global); scope.register(); scope.start(); // register the context so we dont try to reinitialize it registeredContexts.add(ctx); }
public Object getObject(String key) { if (this.beanFactory.containsBean(key)) { return this.beanFactory.getBean(key); } else if (this.scope != null){ return this.scope.resolveContextualObject(key); } else { return null; } }
/** * @param beanFactory a bean factory used for resolving ${...} placeholder * and #{...} SpEL expressions in default values, or {@code null} if default * values are not expected to contain expressions */ public WxArgumentResolver(ConfigurableBeanFactory beanFactory) { super(beanFactory); this.wxUserManager = beanFactory.getBean(WxUserManager.class); this.wxUserProvider = beanFactory.getBean(WxUserProvider.class); }
@Override public <T> T getInstance(Class<T> clazz) { // Simply retrieve a bean by the repository class type. return beanFactory.getBean(clazz); }
private Object createInterfaceProxyForFactoryBean(final Object factoryBean, Class<?> interfaceType, final ConfigurableBeanFactory beanFactory, final String beanName) { return Proxy.newProxyInstance( factoryBean.getClass().getClassLoader(), new Class<?>[] {interfaceType}, (proxy, method, args) -> { if (method.getName().equals("getObject") && args == null) { return beanFactory.getBean(beanName); } return ReflectionUtils.invokeMethod(method, factoryBean, args); }); }
public AcrossModule getCurrentModule() { try { return getBeanFactory().getBean( AcrossModule.class ); } catch ( NoSuchBeanDefinitionException nsbe ) { return null; } }