001/* 002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and others. 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 * Contributors: 016 * Nuxeo - initial API and implementation 017 */ 018 019package org.nuxeo.ecm.user.invite; 020 021import java.io.File; 022import java.net.URL; 023 024import freemarker.template.Configuration; 025import org.nuxeo.ecm.platform.rendering.api.RenderingEngine; 026import org.nuxeo.ecm.platform.rendering.api.ResourceLocator; 027import org.nuxeo.ecm.platform.rendering.fm.FreemarkerEngine; 028 029 030public class RenderingHelper { 031 032 protected static RenderingEngine engine; 033 034 protected class CLResourceLocator implements ResourceLocator { 035 public File getResourceFile(String key) { 036 return null; 037 } 038 039 public URL getResourceURL(String key) { 040 return this.getClass().getClassLoader().getResource(key); 041 } 042 } 043 044 public RenderingEngine getRenderingEngine() { 045 if (engine == null) { 046 engine = new FreemarkerEngine(); 047 engine.setResourceLocator(new CLResourceLocator()); 048 } 049 return engine; 050 } 051 052 public Configuration getEngineConfiguration() { 053 return ((FreemarkerEngine) engine).getConfiguration(); 054 } 055 056}