List of usage examples for org.springframework.beans.factory.config ConfigurableBeanFactory containsBean
boolean containsBean(String name);
From source file:io.spring.initializr.web.test.MockMvcClientHttpRequestFactoryTestExecutionListener.java
@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 {/*from w w w . j a v a 2 s . c o m*/ this.factory = beanFactory.getBean("mockMvcClientHttpRequestFactory", MockMvcClientHttpRequestFactory.class); } }
From source file:org.red5.server.plugin.definst.DefinstPlugin.java
@Override public void doStart() throws Exception { super.doStart(); // add the context to the parent, this will be red5.xml ConfigurableBeanFactory factory = ((ConfigurableApplicationContext) context).getBeanFactory(); // if parent context was not set then lookup red5.common log.debug("Lookup common - bean:{} local:{} singleton:{}", new Object[] { factory.containsBean("red5.common"), factory.containsLocalBean("red5.common"), factory.containsSingleton("red5.common"), }); parentContext = (ApplicationContext) factory.getBean("red5.common"); //create app context appContext = new FileSystemXmlApplicationContext(new String[] { "classpath:/definst.xml" }, true, parentContext);// w w w .j av a 2 s . c o m //get a ref to the "default" global scope GlobalScope global = (GlobalScope) server.getGlobal("default"); //create a scope resolver ScopeResolver scopeResolver = new ScopeResolver(); scopeResolver.setGlobalScope(global); //create a context - this takes the place of the previous web context Context ctx = new Context(appContext, appName); ctx.setClientRegistry(new ClientRegistry()); ctx.setMappingStrategy(new MappingStrategy()); ctx.setPersistanceStore(global.getStore()); ctx.setScopeResolver(scopeResolver); ctx.setServiceInvoker(new ServiceInvoker()); //create a handler handler = new DefinstHandler(); //create a scope for the admin // Scope scope = new Scope.Builder((IScope) global, "scope", appName, false).build(); // scope.setContext(ctx); // scope.setHandler(handler); server.addMapping(hostName, appName, "default"); // if (global.addChildScope(scope)) { // log.info("Scope was added to global (default) scope"); // } else { // log.warn("Scope was not added to global (default) scope"); // } // // //start the scope // scope.start(); }
From source file:org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean.java
private void addBeanFactoryDependency() { if (beanFactory instanceof ConfigurableBeanFactory) { ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory; if (StringUtils.hasText(beanName) && cbf.containsBean(beanName)) { // no need to validate targetBeanName (already did) cbf.registerDependentBean(targetBeanName, BeanFactory.FACTORY_BEAN_PREFIX + beanName); cbf.registerDependentBean(targetBeanName, beanName); }/*from w w w . java 2s . c o m*/ } else { log.warn("The running bean factory cannot support dependencies between beans " + "- importer/exporter dependency cannot be enforced"); } }