001    /**
002     * Copyright (c) 2000-2013 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.xsl;
016    
017    import com.liferay.portal.kernel.security.pacl.DoPrivileged;
018    import com.liferay.portal.kernel.template.Template;
019    import com.liferay.portal.kernel.template.TemplateConstants;
020    import com.liferay.portal.kernel.template.TemplateResource;
021    import com.liferay.portal.template.BaseTemplateManager;
022    import com.liferay.portal.template.TemplateContextHelper;
023    
024    import java.util.Map;
025    
026    /**
027     * @author Tina Tian
028     */
029    @DoPrivileged
030    public class XSLManager extends BaseTemplateManager {
031    
032            @Override
033            public void destroy() {
034                    if (_templateContextHelper == null) {
035                            return;
036                    }
037    
038                    _templateContextHelper.removeAllHelperUtilities();
039    
040                    _templateContextHelper = null;
041            }
042    
043            @Override
044            public void destroy(ClassLoader classLoader) {
045                    _templateContextHelper.removeHelperUtilities(classLoader);
046            }
047    
048            @Override
049            public String getName() {
050                    return TemplateConstants.LANG_TYPE_XSL;
051            }
052    
053            @Override
054            public void init() {
055            }
056    
057            public void setTemplateContextHelper(
058                    TemplateContextHelper templateContextHelper) {
059    
060                    _templateContextHelper = templateContextHelper;
061            }
062    
063            @Override
064            protected Template doGetTemplate(
065                    TemplateResource templateResource,
066                    TemplateResource errorTemplateResource, boolean restricted,
067                    Map<String, Object> helperUtilities) {
068    
069                    XSLTemplateResource xslTemplateResource =
070                            (XSLTemplateResource)templateResource;
071    
072                    return new XSLTemplate(
073                            xslTemplateResource, errorTemplateResource, _templateContextHelper);
074            }
075    
076            @Override
077            protected TemplateContextHelper getTemplateContextHelper() {
078                    return _templateContextHelper;
079            }
080    
081            private TemplateContextHelper _templateContextHelper;
082    
083    }