org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler Java Examples

The following examples show how to use org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler. 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: GlassFishRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
		UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {

	TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
	Writer servletWriter = newServletWriter(handler);
	handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);

	response.setStatus(upgradeResponse.getStatus());
	upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
	response.flushBuffer();
}
 
Example #2
Source File: GlassFishRequestUpgradeStrategy.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private Writer newServletWriter(TyrusHttpUpgradeHandler handler) {
	try {
		return (Writer) constructor.newInstance(handler);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate TyrusServletWriter", ex);
	}
}
 
Example #3
Source File: GlassFishRequestUpgradeStrategy.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
		UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {

	TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
	Writer servletWriter = newServletWriter(handler);
	handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);

	response.setStatus(upgradeResponse.getStatus());
	upgradeResponse.getHeaders().forEach((key, value) -> response.addHeader(key, Utils.getHeaderFromList(value)));
	response.flushBuffer();
}
 
Example #4
Source File: GlassFishRequestUpgradeStrategy.java    From java-technology-stack with MIT License 5 votes vote down vote up
private Writer newServletWriter(TyrusHttpUpgradeHandler handler) {
	try {
		return (Writer) constructor.newInstance(handler);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate TyrusServletWriter", ex);
	}
}
 
Example #5
Source File: GlassFishRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void handleSuccess(HttpServletRequest request, HttpServletResponse response,
		UpgradeInfo upgradeInfo, TyrusUpgradeResponse upgradeResponse) throws IOException, ServletException {

	TyrusHttpUpgradeHandler handler = request.upgrade(TyrusHttpUpgradeHandler.class);
	Writer servletWriter = servletWriterHelper.newInstance(handler);
	handler.preInit(upgradeInfo, servletWriter, request.getUserPrincipal() != null);

	response.setStatus(upgradeResponse.getStatus());
	for (Map.Entry<String, List<String>> entry : upgradeResponse.getHeaders().entrySet()) {
		response.addHeader(entry.getKey(), Utils.getHeaderFromList(entry.getValue()));
	}
	response.flushBuffer();
}
 
Example #6
Source File: GlassFishRequestUpgradeStrategy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private Writer newInstance(TyrusHttpUpgradeHandler handler) {
	try {
		return (Writer) constructor.newInstance(handler);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate TyrusServletWriter", ex);
	}
}