org.springframework.web.socket.server.RequestUpgradeStrategy Java Examples

The following examples show how to use org.springframework.web.socket.server.RequestUpgradeStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultHandshakeHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setServletContext(ServletContext servletContext) {
	RequestUpgradeStrategy strategy = getRequestUpgradeStrategy();
	if (strategy instanceof ServletContextAware) {
		((ServletContextAware) strategy).setServletContext(servletContext);
	}
}
 
Example #2
Source File: WebSocketStompClientIntegrationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void registerStompEndpoints(StompEndpointRegistry registry) {
	// Can't rely on classpath detection
	RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
	registry.addEndpoint("/stomp")
			.setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
			.setAllowedOrigins("*");
}
 
Example #3
Source File: AbstractHandshakeHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private static RequestUpgradeStrategy initRequestUpgradeStrategy() {
	String className;
	if (tomcatWsPresent) {
		className = "org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy";
	}
	else if (jettyWsPresent) {
		className = "org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy";
	}
	else if (undertowWsPresent) {
		className = "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy";
	}
	else if (glassfishWsPresent) {
		className = "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy";
	}
	else if (weblogicWsPresent) {
		className = "org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy";
	}
	else if (websphereWsPresent) {
		className = "org.springframework.web.socket.server.standard.WebSphereRequestUpgradeStrategy";
	}
	else {
		throw new IllegalStateException("No suitable default RequestUpgradeStrategy found");
	}

	try {
		Class<?> clazz = ClassUtils.forName(className, classLoader);
		return (RequestUpgradeStrategy) clazz.newInstance();
	}
	catch (Throwable ex) {
		throw new IllegalStateException(
				"Failed to instantiate RequestUpgradeStrategy: " + className, ex);
	}
}
 
Example #4
Source File: DefaultHandshakeHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void setServletContext(ServletContext servletContext) {
	RequestUpgradeStrategy strategy = getRequestUpgradeStrategy();
	if (strategy instanceof ServletContextAware) {
		((ServletContextAware) strategy).setServletContext(servletContext);
	}
}
 
Example #5
Source File: WebSocketStompClientIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void registerStompEndpoints(StompEndpointRegistry registry) {
	// Can't rely on classpath detection
	RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
	registry.addEndpoint("/stomp")
			.setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
			.setAllowedOrigins("*");
}
 
Example #6
Source File: AbstractHandshakeHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
private static RequestUpgradeStrategy initRequestUpgradeStrategy() {
	String className;
	if (tomcatWsPresent) {
		className = "org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy";
	}
	else if (jettyWsPresent) {
		className = "org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy";
	}
	else if (undertowWsPresent) {
		className = "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy";
	}
	else if (glassfishWsPresent) {
		className = "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy";
	}
	else if (weblogicWsPresent) {
		className = "org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy";
	}
	else if (websphereWsPresent) {
		className = "org.springframework.web.socket.server.standard.WebSphereRequestUpgradeStrategy";
	}
	else {
		throw new IllegalStateException("No suitable default RequestUpgradeStrategy found");
	}

	try {
		Class<?> clazz = ClassUtils.forName(className, AbstractHandshakeHandler.class.getClassLoader());
		return (RequestUpgradeStrategy) ReflectionUtils.accessibleConstructor(clazz).newInstance();
	}
	catch (Throwable ex) {
		throw new IllegalStateException(
				"Failed to instantiate RequestUpgradeStrategy: " + className, ex);
	}
}
 
Example #7
Source File: DefaultHandshakeHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setServletContext(ServletContext servletContext) {
	RequestUpgradeStrategy strategy = getRequestUpgradeStrategy();
	if (strategy instanceof ServletContextAware) {
		((ServletContextAware) strategy).setServletContext(servletContext);
	}
}
 
Example #8
Source File: WebSocketStompClientIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void registerStompEndpoints(StompEndpointRegistry registry) {
	// Can't rely on classpath detection
	RequestUpgradeStrategy upgradeStrategy = new TomcatRequestUpgradeStrategy();
	registry.addEndpoint("/stomp")
			.setHandshakeHandler(new DefaultHandshakeHandler(upgradeStrategy))
			.setAllowedOrigins("*");
}
 
Example #9
Source File: AbstractHandshakeHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private static RequestUpgradeStrategy initRequestUpgradeStrategy() {
	String className;
	if (tomcatWsPresent) {
		className = "org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy";
	}
	else if (jettyWsPresent) {
		className = "org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy";
	}
	else if (undertowWsPresent) {
		className = "org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy";
	}
	else if (glassfishWsPresent) {
		className = "org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy";
	}
	else if (weblogicWsPresent) {
		className = "org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy";
	}
	else if (websphereWsPresent) {
		className = "org.springframework.web.socket.server.standard.WebSphereRequestUpgradeStrategy";
	}
	else {
		throw new IllegalStateException("No suitable default RequestUpgradeStrategy found");
	}

	try {
		Class<?> clazz = ClassUtils.forName(className, AbstractHandshakeHandler.class.getClassLoader());
		return (RequestUpgradeStrategy) ReflectionUtils.accessibleConstructor(clazz).newInstance();
	}
	catch (Throwable ex) {
		throw new IllegalStateException(
				"Failed to instantiate RequestUpgradeStrategy: " + className, ex);
	}
}
 
Example #10
Source File: UndertowSockJsIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy upgradeStrategy() {
	return new UndertowRequestUpgradeStrategy();
}
 
Example #11
Source File: DefaultHandshakeHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
public DefaultHandshakeHandler(RequestUpgradeStrategy requestUpgradeStrategy) {
	super(requestUpgradeStrategy);
}
 
Example #12
Source File: UndertowSockJsIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy upgradeStrategy() {
	return new UndertowRequestUpgradeStrategy();
}
 
Example #13
Source File: JettySockJsIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy upgradeStrategy() {
	return new JettyRequestUpgradeStrategy();
}
 
Example #14
Source File: AbstractWebSocketIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new UndertowRequestUpgradeStrategy();
}
 
Example #15
Source File: AbstractWebSocketIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new TomcatRequestUpgradeStrategy();
}
 
Example #16
Source File: AbstractWebSocketIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new JettyRequestUpgradeStrategy();
}
 
Example #17
Source File: AbstractHandshakeHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Return the {@link RequestUpgradeStrategy} for WebSocket requests.
 */
public RequestUpgradeStrategy getRequestUpgradeStrategy() {
	return this.requestUpgradeStrategy;
}
 
Example #18
Source File: AbstractHandshakeHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * A constructor that accepts a runtime-specific {@link RequestUpgradeStrategy}.
 * @param requestUpgradeStrategy the upgrade strategy to use
 */
protected AbstractHandshakeHandler(RequestUpgradeStrategy requestUpgradeStrategy) {
	Assert.notNull(requestUpgradeStrategy, "RequestUpgradeStrategy must not be null");
	this.requestUpgradeStrategy = requestUpgradeStrategy;
}
 
Example #19
Source File: AbstractHandshakeHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * A constructor that accepts a runtime-specific {@link RequestUpgradeStrategy}.
 * @param requestUpgradeStrategy the upgrade strategy to use
 */
protected AbstractHandshakeHandler(RequestUpgradeStrategy requestUpgradeStrategy) {
	Assert.notNull(requestUpgradeStrategy, "RequestUpgradeStrategy must not be null");
	this.requestUpgradeStrategy = requestUpgradeStrategy;
}
 
Example #20
Source File: DefaultHandshakeHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
public DefaultHandshakeHandler(RequestUpgradeStrategy requestUpgradeStrategy) {
	super(requestUpgradeStrategy);
}
 
Example #21
Source File: WebsocketConfig.java    From spring-boot-protocol with Apache License 2.0 4 votes vote down vote up
/**
     * 容器策略, 这里选用netty
     * @return 容器策略
     */
    public RequestUpgradeStrategy requestUpgradeStrategy() {
//        return new JettyRequestUpgradeStrategy();
//        return new TomcatRequestUpgradeStrategy();
        return new NettyRequestUpgradeStrategy();
    }
 
Example #22
Source File: AbstractHandshakeHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Return the {@link RequestUpgradeStrategy} for WebSocket requests.
 */
public RequestUpgradeStrategy getRequestUpgradeStrategy() {
	return this.requestUpgradeStrategy;
}
 
Example #23
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new UndertowRequestUpgradeStrategy();
}
 
Example #24
Source File: JettySockJsIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy upgradeStrategy() {
	return new JettyRequestUpgradeStrategy();
}
 
Example #25
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new UndertowRequestUpgradeStrategy();
}
 
Example #26
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new TomcatRequestUpgradeStrategy();
}
 
Example #27
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new JettyRequestUpgradeStrategy();
}
 
Example #28
Source File: AbstractHandshakeHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Return the {@link RequestUpgradeStrategy} for WebSocket requests.
 */
public RequestUpgradeStrategy getRequestUpgradeStrategy() {
	return this.requestUpgradeStrategy;
}
 
Example #29
Source File: AbstractHandshakeHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * A constructor that accepts a runtime-specific {@link RequestUpgradeStrategy}.
 * @param requestUpgradeStrategy the upgrade strategy to use
 */
protected AbstractHandshakeHandler(RequestUpgradeStrategy requestUpgradeStrategy) {
	Assert.notNull(requestUpgradeStrategy, "RequestUpgradeStrategy must not be null");
	this.requestUpgradeStrategy = requestUpgradeStrategy;
}
 
Example #30
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Bean
public RequestUpgradeStrategy requestUpgradeStrategy() {
	return new JettyRequestUpgradeStrategy();
}