public class SimpleEventFileResolver extends Object implements EventFileResolver
Modifier and Type | Field and Description |
---|---|
static String |
FILE_EXTENSION_EVENTS
Describes the file extension used for files containing domain events.
|
static String |
FILE_EXTENSION_SNAPSHOTS
Describes the file extension used for files containing snapshot events.
|
Constructor and Description |
---|
SimpleEventFileResolver(File baseDir)
Initialize the SimpleEventFileResolver with the given
baseDir . |
Modifier and Type | Method and Description |
---|---|
boolean |
eventFileExists(String type,
Object identifier)
Indicates whether there is a file containing (regular) events for the given
aggregateIdentifier of
given type . |
InputStream |
openEventFileForReading(String type,
Object identifier)
Provides an input stream to the (regular) events file for the aggregate with the given
aggregateIdentifier and of given type . |
OutputStream |
openEventFileForWriting(String type,
Object aggregateIdentifier)
Provides an output stream to the (regular) events file for the aggregate with the given
aggregateIdentifier and of given type . |
InputStream |
openSnapshotFileForReading(String type,
Object identifier)
Provides an input stream to the snapshot events file for the aggregate with the given
aggregateIdentifier and of given type . |
OutputStream |
openSnapshotFileForWriting(String type,
Object aggregateIdentifier)
Provides an output stream to the snapshot events file for the aggregate with the given
aggregateIdentifier and of given type . |
boolean |
snapshotFileExists(String type,
Object identifier)
Indicates whether there is a file containing snapshot events for the given
aggregateIdentifier of
given type . |
public static final String FILE_EXTENSION_EVENTS
public static final String FILE_EXTENSION_SNAPSHOTS
public SimpleEventFileResolver(File baseDir)
baseDir
.
Note that the resource supplied must point to a folder and should contain a trailing slash. See org.springframework.core.io.FileSystemResource#FileSystemResource(String)
.baseDir
- The directory where event files are stored.public OutputStream openEventFileForWriting(String type, Object aggregateIdentifier) throws IOException
EventFileResolver
aggregateIdentifier
and of given type
. Written bytes are appended to already existing
information.
The caller of this method is responsible for closing the output stream when all data has been written to it.openEventFileForWriting
in interface EventFileResolver
type
- The type of aggregate to open the stream foraggregateIdentifier
- the identifier of the aggregateIOException
- when an error occurs while opening a filepublic OutputStream openSnapshotFileForWriting(String type, Object aggregateIdentifier) throws IOException
EventFileResolver
aggregateIdentifier
and of given type
. Written bytes are appended to already existing
information.
The caller of this method is responsible for closing the output stream when all data has been written to it.openSnapshotFileForWriting
in interface EventFileResolver
type
- The type of aggregate to open the stream foraggregateIdentifier
- the identifier of the aggregateIOException
- when an error occurs while opening a filepublic InputStream openEventFileForReading(String type, Object identifier) throws IOException
EventFileResolver
aggregateIdentifier
and of given type
.
The caller of this method is responsible for closing the input stream when done reading from it.openEventFileForReading
in interface EventFileResolver
type
- The type of aggregate to open the stream foridentifier
- the identifier of the aggregateIOException
- when an error occurs while opening a filepublic InputStream openSnapshotFileForReading(String type, Object identifier) throws IOException
EventFileResolver
aggregateIdentifier
and of given type
.
The caller of this method is responsible for closing the input stream when done reading from it.openSnapshotFileForReading
in interface EventFileResolver
type
- The type of aggregate to open the stream foridentifier
- the identifier of the aggregateIOException
- when an error occurs while opening a filepublic boolean eventFileExists(String type, Object identifier) throws IOException
EventFileResolver
aggregateIdentifier
of
given type
.eventFileExists
in interface EventFileResolver
type
- The type of aggregateidentifier
- the identifier of the aggregatetrue
if an event log exists for the aggregate, false
otherwise.IOException
- when an error occurs while reading from the FileSystem. The existence of the event file is
undetermined.public boolean snapshotFileExists(String type, Object identifier) throws IOException
EventFileResolver
aggregateIdentifier
of
given type
.snapshotFileExists
in interface EventFileResolver
type
- The type of aggregateidentifier
- the identifier of the aggregatetrue
if a snapshot event log exists for the aggregate, false
otherwise.IOException
- when an error occurs while reading from the FileSystem. The existence of the event file is
undetermined.Copyright © 2010-2014. All Rights Reserved.