Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2010-2011. Axon Framework
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.axonframework.eventhandling.scheduling;
Abstract implementation of the org.axonframework.domain.ApplicationEvent that contains the timestamp of the moment the event is scheduled for publication.

Author(s):
Allard Buijze
Since:
0.7
public abstract class ScheduledEvent extends ApplicationEvent {
    private static final long serialVersionUID = 1438418254163373484L;
    private static final String SCHEDULED_TIME_KEY = "scheduledTime";

    
Initializes a new scheduled event, scheduled for publication after a given duration.

Parameters:
source The instance considered the source of this event
duration The amount of time to wait before publication of the even
    public ScheduledEvent(Object sourceDuration duration) {
        this(sourcenew DateTime().plus(duration));
    }

    
Initializes a new scheduled event, scheduled for publication at the given timestamp.

Parameters:
source The instance considered the source of this event
timestamp The time at which to publish the event
    public ScheduledEvent(Object sourceDateTime timestamp) {
        super(source);
        addMetaData(timestamp);
    }

    
Initializes the event using given parameters. This constructor is intended for the reconstruction of exsisting events (e.g. during deserialization).

Parameters:
identifier The identifier of the event
timestamp The original creation timestamp
eventRevision The revision of the event type
sourceDescription The description of the source. If null, will default to "[unknown source]".
triggerDateTime The timestamp the event is scheduled for triggering
    protected ScheduledEvent(String identifierDateTime timestamplong eventRevisionString sourceDescription,
                             DateTime triggerDateTime) {
        super(identifiertimestampeventRevisionsourceDescription);
        addMetaData(triggerDateTime);
    }

    
The time at which the event is to be published. Note that this property should be immutable. If this value changes the exact behavior is undefined.

Returns:
The time at which the event is to be published
    public DateTime getScheduledTime() {
        return (DateTimegetMetaDataValue();
    }
New to GrepCode? Check out our FAQ X