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