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.eventsourcing;
 
 
 import static java.lang.String.format;

AggregateFactory implementation that uses Spring prototype beans to create new uninitialized instances of Aggregates.

Parameters:
<T> The type of aggregate generated by this aggregate factory
Author(s):
Allard Buijze
Since:
1.2
 
 
     private String prototypeBeanName;
     private String typeIdentifier;
     private String beanName;
 
     @SuppressWarnings({"unchecked"})
     @Override
     public T createAggregate(AggregateIdentifier aggregateIdentifierDomainEvent firstEvent) {
         return (T) .getBean(aggregateIdentifier);
     }
 
     @Override
     public String getTypeIdentifier() {
         return ;
     }

    
Sets the name of the prototype bean this repository serves. Note that the the bean should have the prototype scope and have a constructor that takes a single UUID argument.

Parameters:
prototypeBeanName the name of the prototype bean this repository serves.
 
     @Required
     public void setPrototypeBeanName(String prototypeBeanName) {
         this. = prototypeBeanName;
     }

    
Sets the type identifier of the aggregate served by this repository. The type identifier is used to identify events in the event store as belonging to an aggregate served by this repository.

Defaults to the bean name of the prototype bean.

Parameters:
typeIdentifier the type identifier of the aggregate served by this repository.
 
     public void setTypeIdentifier(String typeIdentifier) {
         this. = typeIdentifier;
     }
 
     @Override
     public void setApplicationContext(ApplicationContext applicationContext) {
         this. = applicationContext;
     }
 
     @Override
     public void setBeanName(String beanName) {
         this. = beanName;
     }
 
     @Override
     public void afterPropertiesSet() throws Exception {
         if (this. == null) {
             this. = ;
         }
             throw new IncompatibleAggregateException(format("Cannot initialize repository '%s'. "
                                                                     + "The bean with name '%s' does not have the prototype scope.",
                                                             ));
         }
            throw new IncompatibleAggregateException(format("Cannot initialize repository '%s'. "
                                                                    + "The bean with name '%s' does not extend from EventSourcingAggregateRoot.",
                                                            ));
        }
    }
New to GrepCode? Check out our FAQ X