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


Java Encoder類代碼示例

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


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

示例1: contextInitialized

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

示例2: DefaultServerEndpointConfig

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

示例3: createConfiguredServerEndpoint

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

示例4: createWsServerEndpointConfig

import javax.websocket.Encoder; //導入依賴的package包/類
protected ServerEndpointConfig createWsServerEndpointConfig(ServletContext servletContext) {
  final List<Class<? extends Encoder>> encoders = new LinkedList<>();
  final List<Class<? extends Decoder>> decoders = new LinkedList<>();
  encoders.add(OutputMessageEncoder.class);
  decoders.add(InputMessageDecoder.class);
  final ServerEndpointConfig endpointConfig =
      create(CheWSConnection.class, websocketContext + websocketEndPoint)
          .configurator(createConfigurator())
          .encoders(encoders)
          .decoders(decoders)
          .build();
  endpointConfig
      .getUserProperties()
      .put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext));
  endpointConfig
      .getUserProperties()
      .put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext));
  endpointConfig.getUserProperties().put(EXECUTOR_ATTRIBUTE, createExecutor(servletContext));
  return endpointConfig;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:21,代碼來源:ServerContainerInitializeListener.java

示例5: createEventbusServerEndpointConfig

import javax.websocket.Encoder; //導入依賴的package包/類
protected ServerEndpointConfig createEventbusServerEndpointConfig(ServletContext servletContext) {
  final List<Class<? extends Encoder>> encoders = new LinkedList<>();
  final List<Class<? extends Decoder>> decoders = new LinkedList<>();
  encoders.add(OutputMessageEncoder.class);
  decoders.add(InputMessageDecoder.class);
  final ServerEndpointConfig endpointConfig =
      create(CheWSConnection.class, websocketContext + eventBusEndPoint)
          .configurator(createConfigurator())
          .encoders(encoders)
          .decoders(decoders)
          .build();
  endpointConfig
      .getUserProperties()
      .put(EVERREST_PROCESSOR_ATTRIBUTE, getEverrestProcessor(servletContext));
  endpointConfig
      .getUserProperties()
      .put(EVERREST_CONFIG_ATTRIBUTE, getEverrestConfiguration(servletContext));
  endpointConfig.getUserProperties().put(EXECUTOR_ATTRIBUTE, createExecutor(servletContext));
  return endpointConfig;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:21,代碼來源:ServerContainerInitializeListener.java

示例6: buildServerEndpointConfig

import javax.websocket.Encoder; //導入依賴的package包/類
@Override
protected ServerEndpointConfig buildServerEndpointConfig(String path, WebSocket wseAnnotation,
                                                         Class<?> annotatedClass, String[] subProtocols,
                                                         List<Class<? extends Encoder>> encoderClasses,
                                                         List<Class<? extends Decoder>> decoderClasses) {
    int max = getMaxSessions(annotatedClass);
    if (max != -1) {
        TyrusServerEndpointConfig.Builder builder =
                TyrusServerEndpointConfig.Builder
                        .create(annotatedClass, path)
                        .encoders(encoderClasses)
                        .decoders(decoderClasses)
                        .subprotocols(Arrays.asList(subProtocols));
        if (!ServerEndpointConfig.Configurator.class.equals(wseAnnotation.configurator())) {
            builder = builder.configurator(Injections.getOrCreate(manager, wseAnnotation.configurator()));
        }
        return builder.maxSessions(max).build();
    }
    return super.buildServerEndpointConfig(path, wseAnnotation, annotatedClass,
            subProtocols, encoderClasses, decoderClasses);
}
 
開發者ID:icode,項目名稱:ameba-container-grizzly,代碼行數:22,代碼來源:AnnotatedEndpointMeta.java

示例7: findEncoder

import javax.websocket.Encoder; //導入依賴的package包/類
private Encoder findEncoder(Object obj) {
    for (EncoderEntry entry : encoderEntries) {
        if (entry.getClazz().isAssignableFrom(obj.getClass())) {
            return entry.getEncoder();
        }
    }
    return null;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:9,代碼來源:WsRemoteEndpointImplBase.java

示例8: DefaultServerEndpointConfig

import javax.websocket.Encoder; //導入依賴的package包/類
DefaultServerEndpointConfig(
        Class<?> endpointClass, String path,
        List<String> subprotocols, List<Extension> extensions,
        List<Class<? extends Encoder>> encoders,
        List<Class<? extends Decoder>> decoders,
        Configurator serverEndpointConfigurator) {
    this.endpointClass = endpointClass;
    this.path = path;
    this.subprotocols = subprotocols;
    this.extensions = extensions;
    this.encoders = encoders;
    this.decoders = decoders;
    this.serverEndpointConfigurator = serverEndpointConfigurator;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:15,代碼來源:DefaultServerEndpointConfig.java

示例9: findEncoder

import javax.websocket.Encoder; //導入依賴的package包/類
private Encoder findEncoder(Object obj) {
	for (EncoderEntry entry : encoderEntries) {
		if (entry.getClazz().isAssignableFrom(obj.getClass())) {
			return entry.getEncoder();
		}
	}
	return null;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:9,代碼來源:WsRemoteEndpointImplBase.java

示例10: DefaultServerEndpointConfig

import javax.websocket.Encoder; //導入依賴的package包/類
DefaultServerEndpointConfig(Class<?> endpointClass, String path, List<String> subprotocols,
		List<Extension> extensions, List<Class<? extends Encoder>> encoders,
		List<Class<? extends Decoder>> decoders, Configurator serverEndpointConfigurator) {
	this.endpointClass = endpointClass;
	this.path = path;
	this.subprotocols = subprotocols;
	this.extensions = extensions;
	this.encoders = encoders;
	this.decoders = decoders;
	this.serverEndpointConfigurator = serverEndpointConfigurator;
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:12,代碼來源:DefaultServerEndpointConfig.java

示例11: getEndpointConfigs

import javax.websocket.Encoder; //導入依賴的package包/類
@Override
public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> endpointClasses) {
    logger.info("Checking the endpoint...");
    // Configuring the decoders
    List<Class<? extends Decoder>> decoders = new LinkedList<>();
    decoders.add(CommandMessageDecoder.class);
    // Configuring the encoders
    List<Class<? extends Encoder>> encoders = new LinkedList<>();
    encoders.add(CommandMessageEncoder.class);
    Set<ServerEndpointConfig> configs = new HashSet<>();
    configs.add(ServerEndpointConfig.Builder.create(ClientChatEndpoint.class, "/chat").decoders(decoders).encoders(encoders).build());
    configs.add(ServerEndpointConfig.Builder.create(SupportChatEndpoint.class, "/support").decoders(decoders).encoders(encoders).build());
    return configs;
}
 
開發者ID:rcuprak,項目名稱:actionbazaar,代碼行數:15,代碼來源:ChatEndpointConfig.java

示例12: processRequest

import javax.websocket.Encoder; //導入依賴的package包/類
/**
 * Processes requests for both HTTP
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    try (PrintWriter out = response.getWriter()) {
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet TestServlet</title>");            
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet TestServlet at " + request.getContextPath() + "</h1>");
        
        List<Class<? extends Encoder>> encoders = new ArrayList<>();
        encoders.add(MyMessageEncoder.class);
        List<Class<? extends Decoder>> decoders = new ArrayList<>();
        decoders.add(MyMessageDecoder.class);

        WebSocketContainer container = ContainerProvider.getWebSocketContainer();
        String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";
        out.println("Connecting to " + uri);
        container.connectToServer(MyClient.class, 
                ClientEndpointConfig.Builder.create()
                .encoders(encoders)
                .decoders(decoders)
                .build(),
                URI.create(uri));
        out.println("<br><br>Look in server.log for message exchange between client/server.");
        
        out.println("</body>");
        out.println("</html>");
    } catch (DeploymentException ex) {
        Logger.getLogger(TestClient.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
開發者ID:ftomassetti,項目名稱:JavaIncrementalParser,代碼行數:44,代碼來源:TestClient.java

示例13: EncoderEntry

import javax.websocket.Encoder; //導入依賴的package包/類
public EncoderEntry(Class<?> clazz, Encoder encoder) {
    this.clazz = clazz;
    this.encoder = encoder;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:5,代碼來源:WsRemoteEndpointImplBase.java

示例14: getEncoder

import javax.websocket.Encoder; //導入依賴的package包/類
public Encoder getEncoder() {
    return encoder;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:4,代碼來源:WsRemoteEndpointImplBase.java

示例15: getEncoderType

import javax.websocket.Encoder; //導入依賴的package包/類
static Class<?> getEncoderType(Class<? extends Encoder> encoder) {
    return Util.getGenericType(Encoder.class, encoder).getClazz();
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:4,代碼來源:Util.java


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