001/*
002 * Copyright 2002-2015 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 */
016
017package org.springframework.web.servlet.view.script;
018
019import java.nio.charset.Charset;
020import javax.script.ScriptEngine;
021
022/**
023 * Interface to be implemented by objects that configure and manage a
024 * JSR-223 {@link ScriptEngine} for automatic lookup in a web environment.
025 * Detected and used by {@link ScriptTemplateView}.
026 *
027 * @author Sebastien Deleuze
028 * @since 4.2
029 */
030public interface ScriptTemplateConfig {
031
032        /**
033         * Return the {@link ScriptEngine} to use by the views.
034         */
035        ScriptEngine getEngine();
036
037        /**
038         * Return the engine name that will be used to instantiate the {@link ScriptEngine}.
039         */
040        String getEngineName();
041
042        /**
043         * Return whether to use a shared engine for all threads or whether to create
044         * thread-local engine instances for each thread.
045         */
046        Boolean isSharedEngine();
047
048        /**
049         * Return the scripts to be loaded by the script engine (library or user provided).
050         */
051        String[] getScripts();
052
053        /**
054         * Return the object where the render function belongs (optional).
055         */
056        String getRenderObject();
057
058        /**
059         * Return the render function name (mandatory).
060         */
061        String getRenderFunction();
062
063        /**
064         * Return the content type to use for the response.
065         * @since 4.2.1
066         */
067        String getContentType();
068
069        /**
070         * Return the charset used to read script and template files.
071         */
072        Charset getCharset();
073
074        /**
075         * Return the resource loader path(s) via a Spring resource location.
076         */
077        String getResourceLoaderPath();
078
079}