Spring Framework GenericBeanDefinition - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework GenericBeanDefinition class.

This code example shows how to use the following methods:setBeanClass, setScope
		rac.refresh(); 
		PortletContext pc = new ServletWrappingPortletContext(sc); 
		StaticPortletApplicationContext ac = new StaticPortletApplicationContext(); 
		ac.setParent(rac); 
		ac.setPortletContext(pc); 
		GenericBeanDefinition bd = new GenericBeanDefinition(); 
		bd.setBeanClass(DerivedTestBean.class); 
		bd.setScope(scope); 
		ac.registerBeanDefinition(NAME, bd); 
		ac.refresh(); 
		return ac; 
	} 
 
	@Test 
	public void testRequestScope() { 
		WebApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_REQUEST); 
		MockRenderRequest request = new MockRenderRequest(); 
		PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request); 
		RequestContextHolder.setRequestAttributes(requestAttributes); 
		try { 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setBeanClass, setPropertyValues
	 * Register a singleton bean with the underlying bean factory. 
	 * <p>For more advanced needs, register with the underlying BeanFactory directly. 
	 * @see #getDefaultListableBeanFactory 
	 */ 
	public void registerSingleton(String name, Class<?> clazz, MutablePropertyValues pvs) throws BeansException {
		GenericBeanDefinition bd = new GenericBeanDefinition();
		bd.setBeanClass(clazz);
		bd.setPropertyValues(pvs);
		getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
	} 
 
	/** 
	 * Register a prototype bean with the underlying bean factory. 
	 * <p>For more advanced needs, register with the underlying BeanFactory directly. 
	 * @see #getDefaultListableBeanFactory 
	 */ 
	public void registerPrototype(String name, Class<?> clazz) throws BeansException {
		GenericBeanDefinition bd = new GenericBeanDefinition();
		bd.setScope(GenericBeanDefinition.SCOPE_PROTOTYPE);
		bd.setBeanClass(clazz);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setBeanClass, setConstructorArgumentValues
import org.w3c.dom.Element;
 
public class DatabaseBeanDefinitionParser implements BeanDefinitionParser {
 
	public BeanDefinition parse(Element element, ParserContext parserContext) {
		GenericBeanDefinition bdef = new GenericBeanDefinition();
		bdef.setBeanClass(StdCouchDbConnector.class);
		 
		String id = element.getAttribute("id");
		String name = element.getAttribute("name");
		String url = element.getAttribute("url");
		 
		ConstructorArgumentValues cav = new ConstructorArgumentValues();
		cav.addGenericArgumentValue(name);
		 
		if (url != null && url.length() > 0) {
			BeanDefinition httpClient = InstanceBeanDefinitionParser.buildHttpClientDef(url);
			BeanDefinition dbInstance = InstanceBeanDefinitionParser.buildCouchDBInstance(httpClient);
			cav.addGenericArgumentValue(dbInstance);
		} else { 

7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPropertyValues, getConstructorArgumentValues, setBeanClass
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setBeanClass, setScope
 
 
	private WebApplicationContext initApplicationContext(String scope) { 
		MockServletContext sc = new MockServletContext(); 
		GenericWebApplicationContext ac = new GenericWebApplicationContext(sc); 
		GenericBeanDefinition bd = new GenericBeanDefinition(); 
		bd.setBeanClass(DerivedTestBean.class); 
		bd.setScope(scope); 
		ac.registerBeanDefinition(NAME, bd); 
		ac.refresh(); 
		return ac; 
	} 
 
	@Test 
	public void testRequestScope() { 
		WebApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_REQUEST); 
		MockHttpServletRequest request = new MockHttpServletRequest(); 
		ServletRequestAttributes requestAttributes = new ServletRequestAttributes(request); 
		RequestContextHolder.setRequestAttributes(requestAttributes); 
		try { 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPropertyValues, setBeanClass
This code example shows how to use the following methods:getPropertyValues, setBeanClass
    private final SnapshotterTriggerBeanDefinitionParser snapshotterTriggerParser =
            new SnapshotterTriggerBeanDefinitionParser(); 
 
    @Override 
    protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
        GenericBeanDefinition repositoryDefinition = new GenericBeanDefinition();
        if (element.hasAttribute(CACHE_ATTRIBUTE)) {
            repositoryDefinition.setBeanClass(CachingEventSourcingRepository.class);
        } else { 
            repositoryDefinition.setBeanClass(EventSourcingRepository.class);
        } 
 
        parseAggregateFactory(element, repositoryDefinition, parserContext.getRegistry());
        parseEventStore(element, repositoryDefinition);
        parseLockingStrategy(element, repositoryDefinition);
        parseReferenceAttribute(element, EVENT_BUS_ATTRIBUTE, "eventBus", repositoryDefinition.getPropertyValues(),
                                EventBus.class); 
        parseReferenceAttribute(element, CONFLICT_RESOLVER_ATTRIBUTE, "conflictResolver",
                                repositoryDefinition.getPropertyValues(), null);
        parseReferenceAttribute(element, CACHE_ATTRIBUTE, "cache", repositoryDefinition.getPropertyValues(), null);

6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getConstructorArgumentValues, setBeanClass
     * 
     * @param autowiredTypes The types of bean to autowire. 
     * @return the bean definition that will inject a bean of the required type 
     */ 
    public static GenericBeanDefinition createAutowiredBean(Class<?>... autowiredTypes) {
        final GenericBeanDefinition autowiredBeanDef = new GenericBeanDefinition();
        autowiredBeanDef.setBeanClass(AutowiredDependencyFactoryBean.class);
        autowiredBeanDef.getConstructorArgumentValues().addGenericArgumentValue(autowiredTypes);
        return autowiredBeanDef;
    } 
 
    /** 
     * Creates an autowired dependency on the given <code>autowiredTypes</code>. A lookup is done on the first type, 
     * if no beans of that type are found, the next is evaluated, and so on. If more than one bean of any type is found 
     * when it is evaluated, an exception is thrown. 
     * <p/> 
     * If there are no autowire candidates, the given <code>fallback</code> is used to take its place. If 
     * <code>fallback</code> is <code>null</code>, an exception will be thrown. 
     * <p/> 
     * Beans that are not eligible for autowiring (as defined in Spring configuration) are ignored altogether. 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setBeanClass
		JsrXmlApplicationContext context = new JsrXmlApplicationContext();
		Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml");
		context.setValidating(false);
		context.load(batchXml);
 
		GenericBeanDefinition stepScope = new GenericBeanDefinition();
		stepScope.setBeanClass(StepScope.class);
		context.registerBeanDefinition("stepScope", stepScope);
 
		GenericBeanDefinition bd = new GenericBeanDefinition();
		bd.setBeanClass(AutowiredAnnotationBeanPostProcessor.class);
		context.registerBeanDefinition("postProcessor", bd);
		context.refresh();
 
		ItemProcessor itemProcessor = context.getBean(ItemProcessor.class);
 
		assertNotNull(itemProcessor);
		StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5l))); 
		assertEquals("Test", itemProcessor.process("Test"));
		StepSynchronizationManager.close(); 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getPropertyValues, setDestroyMethodName, setInitMethodName
 
    @Override 
    protected void registerSpecificProperties(Element element, ParserContext parserContext,
                                              GenericBeanDefinition sagaManagerDefinition) {
        Element asyncElement = (Element) element.getElementsByTagName("axon:async").item(0);
        parseTransactionManagerAttribute(asyncElement, sagaManagerDefinition.getPropertyValues());
        parseExecutorAttribute(asyncElement, sagaManagerDefinition.getPropertyValues());
        parseProcessorCountAttribute(asyncElement, sagaManagerDefinition.getPropertyValues());
        parseBufferSizeAttribute(asyncElement, sagaManagerDefinition.getPropertyValues());
        sagaManagerDefinition.setInitMethodName("start");
        sagaManagerDefinition.setDestroyMethodName("stop");
    } 
 
    @Override 
    protected Class<? extends SagaManager> getBeanClass() {
        return AsyncAnnotatedSagaManager.class; 
    } 
 
    @Override 
    protected void registerSagaRepository(Object sagaRepositoryDefinition,
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java