001/*
002 * (C) Copyright 2013 Nuxeo SA (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-2.1.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 * Contributors:
015 *     Florent Guillaume
016 */
017package org.nuxeo.ecm.core.work.api;
018
019import org.nuxeo.common.xmap.annotation.XNode;
020import org.nuxeo.common.xmap.annotation.XObject;
021import org.nuxeo.ecm.core.work.WorkQueuing;
022
023/**
024 * Descriptor for a {@link WorkManager} queuing implementation configuration.
025 *
026 * @since 5.8
027 */
028@XObject("queuing")
029public class WorkQueuingImplDescriptor {
030
031    @XNode("@class")
032    public Class<?> klass;
033
034    @SuppressWarnings("unchecked")
035    public Class<? extends WorkQueuing> getWorkQueuingClass() {
036        if (!(WorkQueuing.class.isAssignableFrom(klass))) {
037            throw new RuntimeException("Invalid class: " + klass.getName());
038        }
039        return (Class<? extends WorkQueuing>) klass;
040    }
041
042}