001/*
002 * (C) Copyright 2006-2010 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 * Contributors:
017 *     bstefanescu
018 */
019package org.nuxeo.connect.update.xml;
020
021import org.nuxeo.common.xmap.annotation.XNode;
022import org.nuxeo.common.xmap.annotation.XObject;
023import org.nuxeo.connect.update.model.TaskDefinition;
024import org.nuxeo.connect.update.task.Task;
025
026/**
027 * Describe an install / uninstall task
028 *
029 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
030 */
031@XObject
032public class TaskDefinitionImpl implements TaskDefinition {
033
034    /**
035     * A class implementing {@link Task}
036     */
037    @XNode("@class")
038    protected String type;
039
040    /**
041     * Whether the platform must be restarted after executing the task.
042     */
043    @XNode("@restart")
044    protected boolean restart;
045
046    public TaskDefinitionImpl() {
047    }
048
049    public TaskDefinitionImpl(boolean restart) {
050        this.restart = restart;
051    }
052
053    public TaskDefinitionImpl(String type, boolean restart) {
054        this.type = type;
055        this.restart = restart;
056    }
057
058    public void setRequireRestart(boolean isRestartRequired) {
059        restart = isRestartRequired;
060    }
061
062    public boolean getRequireRestart() {
063        return restart;
064    }
065
066    public void setType(String type) {
067        this.type = type;
068    }
069
070    public String getType() {
071        return type;
072    }
073
074    @Override
075    public String toString() {
076        return type;
077    }
078}