001/*
002 * Copyright 2002-2016 the original author or authors.
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 *      https://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
017package org.springframework.scheduling.config;
018
019import org.springframework.scheduling.Trigger;
020
021/**
022 * {@link Task} implementation defining a {@code Runnable} to be executed
023 * according to a given {@link Trigger}.
024 *
025 * @author Chris Beams
026 * @since 3.2
027 * @see Trigger#nextExecutionTime(org.springframework.scheduling.TriggerContext)
028 * @see ScheduledTaskRegistrar#setTriggerTasksList(java.util.List)
029 * @see org.springframework.scheduling.TaskScheduler#schedule(Runnable, Trigger)
030 */
031public class TriggerTask extends Task {
032
033        private final Trigger trigger;
034
035
036        /**
037         * Create a new {@link TriggerTask}.
038         * @param runnable the underlying task to execute
039         * @param trigger specifies when the task should be executed
040         */
041        public TriggerTask(Runnable runnable, Trigger trigger) {
042                super(runnable);
043                this.trigger = trigger;
044        }
045
046
047        public Trigger getTrigger() {
048                return this.trigger;
049        }
050
051}