com.google.appengine.api.LifecycleManager.ShutdownHook Java Examples

The following examples show how to use com.google.appengine.api.LifecycleManager.ShutdownHook. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServersStartServlet.java    From appengine-java-vm-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public void service(HttpServletRequest req, HttpServletResponse res) {
  CountServlet.localCount.getAndAdd(datastoreCount());
  final Key key = KeyFactory.createKey("Counter", getKeyName());
  LifecycleManager.getInstance()
      .setShutdownHook(
          new ShutdownHook() {
            @Override
            public void shutdown() {
              datastoreSave(key);
            }
          });
}
 
Example #2
Source File: InitializationServlet.java    From wt1 with Apache License 2.0 5 votes vote down vote up
public void registerShutdownHook() {
    LifecycleManager.getInstance().setShutdownHook(new ShutdownHook() {
        public void shutdown() {
            logger.info("App will stop");
            ProcessingQueue.getInstance().setShutdown();
        }
    });
}