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
  * 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.contextsupport.spring;
 import java.util.List;

The RepositoryBeanDefinitionParser is responsible for parsing the repository element from the Axon namespace. It creates a org.springframework.beans.factory.config.BeanDefinition based on the org.axonframework.eventsourcing.GenericEventSourcingRepository.

Ben Z. Tels
Allard Buijze
The conflict resolver attribute name.
     private static final String CONFLICT_RESOLVER_ATTRIBUTE = "conflict-resolver";
The event store attribute name.
     private static final String EVENT_STORE_ATTRIBUTE = "event-store";
The event bus attribute name.
     private static final String EVENT_BUS_ATTRIBUTE = "event-bus";
The locking strategy attribute name.
     private static final String LOCKING_STRATEGY_ATTRIBUTE = "locking-strategy";
The aggregate root type attribute name.
     private static final String AGGREGATE_ROOT_TYPE_ATTRIBUTE = "aggregate-type";
     private static final String CACHE_ATTRIBUTE = "cache-ref";
     private static final String EVENT_PROCESSORS_ELEMENT = "event-processors";
     private static final String SNAPSHOT_TRIGGER_ELEMENT = "snapshotter-trigger";
     private static final String EVENT_STREAM_DECORATORS_PROPERTY = "eventStreamDecorators";
     private static final String SNAPSHOTTER_TRIGGER_PROPERTY = "snapshotterTrigger";
     protected AbstractBeanDefinition parseInternal(Element elementParserContext parserContext) {
         GenericBeanDefinition repositoryDefinition = new GenericBeanDefinition();
         if (element.hasAttribute()) {
         } else {
                                 repositoryDefinition.getPropertyValues(), null);
         parseReferenceAttribute(element"cache"repositoryDefinition.getPropertyValues(), null);
         return repositoryDefinition;
    private void parseProcessors(Element elementParserContext parserContextGenericBeanDefinition beanDefinition) {
        Element processorsElement = DomUtils.getChildElementByTagName(element);
        Element snapshotTriggerElement = DomUtils.getChildElementByTagName(element);
        if (snapshotTriggerElement != null) {
            BeanDefinition triggerDefinition = .parse(snapshotTriggerElementparserContext);
            PropertyValue aggregateCache = beanDefinition.getPropertyValues().getPropertyValue("cache");
            if (aggregateCache != null) {
        if (processorsElement != null) {
            List<ObjectprocessorsList = parserContext.getDelegate().parseListElement(processorsElement,
            if (!processorsList.isEmpty()) {

Parse the named reference attribute and make it a property reference value.

element The org.w3c.dom.Element being parsed.
referenceName The name of the reference attribute.
propertyName The name of the property to set the references object to
properties The properties of the bean definition
autowiredType An optional class defining the type to autowire. Use null to indicate that no autowiring is required.
    private void parseReferenceAttribute(Element elementString referenceNameString propertyName,
                                         MutablePropertyValues propertiesClass<?> autowiredType) {
        if (element.hasAttribute(referenceName)) {
            properties.add(propertyNamenew RuntimeBeanReference(element.getAttribute(referenceName)));
        } else if (autowiredType != null) {
            properties.add(propertyNamenew AutowiredBean(autowiredType));

Parse the org.axonframework.repository.LockingStrategy selection and make it a constructor argument.

    private void parseLockingStrategy(Element elementGenericBeanDefinition builder) {
        if (element.hasAttribute()) {
            LockingStrategy strategy = LockingStrategy.valueOf(element.getAttribute());

Parse the org.axonframework.domain.AggregateRoot type information and make it a constructor argument.

element The Element being parsed.
builder The being used to construct the BeanDefinition.
    private void parseAggregateRootType(Element elementGenericBeanDefinition builder) {
        // Mandatory in the XSD
        String aggregateRootTypeString = element.getAttribute();
        try {
            Class<?> aggregateRootType = Class.forName(aggregateRootTypeString);
                   .addGenericArgumentValue(new GenericAggregateFactory(aggregateRootType));
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(
                    "No class of name " + aggregateRootTypeString + " was found on the classpath"e);
New to GrepCode? Check out our FAQ X