下面列出了怎么用com.fasterxml.jackson.core.async.NonBlockingInputFeeder的API类实例代码及写法,或者点击链接到github查看源代码。
private static <T> StreamingDeserializer<T> newDeserializer(ObjectReader reader) {
final JsonFactory factory = reader.getFactory();
final JsonParser parser;
try {
// TODO(scott): ByteBufferFeeder is currently not supported by jackson, and the current API throws
// UnsupportedOperationException if not supported. When jackson does support two NonBlockingInputFeeder
// types we need an approach which doesn't involve catching UnsupportedOperationException to try to get
// ByteBufferFeeder and then ByteArrayFeeder.
parser = factory.createNonBlockingByteArrayParser();
} catch (IOException e) {
throw new IllegalArgumentException("parser initialization error for factory: " + factory, e);
}
NonBlockingInputFeeder rawFeeder = parser.getNonBlockingInputFeeder();
if (rawFeeder instanceof ByteBufferFeeder) {
return new ByteBufferJacksonDeserializer<>(reader, parser, (ByteBufferFeeder) rawFeeder);
}
if (rawFeeder instanceof ByteArrayFeeder) {
return new ByteArrayJacksonDeserializer<>(reader, parser, (ByteArrayFeeder) rawFeeder);
}
throw new IllegalArgumentException("unsupported feeder type: " + rawFeeder);
}
@Override
public NonBlockingInputFeeder getNonBlockingInputFeeder() {
return jsonParser.getNonBlockingInputFeeder();
}
/**
* Method that will either return a feeder instance (if parser uses
* non-blocking, aka asynchronous access); or <code>null</code> for
* parsers that use blocking I/O.
*
* @since 2.9
*/
public NonBlockingInputFeeder getNonBlockingInputFeeder() {
return null;
}