Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2010. 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.repository;
The repository provides an abstraction of the storage of aggregates.

Parameters:
<T> The type of aggregate this repository stores.
Author(s):
Allard Buijze
Since:
0.1
public interface Repository<T extends AggregateRoot> {

    
Load the aggregate with the given unique aggregateIdentifier, expecting the version of the aggregate to be equal to the given expectedVersion. If the expectedVersion is null, no version validation is done.

When versions do not match, implementations may either raise an exception immediately when loading an aggregate, or at any other time while the aggregate is registered in the current Unit Of Work.

Parameters:
aggregateIdentifier The identifier of the aggregate to load
expectedVersion The expected version of the aggregate to load, or null to indicate the version should not be checked
Returns:
The aggregate root with the given identifier.
Throws:
AggregateNotFoundException if aggregate with given id cannot be found
ConflictingModificationException if the expectedVersion did not match the aggregate's actual version
See also:
org.axonframework.unitofwork.UnitOfWork
    T load(AggregateIdentifier aggregateIdentifierLong expectedVersion);

    
Load the aggregate with the given unique identifier. No version checks are done when loading an aggregate, meaning that concurrent access will not be checked for.

Parameters:
aggregateIdentifier The identifier of the aggregate to load
Returns:
The aggregate root with the given identifier.
Throws:
AggregateNotFoundException if aggregate with given id cannot be found
    T load(AggregateIdentifier aggregateIdentifier);

    
Adds the given aggregate to the repository. The version of this aggregate must be null, indicating that it has not been previously persisted.

This method will not force the repository to save the aggregate immediately. Instead, it is registered with the current UnitOfWork. To force storage of an aggregate, commit the current unit of work (CurrentUnitOfWork.commit())

Parameters:
aggregate The aggregate to add to the repository.
Throws:
java.lang.IllegalArgumentException if the given aggregate is not newly created. This means org.axonframework.domain.AggregateRoot.getVersion() must return null.
    void add(T aggregate);
New to GrepCode? Check out our FAQ X