org.axonframework.spring.config.EventHandlerRegistrar Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of axon-spring Show documentation
Show all versions of axon-spring Show documentation
Module providing Spring specific helper functionality to ease configuration / set-up of an Axon application, as
well as some Spring specific infrastructure components.
/*
* Copyright (c) 2010-2017. 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.spring.config;
import org.axonframework.config.EventHandlingConfiguration;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.SmartLifecycle;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import java.util.List;
/**
* Spring Bean that registers Event Handler beans with the EventHandlingConfiguration.
*
* To customize this behavior, define a Bean of type {@link EventHandlingConfiguration} in the application context:
*
* @Bean
* public EventHandlingConfiguration eventHandlerConfiguration() {
* return new EventHandlingConfiguration();
* }
*
*/
public class EventHandlerRegistrar implements InitializingBean, SmartLifecycle {
private final AxonConfiguration axonConfiguration;
private final EventHandlingConfiguration delegate;
private volatile boolean running = false;
private volatile boolean initialized;
/**
* Initialize the registrar to register beans discovered with the given {@code eventHandlingConfiguration}.
* The registrar will also initialize the EventHandlerConfiguration using the given {@code axonConfiguration}
* and start it.
*
* @param axonConfiguration The main Axon Configuration instance
* @param eventHandlingConfiguration The main Axon Configuration
*/
public EventHandlerRegistrar(AxonConfiguration axonConfiguration,
EventHandlingConfiguration eventHandlingConfiguration) {
this.axonConfiguration = axonConfiguration;
this.delegate = eventHandlingConfiguration;
}
/**
* Registers the given {@code beans} as event handlers with the Event Handler Configuration. The beans are sorted
* (see {@link AnnotationAwareOrderComparator}) before registering them to the configuration.
*
* @param beans the beans to register
*/
public void setEventHandlers(List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy