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 */ 015package org.nuxeo.ecm.platform.preview.adapter; 016 017import java.io.Serializable; 018 019import org.nuxeo.common.xmap.annotation.XNode; 020import org.nuxeo.common.xmap.annotation.XObject; 021 022/** 023 * Descriptor for contributed Preview Adapter factories. 024 * 025 * @author tiry 026 */ 027@XObject(value = "previewAdapter") 028public class AdapterFactoryDescriptor implements Serializable { 029 030 private static final long serialVersionUID = 1L; 031 032 @XNode("@name") 033 private String name; 034 035 @XNode("@enabled") 036 private boolean enabled = true; 037 038 @XNode("typeName") 039 private String typeName; 040 041 @XNode("class") 042 private Class<?> adapterClass; 043 044 public Class<?> getAdapterClass() { 045 return adapterClass; 046 } 047 048 public boolean isEnabled() { 049 return enabled; 050 } 051 052 public void setEnabled(boolean enabled) { 053 this.enabled = enabled; 054 } 055 056 public String getName() { 057 return name; 058 } 059 060 public void setName(String name) { 061 this.name = name; 062 } 063 064 public String getTypeName() { 065 return typeName; 066 } 067 068 public void setTypeName(String typeName) { 069 this.typeName = typeName; 070 } 071 072 public PreviewAdapterFactory getNewInstance() { 073 try { 074 return (PreviewAdapterFactory) adapterClass.newInstance(); 075 } catch (ReflectiveOperationException e) { 076 throw new RuntimeException(e); 077 } 078 } 079 080}