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    
023    import java.util.Map;
024    
025    /**
026     * @author Tina Tian
027     */
028    @DoPrivileged
029    public class XSLManager extends BaseTemplateManager {
030    
031            @Override
032            public void destroy() {
033                    if (templateContextHelper == null) {
034                            return;
035                    }
036    
037                    templateContextHelper.removeAllHelperUtilities();
038    
039                    templateContextHelper = null;
040            }
041    
042            @Override
043            public void destroy(ClassLoader classLoader) {
044                    templateContextHelper.removeHelperUtilities(classLoader);
045            }
046    
047            @Override
048            public String getName() {
049                    return TemplateConstants.LANG_TYPE_XSL;
050            }
051    
052            @Override
053            public void init() {
054            }
055    
056            @Override
057            protected Template doGetTemplate(
058                    TemplateResource templateResource,
059                    TemplateResource errorTemplateResource, boolean restricted,
060                    Map<String, Object> helperUtilities, boolean privileged) {
061    
062                    XSLTemplateResource xslTemplateResource =
063                            (XSLTemplateResource)templateResource;
064    
065                    return new XSLTemplate(
066                            xslTemplateResource, errorTemplateResource, templateContextHelper);
067            }
068    
069    }