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

The following examples show how to use org.springframework.web.reactive.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: HandshakeWebSocketService.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private static RequestUpgradeStrategy initUpgradeStrategy() {
	String className;
	if (tomcatPresent) {
		className = "TomcatRequestUpgradeStrategy";
	}
	else if (jettyPresent) {
		className = "JettyRequestUpgradeStrategy";
	}
	else if (undertowPresent) {
		className = "UndertowRequestUpgradeStrategy";
	}
	else if (reactorNettyPresent) {
		// As late as possible (Reactor Netty commonly used for WebClient)
		className = "ReactorNettyRequestUpgradeStrategy";
	}
	else {
		throw new IllegalStateException("No suitable default RequestUpgradeStrategy found");
	}

	try {
		className = "org.springframework.web.reactive.socket.server.upgrade." + className;
		Class<?> clazz = ClassUtils.forName(className, HandshakeWebSocketService.class.getClassLoader());
		return (RequestUpgradeStrategy) ReflectionUtils.accessibleConstructor(clazz).newInstance();
	}
	catch (Throwable ex) {
		throw new IllegalStateException(
				"Failed to instantiate RequestUpgradeStrategy: " + className, ex);
	}
}
 
Example #2
Source File: HandshakeWebSocketService.java    From java-technology-stack with MIT License 5 votes vote down vote up
private static RequestUpgradeStrategy initUpgradeStrategy() {
	String className;
	if (tomcatPresent) {
		className = "TomcatRequestUpgradeStrategy";
	}
	else if (jettyPresent) {
		className = "JettyRequestUpgradeStrategy";
	}
	else if (undertowPresent) {
		className = "UndertowRequestUpgradeStrategy";
	}
	else if (reactorNettyPresent) {
		// As late as possible (Reactor Netty commonly used for WebClient)
		className = "ReactorNettyRequestUpgradeStrategy";
	}
	else {
		throw new IllegalStateException("No suitable default RequestUpgradeStrategy found");
	}

	try {
		className = "org.springframework.web.reactive.socket.server.upgrade." + className;
		Class<?> clazz = ClassUtils.forName(className, HandshakeWebSocketService.class.getClassLoader());
		return (RequestUpgradeStrategy) ReflectionUtils.accessibleConstructor(clazz).newInstance();
	}
	catch (Throwable ex) {
		throw new IllegalStateException(
				"Failed to instantiate RequestUpgradeStrategy: " + className, ex);
	}
}
 
Example #3
Source File: HandshakeWebSocketService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Return the {@link RequestUpgradeStrategy} for WebSocket requests.
 */
public RequestUpgradeStrategy getUpgradeStrategy() {
	return this.upgradeStrategy;
}
 
Example #4
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new ReactorNettyRequestUpgradeStrategy();
}
 
Example #5
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new TomcatRequestUpgradeStrategy();
}
 
Example #6
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new UndertowRequestUpgradeStrategy();
}
 
Example #7
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new JettyRequestUpgradeStrategy();
}
 
Example #8
Source File: HandshakeWebSocketService.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Alternative constructor with the {@link RequestUpgradeStrategy} to use.
 * @param upgradeStrategy the strategy to use
 */
public HandshakeWebSocketService(RequestUpgradeStrategy upgradeStrategy) {
	Assert.notNull(upgradeStrategy, "RequestUpgradeStrategy is required");
	this.upgradeStrategy = upgradeStrategy;
}
 
Example #9
Source File: HandshakeWebSocketService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Alternative constructor with the {@link RequestUpgradeStrategy} to use.
 * @param upgradeStrategy the strategy to use
 */
public HandshakeWebSocketService(RequestUpgradeStrategy upgradeStrategy) {
	Assert.notNull(upgradeStrategy, "RequestUpgradeStrategy is required");
	this.upgradeStrategy = upgradeStrategy;
}
 
Example #10
Source File: HandshakeWebSocketService.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Return the {@link RequestUpgradeStrategy} for WebSocket requests.
 */
public RequestUpgradeStrategy getUpgradeStrategy() {
	return this.upgradeStrategy;
}
 
Example #11
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new ReactorNettyRequestUpgradeStrategy();
}
 
Example #12
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new TomcatRequestUpgradeStrategy();
}
 
Example #13
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new UndertowRequestUpgradeStrategy();
}
 
Example #14
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new JettyRequestUpgradeStrategy();
}
 
Example #15
Source File: GatewayAutoConfiguration.java    From spring-cloud-gateway with Apache License 2.0 4 votes vote down vote up
@Bean
public WebSocketService webSocketService(
		RequestUpgradeStrategy requestUpgradeStrategy) {
	return new HandshakeWebSocketService(requestUpgradeStrategy);
}
 
Example #16
Source File: WebSocketIntegrationTests.java    From spring-cloud-gateway with Apache License 2.0 4 votes vote down vote up
protected RequestUpgradeStrategy getUpgradeStrategy() {
	return new ReactorNettyRequestUpgradeStrategy();
}
 
Example #17
Source File: AbstractWebSocketIntegrationTests.java    From spring-analysis-note with MIT License votes vote down vote up
protected abstract RequestUpgradeStrategy getUpgradeStrategy(); 
Example #18
Source File: AbstractWebSocketIntegrationTests.java    From java-technology-stack with MIT License votes vote down vote up
protected abstract RequestUpgradeStrategy getUpgradeStrategy();