001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.xbean.spring.context.v2;
018
019import org.springframework.beans.BeansException;
020import org.springframework.beans.factory.BeanFactory;
021import org.springframework.beans.factory.support.DefaultListableBeanFactory;
022import org.springframework.core.io.Resource;
023
024import java.util.Collections;
025import java.util.List;
026
027public class XBeanXmlBeanFactory extends DefaultListableBeanFactory {
028
029    /**
030     * Create a new XBeanXmlBeanFactory with the given resource,
031     * which must be parsable using DOM.
032     * @param resource XML resource to load bean definitions from
033     * @throws BeansException in case of loading or parsing errors
034     */
035    public XBeanXmlBeanFactory(Resource resource) throws BeansException {
036        this(resource, null, Collections.EMPTY_LIST);
037    }
038
039    /**
040     * Create a new XBeanXmlBeanFactory with the given input stream,
041     * which must be parsable using DOM.
042     * @param resource XML resource to load bean definitions from
043     * @param parentBeanFactory parent bean factory
044     * @throws BeansException in case of loading or parsing errors
045     */
046    public XBeanXmlBeanFactory(Resource resource, BeanFactory parentBeanFactory) throws BeansException {
047        this(resource, parentBeanFactory, Collections.EMPTY_LIST);
048    }
049
050    /**
051     * Create a new XBeanXmlBeanFactory with the given input stream,
052     * which must be parsable using DOM.
053     * @param resource XML resource to load bean definitions from
054     * @param xmlPreprocessors the preprocessors to apply the DOM before passing to Spring for processing
055     * @throws BeansException in case of loading or parsing errors
056     */
057    public XBeanXmlBeanFactory(Resource resource, List xmlPreprocessors) throws BeansException {
058        this(resource, null, xmlPreprocessors);
059    }
060
061    /**
062     * Create a new XBeanXmlBeanFactory with the given input stream,
063     * which must be parsable using DOM.
064     * @param resource XML resource to load bean definitions from
065     * @param parentBeanFactory parent bean factory
066     * @param xmlPreprocessors the preprocessors to apply the DOM before passing to Spring for processing
067     * @throws BeansException in case of loading or parsing errors
068     */
069    public XBeanXmlBeanFactory(Resource resource, BeanFactory parentBeanFactory, List xmlPreprocessors) throws BeansException {
070        super(parentBeanFactory);
071        XBeanXmlBeanDefinitionReader reader = new XBeanXmlBeanDefinitionReader(null, this, xmlPreprocessors);
072        reader.loadBeanDefinitions(resource);
073    }
074
075}