Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) 2010-2012. 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.contextsupport.spring;
The EventBusBeanDefinitionParser is responsible for parsing the eventBus element from the Axon namespace. The parser will create a org.springframework.beans.factory.config.BeanDefinition based on a org.axonframework.eventhandling.SimpleEventBus.

Author(s):
Ben Z. Tels
Since:
0.7
    private static final String TERMINAL_ATTRIBUTE = "terminal";
    private static final String CLUSTER_SELECTOR_REF = "cluster-selector";
    @Override
    protected AbstractBeanDefinition parseInternal(Element elementParserContext parserContext) {
        GenericBeanDefinition eventBusDefinition = new GenericBeanDefinition();
        eventBusDefinition.setBeanClass(ClusteringEventBus.class);
        String clusterSelectorRef = element.getAttribute();
        if (StringUtils.hasText(clusterSelectorRef)) {
            eventBusDefinition.getConstructorArgumentValues()
                              .addIndexedArgumentValue(0,
                                                       new RuntimeBeanReference(clusterSelectorRef));
        } else {
            eventBusDefinition.getConstructorArgumentValues()
                              .addIndexedArgumentValue(0, BeanDefinitionBuilder
                                      .genericBeanDefinition(AutowiringClusterSelector.class).getBeanDefinition());
        }
        String terminalRef = element.getAttribute();
        if (StringUtils.hasText(terminalRef)) {
            eventBusDefinition.getConstructorArgumentValues()
                              .addIndexedArgumentValue(1,
                                                       new RuntimeBeanReference(terminalRef));
        }
        return eventBusDefinition;
    }
    @Override
    protected boolean shouldGenerateIdAsFallback() {
        return true;
    }
New to GrepCode? Check out our FAQ X