001/*
002 * Copyright 2014 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.springframework.batch.core.jsr.configuration.support;
017
018import java.util.ArrayList;
019import java.util.List;
020
021import org.springframework.beans.factory.FactoryBean;
022
023/**
024 * A simple factory bean that consolidates the list of locations to look for the base context for the JSR-352
025 * functionality
026 *
027 * @author Michael Minella
028 * @since 3.0.3
029 */
030public class BaseContextListFactoryBean implements FactoryBean<List<String>>{
031
032        @Override
033        public List<String> getObject() throws Exception {
034                String overrideContextLocation = System.getProperty("JSR-352-BASE-CONTEXT");
035
036                List<String> contextLocations = new ArrayList<String>(2);
037
038                contextLocations.add("baseContext.xml");
039
040                if(overrideContextLocation != null) {
041                        contextLocations.add(overrideContextLocation);
042                }
043
044                return contextLocations;
045        }
046
047        @Override
048        public Class<?> getObjectType() {
049                return List.class;
050        }
051
052        @Override
053        public boolean isSingleton() {
054                return true;
055        }
056}