001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.camel.processor;
018    
019    import java.io.Serializable;
020    
021    /**
022     * The base policy used when a fixed delay is needed.
023     * <p/>
024     * This policy is used by
025     * <a href="http://activemq.apache.org/camel/transactional-client.html">Transactional client</a>
026     * and <a href="http://activemq.apache.org/camel/dead-letter-channel.html">Dead Letter Channel</a>.
027     *
028     * The default values is:
029     * <ul>
030     *   <li>delay = 1000L</li>
031     * </ul>
032     * <p/>
033     *
034     * @version $Revision: 51255 $
035     */
036    public class DelayPolicy implements Cloneable, Serializable {
037    
038        protected long delay = 1000L;
039    
040        public DelayPolicy() {
041        }
042    
043        @Override
044        public String toString() {
045            return "DelayPolicy[delay=" + delay + "]";
046        }
047    
048        public DelayPolicy copy() {
049            try {
050                return (DelayPolicy)clone();
051            } catch (CloneNotSupportedException e) {
052                throw new RuntimeException("Could not clone: " + e, e);
053            }
054        }
055    
056        // Builder methods
057        // -------------------------------------------------------------------------
058    
059        /**
060         * Sets the delay in milliseconds
061         */
062        public DelayPolicy delay(long delay) {
063            setDelay(delay);
064            return this;
065        }
066    
067        // Properties
068        // -------------------------------------------------------------------------
069        public long getDelay() {
070            return delay;
071        }
072    
073        /**
074         * Sets the delay in milliseconds
075         */
076        public void setDelay(long delay) {
077            this.delay = delay;
078        }
079    
080    
081    }