001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * dragos 016 * 017 * $Id$ 018 */ 019package org.nuxeo.ecm.platform.rendering.impl; 020 021import org.nuxeo.common.xmap.annotation.XNode; 022import org.nuxeo.ecm.platform.rendering.RenderingEngine; 023 024/** 025 * Rendering Engine Descriptor objects instantiated with configuration from contributions like: 026 * 027 * <pre> 028 * <engine name=”the_format_name” class=”rendering_engine_impl_class”/> 029 * </pre> 030 * 031 * . Also instantiate rendering engine as defined in contribution. 032 * 033 * @author <a href="mailto:dm@nuxeo.com">Dragos Mihalache</a> 034 */ 035public class RenderingEngineDescriptor { 036 037 @XNode("format") 038 private String format; 039 040 @XNode("class") 041 private Class<RenderingEngine> klass; 042 043 public String getFormat() { 044 return format; 045 } 046 047 public void setFormat(String name) { 048 format = name; 049 } 050 051 public Class<?> getEngineClass() { 052 return klass; 053 } 054 055 public RenderingEngine newInstance() throws InstantiationException, IllegalAccessException { 056 return klass.newInstance(); 057 } 058 059 @Override 060 public String toString() { 061 StringBuilder sb = new StringBuilder(); 062 sb.append(RenderingEngineDescriptor.class.getSimpleName()); 063 sb.append(" {name="); 064 sb.append(format); 065 sb.append(", class="); 066 sb.append(klass); 067 sb.append(" }"); 068 069 return sb.toString(); 070 } 071}