001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     Anahide Tchertchian
011 */
012package org.nuxeo.ecm.core.api.externalblob;
013
014import java.util.HashMap;
015import java.util.Map;
016
017import org.nuxeo.common.xmap.annotation.XNode;
018import org.nuxeo.common.xmap.annotation.XNodeMap;
019import org.nuxeo.common.xmap.annotation.XObject;
020
021/**
022 * Descriptor for registration of an external blob adapter.
023 *
024 * @see ExternalBlobAdapter
025 * @author Anahide Tchertchian
026 */
027@XObject("adapter")
028public class ExternalBlobAdapterDescriptor {
029
030    @XNode("@prefix")
031    protected String prefix;
032
033    @XNode("@class")
034    protected Class<? extends ExternalBlobAdapter> adapter;
035
036    @XNodeMap(value = "property", key = "@name", type = HashMap.class, componentType = String.class)
037    Map<String, String> properties = new HashMap<String, String>();
038
039    public Class<? extends ExternalBlobAdapter> getAdapterClass() {
040        return adapter;
041    }
042
043    public String getPrefix() {
044        return prefix;
045    }
046
047    public Map<String, String> getProperties() {
048        return properties;
049    }
050
051    public ExternalBlobAdapter getAdapter() {
052        try {
053            return adapter.newInstance();
054        } catch (ReflectiveOperationException e) {
055            throw new RuntimeException(e);
056        }
057    }
058
059}