All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sitewhere.spring.handler.SiteWhereBeanDefinitionParser Maven / Gradle / Ivy

/*
 * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */
package com.sitewhere.spring.handler;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;

/**
 * Extension of {@link AbstractBeanDefinitionParser} that supports overriding
 * beans
 * 
 * @author Derek
 */
public abstract class SiteWhereBeanDefinitionParser extends AbstractBeanDefinitionParser {

    /** Map classes that override root bean classes */
    private Map, Class> beanMappings = new HashMap, Class>();

    /**
     * Returns a builder for the given bean, allowing for class override if
     * needed.
     * 
     * @param clazz
     * @return
     */
    protected BeanDefinitionBuilder getBuilderFor(Class clazz) {
	Class override = beanMappings.get(clazz);
	Class used = (override == null) ? clazz : override;
	return BeanDefinitionBuilder.rootBeanDefinition(used);
    }

    public Map, Class> getBeanMappings() {
	return beanMappings;
    }

    public void setBeanMappings(Map, Class> beanMappings) {
	this.beanMappings = beanMappings;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy