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


Java ServerEndpointConfig.getPath方法代码示例

本文整理汇总了Java中javax.websocket.server.ServerEndpointConfig.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java ServerEndpointConfig.getPath方法的具体用法?Java ServerEndpointConfig.getPath怎么用?Java ServerEndpointConfig.getPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.websocket.server.ServerEndpointConfig的用法示例。


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

示例1: addEndpoint

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/**
 * Published the provided endpoint implementation at the specified path with
 * the specified configuration. {@link #WsServerContainer(ServletContext)}
 * must be called before calling this method.
 *
 * @param sec   The configuration to use when creating endpoint instances
 * @throws DeploymentException
 */
@Override
public void addEndpoint(ServerEndpointConfig sec)
        throws DeploymentException {

    if (enforceNoAddAfterHandshake && !addAllowed) {
        throw new DeploymentException(
                sm.getString("serverContainer.addNotAllowed"));
    }

    if (servletContext == null) {
        throw new DeploymentException(
                sm.getString("serverContainer.servletContextMissing"));
    }
    String path = sec.getPath();

    // Add method mapping to user properties
    PojoMethodMapping methodMapping = new PojoMethodMapping(sec.getEndpointClass(),
            sec.getDecoders(), path);
    if (methodMapping.getOnClose() != null || methodMapping.getOnOpen() != null
            || methodMapping.getOnError() != null || methodMapping.hasMessageHandlers()) {
        sec.getUserProperties().put(
                PojoEndpointServer.POJO_METHOD_MAPPING_KEY,
                methodMapping);
    }

    UriTemplate uriTemplate = new UriTemplate(path);
    if (uriTemplate.hasParameters()) {
        Integer key = Integer.valueOf(uriTemplate.getSegmentCount());
        SortedSet<TemplatePathMatch> templateMatches =
                configTemplateMatchMap.get(key);
        if (templateMatches == null) {
            // Ensure that if concurrent threads execute this block they
            // both end up using the same TreeSet instance
            templateMatches = new TreeSet<TemplatePathMatch>(
                    TemplatePathMatchComparator.getInstance());
            configTemplateMatchMap.putIfAbsent(key, templateMatches);
            templateMatches = configTemplateMatchMap.get(key);
        }
        if (!templateMatches.add(new TemplatePathMatch(sec, uriTemplate))) {
            // Duplicate uriTemplate;
            throw new DeploymentException(
                    sm.getString("serverContainer.duplicatePaths", path,
                                 sec.getEndpointClass(),
                                 sec.getEndpointClass()));
        }
    } else {
        // Exact match
        ServerEndpointConfig old = configExactMatchMap.put(path, sec);
        if (old != null) {
            // Duplicate path mappings
            throw new DeploymentException(
                    sm.getString("serverContainer.duplicatePaths", path,
                                 old.getEndpointClass(),
                                 sec.getEndpointClass()));
        }
    }

    endpointsRegistered = true;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:68,代码来源:WsServerContainer.java

示例2: addEndpoint

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/**
 * Published the provided endpoint implementation at the specified path with
 * the specified configuration. {@link #WsServerContainer(ServletContext)}
 * must be called before calling this method.
 *
 * @param sec
 *            The configuration to use when creating endpoint instances
 * @throws DeploymentException
 */
@Override
public void addEndpoint(ServerEndpointConfig sec) throws DeploymentException {

	if (enforceNoAddAfterHandshake && !addAllowed) {
		throw new DeploymentException(sm.getString("serverContainer.addNotAllowed"));
	}

	if (servletContext == null) {
		throw new DeploymentException(sm.getString("serverContainer.servletContextMissing"));
	}
	String path = sec.getPath();

	// Add method mapping to user properties
	PojoMethodMapping methodMapping = new PojoMethodMapping(sec.getEndpointClass(), sec.getDecoders(), path);
	if (methodMapping.getOnClose() != null || methodMapping.getOnOpen() != null
			|| methodMapping.getOnError() != null || methodMapping.hasMessageHandlers()) {
		sec.getUserProperties().put(PojoEndpointServer.POJO_METHOD_MAPPING_KEY, methodMapping);
	}

	UriTemplate uriTemplate = new UriTemplate(path);
	if (uriTemplate.hasParameters()) {
		Integer key = Integer.valueOf(uriTemplate.getSegmentCount());
		SortedSet<TemplatePathMatch> templateMatches = configTemplateMatchMap.get(key);
		if (templateMatches == null) {
			// Ensure that if concurrent threads execute this block they
			// both end up using the same TreeSet instance
			templateMatches = new TreeSet<TemplatePathMatch>(TemplatePathMatchComparator.getInstance());
			configTemplateMatchMap.putIfAbsent(key, templateMatches);
			templateMatches = configTemplateMatchMap.get(key);
		}
		if (!templateMatches.add(new TemplatePathMatch(sec, uriTemplate))) {
			// Duplicate uriTemplate;
			throw new DeploymentException(sm.getString("serverContainer.duplicatePaths", path,
					sec.getEndpointClass(), sec.getEndpointClass()));
		}
	} else {
		// Exact match
		ServerEndpointConfig old = configExactMatchMap.put(path, sec);
		if (old != null) {
			// Duplicate path mappings
			throw new DeploymentException(sm.getString("serverContainer.duplicatePaths", path,
					old.getEndpointClass(), sec.getEndpointClass()));
		}
	}

	endpointsRegistered = true;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:57,代码来源:WsServerContainer.java

示例3: EndpointProgrammaticJava

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
public EndpointProgrammaticJava(ServerEndpointConfig config) {
    super(config.getEndpointClass(), EndpointType.JAVA_PROGRAMMATIC_ENDPOINT, config.getPath());
    this.config = config;
}
 
开发者ID:TomCools,项目名称:dropwizard-websocket-jee7-bundle,代码行数:5,代码来源:EndpointProgrammaticJava.java

示例4: addEndpoint

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/**
 * Published the provided endpoint implementation at the specified path with
 * the specified configuration. {@link #WsServerContainer(ServletContext)}
 * must be called before calling this method.
 *
 * @param sec   The configuration to use when creating endpoint instances
 * @throws DeploymentException
 */
@Override
public void addEndpoint(ServerEndpointConfig sec)
        throws DeploymentException {

    if (enforceNoAddAfterHandshake && !addAllowed) {
        throw new DeploymentException(
                sm.getString("serverContainer.addNotAllowed"));
    }

    if (servletContext == null) {
        throw new DeploymentException(
                sm.getString("serverContainer.servletContextMissing"));
    }
    String path = sec.getPath();

    UriTemplate uriTemplate = new UriTemplate(path);
    if (uriTemplate.hasParameters()) {
        Integer key = Integer.valueOf(uriTemplate.getSegmentCount());
        SortedSet<TemplatePathMatch> templateMatches =
                configTemplateMatchMap.get(key);
        if (templateMatches == null) {
            // Ensure that if concurrent threads execute this block they
            // both end up using the same TreeSet instance
            templateMatches = new TreeSet<TemplatePathMatch>(
                    TemplatePathMatchComparator.getInstance());
            configTemplateMatchMap.putIfAbsent(key, templateMatches);
            templateMatches = configTemplateMatchMap.get(key);
        }
        if (!templateMatches.add(new TemplatePathMatch(sec, uriTemplate))) {
            // Duplicate uriTemplate;
            throw new DeploymentException(
                    sm.getString("serverContainer.duplicatePaths", path));
        }
    } else {
        // Exact match
        ServerEndpointConfig old = configExactMatchMap.put(path, sec);
        if (old != null) {
            // Duplicate path mappings
            throw new DeploymentException(
                    sm.getString("serverContainer.duplicatePaths", path));
        }
    }

    endpointsRegistered = true;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:54,代码来源:WsServerContainer.java

示例5: getListenerKey

import javax.websocket.server.ServerEndpointConfig; //导入方法依赖的package包/类
/**
 * parses the endpoint from the incoming Websocket connection and generates a listener key based on the endpoint
 * only, so that all hosts listening will handle the connection to the endpoint
 *
 * @param sec
 * @param request
 * @return
 */
public String getListenerKey(ServerEndpointConfig sec, HandshakeRequest request) {

	String endpoint = sec.getPath();
	return endpoint;
}
 
开发者ID:isapir,项目名称:lucee-websocket,代码行数:14,代码来源:HandshakeHandler.java


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