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


Java Extension类代码示例

本文整理汇总了Java中javax.websocket.Extension的典型用法代码示例。如果您正苦于以下问题:Java Extension类的具体用法?Java Extension怎么用?Java Extension使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Extension类属于javax.websocket包,在下文中一共展示了Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateExtensionHeaders

import javax.websocket.Extension; //导入依赖的package包/类
private static List<String> generateExtensionHeaders(List<Extension> extensions) {
    List<String> result = new ArrayList<String>(extensions.size());
    for (Extension extension : extensions) {
        StringBuilder header = new StringBuilder();
        header.append(extension.getName());
        for (Extension.Parameter param : extension.getParameters()) {
            header.append(';');
            header.append(param.getName());
            String value = param.getValue();
            if (value != null && value.length() > 0) {
                header.append('=');
                header.append(value);
            }
        }
        result.add(header.toString());
    }
    return result;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:WsWebSocketContainer.java

示例2: getExtensionResponse

import javax.websocket.Extension; //导入依赖的package包/类
@Override
public Extension getExtensionResponse() {
    Extension result = new WsExtension(NAME);

    List<Extension.Parameter> params = result.getParameters();

    if (!serverContextTakeover) {
        params.add(new WsExtensionParameter(SERVER_NO_CONTEXT_TAKEOVER, null));
    }
    if (serverMaxWindowBits != -1) {
        params.add(new WsExtensionParameter(SERVER_MAX_WINDOW_BITS,
                Integer.toString(serverMaxWindowBits)));
    }
    if (!clientContextTakeover) {
        params.add(new WsExtensionParameter(CLIENT_NO_CONTEXT_TAKEOVER, null));
    }
    if (clientMaxWindowBits != -1) {
        params.add(new WsExtensionParameter(CLIENT_MAX_WINDOW_BITS,
                Integer.toString(clientMaxWindowBits)));
    }

    return result;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:PerMessageDeflate.java

示例3: append

import javax.websocket.Extension; //导入依赖的package包/类
private static void append(StringBuilder sb, Extension extension) {
    if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
        return;
    }

    sb.append(extension.getName());

    for (Extension.Parameter p : extension.getParameters()) {
        sb.append(';');
        sb.append(p.getName());
        if (p.getValue() != null) {
            sb.append('=');
            sb.append(p.getValue());
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:UpgradeUtil.java

示例4: doTestParseExtensionHeaderSimple

import javax.websocket.Extension; //导入依赖的package包/类
private void doTestParseExtensionHeaderSimple(String header) {
    // Simple test
    List<Extension> result = new ArrayList<Extension>();
    Util.parseExtensionHeader(result, header);

    Assert.assertEquals(1, result.size());

    Extension ext = result.get(0);
    Assert.assertEquals("ext", ext.getName());
    List<Parameter> params = ext.getParameters();
    Assert.assertEquals(2, params.size());
    Parameter paramA = params.get(0);
    Assert.assertEquals("a", paramA.getName());
    Assert.assertEquals("1", paramA.getValue());
    Parameter paramB = params.get(1);
    Assert.assertEquals("b", paramB.getName());
    Assert.assertEquals("2", paramB.getValue());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:TestUtil.java

示例5: DefaultServerEndpointConfig

import javax.websocket.Extension; //导入依赖的package包/类
DefaultServerEndpointConfig(Class<?> endpointClass,
                                String path,
                                List<String> subprotocols,
                                List<Extension> extensions,
                                List<Class<? extends Encoder>> encoders,
                                List<Class<? extends Decoder>> decoders,
                                ServerEndpointConfig.Configurator serverEndpointConfigurator) {
    this.path = path;
    this.endpointClass = endpointClass;
    this.subprotocols = Collections.unmodifiableList(subprotocols);
    this.extensions = Collections.unmodifiableList(extensions);
    this.encoders = Collections.unmodifiableList(encoders);
    this.decoders = Collections.unmodifiableList(decoders);
    if (serverEndpointConfigurator == null) {
        this.serverEndpointConfigurator = ServerEndpointConfig.Configurator.fetchContainerDefaultConfigurator();
    } else{  
        this.serverEndpointConfigurator = serverEndpointConfigurator;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:DefaultServerEndpointConfig.java

示例6: generateExtensionHeaders

import javax.websocket.Extension; //导入依赖的package包/类
private static List<String> generateExtensionHeaders(List<Extension> extensions) {
	List<String> result = new ArrayList<String>(extensions.size());
	for (Extension extension : extensions) {
		StringBuilder header = new StringBuilder();
		header.append(extension.getName());
		for (Extension.Parameter param : extension.getParameters()) {
			header.append(';');
			header.append(param.getName());
			String value = param.getValue();
			if (value != null && value.length() > 0) {
				header.append('=');
				header.append(value);
			}
		}
		result.add(header.toString());
	}
	return result;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:19,代码来源:WsWebSocketContainer.java

示例7: getExtensionResponse

import javax.websocket.Extension; //导入依赖的package包/类
@Override
public Extension getExtensionResponse() {
	Extension result = new WsExtension(NAME);

	List<Extension.Parameter> params = result.getParameters();

	if (!serverContextTakeover) {
		params.add(new WsExtensionParameter(SERVER_NO_CONTEXT_TAKEOVER, null));
	}
	if (serverMaxWindowBits != -1) {
		params.add(new WsExtensionParameter(SERVER_MAX_WINDOW_BITS, Integer.toString(serverMaxWindowBits)));
	}
	if (!clientContextTakeover) {
		params.add(new WsExtensionParameter(CLIENT_NO_CONTEXT_TAKEOVER, null));
	}
	if (clientMaxWindowBits != -1) {
		params.add(new WsExtensionParameter(CLIENT_MAX_WINDOW_BITS, Integer.toString(clientMaxWindowBits)));
	}

	return result;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:22,代码来源:PerMessageDeflate.java

示例8: append

import javax.websocket.Extension; //导入依赖的package包/类
private static void append(StringBuilder sb, Extension extension) {
	if (extension == null || extension.getName() == null || extension.getName().length() == 0) {
		return;
	}

	sb.append(extension.getName());

	for (Extension.Parameter p : extension.getParameters()) {
		sb.append(';');
		sb.append(p.getName());
		if (p.getValue() != null) {
			sb.append('=');
			sb.append(p.getValue());
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:UpgradeUtil.java

示例9: initializeNativeSession

import javax.websocket.Extension; //导入依赖的package包/类
@Override
public void initializeNativeSession(Session session) {
	super.initializeNativeSession(session);

	this.id = session.getId();
	this.uri = session.getRequestURI();

	this.acceptedProtocol = session.getNegotiatedSubprotocol();

	List<Extension> source = getNativeSession().getNegotiatedExtensions();
	this.extensions = new ArrayList<WebSocketExtension>(source.size());
	for (Extension ext : source) {
		this.extensions.add(new StandardToWebSocketExtensionAdapter(ext));
	}

	if (this.user == null) {
		this.user = session.getUserPrincipal();
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:StandardWebSocketSession.java

示例10: upgrade

import javax.websocket.Extension; //导入依赖的package包/类
@Override
public void upgrade(ServerHttpRequest request, ServerHttpResponse response,
		String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user,
		WebSocketHandler wsHandler, Map<String, Object> attrs) throws HandshakeFailureException {

	HttpHeaders headers = request.getHeaders();
	InetSocketAddress localAddr = request.getLocalAddress();
	InetSocketAddress remoteAddr = request.getRemoteAddress();

	StandardWebSocketSession session = new StandardWebSocketSession(headers, attrs, localAddr, remoteAddr, user);
	StandardWebSocketHandlerAdapter endpoint = new StandardWebSocketHandlerAdapter(wsHandler, session);

	List<Extension> extensions = new ArrayList<Extension>();
	for (WebSocketExtension extension : selectedExtensions) {
		extensions.add(new WebSocketToStandardExtensionAdapter(extension));
	}

	upgradeInternal(request, response, selectedProtocol, extensions, endpoint);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:AbstractStandardUpgradeStrategy.java

示例11: upgradeInternal

import javax.websocket.Extension; //导入依赖的package包/类
@Override
public void upgradeInternal(ServerHttpRequest httpRequest, ServerHttpResponse httpResponse,
		String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint)
		throws HandshakeFailureException {

	HttpServletRequest request = getHttpServletRequest(httpRequest);
	HttpServletResponse response = getHttpServletResponse(httpResponse);

	StringBuffer requestUrl = request.getRequestURL();
	String path = request.getRequestURI();  // shouldn't matter
	Map<String, String> pathParams = Collections.<String, String> emptyMap();

	ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint);
	endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol));
	endpointConfig.setExtensions(selectedExtensions);

	try {
		ServerContainer container = getContainer(request);
		upgradeMethod.invoke(container, request, response, endpointConfig, pathParams);
	}
	catch (Exception ex) {
		throw new HandshakeFailureException(
				"Servlet request failed to upgrade to WebSocket for " + requestUrl, ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:WebSphereRequestUpgradeStrategy.java

示例12: createConfiguredServerEndpoint

import javax.websocket.Extension; //导入依赖的package包/类
private ConfiguredServerEndpoint createConfiguredServerEndpoint(String selectedProtocol,
		List<Extension> selectedExtensions, Endpoint endpoint, HttpServletRequest servletRequest) {

	String path = servletRequest.getRequestURI();  // shouldn't matter
	ServerEndpointRegistration endpointRegistration = new ServerEndpointRegistration(path, endpoint);
	endpointRegistration.setSubprotocols(Arrays.asList(selectedProtocol));
	endpointRegistration.setExtensions(selectedExtensions);

	EncodingFactory encodingFactory = new EncodingFactory(
			Collections.<Class<?>, List<InstanceFactory<? extends Encoder>>>emptyMap(),
			Collections.<Class<?>, List<InstanceFactory<? extends Decoder>>>emptyMap(),
			Collections.<Class<?>, List<InstanceFactory<? extends Encoder>>>emptyMap(),
			Collections.<Class<?>, List<InstanceFactory<? extends Decoder>>>emptyMap());
	try {
		return (endpointConstructorWithEndpointFactory ?
				endpointConstructor.newInstance(endpointRegistration,
						new EndpointInstanceFactory(endpoint), null, encodingFactory, null) :
				endpointConstructor.newInstance(endpointRegistration,
						new EndpointInstanceFactory(endpoint), null, encodingFactory));
	}
	catch (Exception ex) {
		throw new HandshakeFailureException("Failed to instantiate ConfiguredServerEndpoint", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:UndertowRequestUpgradeStrategy.java

示例13: generateExtensionHeaders

import javax.websocket.Extension; //导入依赖的package包/类
private List<String> generateExtensionHeaders(List<Extension> extensions) {
    List<String> result = new ArrayList<String>(extensions.size());
    for (Extension extension : extensions) {
        StringBuilder header = new StringBuilder();
        header.append(extension.getName());
        for (Extension.Parameter param : extension.getParameters()) {
            header.append(';');
            header.append(param.getName());
            String value = param.getValue();
            if (value != null && value.length() > 0) {
                header.append('=');
                header.append(value);
            }
        }
    }
    return result;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:18,代码来源:WsWebSocketContainer.java

示例14: preInit

import javax.websocket.Extension; //导入依赖的package包/类
public void preInit(Endpoint ep, EndpointConfig endpointConfig,
        WsServerContainer wsc, WsHandshakeRequest handshakeRequest,
        List<Extension> negotiatedExtensionsPhase2, String subProtocol,
        Transformation transformation, Map<String,String> pathParameters,
        boolean secure) {
    this.ep = ep;
    this.endpointConfig = endpointConfig;
    this.webSocketContainer = wsc;
    this.handshakeRequest = handshakeRequest;
    this.negotiatedExtensions = negotiatedExtensionsPhase2;
    this.subProtocol = subProtocol;
    this.transformation = transformation;
    this.pathParameters = pathParameters;
    this.secure = secure;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:WsHttpUpgradeHandler.java

示例15: getNegotiatedExtensions

import javax.websocket.Extension; //导入依赖的package包/类
@Override
public List<Extension> getNegotiatedExtensions(List<Extension> installed,
        List<Extension> requested) {
    Set<String> installedNames = new HashSet<String>();
    for (Extension e : installed) {
        installedNames.add(e.getName());
    }
    List<Extension> result = new ArrayList<Extension>();
    for (Extension request : requested) {
        if (installedNames.contains(request.getName())) {
            result.add(request);
        }
    }
    return result;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:DefaultServerEndpointConfigurator.java


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