Package com.google.api.client.googleapis.notifications (2.0.0)

com.google.api.client.util.Beta
Support for notification channels to listen for changes to watched Google API resources.

Classes

AbstractNotification

Beta
Notification metadata sent to this client about a watched resource.

Implementation is not thread-safe.

NotificationUtils

Utilities for notifications and notification channels.

ResourceStates

Beta
Standard resource states used by notifications.

StoredChannel

Beta
Notification channel information to be stored in a data store.

Implementation is thread safe.

TypedNotification<T>

Beta
Notification metadata and parsed content sent to this client about a watched resource.

Implementation is not thread-safe.

TypedNotificationCallback<T>

Beta
Callback to receive notifications for watched resource in which the . Callback which is used to receive typed 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{@literal <}listresponse{@literal>} {

   private static final long serialVersionUID = 1L;

   {@literal @}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;
     }
   }

    {@literal @}Override
    protected ObjectParser getObjectParser(Notification notification) throws IOException {
      return new JsonObjectParser(new GsonFactory());
    }

    {@literal @}Override
    protected Class{@literal <}listresponse{@literal>} getDataClass() throws IOException {
      return ListResponse.class;
    }
 }
 

UnparsedNotification

Beta
Notification metadata and unparsed content stream sent to this client about a watched resource.

Implementation is not thread-safe.

Interfaces

UnparsedNotificationCallback

Beta
Callback to receive unparsed notifications for watched resource.

Must NOT be implemented in form of an anonymous class since this would break serialization.

Should be thread-safe as several notifications might be processed at the same time. Example usage:


 static class MyNotificationCallback implements UnparsedNotificationCallback {

   private static final long serialVersionUID = 1L;

   {@literal @}Override
   public void onNotification(StoredChannel storedChannel, UnparsedNotification notification) {
     String contentType = notification.getContentType();
     InputStream contentStream = notification.getContentStream();
     switch (notification.getResourceState()) {
       case ResourceStates.SYNC:
         break;
       case ResourceStates.EXISTS:
         break;
       case ResourceStates.NOT_EXISTS:
         break;
     }
   }
 }