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    @Override
059    public void setRequireRestart(boolean isRestartRequired) {
060        restart = isRestartRequired;
061    }
062
063    @Override
064    public boolean getRequireRestart() {
065        return restart;
066    }
067
068    @Override
069    public void setType(String type) {
070        this.type = type;
071    }
072
073    @Override
074    public String getType() {
075        return type;
076    }
077
078    @Override
079    public String toString() {
080        return type;
081    }
082}