001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.scripting;
016    
017    import java.util.Map;
018    import java.util.Set;
019    
020    import javax.portlet.PortletConfig;
021    import javax.portlet.PortletContext;
022    import javax.portlet.PortletRequest;
023    import javax.portlet.PortletResponse;
024    
025    /**
026     * @author Alberto Montero
027     * @author Brian Wing Shun Chan
028     */
029    public class ScriptingUtil {
030    
031            public static void clearCache(String language) throws ScriptingException {
032                    getScripting().clearCache(language);
033            }
034    
035            public static Map<String, Object> eval(
036                            Set<String> allowedClasses, Map<String, Object> inputObjects,
037                            Set<String> outputNames, String language, String script)
038                    throws ScriptingException {
039    
040                    return getScripting().eval(
041                            allowedClasses, inputObjects, outputNames, language, script);
042            }
043    
044            public static void exec(
045                            Set<String> allowedClasses, Map<String, Object> inputObjects,
046                            String language, String script)
047                    throws ScriptingException {
048    
049                    getScripting().exec(allowedClasses, inputObjects, language, script);
050            }
051    
052            public static Map<String, Object> getPortletObjects(
053                    PortletConfig portletConfig, PortletContext portletContext,
054                    PortletRequest portletRequest, PortletResponse portletResponse) {
055    
056                    return getScripting().getPortletObjects(
057                            portletConfig, portletContext, portletRequest, portletResponse);
058            }
059    
060            public static Scripting getScripting() {
061                    return _scripting;
062            }
063    
064            public static Set<String> getSupportedLanguages() {
065                    return getScripting().getSupportedLanguages();
066            }
067    
068            public void setScripting(Scripting scripting) {
069                    _scripting = scripting;
070            }
071    
072            private static Scripting _scripting;
073    
074    }