本文整理汇总了Java中org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor类的典型用法代码示例。如果您正苦于以下问题:Java HttpSessionHandshakeInterceptor类的具体用法?Java HttpSessionHandshakeInterceptor怎么用?Java HttpSessionHandshakeInterceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpSessionHandshakeInterceptor类属于org.springframework.web.socket.server.support包,在下文中一共展示了HttpSessionHandshakeInterceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: interceptors
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void interceptors() {
WebSocketHandler handler = new TextWebSocketHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
this.registration.addHandler(handler, "/foo").addInterceptors(interceptor);
List<Mapping> mappings = this.registration.getMappings();
assertEquals(1, mappings.size());
Mapping mapping = mappings.get(0);
assertEquals(handler, mapping.webSocketHandler);
assertEquals("/foo", mapping.path);
assertEquals(2, mapping.interceptors.length);
assertEquals(interceptor, mapping.interceptors[0]);
assertEquals(OriginHandshakeInterceptor.class, mapping.interceptors[1].getClass());
}
示例2: emptyAllowedOrigin
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void emptyAllowedOrigin() {
WebSocketHandler handler = new TextWebSocketHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
this.registration.addHandler(handler, "/foo").addInterceptors(interceptor).setAllowedOrigins();
List<Mapping> mappings = this.registration.getMappings();
assertEquals(1, mappings.size());
Mapping mapping = mappings.get(0);
assertEquals(handler, mapping.webSocketHandler);
assertEquals("/foo", mapping.path);
assertEquals(2, mapping.interceptors.length);
assertEquals(interceptor, mapping.interceptors[0]);
assertEquals(OriginHandshakeInterceptor.class, mapping.interceptors[1].getClass());
}
示例3: interceptorsWithAllowedOrigins
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void interceptorsWithAllowedOrigins() {
WebSocketHandler handler = new TextWebSocketHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
this.registration.addHandler(handler, "/foo").addInterceptors(interceptor).setAllowedOrigins("http://mydomain1.com");
List<Mapping> mappings = this.registration.getMappings();
assertEquals(1, mappings.size());
Mapping mapping = mappings.get(0);
assertEquals(handler, mapping.webSocketHandler);
assertEquals("/foo", mapping.path);
assertEquals(2, mapping.interceptors.length);
assertEquals(interceptor, mapping.interceptors[0]);
assertEquals(OriginHandshakeInterceptor.class, mapping.interceptors[1].getClass());
}
示例4: interceptorsPassedToSockJsRegistration
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void interceptorsPassedToSockJsRegistration() {
WebSocketHandler handler = new TextWebSocketHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
this.registration.addHandler(handler, "/foo").addInterceptors(interceptor)
.setAllowedOrigins("http://mydomain1.com").withSockJS();
List<Mapping> mappings = this.registration.getMappings();
assertEquals(1, mappings.size());
Mapping mapping = mappings.get(0);
assertEquals(handler, mapping.webSocketHandler);
assertEquals("/foo/**", mapping.path);
assertNotNull(mapping.sockJsService);
assertTrue(mapping.sockJsService.getAllowedOrigins().contains("http://mydomain1.com"));
List<HandshakeInterceptor> interceptors = mapping.sockJsService.getHandshakeInterceptors();
assertEquals(interceptor, interceptors.get(0));
assertEquals(OriginHandshakeInterceptor.class, interceptors.get(1).getClass());
}
示例5: handshakeHandlerAndInterceptor
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void handshakeHandlerAndInterceptor() {
WebMvcStompWebSocketEndpointRegistration registration =
new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);
DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor);
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
assertEquals(1, mappings.size());
Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
assertEquals(Arrays.asList("/foo"), entry.getValue());
WebSocketHttpRequestHandler requestHandler = (WebSocketHttpRequestHandler) entry.getKey();
assertNotNull(requestHandler.getWebSocketHandler());
assertSame(handshakeHandler, requestHandler.getHandshakeHandler());
assertEquals(2, requestHandler.getHandshakeInterceptors().size());
assertEquals(interceptor, requestHandler.getHandshakeInterceptors().get(0));
assertEquals(OriginHandshakeInterceptor.class, requestHandler.getHandshakeInterceptors().get(1).getClass());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java
示例6: handshakeHandlerAndInterceptorWithAllowedOrigins
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void handshakeHandlerAndInterceptorWithAllowedOrigins() {
WebMvcStompWebSocketEndpointRegistration registration =
new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);
DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
String origin = "http://mydomain.com";
registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).setAllowedOrigins(origin);
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
assertEquals(1, mappings.size());
Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
assertEquals(Arrays.asList("/foo"), entry.getValue());
WebSocketHttpRequestHandler requestHandler = (WebSocketHttpRequestHandler) entry.getKey();
assertNotNull(requestHandler.getWebSocketHandler());
assertSame(handshakeHandler, requestHandler.getHandshakeHandler());
assertEquals(2, requestHandler.getHandshakeInterceptors().size());
assertEquals(interceptor, requestHandler.getHandshakeInterceptors().get(0));
assertEquals(OriginHandshakeInterceptor.class, requestHandler.getHandshakeInterceptors().get(1).getClass());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java
示例7: getHttpSessionId
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
private String getHttpSessionId(WebSocketSession session) {
String httpSessionIdKey = HttpSessionHandshakeInterceptor.HTTP_SESSION_ID_ATTR_NAME;
String sessionId = "Undefined";
try {
sessionId = session.getAttributes().get(httpSessionIdKey).toString();
} catch (Exception e) {}
return sessionId;
}
示例8: handshakeHandlerInterceptorWithSockJsService
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void handshakeHandlerInterceptorWithSockJsService() {
WebMvcStompWebSocketEndpointRegistration registration =
new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);
DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).withSockJS();
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
assertEquals(1, mappings.size());
Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
assertEquals(Arrays.asList("/foo/**"), entry.getValue());
SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey();
assertNotNull(requestHandler.getWebSocketHandler());
DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService();
assertNotNull(sockJsService);
Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers();
WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET);
assertSame(handshakeHandler, transportHandler.getHandshakeHandler());
assertEquals(2, sockJsService.getHandshakeInterceptors().size());
assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0));
assertEquals(OriginHandshakeInterceptor.class, sockJsService.getHandshakeInterceptors().get(1).getClass());
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java
示例9: handshakeHandlerInterceptorWithSockJsServiceAndAllowedOrigins
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Test
public void handshakeHandlerInterceptorWithSockJsServiceAndAllowedOrigins() {
WebMvcStompWebSocketEndpointRegistration registration =
new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);
DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
String origin = "http://mydomain.com";
registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).setAllowedOrigins(origin).withSockJS();
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
assertEquals(1, mappings.size());
Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
assertEquals(Arrays.asList("/foo/**"), entry.getValue());
SockJsHttpRequestHandler requestHandler = (SockJsHttpRequestHandler) entry.getKey();
assertNotNull(requestHandler.getWebSocketHandler());
DefaultSockJsService sockJsService = (DefaultSockJsService) requestHandler.getSockJsService();
assertNotNull(sockJsService);
Map<TransportType, TransportHandler> handlers = sockJsService.getTransportHandlers();
WebSocketTransportHandler transportHandler = (WebSocketTransportHandler) handlers.get(TransportType.WEBSOCKET);
assertSame(handshakeHandler, transportHandler.getHandshakeHandler());
assertEquals(2, sockJsService.getHandshakeInterceptors().size());
assertEquals(interceptor, sockJsService.getHandshakeInterceptors().get(0));
assertEquals(OriginHandshakeInterceptor.class,
sockJsService.getHandshakeInterceptors().get(1).getClass());
assertTrue(sockJsService.getAllowedOrigins().contains(origin));
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:33,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java
示例10: afterConnectionEstablished
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Override
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
log.debug("after WebSocket connection established, http session id => {}, spaceKey => {}",
session.getAttributes().get(HttpSessionHandshakeInterceptor.HTTP_SESSION_ID_ATTR_NAME),
session.getAttributes().get("spaceKey"));
webSocketSessionStore.addSession(session.getId(), session);
super.afterConnectionEstablished(session);
}
示例11: registerStompEndpoints
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Override
protected void registerStompEndpoints(StompEndpointRegistry stompEndpointRegistry) {
stompEndpointRegistry.addEndpoint(SdcctWebSocketPaths.TESTCASES_IHE_RESULTS)
.setHandshakeHandler(new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy())).addInterceptors(new HttpSessionHandshakeInterceptor())
.withSockJS().setClientLibraryUrl(this.sockJsClientLibUrl).setDisconnectDelay(this.sockJsDisconnectDelay).setHeartbeatTime(this.sockJsHeartbeatTime)
.setHttpMessageCacheSize(this.sockJsHttpMsgCacheSize).setMessageCodec(new Jackson2SockJsMessageCodec(this.objMapper))
.setStreamBytesLimit(this.sockJsStreamLimit);
}
示例12: registerWebSocketHandlers
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
//@formatter:off
registry
.addHandler(clearHandler, clrPath)
.addHandler(encHandler, encPath)
.addInterceptors(new HttpSessionHandshakeInterceptor())
.setHandshakeHandler(createHandshakeHandler());
//@formatter:on
}
示例13: registerStompEndpoints
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/portfolio")
.addInterceptors(new HttpSessionHandshakeInterceptor())
.withSockJS();
}
示例14: registerWebSocketHandlers
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
final String[] allowedOriginArray = getAllowedOriginArray(configProperties.getWebSocketAllowedOrigins());
for (PinpointWebSocketHandler handler : handlerRepository.getWebSocketHandlerRepository()) {
String path = handler.getRequestMapping() + WEBSOCKET_SUFFIX;
final WebSocketHandlerRegistration webSocketHandlerRegistration = registry.addHandler(handler, path);
webSocketHandlerRegistration.addInterceptors(new HttpSessionHandshakeInterceptor());
webSocketHandlerRegistration.addInterceptors(new WebSocketSessionContextPrepareHandshakeInterceptor());
webSocketHandlerRegistration.setAllowedOrigins(allowedOriginArray);
}
}
示例15: registerStompEndpoints
import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Override
public void registerStompEndpoints(final StompEndpointRegistry registry) {
registry.addEndpoint("/logoutput")
.addInterceptors(new HttpSessionHandshakeInterceptor())
.withSockJS();
}