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


Java Decoder类代码示例

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


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

示例1: decode

import javax.websocket.Decoder; //导入依赖的package包/类
@Override
protected Object decode(ByteBuffer message) throws DecodeException {
    for (Decoder decoder : decoders) {
        if (decoder instanceof Binary) {
            if (((Binary<?>) decoder).willDecode(message)) {
                return ((Binary<?>) decoder).decode(message);
            }
        } else {
            byte[] array = new byte[message.limit() - message.position()];
            message.get(array);
            ByteArrayInputStream bais = new ByteArrayInputStream(array);
            try {
                return ((BinaryStream<?>) decoder).decode(bais);
            } catch (IOException ioe) {
                throw new DecodeException(message, sm.getString(
                        "pojoMessageHandlerWhole.decodeIoFail"), ioe);
            }
        }
    }
    return null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:PojoMessageHandlerWholeBinary.java

示例2: decode

import javax.websocket.Decoder; //导入依赖的package包/类
@Override
protected Object decode(String message) throws DecodeException {
    // Handle primitives
    if (primitiveType != null) {
        return Util.coerceToType(primitiveType, message);
    }
    // Handle full decoders
    for (Decoder decoder : decoders) {
        if (decoder instanceof Text) {
            if (((Text<?>) decoder).willDecode(message)) {
                return ((Text<?>) decoder).decode(message);
            }
        } else {
            StringReader r = new StringReader(message);
            try {
                return ((TextStream<?>) decoder).decode(r);
            } catch (IOException ioe) {
                throw new DecodeException(message, sm.getString(
                        "pojoMessageHandlerWhole.decodeIoFail"), ioe);
            }
        }
    }
    return null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:PojoMessageHandlerWholeText.java

示例3: DefaultServerEndpointConfig

import javax.websocket.Decoder; //导入依赖的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

示例4: decode

import javax.websocket.Decoder; //导入依赖的package包/类
@Override
protected Object decode(ByteBuffer message) throws DecodeException {
	for (Decoder decoder : decoders) {
		if (decoder instanceof Binary) {
			if (((Binary<?>) decoder).willDecode(message)) {
				return ((Binary<?>) decoder).decode(message);
			}
		} else {
			byte[] array = new byte[message.limit() - message.position()];
			message.get(array);
			ByteArrayInputStream bais = new ByteArrayInputStream(array);
			try {
				return ((BinaryStream<?>) decoder).decode(bais);
			} catch (IOException ioe) {
				throw new DecodeException(message, sm.getString("pojoMessageHandlerWhole.decodeIoFail"), ioe);
			}
		}
	}
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:21,代码来源:PojoMessageHandlerWholeBinary.java

示例5: decode

import javax.websocket.Decoder; //导入依赖的package包/类
@Override
protected Object decode(String message) throws DecodeException {
	// Handle primitives
	if (primitiveType != null) {
		return Util.coerceToType(primitiveType, message);
	}
	// Handle full decoders
	for (Decoder decoder : decoders) {
		if (decoder instanceof Text) {
			if (((Text<?>) decoder).willDecode(message)) {
				return ((Text<?>) decoder).decode(message);
			}
		} else {
			StringReader r = new StringReader(message);
			try {
				return ((TextStream<?>) decoder).decode(r);
			} catch (IOException ioe) {
				throw new DecodeException(message, sm.getString("pojoMessageHandlerWhole.decodeIoFail"), ioe);
			}
		}
	}
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:24,代码来源:PojoMessageHandlerWholeText.java

示例6: createConfiguredServerEndpoint

import javax.websocket.Decoder; //导入依赖的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

示例7: createWsServerEndpointConfig

import javax.websocket.Decoder; //导入依赖的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

示例8: createEventbusServerEndpointConfig

import javax.websocket.Decoder; //导入依赖的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

示例9: buildServerEndpointConfig

import javax.websocket.Decoder; //导入依赖的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

示例10: PojoEndpointClient

import javax.websocket.Decoder; //导入依赖的package包/类
public PojoEndpointClient(Object pojo,
        List<Class<? extends Decoder>> decoders) throws DeploymentException {
    setPojo(pojo);
    setMethodMapping(
            new PojoMethodMapping(pojo.getClass(), decoders, null));
    setPathParameters(Collections.<String,String>emptyMap());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:8,代码来源:PojoEndpointClient.java

示例11: matchDecoders

import javax.websocket.Decoder; //导入依赖的package包/类
private static List<Class<? extends Decoder>> matchDecoders(Class<?> target,
        EndpointConfig endpointConfig, boolean binary) {
    DecoderMatch decoderMatch = matchDecoders(target, endpointConfig);
    if (binary) {
        if (decoderMatch.getBinaryDecoders().size() > 0) {
            return decoderMatch.getBinaryDecoders();
        }
    } else if (decoderMatch.getTextDecoders().size() > 0) {
        return decoderMatch.getTextDecoders();
    }
    return null;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:13,代码来源:Util.java

示例12: DefaultServerEndpointConfig

import javax.websocket.Decoder; //导入依赖的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

示例13: init

import javax.websocket.Decoder; //导入依赖的package包/类
@PostConstruct
public void init(){
    try {
        WebSocketContainer webSocketContainer = ContainerProvider.getWebSocketContainer();
        List<Class<? extends Decoder>> decoders = new ArrayList<>();
        decoders.add(MeetupRSVPJSONDecoder.class);
        session = webSocketContainer.connectToServer(new MeetupRSVPsWebSocketClient(),
                ClientEndpointConfig.Builder.create().decoders(decoders).build(),
                URI.create("ws://stream.meetup.com/2/rsvps"));
    } catch (DeploymentException | IOException ex) {
        Logger.getLogger(MeetupRSVPsWebSocketClientSession.class.getName()).log(Level.SEVERE, null, ex);
    }
   
}
 
开发者ID:abhirockzz,项目名称:redis-websocket-javaee,代码行数:15,代码来源:MeetupRSVPsWebSocketClientSession.java

示例14: matchDecoders

import javax.websocket.Decoder; //导入依赖的package包/类
private static List<Class<? extends Decoder>> matchDecoders(Class<?> target, EndpointConfig endpointConfig,
		boolean binary) {
	DecoderMatch decoderMatch = matchDecoders(target, endpointConfig);
	if (binary) {
		if (decoderMatch.getBinaryDecoders().size() > 0) {
			return decoderMatch.getBinaryDecoders();
		}
	} else if (decoderMatch.getTextDecoders().size() > 0) {
		return decoderMatch.getTextDecoders();
	}
	return null;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:13,代码来源:Util.java

示例15: DefaultServerEndpointConfig

import javax.websocket.Decoder; //导入依赖的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


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