Search in sources :

Example 91 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method userDestinationMessageHandler.

@Bean
public UserDestinationMessageHandler userDestinationMessageHandler() {
    UserDestinationMessageHandler handler = new UserDestinationMessageHandler(clientInboundChannel(), brokerChannel(), userDestinationResolver());
    String destination = getBrokerRegistry().getUserDestinationBroadcast();
    handler.setBroadcastDestination(destination);
    return handler;
}
Also used : UserDestinationMessageHandler(org.springframework.messaging.simp.user.UserDestinationMessageHandler) Bean(org.springframework.context.annotation.Bean)

Example 92 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method userDestinationResolver.

@Bean
public UserDestinationResolver userDestinationResolver() {
    DefaultUserDestinationResolver resolver = new DefaultUserDestinationResolver(userRegistry());
    String prefix = getBrokerRegistry().getUserDestinationPrefix();
    if (prefix != null) {
        resolver.setUserDestinationPrefix(prefix);
    }
    resolver.setPathMatcher(getBrokerRegistry().getPathMatcher());
    return resolver;
}
Also used : DefaultUserDestinationResolver(org.springframework.messaging.simp.user.DefaultUserDestinationResolver) Bean(org.springframework.context.annotation.Bean)

Example 93 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method brokerChannel.

@Bean
public AbstractSubscribableChannel brokerChannel() {
    ChannelRegistration reg = getBrokerRegistry().getBrokerChannelRegistration();
    ExecutorSubscribableChannel channel = reg.hasTaskExecutor() ? new ExecutorSubscribableChannel(brokerChannelExecutor()) : new ExecutorSubscribableChannel();
    reg.setInterceptors(new ImmutableMessageChannelInterceptor());
    channel.setInterceptors(reg.getInterceptors());
    return channel;
}
Also used : ExecutorSubscribableChannel(org.springframework.messaging.support.ExecutorSubscribableChannel) ImmutableMessageChannelInterceptor(org.springframework.messaging.support.ImmutableMessageChannelInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 94 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method simpAnnotationMethodMessageHandler.

@Bean
public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler() {
    SimpAnnotationMethodMessageHandler handler = createAnnotationMethodMessageHandler();
    handler.setDestinationPrefixes(getBrokerRegistry().getApplicationDestinationPrefixes());
    handler.setMessageConverter(brokerMessageConverter());
    handler.setValidator(simpValidator());
    List<HandlerMethodArgumentResolver> argumentResolvers = new ArrayList<>();
    addArgumentResolvers(argumentResolvers);
    handler.setCustomArgumentResolvers(argumentResolvers);
    List<HandlerMethodReturnValueHandler> returnValueHandlers = new ArrayList<>();
    addReturnValueHandlers(returnValueHandlers);
    handler.setCustomReturnValueHandlers(returnValueHandlers);
    PathMatcher pathMatcher = getBrokerRegistry().getPathMatcher();
    if (pathMatcher != null) {
        handler.setPathMatcher(pathMatcher);
    }
    return handler;
}
Also used : HandlerMethodReturnValueHandler(org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler) PathMatcher(org.springframework.util.PathMatcher) ArrayList(java.util.ArrayList) SimpAnnotationMethodMessageHandler(org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler) HandlerMethodArgumentResolver(org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver) Bean(org.springframework.context.annotation.Bean)

Example 95 with Bean

use of org.springframework.context.annotation.Bean in project spring-framework by spring-projects.

the class AbstractMessageBrokerConfiguration method stompBrokerRelayMessageHandler.

@Bean
public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler() {
    StompBrokerRelayMessageHandler handler = getBrokerRegistry().getStompBrokerRelay(brokerChannel());
    if (handler == null) {
        return new NoOpBrokerMessageHandler();
    }
    Map<String, MessageHandler> subscriptions = new HashMap<>(1);
    String destination = getBrokerRegistry().getUserDestinationBroadcast();
    if (destination != null) {
        subscriptions.put(destination, userDestinationMessageHandler());
    }
    destination = getBrokerRegistry().getUserRegistryBroadcast();
    if (destination != null) {
        subscriptions.put(destination, userRegistryMessageHandler());
    }
    handler.setSystemSubscriptions(subscriptions);
    return handler;
}
Also used : SimpleBrokerMessageHandler(org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler) StompBrokerRelayMessageHandler(org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler) AbstractBrokerMessageHandler(org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler) UserRegistryMessageHandler(org.springframework.messaging.simp.user.UserRegistryMessageHandler) UserDestinationMessageHandler(org.springframework.messaging.simp.user.UserDestinationMessageHandler) MessageHandler(org.springframework.messaging.MessageHandler) SimpAnnotationMethodMessageHandler(org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler) HashMap(java.util.HashMap) StompBrokerRelayMessageHandler(org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler) Bean(org.springframework.context.annotation.Bean)

Aggregations

Bean (org.springframework.context.annotation.Bean)4059 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1090 RefreshScope (org.springframework.cloud.context.config.annotation.RefreshScope)444 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)393 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)309 lombok.val (lombok.val)294 HashMap (java.util.HashMap)285 Lazy (org.springframework.context.annotation.Lazy)257 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)194 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)158 Map (java.util.Map)152 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)112 Properties (java.util.Properties)100 Autowired (org.springframework.beans.factory.annotation.Autowired)93 ArrayList (java.util.ArrayList)85 Primary (org.springframework.context.annotation.Primary)84 Qualifier (org.springframework.beans.factory.annotation.Qualifier)75 CamelContextAware (org.apache.camel.CamelContextAware)69 ThreadPoolTaskExecutor (org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor)69 JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)61