diff --git a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/ErrorServlet.java b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/ErrorServlet.java
index 49e96ffbf0c..20a6779207c 100644
--- a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/ErrorServlet.java
+++ b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/ErrorServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,30 +16,32 @@
package com.example.appengine.xmpp;
+import com.google.common.io.ByteStreams;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.logging.Logger;
+
import javax.servlet.ServletInputStream;
-import javax.servlet.http.*;
-import com.google.common.io.ByteStreams;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
// [START example]
@SuppressWarnings("serial")
public class ErrorServlet extends HttpServlet {
+ private static final Logger log = Logger.getLogger(ErrorServlet.class.getName());
- private static final Logger log = Logger.getLogger(ErrorServlet.class.getName());
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws IOException {
-
- // Parse the POST data, which is sent as a MIME stream containing the stanza.
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ServletInputStream inputStream = req.getInputStream();
- ByteStreams.copy(inputStream, baos);
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse res)
+ throws IOException {
+ // Parse the POST data, which is sent as a MIME stream containing the stanza.
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ServletInputStream inputStream = req.getInputStream();
+ ByteStreams.copy(inputStream, baos);
- // Log the error
- log.warning("Error stanza received: " + baos.toString());
- }
+ // Log the error
+ log.warning("Error stanza received: " + baos.toString());
+ }
}
// [END example]
diff --git a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageReceiverServlet.java b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageReceiverServlet.java
index 2115c5cca7b..d43754048a2 100644
--- a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageReceiverServlet.java
+++ b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageReceiverServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,32 +16,35 @@
package com.example.appengine.xmpp;
-import java.io.IOException;
-import java.util.logging.Logger;
-import javax.servlet.http.*;
import com.google.appengine.api.xmpp.JID;
import com.google.appengine.api.xmpp.Message;
import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
// [START example]
@SuppressWarnings("serial")
public class MessageReceiverServlet extends HttpServlet {
+ private static final Logger log = Logger.getLogger(MessageReceiverServlet.class.getName());
- private static final Logger log = Logger.getLogger(MessageReceiverServlet.class.getName());
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws IOException {
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse res)
+ throws IOException {
- XMPPService xmpp = XMPPServiceFactory.getXMPPService();
- Message message = xmpp.parseMessage(req);
+ XMPPService xmpp = XMPPServiceFactory.getXMPPService();
+ Message message = xmpp.parseMessage(req);
- JID fromJid = message.getFromJid();
- String body = message.getBody();
+ JID fromJid = message.getFromJid();
+ String body = message.getBody();
- log.info("Received a message with id: " + fromJid + " and body: " + body);
- // ...
- }
+ log.info("Received a message with id: " + fromJid + " and body: " + body);
+ // ...
+ }
}
// [END example]
diff --git a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageSenderServlet.java b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageSenderServlet.java
index 4264c5190ef..05461091698 100644
--- a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageSenderServlet.java
+++ b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/MessageSenderServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,9 +16,6 @@
package com.example.appengine.xmpp;
-import java.io.IOException;
-import java.util.logging.Logger;
-import javax.servlet.http.*;
import com.google.appengine.api.xmpp.JID;
import com.google.appengine.api.xmpp.Message;
import com.google.appengine.api.xmpp.MessageBuilder;
@@ -26,33 +23,40 @@
import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
// [START example]
@SuppressWarnings("serial")
public class MessageSenderServlet extends HttpServlet {
+ private static final Logger log = Logger.getLogger(MessageSenderServlet.class.getName());
- private static final Logger log = Logger.getLogger(MessageSenderServlet.class.getName());
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse res)
- throws IOException {
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
+ throws IOException {
- JID jid = new JID("example@gmail.com");
- String msgBody = "Someone has sent you a gift on Example.com. To view: http://example.com/gifts/";
- Message msg = new MessageBuilder()
+ JID jid = new JID("example@gmail.com");
+ String msgBody = "Someone has sent you a gift on Example.com. To view: http://example.com/gifts/";
+ Message msg =
+ new MessageBuilder()
.withRecipientJids(jid)
.withBody(msgBody)
.build();
- boolean messageSent = false;
- XMPPService xmpp = XMPPServiceFactory.getXMPPService();
- SendResponse status = xmpp.sendMessage(msg);
- messageSent = (status.getStatusMap().get(jid) == SendResponse.Status.SUCCESS);
+ boolean messageSent = false;
+ XMPPService xmpp = XMPPServiceFactory.getXMPPService();
+ SendResponse status = xmpp.sendMessage(msg);
+ messageSent = (status.getStatusMap().get(jid) == SendResponse.Status.SUCCESS);
- log.info("Message sent? " + messageSent);
+ log.info("Message sent? " + messageSent);
- if (!messageSent) {
- // Send an email message instead...
- }
+ if (!messageSent) {
+ // Send an email message instead...
}
+ }
}
// [END example]
diff --git a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/PresenceServlet.java b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/PresenceServlet.java
index f85486fa288..1af7e0bea5a 100644
--- a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/PresenceServlet.java
+++ b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/PresenceServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,35 +16,42 @@
package com.example.appengine.xmpp;
-import java.io.IOException;
-import java.util.logging.Logger;
-import javax.servlet.http.*;
import com.google.appengine.api.xmpp.Presence;
import com.google.appengine.api.xmpp.PresenceType;
import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
// [START example]
@SuppressWarnings("serial")
public class PresenceServlet extends HttpServlet {
+ private static final Logger log = Logger.getLogger(PresenceServlet.class.getName());
- private static final Logger log = Logger.getLogger(PresenceServlet.class.getName());
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws IOException {
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse res)
+ throws IOException {
- XMPPService xmpp = XMPPServiceFactory.getXMPPService();
- Presence presence = xmpp.parsePresence(req);
+ XMPPService xmpp = XMPPServiceFactory.getXMPPService();
+ Presence presence = xmpp.parsePresence(req);
- // Split the XMPP address (e.g., user@gmail.com)
- // from the resource (e.g., gmail.CD6EBC4A)
- String from = presence.getFromJid().getId().split("/")[0];
+ // Split the XMPP address (e.g., user@gmail.com)
+ // from the resource (e.g., gmail.CD6EBC4A)
+ String from = presence.getFromJid().getId().split("/")[0];
- log.info("Received presence from: " + from);
+ log.info("Received presence from: " + from);
- // Mirror the contact's presence back to them
- xmpp.sendPresence(presence.getFromJid(), PresenceType.AVAILABLE, presence.getPresenceShow(), presence.getStatus());
- }
+ // Mirror the contact's presence back to them
+ xmpp.sendPresence(
+ presence.getFromJid(),
+ PresenceType.AVAILABLE,
+ presence.getPresenceShow(),
+ presence.getStatus());
+ }
}
// [END example]
diff --git a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/SubscriptionServlet.java b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/SubscriptionServlet.java
index 9f7f2832350..e330006109f 100644
--- a/appengine/xmpp/src/main/java/com/example/appengine/xmpp/SubscriptionServlet.java
+++ b/appengine/xmpp/src/main/java/com/example/appengine/xmpp/SubscriptionServlet.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,31 +16,33 @@
package com.example.appengine.xmpp;
-import java.io.IOException;
-import java.util.logging.Logger;
-import javax.servlet.http.*;
import com.google.appengine.api.xmpp.Subscription;
import com.google.appengine.api.xmpp.XMPPService;
import com.google.appengine.api.xmpp.XMPPServiceFactory;
+import java.io.IOException;
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
// [START example]
@SuppressWarnings("serial")
public class SubscriptionServlet extends HttpServlet {
+ private static final Logger log = Logger.getLogger(SubscriptionServlet.class.getName());
- private static final Logger log = Logger.getLogger(SubscriptionServlet.class.getName());
-
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse res)
- throws IOException {
-
- XMPPService xmppService = XMPPServiceFactory.getXMPPService();
- Subscription sub = xmppService.parseSubscription(req);
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse res)
+ throws IOException {
+ XMPPService xmppService = XMPPServiceFactory.getXMPPService();
+ Subscription sub = xmppService.parseSubscription(req);
- // Split the bare XMPP address (e.g., user@gmail.com)
- // from the resource (e.g., gmail.CD6EBC4A)
- String from = sub.getFromJid().getId().split("/")[0];
+ // Split the bare XMPP address (e.g., user@gmail.com)
+ // from the resource (e.g., gmail.CD6EBC4A)
+ String from = sub.getFromJid().getId().split("/")[0];
- log.info("Received subscription event from: " + from);
- }
+ log.info("Received subscription event from: " + from);
+ }
}
// [END example]
diff --git a/pom.xml b/pom.xml
index cb181a14a9e..69f7d3e9fc4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,6 +62,7 @@
appengine/twilio
appengine/urlfetch
appengine/users
+ appengine/xmpp
bigquery
compute/cmdline
datastore