Search in sources :

Example 1 with RpcHint

use of com.navercorp.pinpoint.web.filter.RpcHint in project pinpoint by naver.

the class FilterHintListJsonDeserializer method deserialize.

@Override
public FilterHint deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    if (!jp.getCurrentToken().isStructStart()) {
        throw ctxt.mappingException(RpcHint.class, jp.getCurrentToken());
    }
    // skip json start
    final JsonToken jsonToken = jp.nextToken();
    if (jsonToken == JsonToken.END_OBJECT) {
        return new FilterHint(Collections.<RpcHint>emptyList());
    }
    List<RpcHint> rpcHintList = new ArrayList<>();
    while (true) {
        final RpcHint rpcHint = jp.readValueAs(RpcHint.class);
        rpcHintList.add(rpcHint);
        if (jp.nextToken() == JsonToken.END_OBJECT) {
            break;
        }
    }
    return new FilterHint(rpcHintList);
}
Also used : FilterHint(com.navercorp.pinpoint.web.filter.FilterHint) ArrayList(java.util.ArrayList) JsonToken(com.fasterxml.jackson.core.JsonToken) RpcHint(com.navercorp.pinpoint.web.filter.RpcHint)

Example 2 with RpcHint

use of com.navercorp.pinpoint.web.filter.RpcHint in project pinpoint by naver.

the class RpcHintJsonDeserializer method deserialize.

@Override
public RpcHint deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    final String applicationName = jp.getText();
    if (jp.nextToken() != JsonToken.START_ARRAY) {
        throw ctxt.mappingException(RpcHint.class, jp.getCurrentToken());
    }
    // skip start array
    final JsonToken token = jp.nextToken();
    // [] empty array
    if (token == JsonToken.END_ARRAY) {
        return new RpcHint(applicationName, Collections.<RpcType>emptyList());
    }
    final List<RpcType> rpcHintList = new ArrayList<>();
    while (true) {
        RpcType rpcType = jp.readValueAs(RpcType.class);
        rpcHintList.add(rpcType);
        if (jp.nextToken() == JsonToken.END_ARRAY) {
            break;
        }
    }
    return new RpcHint(applicationName, rpcHintList);
}
Also used : RpcType(com.navercorp.pinpoint.web.filter.RpcType) ArrayList(java.util.ArrayList) JsonToken(com.fasterxml.jackson.core.JsonToken) RpcHint(com.navercorp.pinpoint.web.filter.RpcHint)

Aggregations

JsonToken (com.fasterxml.jackson.core.JsonToken)2 RpcHint (com.navercorp.pinpoint.web.filter.RpcHint)2 ArrayList (java.util.ArrayList)2 FilterHint (com.navercorp.pinpoint.web.filter.FilterHint)1 RpcType (com.navercorp.pinpoint.web.filter.RpcType)1