當前位置: 首頁>>代碼示例>>Java>>正文


Java ServerEndpoint類代碼示例

本文整理匯總了Java中javax.websocket.server.ServerEndpoint的典型用法代碼示例。如果您正苦於以下問題:Java ServerEndpoint類的具體用法?Java ServerEndpoint怎麽用?Java ServerEndpoint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ServerEndpoint類屬於javax.websocket.server包,在下文中一共展示了ServerEndpoint類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerEndpoints

import javax.websocket.server.ServerEndpoint; //導入依賴的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

示例2: createEndpointConfig

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
private ServerEndpointConfig createEndpointConfig(Class<?> endpointClass) throws DeploymentException {
    ServerEndpoint annotation = endpointClass.getAnnotation(ServerEndpoint.class);
    if (annotation == null) {
        throw new InvalidWebSocketException("Unsupported WebSocket object, missing @" + ServerEndpoint.class + " annotation");
    }

    return ServerEndpointConfig.Builder.create(endpointClass, annotation.value())
            .subprotocols(Arrays.asList(annotation.subprotocols()))
            .decoders(Arrays.asList(annotation.decoders()))
            .encoders(Arrays.asList(annotation.encoders()))
            .configurator(configurator)
            .build();
}
 
開發者ID:asafalima,項目名稱:guice-websocket,代碼行數:14,代碼來源:JettyServer.java

示例3: JbootWebsocketManager

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
private JbootWebsocketManager() {
    List<Class> endPointClasses = ClassScanner.scanClassByAnnotation(ServerEndpoint.class, false);
    if (endPointClasses != null && endPointClasses.size() != 0) {
        for (Class entry : endPointClasses) {
            ServerEndpoint serverEndpoint = (ServerEndpoint) entry.getAnnotation(ServerEndpoint.class);
            String value = serverEndpoint.value();
            if (!StringUtils.isBlank(value)) {
                websocketEndPoints.add(entry);
                websocketEndPointValues.add(value);
            }
        }
    }
}
 
開發者ID:yangfuhai,項目名稱:jboot,代碼行數:14,代碼來源:JbootWebsocketManager.java

示例4: init

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
public static void init(final ServletContextHandler context, final MinijaxApplication application)
        throws ServletException, DeploymentException {

    final ServerContainer container = WebSocketServerContainerInitializer.configureContext(context);
    final Configurator configurator = new MinijaxWebSocketConfigurator(application);

    for (final Class<?> c : application.getWebSockets()) {
        final ServerEndpointConfig config = ServerEndpointConfig.Builder
                .create(c, c.getAnnotation(ServerEndpoint.class).value())
                .configurator(configurator)
                .build();
        container.addEndpoint(config);
    }
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:15,代碼來源:MinijaxWebSocketUtils.java

示例5: determineAnnotatedEndpointPath

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
private String determineAnnotatedEndpointPath(Class<?> endpointClass) {
    if (endpointClass.isAnnotationPresent(ServerEndpoint.class)) {
        return endpointClass.getAnnotation(ServerEndpoint.class).value();
    } else {
        throw new IllegalArgumentException(String.format("@ServerEndpoint annotation not found on Websocket-class: '%s'. Either annotate the class or register it as a programmatic endpoint using ServerEndpointConfig.class", endpointClass));
    }
}
 
開發者ID:TomCools,項目名稱:dropwizard-websocket-jee7-bundle,代碼行數:8,代碼來源:EndpointRegistration.java

示例6: validateEndpointUri

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
/**
 * Validate the endpoint against the {@link ServerEndpoint} since without {@link ServerEndpoint} definition
 * there can't be a WebSocket endpoint.
 * @param websocketEndpoint endpoint which should be validated.
 */
public boolean validateEndpointUri(Object websocketEndpoint) {
    if (websocketEndpoint != null) {
        return websocketEndpoint.getClass().isAnnotationPresent(ServerEndpoint.class);
    }
    return false;
}
 
開發者ID:wso2,項目名稱:msf4j,代碼行數:12,代碼來源:EndpointDispatcher.java

示例7: create

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
@Override
public EventDriver create(Object websocket, WebSocketPolicy policy) throws Throwable {
    if (!(websocket instanceof EndpointInstance)) {
        throw new IllegalStateException(String.format("Websocket %s must be an %s", websocket.getClass().getName(), EndpointInstance.class.getName()));
    }

    EndpointInstance ei = (EndpointInstance) websocket;
    AnnotatedServerEndpointMetadata metadata = (AnnotatedServerEndpointMetadata) ei.getMetadata();
    JsrEvents<ServerEndpoint, ServerEndpointConfig> events = new JsrEvents<>(metadata);

    // Handle @OnMessage maxMessageSizes
    int maxBinaryMessage = getMaxMessageSize(policy.getMaxBinaryMessageSize(), metadata.onBinary, metadata.onBinaryStream);
    int maxTextMessage = getMaxMessageSize(policy.getMaxTextMessageSize(), metadata.onText, metadata.onTextStream);

    policy.setMaxBinaryMessageSize(maxBinaryMessage);
    policy.setMaxTextMessageSize(maxTextMessage);

    //////// instrumentation is here
    JsrAnnotatedEventDriver driver = new InstJsrAnnotatedEventDriver(policy, ei, events, metrics);
    ////////
    
    // Handle @PathParam values
    ServerEndpointConfig config = (ServerEndpointConfig) ei.getConfig();
    if (config instanceof PathParamServerEndpointConfig) {
        PathParamServerEndpointConfig ppconfig = (PathParamServerEndpointConfig) config;
        driver.setPathParameters(ppconfig.getPathParamMap());
    }

    return driver;
}
 
開發者ID:LivePersonInc,項目名稱:dropwizard-websockets,代碼行數:31,代碼來源:InstJsrServerEndpointImpl.java

示例8: addEndpoint

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
public void addEndpoint(Class<?> clazz) {
    ServerEndpoint anno = clazz.getAnnotation(ServerEndpoint.class);
    if(anno == null){
        throw new RuntimeException(clazz.getCanonicalName()+" does not have a "+ServerEndpoint.class.getCanonicalName()+" annotation");
    }
    ServerEndpointConfig.Builder bldr =  ServerEndpointConfig.Builder.create(clazz, anno.value());
    if(defaultConfigurator != null){
        bldr = bldr.configurator(defaultConfigurator);
    }
    endpointConfigs.add(bldr.build());
    if (starting)
        throw new RuntimeException("can't add endpoint after starting lifecycle");
}
 
開發者ID:LivePersonInc,項目名稱:dropwizard-websockets,代碼行數:14,代碼來源:WebsocketBundle.java

示例9: isEndpoint

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
protected boolean isEndpoint(final Class<?> cls) {
  return cls.isAnnotationPresent(ServerEndpoint.class);
}
 
開發者ID:jkiddo,項目名稱:ccow,代碼行數:4,代碼來源:WebSocketsModule.java

示例10: validateURI

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
private boolean validateURI(Object webSocketEndpoint) throws WebSocketEndpointAnnotationException {
    if (webSocketEndpoint.getClass().isAnnotationPresent(ServerEndpoint.class)) {
        return true;
    }
    throw new WebSocketEndpointAnnotationException("Server Endpoint is not defined.");
}
 
開發者ID:wso2,項目名稱:msf4j,代碼行數:7,代碼來源:EndpointValidator.java

示例11: InstJsrAnnotatedEventDriver

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
public InstJsrAnnotatedEventDriver(WebSocketPolicy policy, EndpointInstance ei, JsrEvents<ServerEndpoint, ServerEndpointConfig> events, MetricRegistry metrics) {
    super(policy, ei, events);
    this.edm = new EventDriverMetrics(metadata.getEndpointClass(), metrics);
}
 
開發者ID:LivePersonInc,項目名稱:dropwizard-websockets,代碼行數:5,代碼來源:InstJsrAnnotatedEventDriver.java

示例12: findWebSocketServers

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
public void findWebSocketServers(@Observes @WithAnnotations(ServerEndpoint.class)ProcessAnnotatedType<?> pat) {
    endpointClasses.add(pat.getAnnotatedType().getJavaClass());
}
 
開發者ID:hammock-project,項目名稱:hammock,代碼行數:4,代碼來源:UndertowWebSocketExtension.java

示例13: requireServerEndPointAnnotation

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
private void requireServerEndPointAnnotation(Class c) {
    Annotation annotation = c.getAnnotation(ServerEndpoint.class);
    if (annotation == null) {
        throw new IllegalArgumentException(String.format("Endpoint class must be annotated with javax.websocket.server.ServerEndpoint"));
    }
}
 
開發者ID:xoom,項目名稱:feathercon,代碼行數:7,代碼來源:WebSocketEndpointConfiguration.java

示例14: getUri

import javax.websocket.server.ServerEndpoint; //導入依賴的package包/類
/**
 * Extract the URI from the endpoint.
 * <b>Note that it is better use validateEndpointUri method to validate the endpoint uri
 * before getting it out if needed. Otherwise it will cause issues. Use this method only and only if
 * it is sure that endpoint contains {@link ServerEndpoint} defined.</b>
 *
 * @param webSocketEndpoint WebSocket endpoint which the URI should be extracted.
 * @return the URI of the Endpoint as a String.
 */
public String getUri(Object webSocketEndpoint) {
    return webSocketEndpoint.getClass().getAnnotation(ServerEndpoint.class).value();
}
 
開發者ID:wso2,項目名稱:msf4j,代碼行數:13,代碼來源:EndpointDispatcher.java


注:本文中的javax.websocket.server.ServerEndpoint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。