@Beta
public abstract class AbstractWebHookServlet
extends javax.servlet.http.HttpServlet
Beta UnparsedNotification.
In order to use this servlet you should create a class inheriting from
AbstractWebHookServlet and register the servlet in your web.xml.
Implementation is thread-safe.
Example usage:
public class NotificationServlet extends AbstractWebHookServlet {
private static final long serialVersionUID = 1L;
@Override
protected SubscriptionStore createSubscriptionStore() {
return new CachedAppEngineSubscriptionStore();
}
}
web.xml setup:
<servlet>
<servlet-name>NotificationServlet</servlet-name>
<servlet-class>com.mypackage.NotificationServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>NotificationServlet</servlet-name>
<url-pattern>/notificiations</url-pattern>
</servlet-mapping>
<security-constraint>
<!-- Lift any ACL imposed upon the servlet -->
<web-resource-collection>
<web-resource-name>any</web-resource-name>
<url-pattern>/notifications</url-pattern>
</web-resource-collection>
</security-constraint>
| Modifier and Type | Field and Description |
|---|---|
static String |
UNSUBSCRIBE_HEADER
Name of header for the ID of the subscription for which you no longer wish to receive
notifications (used in the response to a WebHook notification).
|
| Constructor and Description |
|---|
AbstractWebHookServlet() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract SubscriptionStore |
createSubscriptionStore()
Used to get access to the subscription store in order to handle incoming notifications.
|
protected void |
doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) |
protected void |
doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp) |
SubscriptionStore |
getSubscriptionStore()
Returns the (cached) subscription store.
|
protected void |
sendUnsubscribeResponse(javax.servlet.http.HttpServletResponse resp,
UnparsedNotification notification)
Responds to a notification with a 200 OK response with the X-Unsubscribe header which causes
the subscription to be removed.
|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, servicepublic static final String UNSUBSCRIBE_HEADER
protected abstract SubscriptionStore createSubscriptionStore()
public final SubscriptionStore getSubscriptionStore()
protected void sendUnsubscribeResponse(javax.servlet.http.HttpServletResponse resp,
UnparsedNotification notification)
protected void doPost(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
IOException
doPost in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionIOExceptionprotected void doGet(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
throws javax.servlet.ServletException,
IOException
doGet in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionIOExceptionCopyright © 2010-2013 Google. All Rights Reserved.