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


Java ServerEndpointConfig类代码示例

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


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

示例1: onOpen

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void onOpen(Session session, EndpointConfig endpointConfig) {

	ServerEndpointConfig sec = (ServerEndpointConfig) endpointConfig;

	Object pojo;
	try {
		pojo = sec.getConfigurator().getEndpointInstance(sec.getEndpointClass());
	} catch (InstantiationException e) {
		throw new IllegalArgumentException(
				sm.getString("pojoEndpointServer.getPojoInstanceFail", sec.getEndpointClass().getName()), e);
	}
	setPojo(pojo);

	@SuppressWarnings("unchecked")
	Map<String, String> pathParameters = (Map<String, String>) sec.getUserProperties().get(POJO_PATH_PARAM_KEY);
	setPathParameters(pathParameters);

	PojoMethodMapping methodMapping = (PojoMethodMapping) sec.getUserProperties().get(POJO_METHOD_MAPPING_KEY);
	setMethodMapping(methodMapping);

	doOnOpen(session, endpointConfig);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:24,代码来源:PojoEndpointServer.java

示例2: contextInitialized

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void contextInitialized(final ServletContextEvent servletContextEvent) {
	super.contextInitialized(servletContextEvent);
	final ServerContainer serverContainer = (ServerContainer) servletContextEvent.getServletContext()
			.getAttribute("javax.websocket.server.ServerContainer");

	if (serverContainer != null) {
		try {
			serverContainer.addEndpoint(ServerEndpointConfig.Builder
					.create(SubscriptionEndpoint.class, "/ContextManager/{" + PATH_NAME + "}").build());
			// serverContainer.addEndpoint(ServerEndpointConfig.Builder
			// .create(ExtendedSubscriptionEndpoint.class,
			// "/ContextManager/{contextParticipantId}")
			// .configurator(new WebSocketsConfigurator()).build());
		} catch (final DeploymentException e) {
			throw new RuntimeException(e.getMessage(), e);
		}
	}
}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:20,代码来源:CCOWContextListener.java

示例3: setWebSocketEndpoints

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
/**
 *
 * @param context the context to add the web socket endpoints to
 * @param rtEventResource The instance of the websocket endpoint to return
 * @throws DeploymentException
 */
private static void setWebSocketEndpoints(ServletContextHandler context,
                                          EventsResource rtEventResource)
        throws DeploymentException, ServletException {

    ServerContainer wsContainer = WebSocketServerContainerInitializer.configureContext(context);

    ServerEndpointConfig serverConfig =
            ServerEndpointConfig.Builder
                                .create(EventsResource.class, EventsResource.RT_EVENT_ENDPOINT)
                                .configurator(new Configurator() {
                                    @Override
                                    public <T> T getEndpointInstance(Class<T> endpointClass)
                                            throws InstantiationException {
                                        return endpointClass.cast(rtEventResource);
                                    }
                                }).build();

    wsContainer.addEndpoint(serverConfig);
}
 
开发者ID:OpenChatAlytics,项目名称:OpenChatAlytics,代码行数:26,代码来源:ServerMain.java

示例4: configureEndpoint

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
public static void configureEndpoint(String endpointPath, Class endpointClass, Class handshakeHandlerClass,
		LuceeApp app) throws ClassNotFoundException, IllegalAccessException, InstantiationException,
		DeploymentException, PageException {

	ServerEndpointConfig serverEndpointConfig = ServerEndpointConfig.Builder.create(endpointClass,
			endpointPath).configurator(
					(ServerEndpointConfig.Configurator) handshakeHandlerClass.newInstance()).build();

	try {

		ServerContainer serverContainer = (ServerContainer) app.getServletContext().getAttribute(
				"javax.websocket.server.ServerContainer");
		serverContainer.addEndpoint(serverEndpointConfig);
	}
	catch (DeploymentException ex) {

		app.log(Log.LEVEL_DEBUG, "Failed to register endpoint " + endpointPath + ": " + ex.getMessage(),
				app.getName(), "websocket");
	}
	// System.out.println(Configurator.class.getName() + " >>> exit configureEndpoint()");
}
 
开发者ID:isapir,项目名称:lucee-websocket,代码行数:22,代码来源:Configurator.java

示例5: contextInitialized

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);

    ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute(
            Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);

    ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(
            Bug58624ServerEndpoint.class, PATH).build();

    try {
        sc.addEndpoint(sec);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestCloseBug58624.java

示例6: contextInitialized

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);

    ServerContainer sc =
            (ServerContainer) sce.getServletContext().getAttribute(
                    Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);

    ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(
            TesterEchoServer.Basic.class, "/{param}").build();

    try {
        sc.addEndpoint(sec);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:TestWsServerContainer.java

示例7: testSpecExample3

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Test
public void testSpecExample3() throws Exception {
    WsServerContainer sc =
            new WsServerContainer(new TesterServletContext());

    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(
            Object.class, "/a/{var}/c").build();
    ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(
            Object.class, "/a/b/c").build();
    ServerEndpointConfig configC = ServerEndpointConfig.Builder.create(
            Object.class, "/a/{var1}/{var2}").build();

    sc.addEndpoint(configA);
    sc.addEndpoint(configB);
    sc.addEndpoint(configC);

    Assert.assertEquals(configB, sc.findMapping("/a/b/c").getConfig());
    Assert.assertEquals(configA, sc.findMapping("/a/d/c").getConfig());
    Assert.assertEquals(configC, sc.findMapping("/a/x/y").getConfig());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:TestWsServerContainer.java

示例8: testDuplicatePaths_04

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Test
public void testDuplicatePaths_04() throws Exception {
    WsServerContainer sc =
            new WsServerContainer(new TesterServletContext());

    ServerEndpointConfig configA = ServerEndpointConfig.Builder.create(
            Object.class, "/a/{var1}/{var2}").build();
    ServerEndpointConfig configB = ServerEndpointConfig.Builder.create(
            Object.class, "/a/b/{var2}").build();

    sc.addEndpoint(configA);
    sc.addEndpoint(configB);

    Assert.assertEquals(configA, sc.findMapping("/a/x/y").getConfig());
    Assert.assertEquals(configB, sc.findMapping("/a/b/y").getConfig());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestWsServerContainer.java

示例9: contextInitialized

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);

    ServerContainer sc = (ServerContainer) sce.getServletContext().getAttribute(
            Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);

    List<Class<? extends Encoder>> encoders = new ArrayList<Class<? extends Encoder>>();
    encoders.add(Bug58624Encoder.class);
    ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(
            Bug58624Endpoint.class, PATH).encoders(encoders).build();

    try {
        sc.addEndpoint(sec);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:TestWsRemoteEndpointImplServer.java

示例10: contextInitialized

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);

    ServerContainer sc = (ServerContainer) sce
            .getServletContext()
            .getAttribute(
                    Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);

    ServerEndpointConfig sec = ServerEndpointConfig.Builder.create(
            getEndpointClass(), PATH).build();

    try {
        sc.addEndpoint(sec);
    } catch (DeploymentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:TestClose.java

示例11: contextInitialized

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent sce) {
    super.contextInitialized(sce);
    ServerContainer sc =
            (ServerContainer) sce.getServletContext().getAttribute(
                    Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
    try {
        sc.addEndpoint(ServerEndpointConfig.Builder.create(
                ConstantTxEndpoint.class, PATH).build());
        if (TestWsWebSocketContainer.timeoutOnContainer) {
            sc.setAsyncSendTimeout(TIMEOUT_MS);
        }
    } catch (DeploymentException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestWsWebSocketContainer.java

示例12: getEndpointConfigs

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public Set<ServerEndpointConfig> getEndpointConfigs(
        Set<Class<? extends Endpoint>> scanned) {

    Set<ServerEndpointConfig> result = new HashSet<ServerEndpointConfig>();

    if (scanned.contains(EchoEndpoint.class)) {
        result.add(ServerEndpointConfig.Builder.create(
                EchoEndpoint.class,
                "/websocket/echoProgrammatic").build());
    }

    if (scanned.contains(DrawboardEndpoint.class)) {
        result.add(ServerEndpointConfig.Builder.create(
                DrawboardEndpoint.class,
                "/websocket/drawboard").build());
    }

    return result;
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:21,代码来源:ExamplesConfig.java

示例13: addEndpoint

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
protected void addEndpoint(final Class<?> cls) {

    final ServerContainer container = getServerContainer();

    if (container == null) {
      LOG.warn("ServerContainer is null. Skip registration of websocket endpoint {}", cls);
      return;
    }

    try {
      LOG.debug("Register endpoint {}", cls);

      final ServerEndpointConfig config = createEndpointConfig(cls);
      container.addEndpoint(config);

    } catch (final DeploymentException e) {
      addError(e);
    }
  }
 
开发者ID:jkiddo,项目名称:ccow,代码行数:20,代码来源:WebSocketsModule.java

示例14: registerEndpoints

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
/**
 * Actually register the endpoints. Called by {@link #afterSingletonsInstantiated()}.
 */
protected void registerEndpoints() {
	Set<Class<?>> endpointClasses = new LinkedHashSet<Class<?>>();
	if (this.annotatedEndpointClasses != null) {
		endpointClasses.addAll(this.annotatedEndpointClasses);
	}

	ApplicationContext context = getApplicationContext();
	if (context != null) {
		String[] endpointBeanNames = context.getBeanNamesForAnnotation(ServerEndpoint.class);
		for (String beanName : endpointBeanNames) {
			endpointClasses.add(context.getType(beanName));
		}
	}

	for (Class<?> endpointClass : endpointClasses) {
		registerEndpoint(endpointClass);
	}

	if (context != null) {
		Map<String, ServerEndpointConfig> endpointConfigMap = context.getBeansOfType(ServerEndpointConfig.class);
		for (ServerEndpointConfig endpointConfig : endpointConfigMap.values()) {
			registerEndpoint(endpointConfig);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:ServerEndpointExporter.java

示例15: modifyHandshake

import javax.websocket.server.ServerEndpointConfig; //导入依赖的package包/类
@Override
public void modifyHandshake(ServerEndpointConfig config,
        HandshakeRequest request, HandshakeResponse response) {

    HttpSession httpSession = (HttpSession) request.getHttpSession();

    super.modifyHandshake(config, request, response);

    if (httpSession == null) {
        LOGGER.info("httpSession == null after modifyHandshake");
        httpSession = (HttpSession) request.getHttpSession();
    }

    if (httpSession == null) {
        LOGGER.info("httpSession == null");
        return;
    }

    config.getUserProperties().put("httpSession", httpSession);

    httpSession = (HttpSession) request.getHttpSession();
    LOGGER.info("modifyHandshake " + httpSession.getId());

}
 
开发者ID:webfirmframework,项目名称:tomcat-8-wffweb-demo-apps,代码行数:25,代码来源:WSServerForIndexPage.java


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