T - Type of the data contained within a notification@Beta public abstract class JsonNotificationCallback<T> extends TypedNotificationCallback<T>
Beta TypedNotificationCallback which uses an JSON content encoding.
Must NOT be implemented in form of an anonymous class as this will break serialization.
Implementation should be thread-safe.
Example usage:
static class MyNotificationCallback
extends JsonNotificationCallback<ListResponse> {
private static final long serialVersionUID = 1L;
@Override
protected void onNotification(
StoredChannel channel, TypedNotification<ListResponse> notification) {
ListResponse content = notification.getContent();
switch (notification.getResourceState()) {
case ResourceStates.SYNC:
break;
case ResourceStates.EXISTS:
break;
case ResourceStates.NOT_EXISTS:
break;
}
}
@Override
protected JsonFactory getJsonFactory() throws IOException {
return new JacksonFactory();
}
@Override
protected Class<ListResponse> getDataClass() throws IOException {
return ListResponse.class;
}
}
| Constructor and Description |
|---|
JsonNotificationCallback() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract com.google.api.client.json.JsonFactory |
getJsonFactory()
Returns the JSON factory to use to parse the notification content.
|
protected com.google.api.client.json.JsonObjectParser |
getObjectParser()
Returns an
ObjectParser which can be used to parse this notification. |
getDataClass, onNotification, onNotificationprotected final com.google.api.client.json.JsonObjectParser getObjectParser()
throws IOException
TypedNotificationCallbackObjectParser which can be used to parse this notification.getObjectParser in class TypedNotificationCallback<T>IOExceptionprotected abstract com.google.api.client.json.JsonFactory getJsonFactory()
throws IOException
IOExceptionCopyright © 2010-2013 Google. All Rights Reserved.