001/*
002 * Copyright 2012-2017 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 *      http://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 */
016
017package org.springframework.boot.autoconfigure.freemarker;
018
019import java.util.ArrayList;
020import java.util.Arrays;
021import java.util.List;
022
023import org.springframework.boot.autoconfigure.template.PathBasedTemplateAvailabilityProvider;
024import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
025
026/**
027 * {@link TemplateAvailabilityProvider} that provides availability information for
028 * FreeMarker view templates.
029 *
030 * @author Andy Wilkinson
031 * @since 1.1.0
032 */
033public class FreeMarkerTemplateAvailabilityProvider
034                extends PathBasedTemplateAvailabilityProvider {
035
036        public FreeMarkerTemplateAvailabilityProvider() {
037                super("freemarker.template.Configuration",
038                                FreeMarkerTemplateAvailabilityProperties.class, "spring.freemarker");
039        }
040
041        static final class FreeMarkerTemplateAvailabilityProperties
042                        extends TemplateAvailabilityProperties {
043
044                private List<String> templateLoaderPath = new ArrayList<>(
045                                Arrays.asList(FreeMarkerProperties.DEFAULT_TEMPLATE_LOADER_PATH));
046
047                FreeMarkerTemplateAvailabilityProperties() {
048                        super(FreeMarkerProperties.DEFAULT_PREFIX,
049                                        FreeMarkerProperties.DEFAULT_SUFFIX);
050                }
051
052                @Override
053                protected List<String> getLoaderPath() {
054                        return this.templateLoaderPath;
055                }
056
057                public List<String> getTemplateLoaderPath() {
058                        return this.templateLoaderPath;
059                }
060
061                public void setTemplateLoaderPath(List<String> templateLoaderPath) {
062                        this.templateLoaderPath = templateLoaderPath;
063                }
064
065        }
066
067}