001/* 002 * (C) Copyright 2006-2007 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 * 016 */ 017package org.nuxeo.ecm.platform.preview.adapter; 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 { 029 030 @XNode("@name") 031 private String name; 032 033 @XNode("@enabled") 034 private boolean enabled = true; 035 036 @XNode("typeName") 037 private String typeName; 038 039 @XNode("class") 040 private Class<?> adapterClass; 041 042 public Class<?> getAdapterClass() { 043 return adapterClass; 044 } 045 046 public boolean isEnabled() { 047 return enabled; 048 } 049 050 public void setEnabled(boolean enabled) { 051 this.enabled = enabled; 052 } 053 054 public String getName() { 055 return name; 056 } 057 058 public void setName(String name) { 059 this.name = name; 060 } 061 062 public String getTypeName() { 063 return typeName; 064 } 065 066 public void setTypeName(String typeName) { 067 this.typeName = typeName; 068 } 069 070 public PreviewAdapterFactory getNewInstance() { 071 try { 072 return (PreviewAdapterFactory) adapterClass.getDeclaredConstructor().newInstance(); 073 } catch (ReflectiveOperationException e) { 074 throw new RuntimeException(e); 075 } 076 } 077 078}