Monday, June 24, 2013

Life Behind Proxy - gradle

today, brought another challenge, making gradlew/gradle working from behind corporate proxy. Solution/Failure article comming soon I hope. Update: 23:11 I gave up, proxy scanning makes all unusable, instead of configuring proxy changing repository URL to local nexus.
sed -i "s;repo.springsource.org/libs-milestone;nexushost/nexus/content/groups/public;" build.gradle
TODO: some "global" remapping line in .m2 ? without touching each build.gradle ?

Tuesday, June 11, 2013

webmessaging, postMessage and naive properties access

Sometimes I tend to put debug codes to dump method arguments. My favorite construction is
console.debug("dumpEvent:", evt); 
instead of often seen:
console.debug("dumpEvent:"+evt);
However, using this code is not a good idea with cross domain integration code:
win.global.addEventListener("message", dumpEvent);
function dumpEvent(evt) {
 // this will raise some errors in console
 // Blocked a frame with origin "http://a" from accessing 
 // a frame with origin "http://b". 
 // Protocols, domains, and ports must match.
 console.debug("dumpEvent", evt); // not a good idea
}

win.global.addEventListener("message", dumpEventProperties);
function dumpEventProperties(evt) {
 // this shall work, dump only properies specified in: 
 // http://www.w3.org/TR/webmessaging/
 console.debug("dumpEvent", {
  data : evt.data,
  origin : evt.origin,
  lastEventId : evt.lastEventId,
  //source : evt.source, //and this is the cause of problem ;-)
  ports : evt.ports
 });
}
So be aware, sometimes your logging statements can produce errors as well ;-)