<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:websocket="http://www.springframework.org/schema/websocket"
       xmlns:context="http://www.springframework.org/schema/context" xmlns:int="http://www.springframework.org/schema/integration"
       xmlns="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/websocket
        http://www.springframework.org/schema/websocket/spring-websocket.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:annotation-config/>

    <websocket:message-broker application-destination-prefix="#{socketsConfig.applicationDestinationPrefix}">
        <websocket:stomp-endpoint path="#{socketsConfig.stompEndpoint}">
            <!--
                client-library-url: sockjs version must be always aligned with bower dependency;
                the path is relative to /sockjs/iframe.html, iframe URL created by sockjs
                (make sure sockjs bower dependency is still copied there, it may change over time)
            -->
            <websocket:sockjs websocket-enabled="true" client-library-url="../node_modules/@bower_components/sockjs-client/dist/sockjs.min.js"></websocket:sockjs>
        </websocket:stomp-endpoint>
        <websocket:stomp-broker-relay prefix="/topic,/queue"/>
        <websocket:client-inbound-channel>
            <websocket:interceptors>
                <bean class="com.armedia.acm.websockets.AcmWebSocketChannelInterceptor"></bean>
            </websocket:interceptors>
        </websocket:client-inbound-channel>
    </websocket:message-broker>

    <bean class="com.armedia.acm.websockets.configuration.StompBrokerRelayMessageHandlerBeanPostProcessor">
        <property name="socketConfig" ref="socketsConfig"/>
    </bean>

    <bean id="messageReceiver" class="com.armedia.acm.websockets.MessageReceiver"/>

    <bean id="objectUpdateNotifier" class="com.armedia.acm.websockets.ObjectUpdateNotifier">
        <property name="objectNotificationsConfig" ref="objectNotificationConfig"/>
    </bean>

    <int:service-activator ref="objectUpdateNotifier" input-channel="objectEventChannel" method="notifyChange"/>

    <bean id="configurationUpdateNotifier" class="com.armedia.acm.websockets.ConfigurationUpdateNotifier"/>
    <int:service-activator ref="configurationUpdateNotifier" input-channel="configurationUpdatedChannel" method="notifyChange"/>

    <bean id="simplePushNotifier" class="com.armedia.acm.websockets.SimplePushNotifier"/>
    <int:service-activator ref="simplePushNotifier" input-channel="genericMessagesChannel" method="receiveMessage"/>

    <bean id="scheduledJobsNotifier" class="com.armedia.acm.websockets.ScheduledJobsNotifier"/>
    <int:service-activator ref="scheduledJobsNotifier" input-channel="jobsStatusChannel" method="receiveMessage"/>
</beans>
