本文整理汇总了Java中org.springframework.web.socket.sockjs.SockJsService类的典型用法代码示例。如果您正苦于以下问题:Java SockJsService类的具体用法?Java SockJsService怎么用?Java SockJsService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SockJsService类属于org.springframework.web.socket.sockjs包,在下文中一共展示了SockJsService类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SockJsHttpRequestHandler
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
/**
* Create a new SockJsHttpRequestHandler.
* @param sockJsService the SockJS service
* @param webSocketHandler the websocket handler
*/
public SockJsHttpRequestHandler(SockJsService sockJsService, WebSocketHandler webSocketHandler) {
Assert.notNull(sockJsService, "SockJsService must not be null");
Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
this.sockJsService = sockJsService;
this.webSocketHandler =
new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(webSocketHandler));
}
示例2: addSockJsServiceMapping
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
@Override
protected void addSockJsServiceMapping(MultiValueMap<HttpRequestHandler, String> mappings,
SockJsService sockJsService, WebSocketHandler handler, String pathPattern) {
SockJsHttpRequestHandler httpHandler = new SockJsHttpRequestHandler(sockJsService, handler);
mappings.add(httpHandler, pathPattern);
}
示例3: getSockJsService
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
protected SockJsService getSockJsService() {
TransportHandlingSockJsService service = createSockJsService();
service.setHandshakeInterceptors(this.interceptors);
if (this.clientLibraryUrl != null) {
service.setSockJsClientLibraryUrl(this.clientLibraryUrl);
}
if (this.streamBytesLimit != null) {
service.setStreamBytesLimit(this.streamBytesLimit);
}
if (this.sessionCookieNeeded != null) {
service.setSessionCookieNeeded(this.sessionCookieNeeded);
}
if (this.heartbeatTime != null) {
service.setHeartbeatTime(this.heartbeatTime);
}
if (this.disconnectDelay != null) {
service.setDisconnectDelay(this.disconnectDelay);
}
if (this.httpMessageCacheSize != null) {
service.setHttpMessageCacheSize(this.httpMessageCacheSize);
}
if (this.webSocketEnabled != null) {
service.setWebSocketEnabled(this.webSocketEnabled);
}
if (this.allowedOrigins != null) {
service.setAllowedOrigins(this.allowedOrigins);
}
if (this.suppressCors != null) {
service.setSuppressCors(this.suppressCors);
}
if (this.messageCodec != null) {
service.setMessageCodec(this.messageCodec);
}
return service;
}
示例4: Mapping
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
public Mapping(WebSocketHandler handler, String path, SockJsService sockJsService) {
this.webSocketHandler = handler;
this.path = path;
this.handshakeHandler = null;
this.interceptors = null;
this.sockJsService = (DefaultSockJsService) sockJsService;
}
示例5: sockJsAttributes
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void sockJsAttributes() {
loadBeanDefinitions("websocket-config-handlers-sockjs-attributes.xml");
SimpleUrlHandlerMapping handlerMapping = appContext.getBean(SimpleUrlHandlerMapping.class);
assertNotNull(handlerMapping);
SockJsHttpRequestHandler handler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**");
assertNotNull(handler);
unwrapAndCheckDecoratedHandlerType(handler.getWebSocketHandler(), TestWebSocketHandler.class);
SockJsService sockJsService = handler.getSockJsService();
assertNotNull(sockJsService);
assertThat(sockJsService, instanceOf(TransportHandlingSockJsService.class));
TransportHandlingSockJsService transportService = (TransportHandlingSockJsService) sockJsService;
assertThat(transportService.getTaskScheduler(), instanceOf(TestTaskScheduler.class));
assertThat(transportService.getTransportHandlers().values(),
containsInAnyOrder(
instanceOf(XhrPollingTransportHandler.class),
instanceOf(XhrStreamingTransportHandler.class)));
assertEquals("testSockJsService", transportService.getName());
assertFalse(transportService.isWebSocketEnabled());
assertFalse(transportService.isSessionCookieNeeded());
assertEquals(2048, transportService.getStreamBytesLimit());
assertEquals(256, transportService.getDisconnectDelay());
assertEquals(1024, transportService.getHttpMessageCacheSize());
assertEquals(20, transportService.getHeartbeatTime());
assertEquals("/js/sockjs.min.js", transportService.getSockJsClientLibraryUrl());
assertEquals(TestMessageCodec.class, transportService.getMessageCodec().getClass());
List<HandshakeInterceptor> interceptors = transportService.getHandshakeInterceptors();
assertThat(interceptors, contains(instanceOf(OriginHandshakeInterceptor.class)));
assertTrue(transportService.shouldSuppressCors());
assertTrue(transportService.getAllowedOrigins().contains("http://mydomain1.com"));
assertTrue(transportService.getAllowedOrigins().contains("http://mydomain2.com"));
}
示例6: handlerMapping
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
@Bean
public SimpleUrlHandlerMapping handlerMapping() {
SockJsService sockJsService = new DefaultSockJsService(taskScheduler());
Map<String, Object> urlMap = new HashMap<String, Object>();
urlMap.put("/game/websocket/**", new SockJsHttpRequestHandler(sockJsService, gameHandler));
SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
hm.setUrlMap(urlMap);
return hm;
}
示例7: getSockJsService
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
/**
* Return the {@link SockJsService}.
*/
public SockJsService getSockJsService() {
return this.sockJsService;
}
示例8: getSockJsService
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
protected SockJsService getSockJsService() {
return super.getSockJsService();
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:4,代码来源:WebMvcStompWebSocketEndpointRegistration.java
示例9: addSockJsServiceMapping
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
protected abstract void addSockJsServiceMapping(M mappings, SockJsService sockJsService,
WebSocketHandler handler, String pathPattern);
示例10: addSockJsServiceMapping
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
@Override
protected void addSockJsServiceMapping(List<Mapping> mappings, SockJsService sockJsService,
WebSocketHandler wsHandler, String pathPattern) {
mappings.add(new Mapping(wsHandler, pathPattern, sockJsService));
}
示例11: sockJs
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void sockJs() {
loadBeanDefinitions("websocket-config-handlers-sockjs.xml");
SimpleUrlHandlerMapping handlerMapping = this.appContext.getBean(SimpleUrlHandlerMapping.class);
assertNotNull(handlerMapping);
SockJsHttpRequestHandler testHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/test/**");
assertNotNull(testHandler);
unwrapAndCheckDecoratedHandlerType(testHandler.getWebSocketHandler(), TestWebSocketHandler.class);
SockJsService testSockJsService = testHandler.getSockJsService();
SockJsHttpRequestHandler fooHandler = (SockJsHttpRequestHandler) handlerMapping.getUrlMap().get("/foo/**");
assertNotNull(fooHandler);
unwrapAndCheckDecoratedHandlerType(fooHandler.getWebSocketHandler(), FooWebSocketHandler.class);
SockJsService sockJsService = fooHandler.getSockJsService();
assertNotNull(sockJsService);
assertSame(testSockJsService, sockJsService);
assertThat(sockJsService, instanceOf(DefaultSockJsService.class));
DefaultSockJsService defaultSockJsService = (DefaultSockJsService) sockJsService;
assertThat(defaultSockJsService.getTaskScheduler(), instanceOf(ThreadPoolTaskScheduler.class));
assertFalse(defaultSockJsService.shouldSuppressCors());
Map<TransportType, TransportHandler> transportHandlers = defaultSockJsService.getTransportHandlers();
assertThat(transportHandlers.values(),
containsInAnyOrder(
instanceOf(XhrPollingTransportHandler.class),
instanceOf(XhrReceivingTransportHandler.class),
instanceOf(JsonpPollingTransportHandler.class),
instanceOf(JsonpReceivingTransportHandler.class),
instanceOf(XhrStreamingTransportHandler.class),
instanceOf(EventSourceTransportHandler.class),
instanceOf(HtmlFileTransportHandler.class),
instanceOf(WebSocketTransportHandler.class)));
WebSocketTransportHandler handler = (WebSocketTransportHandler) transportHandlers.get(TransportType.WEBSOCKET);
assertEquals(TestHandshakeHandler.class, handler.getHandshakeHandler().getClass());
List<HandshakeInterceptor> interceptors = defaultSockJsService.getHandshakeInterceptors();
assertThat(interceptors, contains(instanceOf(FooTestInterceptor.class), instanceOf(BarTestInterceptor.class), instanceOf(OriginHandshakeInterceptor.class)));
}
示例12: getSockJsService
import org.springframework.web.socket.sockjs.SockJsService; //导入依赖的package包/类
@Override
protected SockJsService getSockJsService() {
return super.getSockJsService();
}