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.bam.model;
018    
019    import org.apache.camel.bam.TimerEventHandler;
020    
021    import javax.persistence.Entity;
022    import javax.persistence.ManyToOne;
023    import javax.persistence.FetchType;
024    import javax.persistence.CascadeType;
025    import java.util.Date;
026    
027    /**
028     * Represents a persistent timer event
029     *
030     * @version $Revision: $
031     */
032    @Entity
033    public class TimerEvent extends EntitySupport {
034        private Date time;
035    
036        @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
037        private TimerEventHandler handler;
038    
039        public Date getTime() {
040            return time;
041        }
042    
043        public void setTime(Date time) {
044            this.time = time;
045        }
046    
047        public TimerEventHandler getHandler() {
048            return handler;
049        }
050    
051        public void setHandler(TimerEventHandler handler) {
052            this.handler = handler;
053        }
054    
055        public void fire() {
056            getHandler().onTimerEvent(this);
057        }
058    }