package com.megatim.fdxconsultation.service.impl.sockets.encoders;
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.megatim.fdxconsultation.model.supervision.StandaloneServerStateEntity;
|
import javax.websocket.DecodeException;
|
import javax.websocket.Decoder;
|
import javax.websocket.EndpointConfig;
|
|
/**
|
*
|
* @author lenovo
|
*/
|
public class StandaloneServerStateEntityDecoder implements Decoder.Text<StandaloneServerStateEntity> {
|
|
private ObjectMapper objectMapper = new ObjectMapper();
|
|
@Override
|
public StandaloneServerStateEntity decode(String s) throws DecodeException {
|
try {
|
return objectMapper.readValue(s, new TypeReference<StandaloneServerStateEntity>() {});
|
} catch (Exception e) {
|
throw new DecodeException(s, "Unable to decode map", e);
|
}
|
}
|
|
@Override
|
public boolean willDecode(String s) {
|
return s != null;
|
}
|
|
@Override
|
public void init(EndpointConfig endpointConfig) {
|
}
|
|
@Override
|
public void destroy() {
|
}
|
}
|