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 *     Nuxeo - initial API and implementation
011 *
012 */
013package org.nuxeo.ecm.core.convert.extension;
014
015import java.io.Serializable;
016import java.util.Map;
017
018import org.nuxeo.ecm.core.api.blobholder.BlobHolder;
019import org.nuxeo.ecm.core.convert.api.ConversionException;
020import org.nuxeo.ecm.core.convert.cache.CachableBlobHolder;
021
022/**
023 * Interface that must be implemented by any contributer Converter class.
024 * <p>
025 * There is only one instance of each contributed converter class: that means that the implementation must be
026 * thread-safe.
027 *
028 * @author tiry
029 */
030public interface Converter {
031
032    /**
033     * Initializes the Converter.
034     * <p>
035     * This can be used to retrieve some configuration information from the XMap Descriptor.
036     */
037    void init(ConverterDescriptor descriptor);
038
039    /**
040     * Main method to handle the real Conversion Job.
041     * <p>
042     * Returned {@link BlobHolder} must implement {@link CachableBlobHolder}, otherwise result won't be cached.
043     */
044    BlobHolder convert(BlobHolder blobHolder, Map<String, Serializable> parameters) throws ConversionException;
045
046}