001/*
002 * JPPF.
003 * Copyright (C) 2005-2015 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.jppf.client.concurrent;
020
021import org.jppf.client.taskwrapper.JPPFTaskCallback;
022import org.jppf.scheduling.JPPFSchedule;
023
024/**
025 * This interface defines the properties that can be provided to a task
026 * submitted by a {@link JPPFExecutorService} and that is not a {@link org.jppf.node.protocol.Task Task} instance.
027 * These properties include:
028 * <ul>
029 * <li>the task expiration schedule</li>
030 * <li>a callback that will replace the task's {@link org.jppf.node.protocol.Task#onTimeout() onTimeout()} method</li>
031 * <li>a callback that will replace the task's {@link org.jppf.node.protocol.Task#onCancel() onCancel()} method</li>
032 * </ul>
033 * @author Laurent Cohen
034 */
035public interface TaskConfiguration
036{
037  /**
038   * Get the delegate for the <code>onCancel()</code> method.
039   * @return a {@link JPPFTaskCallback} instance.
040   */
041  JPPFTaskCallback getOnCancelCallback();
042
043  /**
044   * Set the delegate for the <code>onCancel()</code> method.
045   * @param cancelCallback a {@link JPPFTaskCallback} instance.
046   */
047  void setOnCancelCallback(final JPPFTaskCallback cancelCallback);
048
049  /**
050   * Get the delegate for the <code>onTimeout()</code> method.
051   * @return a {@link JPPFTaskCallback} instance.
052   */
053  JPPFTaskCallback getOnTimeoutCallback();
054
055  /**
056   * Set the delegate for the <code>onTimeout()</code> method.
057   * @param timeoutCallback a {@link JPPFTaskCallback} instance.
058   */
059  void setOnTimeoutCallback(final JPPFTaskCallback timeoutCallback);
060
061  /**
062   * Get the timeout set on the task.
063   * @return a {@link JPPFSchedule} instance, or null if no timeout was set.
064   */
065  JPPFSchedule getTimeoutSchedule();
066
067  /**
068   * Set the timeout set on the task.
069   * @param timeoutSchedule a {@link JPPFSchedule} instance.
070   */
071  void setTimeoutSchedule(final JPPFSchedule timeoutSchedule);
072}