当前位置: 首页>>代码示例>>Java>>正文


Java HttpSessionHandshakeInterceptor类代码示例

本文整理汇总了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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:WebSocketHandlerRegistrationTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:WebSocketHandlerRegistrationTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:WebSocketHandlerRegistrationTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:WebSocketHandlerRegistrationTests.java

示例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;
}
 
开发者ID:apostx,项目名称:broadcast_server,代码行数:11,代码来源:ServerMessageHandler.java

示例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);
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:10,代码来源:SessionCacheWebSocketHandler.java

示例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);
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:9,代码来源:SdcctWebSocketMessageBrokerConfiguration.java

示例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
}
 
开发者ID:mrstampy,项目名称:gameboot,代码行数:11,代码来源:OtpWebSocketTestConfiguration.java

示例13: registerStompEndpoints

import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; //导入依赖的package包/类
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {

    registry.addEndpoint("/portfolio")
            .addInterceptors(new HttpSessionHandshakeInterceptor())
            .withSockJS();
}
 
开发者ID:nithril,项目名称:whisper,代码行数:8,代码来源:StompWebSocketConfig.java

示例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);
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:14,代码来源:WebSocketConfig.java

示例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();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:7,代码来源:CasReportsConfiguration.java


注:本文中的org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。