<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 07/02/2013 09:13 AM, Sebastien Blanc
wrote:<br>
</div>
<blockquote
cite="mid:CAD_dpu3ku82zxjU4T9okywWw3zMr4s8xNN56pPcrGuZB4iKA3g@mail.gmail.com"
type="cite">
<div dir="ltr">Hi Folks,
<div style="">As you know we have a Java Sender Library that can
be used by any backend application that want to send messages
to the Unified Message Push Server (<a moz-do-not-send="true"
href="https://github.com/aerogear/aerogear-unified-push-java-client">https://github.com/aerogear/aerogear-unified-push-java-client</a>).</div>
<div style="">The format is quite open and flexible as
Matthias described it here : <a moz-do-not-send="true"
href="https://gist.github.com/matzew/b21c1404cc093825f0fb">https://gist.github.com/matzew/b21c1404cc093825f0fb</a><br>
</div>
<div style="">We can divide the creation of a message in 2 main
parts :</div>
<div style=""><br>
</div>
<div style="">- The "signalling" part : list of client
identifiers / specific devices etc ...</div>
<div style="">- The "core" message containing actually the
information we want to push</div>
<div style=""><br>
</div>
<div style="">Both are passed as Map and are finally converted
into JSON. </div>
<div style="">Here an example of how a "core" message is build :</div>
<div style=""><br>
</div>
<div style="">
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;line-height:19px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0);margin-top:0px!important"><code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Map categories = new HashMap();
categories.put("lead", "version="+leadVersion++);
Map json = new HashMap();
json.put("id", lead.getId());
json.put("messageType", "pushed_lead");
json.put("name", lead.getName());
json.put("location", lead.getLocation());
json.put("phone", lead.getPhoneNumber());
json.put("simple-push", categories);
json.put("sound" ,"default");
json.put("alert" ,"A new lead has been created");</code></pre>
</div>
<div style=""><br>
</div>
<div style="">Even the format is open, we could "assist" a bit
the developer in building the message. For that we have
different options : </div>
<div style="">- Propose a simple Message object containing the
message "API" :</div>
<div style=""><br>
</div>
<div style="">
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;line-height:19px;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0)"><code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Message message = new Message();
message.setClientIdentifiers("jake","maria");
message.enableSound();//by default use "default" or we could do message.enableSound("boing")
message.setAlert("Watch out!);
message.setAttribute("customAttribute","yo"); // custom simple strings
message.setAttribute("customStructure",myObject); // passing objects</code></pre>
</div>
<div style=""><br>
</div>
<div style="">- Propose a Message Builder (following the Builder
Pattern) to propose a more fluent API : </div>
<div style=""><br>
</div>
<div style="">
<pre style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:13px;line-height:19px;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0)"><code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Message message = new Message().builder()
.clientIdentifiers("jake","maria")
.enableSound()
.alert("AAAAHHH!")
.attribute("customAttribute","yo")
.attribute("customStructure",myObject)
.build()</code></pre>
</div>
<div style=""><br>
</div>
<div style="">- Same as above but more DSL focused (not sure
about this one ;) )</div>
<div style="">
<pre style="font-size:13px;font-family:Consolas,'Liberation Mono',Courier,monospace;line-height:19px;margin-top:15px;margin-bottom:15px;background-color:rgb(248,248,248);border:1px solid rgb(221,221,221);overflow:auto;padding:6px 10px;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(0,0,0)"><code style="font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:normal;margin:0px;padding:0px;border:none;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Message message = MessageDSL.to(<span style="background-color:transparent">"jake","maria").withSound() //etc ...</span>
</code></pre>
</div>
<div style=""><br>
</div>
<div style="">So, beside that we have to discuss what we want
allow to pass to the message API : only Strings and simple
Maps ? Full Objects that will be JSONified ? <br>
</div>
</div>
</blockquote>
+1 to Strings and Simple Maps. JSONIfying full objects can be error
prone/tricky sometimes so -.5 to that.<br>
I don't hate it would rather just not give people that gun to shoot
themselves with so soon ;)<br>
<blockquote
cite="mid:CAD_dpu3ku82zxjU4T9okywWw3zMr4s8xNN56pPcrGuZB4iKA3g@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style="">
<br>
</div>
<div style="">Do we want also to separate the "signalling" part
from the "core" part when building a message ? </div>
<div style=""><br>
</div>
<div style="">Inputs and comments more than welcome !</div>
</div>
</blockquote>
I like the Builder. It is very simple, very neutral, and very
exact.<br>
<blockquote
cite="mid:CAD_dpu3ku82zxjU4T9okywWw3zMr4s8xNN56pPcrGuZB4iKA3g@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style=""><br>
</div>
<div style="">Seb</div>
<div style=""><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
aerogear-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></pre>
</blockquote>
<br>
</body>
</html>