Example usage for org.springframework.web.socket.sockjs.transport TransportHandler initialize

List of usage examples for org.springframework.web.socket.sockjs.transport TransportHandler initialize

Introduction

In this page you can find the example usage for org.springframework.web.socket.sockjs.transport TransportHandler initialize.

Prototype

void initialize(SockJsServiceConfig serviceConfig);

Source Link

Document

Initialize this handler with the given configuration.

Usage

From source file:org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.java

/**
 * Create a TransportHandlingSockJsService with given {@link TransportHandler handler} types.
 * @param scheduler a task scheduler for heart-beat messages and removing timed-out sessions;
 * the provided TaskScheduler should be declared as a Spring bean to ensure it gets
 * initialized at start-up and shuts down when the application stops
 * @param handlers one or more {@link TransportHandler} implementations to use
 *///from   w  w  w  .ja  v  a  2s.c  o m
public TransportHandlingSockJsService(TaskScheduler scheduler, Collection<TransportHandler> handlers) {
    super(scheduler);

    if (CollectionUtils.isEmpty(handlers)) {
        logger.warn("No transport handlers specified for TransportHandlingSockJsService");
    } else {
        for (TransportHandler handler : handlers) {
            handler.initialize(this);
            this.handlers.put(handler.getTransportType(), handler);
        }
    }

    if (jackson2Present) {
        this.messageCodec = new Jackson2SockJsMessageCodec();
    }
}