T - Java type of the notification content@Beta public abstract class TypedNotificationCallback<T> extends java.lang.Object implements UnparsedNotificationCallback
Beta AbstractNotifications after subscribing to a topic.
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 subscription, Notification notification, ListResponse content) {
switch (notification.getResourceState()) {
case ResourceStates.SYNC:
break;
case ResourceStates.EXISTS:
break;
case ResourceStates.NOT_EXISTS:
break;
}
}
@Override
protected ObjectParser getObjectParser(Notification notification) throws IOException {
return new JsonObjectParser(new JacksonFactory());
}
@Override
protected Class <ListResponse > getDataClass() throws IOException {
return ListResponse.class;
}
}
| Constructor and Description |
|---|
TypedNotificationCallback() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract java.lang.Class<T> |
getDataClass()
Returns the data class to parse the notification content into or
Void.class if no
notification content is expected. |
protected abstract com.google.api.client.util.ObjectParser |
getObjectParser()
Returns an
ObjectParser which can be used to parse this notification. |
protected abstract void |
onNotification(StoredChannel storedChannel,
TypedNotification<T> notification)
Handles a received typed notification.
|
void |
onNotification(StoredChannel storedChannel,
UnparsedNotification notification)
Handles a received unparsed notification.
|
protected abstract void onNotification(StoredChannel storedChannel, TypedNotification<T> notification) throws java.io.IOException
storedChannel - stored notification channelnotification - typed notificationjava.io.IOExceptionprotected abstract com.google.api.client.util.ObjectParser getObjectParser()
throws java.io.IOException
ObjectParser which can be used to parse this notification.java.io.IOExceptionprotected abstract java.lang.Class<T> getDataClass() throws java.io.IOException
Void.class if no
notification content is expected.java.io.IOExceptionpublic final void onNotification(StoredChannel storedChannel, UnparsedNotification notification) throws java.io.IOException
UnparsedNotificationCallbackonNotification in interface UnparsedNotificationCallbackstoredChannel - stored notification channelnotification - unparsed notificationjava.io.IOExceptionCopyright © 2010-2019 Google. All Rights Reserved.