Hi,
As a newbie learning clojure, I would like to code in clojure rather than
'java disguised as clojure' and I am wondering what would it looks like for
the following typical java(shown below) implementation. which has:
1. a static class member for the logger
2. and typical imperative style coding
=============================================================
public class xmpp extends HttpServlet {
public static final Logger _log =
Logger.getLogger(xmpp.class.getName());
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException
{
try {
String strStatus = "";
XMPPService xmpp = XMPPServiceFactory.getXMPPService();
//STEP 2
Message msg = xmpp.parseMessage(req);
JID fromJid = msg.getFromJid();
String body = msg.getBody();
_log.info("Received a message from " + fromJid + " and body = "
+ body);
//STEP 3
String msgBody = "You sent me : " + body;
Message replyMessage = new MessageBuilder()
.withRecipientJids(fromJid)
.withBody(msgBody)
.build();
//STEP 4
boolean messageSent = false;
SendResponse status = xmpp.sendMessage(replyMessage);
messageSent = (status.getStatusMap().get(fromJid) ==
SendResponse.Status.SUCCESS);
//STEP 5
if (messageSent) {
strStatus = "Message has been sent successfully";
}
else {
strStatus = "Message could not be sent";
}
_log.info(strStatus);
}
catch (Exception e)
{
_log.log(Level.SEVERE,e.getMessage());
}
}
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en