Package com.google.api.client.googleapis.extensions.servlet.notifications (2.4.1)

com.google.api.client.util.Beta
Support for subscribing to topics and receiving notifications on servlet-based platforms.

Classes

NotificationServlet

Beta
Thread-safe Webhook Servlet to receive notifications.

In order to use this servlet you should create a class inheriting from NotificationServlet and register the servlet in your web.xml.

It is a simple wrapper around WebhookUtils#processWebhookNotification, so if you you may alternatively call that method instead from your HttpServlet#doPost with no loss of functionality. Example usage:


 public class MyNotificationServlet extends NotificationServlet {

   private static final long serialVersionUID = 1L;

   public MyNotificationServlet() throws IOException {
     super(new SomeDataStoreFactory());
   }
 }
 

Sample web.xml setup:


 {@literal <}servlet{@literal>}
 {@literal <}servlet-name{@literal>}MyNotificationServlet{@literal <} ervlet-name{@literal="">}
 {@literal <}servlet-class{@literal>}com.mypackage.MyNotificationServlet{@literal <} ervlet-class{@literal="">}
 {@literal <} ervlet{@literal="">}
 {@literal <}servlet-mapping{@literal>}
 {@literal <}servlet-name{@literal>}MyNotificationServlet{@literal <} ervlet-name{@literal="">}
 {@literal <}url-pattern{@literal>}/notifications{@literal <} rl-pattern{@literal="">}
 {@literal <} ervlet-mapping{@literal="">}
 

WARNING: by default it uses MemoryDataStoreFactory#getDefaultInstance() which means it will NOT persist the notification channels when the servlet process dies, so it is a BAD CHOICE for a production application. But it is a convenient choice when testing locally, in which case you don't need to override it, and can simply reference it directly in your web.xml file. For example:


 {@literal <}servlet{@literal>}
 {@literal <}servlet-name{@literal>}NotificationServlet{@literal <} ervlet-name{@literal="">}
 {@literal <}servlet-class{@literal>}com.google.api.client.googleapis.extensions.servlet.notificationsNotificationServlet{@literal <} ervlet-class{@literal="">}
 {@literal <} ervlet{@literal="">}
 {@literal <}servlet-mapping{@literal>}
 {@literal <}servlet-name{@literal>}NotificationServlet{@literal <} ervlet-name{@literal="">}
 {@literal <}url-pattern{@literal>}/notifications{@literal <} rl-pattern{@literal="">}
 {@literal <} ervlet-mapping{@literal="">}
 

WebhookHeaders

Beta
Headers for Webhook notifications.

WebhookUtils

Beta
Utilities for Webhook notifications.