[seam-commits] Seam SVN: r11717 - in modules/trunk/remoting: src/main/java/org/jboss/seam/remoting and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu Dec 3 08:28:33 EST 2009


Author: shane.bryzak at jboss.com
Date: 2009-12-03 08:28:32 -0500 (Thu, 03 Dec 2009)
New Revision: 11717

Modified:
   modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml
   modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java
   modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java
   modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js
Log:
js api changes, reduced js resource size


Modified: modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml
===================================================================
--- modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml	2009-12-03 10:20:11 UTC (rev 11716)
+++ modules/trunk/remoting/examples/helloworld/src/main/webapp/helloworld.xhtml	2009-12-03 13:28:32 UTC (rev 11717)
@@ -68,7 +68,7 @@
       var callback = function(result) { alert(result); };
       
       // Get a reference to the HelloAction bean and invoke the sayHello() method
-      Seam.Component.create("org.jboss.seam.remoting.examples.helloworld.HelloAction", qualifiers).sayHello(name, callback);
+      Seam.Remoting.instance("org.jboss.seam.remoting.examples.helloworld.HelloAction", qualifiers).sayHello(name, callback);
       
       // ]]>
     }

Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java	2009-12-03 10:20:11 UTC (rev 11716)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/AnnotationsParser.java	2009-12-03 13:28:32 UTC (rev 11717)
@@ -170,6 +170,8 @@
       List<org.jboss.seam.remoting.annotationparser.syntaxtree.Annotation> annotations = 
          new ArrayList<org.jboss.seam.remoting.annotationparser.syntaxtree.Annotation>(); 
       
+      // TODO messy! turn this into a recursive function
+      
       NodeOptional n = (NodeOptional) node.f0;
       if (n.present())
       {

Modified: modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java
===================================================================
--- modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java	2009-12-03 10:20:11 UTC (rev 11716)
+++ modules/trunk/remoting/src/main/java/org/jboss/seam/remoting/InterfaceGenerator.java	2009-12-03 13:28:32 UTC (rev 11717)
@@ -405,7 +405,7 @@
          componentSrc.append("\";\n\n");
 
          // Register the component
-         componentSrc.append("Seam.Component.register(Seam.Remoting.type.");
+         componentSrc.append("Seam.Remoting.registerBean(Seam.Remoting.type.");
          componentSrc.append(beanName);
          componentSrc.append(");\n\n");
 
@@ -681,7 +681,7 @@
       // TODO fix this - a bean might not be named
       if (classType.isAnnotationPresent(Named.class))
       {
-         typeSource.append("Seam.Component.register(Seam.Remoting.type.");
+         typeSource.append("Seam.Remoting.registerBean(Seam.Remoting.type.");
       }
       else
       {

Modified: modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js
===================================================================
--- modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js	2009-12-03 10:20:11 UTC (rev 11716)
+++ modules/trunk/remoting/src/main/resources/org/jboss/seam/remoting/remote.js	2009-12-03 13:28:32 UTC (rev 11717)
@@ -1,95 +1,72 @@
-// Init base-level objects
 var Seam = new Object();
 Seam.Remoting = new Object();
-Seam.Component = new Object();
-Seam.pageContext = new Object();
+Seam.Remoting.beans = new Array();
 
-// Components registered here
-Seam.Component.components = new Array();
-Seam.Component.instances = new Array();
-
-Seam.Component.create = function(name)
-{
-  for (var i = 0; i < Seam.Component.components.length; i++)
-  {
-    if (Seam.Component.components[i].__name == name)
-    {
-      var value = new Seam.Component.components[i];
-      if (arguments.length > 1)
-      {
-        value.__qualifiers = new Array();
-        for (var j = 1; j < arguments.length; j++)
-        { 
-          value.__qualifiers.push(arguments[j]);
+Seam.Remoting.instance = function(name) {
+  var b = Seam.Remoting.beans;
+  for (var i = 0; i < b.length; i++) {
+    if (b[i].__name == name) {
+      var v = new b[i];
+      if (arguments.length > 1) {
+        v.__qualifiers = new Array();
+        for (var j = 1; j < arguments.length; j++) { 
+          v.__qualifiers.push(arguments[j]);
         }
       }
-      
-      return value;
+      return v;
     }
   }
   return null;
 }
 
-Seam.Component.getComponentType = function(obj)
-{
-  for (var i = 0; i < Seam.Component.components.length; i++)
-  {
-    if (obj instanceof Seam.Component.components[i])
-      return Seam.Component.components[i];
+Seam.Remoting.getBeanType = function(obj) {
+  var b = Seam.Remoting.beans;
+  for (var i = 0; i < b.length; i++) {
+    if (obj instanceof b[i]) return b[i];
   }
   return null;
 }
 
-Seam.Component.getComponentName = function(obj)
-{
-  var componentType = Seam.Component.getComponentType(obj);
-  return componentType ? componentType.__name : null;
+Seam.Remoting.getBeanName = function(obj) {
+  var t = Seam.Remoting.getBeanType(obj);
+  return t ? t.__name : null;
 }
 
-Seam.Component.register = function(component)
-{
-  for (var i = 0; i < Seam.Component.components.length; i++)
-  {
-    if (Seam.Component.components[i].__name == component.__name)
-    {
-      // Replace the existing component with the new one
-      Seam.Component.components[i] = component;
+Seam.Remoting.registerBean = function(bean) {
+  var b = Seam.Remoting.beans;
+  for (var i = 0; i < b.length; i++) {
+    if (b[i].__name == bean.__name) {
+      b[i] = bean;
       return;
     }
   }
-  Seam.Component.components.push(component);
-  component.__instance = null;
+  b.push(bean);
 }
 
-Seam.Component.isRegistered = function(name)
-{
-  for (var i = 0; i < Seam.Component.components.length; i++)
-  {
-    if (Seam.Component.components[i].__name == name)
+Seam.Remoting.isBeanRegistered = function(name) {
+  var b = Seam.Remoting.beans;
+  for (var i = 0; i < b.length; i++) {
+    if (b[i].__name == name)
       return true;
   }
   return false;
 }
 
-Seam.Component.getMetadata = function(obj)
-{
-  for (var i = 0; i < Seam.Component.components.length; i++)
-  {
-    if (obj instanceof Seam.Component.components[i])
-      return Seam.Component.components[i].__metadata;
+Seam.Remoting.getBeanMetadata = function(obj) {
+  var b = Seam.Remoting.beans;
+  for (var i = 0; i < b.length; i++) {
+    if (obj instanceof b[i]) return b[i].__metadata;
   }
   return null;
 }
 
-Seam.Remoting.extractEncodedSessionId = function(url) 
-{
-	var sessionId = null;
-  if (url.indexOf(';jsessionid=') >= 0)
-  {
+Seam.Remoting.extractEncodedSessionId = function(url) {
+	var sid = null;
+  if (url.indexOf(';jsessionid=') >= 0) {
     var qpos = url.indexOf('?');
-    sessionId = url.substring(url.indexOf(';jsessionid=') + 12, qpos >= 0 ? qpos : url.length); 
+    sid = url.substring(url.indexOf(';jsessionid=') + 12, qpos >= 0 ? qpos : url.length); 
   }
-	return sessionId;
+	return sid;
 }
 
 Seam.Remoting.PATH_EXECUTE = "/execute";
@@ -98,137 +75,106 @@
 
 Seam.Remoting.encodedSessionId = Seam.Remoting.extractEncodedSessionId(window.location.href);
 
-// Type declarations will live in this namespace
-Seam.Remoting.type = new Object();
+Seam.Remoting.type = new Object(); // namespace
+Seam.Remoting.types = new Array(); 
 
-// Types are registered in an array
-Seam.Remoting.types = new Array();
-
 Seam.Remoting.debug = false;
 Seam.Remoting.debugWindow = null;
 
-Seam.Remoting.setDebug = function(val)
-{
+Seam.Remoting.setDebug = function(val) {
   Seam.Remoting.debug = val;
 }
 
-// Log a message to a popup debug window
-Seam.Remoting.log = function(msg)
-{
-  if (!Seam.Remoting.debug)
-    return;
+Seam.Remoting.log = function(msg) {
+  if (!Seam.Remoting.debug) return;
 
-  if (!Seam.Remoting.debugWindow || Seam.Remoting.debugWindow.document == null)
-  {
+  if (!Seam.Remoting.debugWindow || Seam.Remoting.debugWindow.document == null) {
     var attr = "left=400,top=400,resizable=yes,scrollbars=yes,width=400,height=400";
     Seam.Remoting.debugWindow = window.open("", "__seamDebugWindow", attr);
-    if (Seam.Remoting.debugWindow)
-    {
+    if (Seam.Remoting.debugWindow) {
       Seam.Remoting.debugWindow.document.write("<html><head><title>Seam Debug Window</title></head><body></body></html>");
-      var bodyTag = Seam.Remoting.debugWindow.document.getElementsByTagName("body").item(0);
-      bodyTag.style.fontFamily = "arial";
-      bodyTag.style.fontSize = "8pt";
+      var t = Seam.Remoting.debugWindow.document.getElementsByTagName("body").item(0);
+      t.style.fontFamily = "arial";
+      t.style.fontSize = "8pt";
     }
   }
 
-  if (Seam.Remoting.debugWindow)
-  {
-    msg = msg.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
-    Seam.Remoting.debugWindow.document.write("<pre>" + (new Date()) + ": " + msg + "</pre><br/>");
+  if (Seam.Remoting.debugWindow) {
+    Seam.Remoting.debugWindow.document.write("<pre>" + (new Date()) + ": " + msg.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") + "</pre><br/>");
   }
 }
 
-Seam.Remoting.createNamespace = function(namespace)
-{
-  var parts = namespace.split(".");
-  var base = Seam.Remoting.type;
+Seam.Remoting.createNamespace = function(namespace) {
+  var p = namespace.split(".");
+  var b = Seam.Remoting.type;
   
-  for(var i = 0; i < parts.length; i++)
-  {
-    if (typeof base[parts[i]] == "undefined")
-      base[parts[i]] = new Object();
-    base = base[parts[i]];
+  for(var i = 0; i < p.length; i++) {
+    if (typeof b[p[i]] == "undefined") b[p[i]] = new Object();
+    b = b[p[i]];
   }
 }
 
-Seam.Remoting.__Context = function()
-{
+Seam.Remoting.__Context = function() {
   this.conversationId = null;
-
-  Seam.Remoting.__Context.prototype.setConversationId = function(conversationId)
-  {
+  Seam.Remoting.__Context.prototype.setConversationId = function(conversationId) {
     this.conversationId = conversationId;
   }
 
-  Seam.Remoting.__Context.prototype.getConversationId = function()
-  {
+  Seam.Remoting.__Context.prototype.getConversationId = function() {
     return this.conversationId;
   }
 }
 
-Seam.Remoting.Exception = function(msg) 
-{
+Seam.Remoting.Exception = function(msg) {
   this.message = msg;
-  
-  Seam.Remoting.Exception.prototype.getMessage = function()
-  {
+  Seam.Remoting.Exception.prototype.getMessage = function() {
     return this.message;
   }
 }
 
 Seam.Remoting.context = new Seam.Remoting.__Context();
 
-Seam.Remoting.getContext = function()
-{
+Seam.Remoting.getContext = function() {
   return Seam.Remoting.context;
 }
 
-Seam.Remoting.Map = function()
-{
+Seam.Remoting.Map = function() {
   this.elements = new Array();
 
-  Seam.Remoting.Map.prototype.size = function()
-  {
+  Seam.Remoting.Map.prototype.size = function() {
     return this.elements.length;
   }
 
-  Seam.Remoting.Map.prototype.isEmpty = function()
-  {
+  Seam.Remoting.Map.prototype.isEmpty = function() {
     return this.elements.length == 0;
   }
 
-  Seam.Remoting.Map.prototype.keySet = function()
-  {
+  Seam.Remoting.Map.prototype.keySet = function() {
     var keySet = new Array();
-    for (var i = 0; i < this.elements.length; i++)
+    for (var i = 0; i < this.elements.length; i++) {
       keySet[keySet.length] = this.elements[i].key;
+    }
     return keySet;
   }
 
-  Seam.Remoting.Map.prototype.values = function()
-  {
+  Seam.Remoting.Map.prototype.values = function() {
     var values = new Array();
-    for (var i = 0; i < this.elements.length; i++)
+    for (var i = 0; i < this.elements.length; i++) {
       values[values.length] = this.elements[i].value;
+    }
     return values;
   }
 
-  Seam.Remoting.Map.prototype.get = function(key)
-  {
-    for (var i = 0; i < this.elements.length; i++)
-    {
-      if (this.elements[i].key == key)
-        return this.elements[i].value;
+  Seam.Remoting.Map.prototype.get = function(key) {
+    for (var i = 0; i < this.elements.length; i++) {
+      if (this.elements[i].key == key) return this.elements[i].value;
     }
     return null;
   }
 
-  Seam.Remoting.Map.prototype.put = function(key, value)
-  {
-    for (var i = 0; i < this.elements.length; i++)
-    {
-      if (this.elements[i].key == key)
-      {
+  Seam.Remoting.Map.prototype.put = function(key, value) {
+    for (var i = 0; i < this.elements.length; i++) {
+      if (this.elements[i].key == key) {
         this.elements[i].value = value;
         return;
       }
@@ -236,32 +182,24 @@
     this.elements.push({key:key,value:value});
   }
 
-  Seam.Remoting.Map.prototype.remove = function(key)
-  {
-    for (var i = 0; i < this.elements.length; i++)
-    {
+  Seam.Remoting.Map.prototype.remove = function(key) {
+    for (var i = 0; i < this.elements.length; i++) {
       if (this.elements[i].key == key)
         this.elements.splice(i, 1);
     }
   }
 
-  Seam.Remoting.Map.prototype.contains = function(key)
-  {
-    for (var i = 0; i < this.elements.length; i++)
-    {
-      if (this.elements[i].key == key)
-        return true;
+  Seam.Remoting.Map.prototype.contains = function(key) {
+    for (var i = 0; i < this.elements.length; i++) {
+      if (this.elements[i].key == key) return true;
     }
     return false;
   }
 }
 
-Seam.Remoting.registerType = function(type)
-{
-  for (var i = 0; i < Seam.Remoting.types.length; i++)
-  {
-    if (Seam.Remoting.types[i].__name == type.__name)
-    {
+Seam.Remoting.registerType = function(type) {
+  for (var i = 0; i < Seam.Remoting.types.length; i++) {
+    if (Seam.Remoting.types[i].__name == type.__name) {
       Seam.Remoting.types[i] = type;
       return;
     }
@@ -269,68 +207,49 @@
   Seam.Remoting.types.push(type);
 }
 
-Seam.Remoting.createType = function(name)
-{
-  for (var i = 0; i < Seam.Remoting.types.length; i++)
-  {
+Seam.Remoting.createType = function(name) {
+  for (var i = 0; i < Seam.Remoting.types.length; i++) {
     if (Seam.Remoting.types[i].__name == name)
       return new Seam.Remoting.types[i];
   }
 }
 
-Seam.Remoting.getType = function(obj)
-{
-  for (var i = 0; i < Seam.Remoting.types.length; i++)
-  {
-    if (obj instanceof Seam.Remoting.types[i])
-      return Seam.Remoting.types[i];
+Seam.Remoting.getType = function(obj) {
+  for (var i = 0; i < Seam.Remoting.types.length; i++) {
+    if (obj instanceof Seam.Remoting.types[i]) return Seam.Remoting.types[i];
   }
   return null;
 }
 
-Seam.Remoting.getTypeName = function(obj)
-{
+Seam.Remoting.getTypeName = function(obj) {
   var type = Seam.Remoting.getType(obj);
   return type ? type.__name : null;
 }
 
-Seam.Remoting.getMetadata = function(obj)
-{
-  for (var i = 0; i < Seam.Remoting.types.length; i++)
-  {
+Seam.Remoting.getMetadata = function(obj) {
+  for (var i = 0; i < Seam.Remoting.types.length; i++) {
     if (obj instanceof Seam.Remoting.types[i])
       return Seam.Remoting.types[i].__metadata;
   }
   return null;
 }
 
-Seam.Remoting.serializeValue = function(value, type, refs)
-{
-  if (value == null)
+Seam.Remoting.serializeValue = function(value, type, refs) {
+  if (value == null) {
     return "<null/>";
-  else if (type)
-  {
+  }
+  else if (type) {
     switch (type) {
-      // Boolean
       case "bool": return "<bool>" + (value ? "true" : "false") + "</bool>";
-
-      // Numerical types
       case "number": return "<number>" + value + "</number>";
-
-      // Date
       case "date": return Seam.Remoting.serializeDate(value);
-      // Beans
       case "bean": return Seam.Remoting.getTypeRef(value, refs);
-
-      // Collections
       case "bag": return Seam.Remoting.serializeBag(value, refs);
       case "map": return Seam.Remoting.serializeMap(value, refs);
-
       default: return "<str>" + encodeURIComponent(value) + "</str>";
     }
   }
-  else // We don't know the type.. try to guess
-  {
+  else {
     switch (typeof(value)) {
       case "number":
         return "<number>" + value + "</number>";
@@ -346,403 +265,285 @@
         else
           return Seam.Remoting.getTypeRef(value, refs);
       default:
-        return "<str>" + encodeURIComponent(value) + "</str>"; // Default to String
+        return "<str>" + encodeURIComponent(value) + "</str>";
     }
   }
 }
 
-Seam.Remoting.serializeBag = function(value, refs)
-{
-  var data = "<bag>";
-
-  for (var i = 0; i < value.length; i++)
-  {
-    data += "<element>";
-    data += Seam.Remoting.serializeValue(value[i], null, refs);
-    data += "</element>";
+Seam.Remoting.serializeBag = function(value, refs) {
+  var d = "<bag>";
+  for (var i = 0; i < value.length; i++) {
+    d += "<element>";
+    d += Seam.Remoting.serializeValue(value[i], null, refs);
+    d += "</element>";
   }
-
-  data += "</bag>";
-  return data;
+  d += "</bag>";
+  return d;
 }
 
-Seam.Remoting.serializeMap = function(value, refs)
-{
-  var data = "<map>";
-
+Seam.Remoting.serializeMap = function(value, refs) {
+  var d = "<map>";
   var keyset = value.keySet();
-  for (var i = 0; i < keyset.length; i++)
-  {
-    data += "<element><k>";
-    data += Seam.Remoting.serializeValue(keyset[i], null, refs);
-    data += "</k><v>";
-    data += Seam.Remoting.serializeValue(value.get(keyset[i]), null, refs);
-    data += "</v></element>";
+  for (var i = 0; i < keyset.length; i++) {
+    d += "<element><k>";
+    d += Seam.Remoting.serializeValue(keyset[i], null, refs);
+    d += "</k><v>";
+    d += Seam.Remoting.serializeValue(value.get(keyset[i]), null, refs);
+    d += "</v></element>";
   }
 
-  data += "</map>";
-  return data;
+  d += "</map>";
+  return d;
 }
 
-Seam.Remoting.serializeDate = function(value)
-{
+Seam.Remoting.serializeDate = function(value) {
   var zeroPad = function(val, digits) { while (("" + val).length < digits) val = "0" + val; return val; };
 
-  var data = "<date>";
-  data += value.getFullYear();
-  data += zeroPad(value.getMonth() + 1, 2);
-  data += zeroPad(value.getDate(), 2);
-  data += zeroPad(value.getHours(), 2);
-  data += zeroPad(value.getMinutes(), 2);
-  data += zeroPad(value.getSeconds(), 2);
-  data += zeroPad(value.getMilliseconds(), 3);
-  data += "</date>";
-  return data;
+  return "<date>" + value.getFullYear() + zeroPad(value.getMonth() + 1, 2) + zeroPad(value.getDate(), 2) +
+    zeroPad(value.getHours(), 2) + zeroPad(value.getMinutes(), 2) + zeroPad(value.getSeconds(), 2) +
+    zeroPad(value.getMilliseconds(), 3) +"</date>";
 }
 
-Seam.Remoting.getTypeRef = function(obj, refs)
-{
+Seam.Remoting.getTypeRef = function(obj, refs) {
   var refId = -1;
-
-  for (var i = 0; i < refs.length; i++)
-  {
-    if (refs[i] == obj)
-    {
+  for (var i = 0; i < refs.length; i++) {
+    if (refs[i] == obj) {
       refId = i;
       break;
     }
   }
-
-  if (refId == -1)
-  {
+  if (refId == -1) {
     refId = refs.length;
     refs[refId] = obj;
   }
-
   return "<ref id=\"" + refId + "\"/>";
 }
 
-Seam.Remoting.serializeType = function(obj, refs)
-{
-  var data = "<bean type=\"";
+Seam.Remoting.serializeType = function(obj, refs) {
+  var d = "<bean type=\"";
+  var t = Seam.Remoting.getBeanType(obj);
+  var isComponent = t != null;
+  if (!isComponent) t = Seam.Remoting.getType(obj);
 
-  var objType = Seam.Component.getComponentType(obj);
-  var isComponent = objType != null;
-
-  if (!isComponent)
-    objType = Seam.Remoting.getType(obj);
-
-  if (!objType)
-  {
+  if (!t) {
     alert("Unknown Type error.");
     return null;
   }
 
-  data += objType.__name;
-  data += "\">\n";
+  d += t.__name;
+  d += "\">\n";
 
-  var meta = isComponent ? Seam.Component.getMetadata(obj) : Seam.Remoting.getMetadata(obj);
-  for (var i = 0; i < meta.length; i++)
-  {
-    data += "<member name=\"";
-    data += meta[i].field;
-    data += "\">";
-    data += Seam.Remoting.serializeValue(obj[meta[i].field], meta[i].type, refs);
-    data += "</member>\n";
+  var meta = isComponent ? Seam.Remoting.getBeanMetadata(obj) : Seam.Remoting.getMetadata(obj);
+  for (var i = 0; i < meta.length; i++) {
+    d += "<member name=\"";
+    d += meta[i].field;
+    d += "\">";
+    d += Seam.Remoting.serializeValue(obj[meta[i].field], meta[i].type, refs);
+    d += "</member>\n";
   }
 
-  data += "</bean>";
+  d += "</bean>";
 
-  return data;
+  return d;
 }
 
 Seam.Remoting.__callId = 0;
 
-// eval() disabled until security issues resolved.
-
-//Seam.Remoting.eval = function(expression, callback)
-//{
-//  var callId = "" + Seam.Remoting.__callId++; 
-//  var data = "<eval expr=\"";
-//  data += expression;
-//  data += "\" id=\"";
-//  data += callId;
-//  data += "\"/>";
-//  var call = {data: data, id: callId, callback: callback};  
-  
-//  var envelope = Seam.Remoting.createEnvelope(Seam.Remoting.createHeader(), data);
-//  Seam.Remoting.pendingCalls.put(call.id, call);
-  
-//  call.asyncReq = Seam.Remoting.sendAjaxRequest(envelope, Seam.Remoting.PATH_EXECUTE, Seam.Remoting.processResponse, false);
-//}
-
-Seam.Remoting.createCall = function(component, methodName, params, callback, exceptionHandler)
-{
+Seam.Remoting.createCall = function(component, methodName, params, callback, exceptionHandler) {
   var callId = "" + Seam.Remoting.__callId++;
-  if (!callback)
-    callback = component.__callback[methodName];
+  if (!callback) callback = component.__callback[methodName];
 
-  var data = "<call id=\"" + callId + "\">\n";   
-  data += "<target>" + Seam.Component.getComponentType(component).__name + "</target>";
+  var d = "<call id=\"" + callId + "\">\n";   
+  d += "<target>" + Seam.Remoting.getBeanType(component).__name + "</target>";
   
-  if (component.__qualifiers != null)
-  {
-    data += "<qualifiers>";
-    
-    for (var i = 0; i < component.__qualifiers.length; i++)
-    {
-      data += component.__qualifiers[i];
+  if (component.__qualifiers != null) {
+    d += "<qualifiers>";    
+    for (var i = 0; i < component.__qualifiers.length; i++) {
+      d += component.__qualifiers[i];
       if (i < component.__qualifiers.length - 1) data += ",";
-    }    
-    
-    data += "</qualifiers>";
+    }
+    d += "</qualifiers>";
   }
   
-  data += "<method>" + methodName + "</method>";
+  d += "<method>" + methodName + "</method>";
+  d += "<params>";
 
-  // Add parameters
-  data += "<params>";
-
   var refs = new Array();
-
-  for (var i = 0; i < params.length; i++)
-  {
-    data += "<param>";
-    data += Seam.Remoting.serializeValue(params[i], null, refs);
-    data += "</param>";
+  for (var i = 0; i < params.length; i++) {
+    d += "<param>";
+    d += Seam.Remoting.serializeValue(params[i], null, refs);
+    d += "</param>";
   }
 
-  data += "</params>";
-
-  // Add refs
-  data += "<refs>";
-  for (var i = 0; i < refs.length; i++)
-  {
-    data += "<ref id=\"" + i + "\">";
-    data += Seam.Remoting.serializeType(refs[i], refs);
-    data += "</ref>";
+  d += "</params>";
+  d += "<refs>";
+  for (var i = 0; i < refs.length; i++) {
+    d += "<ref id=\"" + i + "\">";
+    d += Seam.Remoting.serializeType(refs[i], refs);
+    d += "</ref>";
   }
-  data += "</refs>";
+  d += "</refs>";
+  d += "</call>";
 
-  data += "</call>";
-
-  return {data: data, id: callId, callback: callback, exceptionHandler: exceptionHandler};
+  return {data: d, id: callId, callback: callback, exceptionHandler: exceptionHandler};
 }
 
-Seam.Remoting.createHeader = function()
-{
-  var header = "";
-
-  header += "<context>";
-  if (Seam.Remoting.getContext().getConversationId())
-  {
-    header += "<conversationId>";
-    header += Seam.Remoting.getContext().getConversationId();
-    header += "</conversationId>";
+Seam.Remoting.createHeader = function() {
+  var h = "<context>";
+  if (Seam.Remoting.getContext().getConversationId()) {
+    h += "<conversationId>";
+    h += Seam.Remoting.getContext().getConversationId();
+    h += "</conversationId>";
   }
-  header += "</context>";
-
-  return header;
+  h += "</context>";
+  return h;
 }
 
-Seam.Remoting.createEnvelope = function(header, body)
-{
-  var data = "<envelope>";
-
-  if (header)
-  {
-    data += "<header>";
-    data += header;
-    data += "</header>";
-  }
-
-  if (body)
-  {
-    data += "<body>";
-    data += body;
-    data += "</body>";
-  }
-
-  data += "</envelope>";
-
-  return data;
+Seam.Remoting.createEnvelope = function(header, body) {
+  var d = "<envelope>";
+  if (header) d += "<header>" + header + "</header>";
+  if (body) d += "<body>" + body + "</body>";
+  d += "</envelope>";
+  return d;
 }
 
 Seam.Remoting.pendingCalls = new Seam.Remoting.Map();
 Seam.Remoting.inBatch = false;
 Seam.Remoting.batchedCalls = new Array();
 
-Seam.Remoting.startBatch = function()
-{
+Seam.Remoting.startBatch = function() {
   Seam.Remoting.inBatch = true;
   Seam.Remoting.batchedCalls.length = 0;
 }
 
-Seam.Remoting.executeBatch = function()
-{
-  if (!Seam.Remoting.inBatch)
-    return;
+Seam.Remoting.executeBatch = function() {
+  if (!Seam.Remoting.inBatch) return;
 
-  var data = "";
-  for (var i = 0; i < Seam.Remoting.batchedCalls.length; i++)
-  {
+  var d = "";
+  for (var i = 0; i < Seam.Remoting.batchedCalls.length; i++) {
     Seam.Remoting.pendingCalls.put(Seam.Remoting.batchedCalls[i].id, Seam.Remoting.batchedCalls[i]);
-    data += Seam.Remoting.batchedCalls[i].data;
+    d += Seam.Remoting.batchedCalls[i].data;
   }
 
-  var envelope = Seam.Remoting.createEnvelope(Seam.Remoting.createHeader(), data);
-  Seam.Remoting.batchAsyncReq = Seam.Remoting.sendAjaxRequest(envelope, Seam.Remoting.PATH_EXECUTE, Seam.Remoting.processResponse, false);
+  var envelope = Seam.Remoting.createEnvelope(Seam.Remoting.createHeader(), d);
+  Seam.Remoting.batchAsyncReq = Seam.Remoting.sendAjaxRequest(envelope, Seam.Remoting.PATH_EXECUTE,
+    Seam.Remoting.processResponse, false);
   Seam.Remoting.inBatch = false;
 }
 
-Seam.Remoting.cancelBatch = function()
-{
+Seam.Remoting.cancelBatch = function() {
   Seam.Remoting.inBatch = false;
-  for (var i = 0; i < Seam.Remoting.batchedCalls.length; i++)
+  for (var i = 0; i < Seam.Remoting.batchedCalls.length; i++) {
     Seam.Remoting.pendingCalls.remove(Seam.Remoting.batchedCalls[i].id);
+  }
 }
 
-Seam.Remoting.cancelCall = function(callId)
-{
-  var call = Seam.Remoting.pendingCalls.get(callId);
+Seam.Remoting.cancelCall = function(callId) {
+  var c = Seam.Remoting.pendingCalls.get(callId);
   Seam.Remoting.pendingCalls.remove(callId);
-  if (call && call.asyncReq)
-  {
-    if (Seam.Remoting.pendingCalls.isEmpty())
-      Seam.Remoting.hideLoadingMessage();
+  if (c && c.asyncReq) {
+    if (Seam.Remoting.pendingCalls.isEmpty()) Seam.Remoting.hideLoadingMessage();
     window.setTimeout(function() {
-      call.asyncReq.onreadystatechange = function() {};
+      c.asyncReq.onreadystatechange = function() {};
     }, 0);
-    call.asyncReq.abort();
+    c.asyncReq.abort();
   }
 }
 
-Seam.Remoting.execute = function(component, methodName, params, callback, exceptionHandler)
-{
-  var call = Seam.Remoting.createCall(component, methodName, params, callback, exceptionHandler);
-
-  if (Seam.Remoting.inBatch)
-  {
-    Seam.Remoting.batchedCalls[Seam.Remoting.batchedCalls.length] = call;
+Seam.Remoting.execute = function(component, methodName, params, callback, exceptionHandler) {
+  var c = Seam.Remoting.createCall(component, methodName, params, callback, exceptionHandler);
+  if (Seam.Remoting.inBatch) {
+    Seam.Remoting.batchedCalls[Seam.Remoting.batchedCalls.length] = c;
   }
-  else
-  {
-    // Marshal the request
-    var envelope = Seam.Remoting.createEnvelope(Seam.Remoting.createHeader(), call.data);
-    Seam.Remoting.pendingCalls.put(call.id, call);
+  else {
+    var envelope = Seam.Remoting.createEnvelope(Seam.Remoting.createHeader(), c.data);
+    Seam.Remoting.pendingCalls.put(c.id, c);
     Seam.Remoting.sendAjaxRequest(envelope, Seam.Remoting.PATH_EXECUTE, Seam.Remoting.processResponse, false);
   }
-
-  return call;
+  return c;
 }
 
 Seam.Remoting.sendAjaxRequest = function(envelope, path, callback, silent)
 {
   Seam.Remoting.log("Request packet:\n" + envelope);
-
-  if (!silent)
-    Seam.Remoting.displayLoadingMessage();
-    
-  var asyncReq;
-
-  if (window.XMLHttpRequest)
-  {
-    asyncReq = new XMLHttpRequest();
-    if (asyncReq.overrideMimeType)
-      asyncReq.overrideMimeType('text/xml');
+  if (!silent) Seam.Remoting.displayLoadingMessage();    
+  var r;
+  if (window.XMLHttpRequest) {
+    r = new XMLHttpRequest();
+    if (r.overrideMimeType) r.overrideMimeType('text/xml');
   }
-  else
-  {
-    asyncReq = new ActiveXObject("Microsoft.XMLHTTP");
+  else {
+    r = new ActiveXObject("Microsoft.XMLHTTP");
   }
 
-  asyncReq.onreadystatechange = function() 
-  {
-    if (asyncReq.readyState == 4)
-    {
-      var inScope = typeof(Seam) == "undefined" ? false : true;
-      
+  r.onreadystatechange = function() {
+    if (r.readyState == 4) {
+      var inScope = typeof(Seam) == "undefined" ? false : true;      
       if (inScope) Seam.Remoting.hideLoadingMessage();
         
-      if (asyncReq.status == 200)
-      {
+      if (r.status == 200) {
         // We do this to avoid a memory leak
         window.setTimeout(function() {
-          asyncReq.onreadystatechange = function() {};
+          r.onreadystatechange = function() {};
         }, 0);      
       
-        if (inScope) Seam.Remoting.log("Response packet:\n" + asyncReq.responseText);
+        if (inScope) Seam.Remoting.log("Response packet:\n" + r.responseText);
   
-        if (callback)
-        {
+        if (callback) {
           // The following code deals with a Firefox security issue.  It reparses the XML
           // response if accessing the documentElement throws an exception
-          try
-          {         
-            asyncReq.responseXML.documentElement;
-            //Seam.Remoting.processResponse(asyncReq.responseXML);
-	    callback(asyncReq.responseXML);
+          try {         
+            r.responseXML.documentElement;
+            callback(r.responseXML);
           }
-          catch (ex)
-          {
-             try
-             {
+          catch (ex) {
+             try {
                // Try it the IE way first...
                var doc = new ActiveXObject("Microsoft.XMLDOM");
                doc.async = "false";
-               doc.loadXML(asyncReq.responseText);
+               doc.loadXML(r.responseText);
                callback(doc);
              }
-             catch (e)
-             {
+             catch (e) {
                // If that fails, use standards
                var parser = new DOMParser();
-               //Seam.Remoting.processResponse(parser.parseFromString(asyncReq.responseText, "text/xml"));
-	       callback(parser.parseFromString(asyncReq.responseText, "text/xml")); 
+               callback(parser.parseFromString(r.responseText, "text/xml")); 
              }
           } 
         }
       }
-      else
-      {
-        Seam.Remoting.displayError(asyncReq.status);
+      else {
+        Seam.Remoting.displayError(r.status);
       }
     }    
   }
 
-  if (Seam.Remoting.encodedSessionId)
-  {
+  if (Seam.Remoting.encodedSessionId) {
     path += ';jsessionid=' + Seam.Remoting.encodedSessionId;
   }
     
-  asyncReq.open("POST", Seam.Remoting.resourcePath + path, true);
-  asyncReq.send(envelope);
+  r.open("POST", Seam.Remoting.resourcePath + path, true);
+  r.send(envelope);
 }
 
-Seam.Remoting.displayError = function(code)
-{
+Seam.Remoting.displayError = function(code) {
   alert("There was an error processing your request.  Error code: " + code);  
 }
 
-Seam.Remoting.setCallback = function(component, methodName, callback)
-{
+Seam.Remoting.setCallback = function(component, methodName, callback) {
   component.__callback[methodName] = callback;
 }
 
-Seam.Remoting.processResponse = function(doc)
-{
+Seam.Remoting.processResponse = function(doc) {
   var headerNode;
   var bodyNode;
-
   var inScope = typeof(Seam) == "undefined" ? false : true;
   if (!inScope) return;    
   
   var context = new Seam.Remoting.__Context;
 
-  if (doc.documentElement)
-  {
-    for (var i = 0; i < doc.documentElement.childNodes.length; i++)
-    {
+  if (doc.documentElement) {
+    for (var i = 0; i < doc.documentElement.childNodes.length; i++) {
       var node = doc.documentElement.childNodes.item(i);
       if (node.tagName == "header")
         headerNode = node;
@@ -751,122 +552,97 @@
     }
   }
 
-  if (headerNode)
-  {
+  if (headerNode) {
     var contextNode;
-    for (var i = 0; i < headerNode.childNodes.length; i++)
-    {
+    for (var i = 0; i < headerNode.childNodes.length; i++) {
       var node = headerNode.childNodes.item(i);
-      if (node.tagName == "context")
-      {
+      if (node.tagName == "context") {
         contextNode = node;
         break;
       }
     }
-    if (contextNode && context)
-    {
+    if (contextNode && context) {
       Seam.Remoting.unmarshalContext(contextNode, context);
       if (context.getConversationId() && Seam.Remoting.getContext().getConversationId() == null)
         Seam.Remoting.getContext().setConversationId(context.getConversationId());
     }
   }
 
-  if (bodyNode)
-  {
-    for (var i = 0; i < bodyNode.childNodes.length; i++)
-    {
-      var node = bodyNode.childNodes.item(i);
-      if (node.tagName == "result")
-        Seam.Remoting.processResult(node, context);
+  if (bodyNode) {
+    for (var i = 0; i < bodyNode.childNodes.length; i++) {
+      var n = bodyNode.childNodes.item(i);
+      if (n.tagName == "result") Seam.Remoting.processResult(n, context);
     }
   }
 }
 
-Seam.Remoting.processResult = function(result, context)
-{
+Seam.Remoting.processResult = function(result, context) {
   var callId = result.getAttribute("id");
   var call = Seam.Remoting.pendingCalls.get(callId);
   Seam.Remoting.pendingCalls.remove(callId);
 
-  if (call && (call.callback || call.exceptionHandler))
-  {
+  if (call && (call.callback || call.exceptionHandler)) {
     var valueNode = null;
     var refsNode = null;
     var exceptionNode = null;
 
-    var children = result.childNodes;
-    for (var i = 0; i < children.length; i++)
-    {
-      var tag = children.item(i).tagName;
+    var c = result.childNodes;
+    for (var i = 0; i < c.length; i++) {
+      var tag = c.item(i).tagName;
       if (tag == "value")
-        valueNode = children.item(i);
+        valueNode = c.item(i);
       else if (tag == "refs")
-        refsNode = children.item(i);
+        refsNode = c.item(i);
       else if (tag == "exception")
-        exceptionNode = children.item(i);
+        exceptionNode = c.item(i);
     }
 
-    if (exceptionNode != null)
-    {
+    if (exceptionNode != null) {
       var msgNode = null;
-      var children = exceptionNode.childNodes;
-      for (var i = 0; i < children.length; i++)
-      {
-        var tag = children.item(i).tagName;
+      var c = exceptionNode.childNodes;
+      for (var i = 0; i < c.length; i++) {
+        var tag = c.item(i).tagName;
         if (tag == "message")
-          msgNode = children.item(i); 
+          msgNode = c.item(i); 
       }
       
       var msg = Seam.Remoting.unmarshalValue(msgNode.firstChild);
       var ex = new Seam.Remoting.Exception(msg);
       call.exceptionHandler(ex); 
     }
-    else
-    {
+    else {
       var refs = new Array();
-      if (refsNode)
-        Seam.Remoting.unmarshalRefs(refsNode, refs);
-  
+      if (refsNode) Seam.Remoting.unmarshalRefs(refsNode, refs);
       var value = Seam.Remoting.unmarshalValue(valueNode.firstChild, refs);
-  
       call.callback(value, context, callId);
     }
   }
 }
 
-Seam.Remoting.unmarshalContext = function(ctxNode, context)
-{
-  for (var i = 0; i < ctxNode.childNodes.length; i++)
-  {
+Seam.Remoting.unmarshalContext = function(ctxNode, context) {
+  for (var i = 0; i < ctxNode.childNodes.length; i++) {
     var tag = ctxNode.childNodes.item(i).tagName;
-    if (tag == "conversationId")
-      context.setConversationId(ctxNode.childNodes.item(i).firstChild.nodeValue);
+    if (tag == "conversationId") context.setConversationId(ctxNode.childNodes.item(i).firstChild.nodeValue);
   }
 }
 
-Seam.Remoting.unmarshalRefs = function(refsNode, refs)
-{
+Seam.Remoting.unmarshalRefs = function(refsNode, refs) {
   var objs = new Array();
 
-  // Pass 1 - create the reference objects
-  for (var i = 0; i < refsNode.childNodes.length; i++)
-  {
-    if (refsNode.childNodes.item(i).tagName == "ref")
-    {
+  for (var i = 0; i < refsNode.childNodes.length; i++) {
+    if (refsNode.childNodes.item(i).tagName == "ref") {
       var refNode = refsNode.childNodes.item(i);
       var refId = parseInt(refNode.getAttribute("id"));
 
       var valueNode = refNode.firstChild;
-      if (valueNode.tagName == "bean")
-      {
+      if (valueNode.tagName == "bean") {
         var obj = null;
         var typeName = valueNode.getAttribute("type");
-        if (Seam.Component.isRegistered(typeName))
-          obj = Seam.Component.newInstance(typeName);
+        if (Seam.Remoting.isBeanRegistered(typeName))
+          obj = Seam.Remoting.instance(typeName);
         else
           obj = Seam.Remoting.createType(typeName);
-        if (obj)
-        {
+        if (obj) {
           refs[refId] = obj;
           objs[objs.length] = {obj: obj, node: valueNode};
         }
@@ -874,14 +650,10 @@
     }
   }
 
-  // Pass 2 - populate the object members
-  for (var i = 0; i < objs.length; i++)
-  {
-    for (var j = 0; j < objs[i].node.childNodes.length; j++)
-    {
+  for (var i = 0; i < objs.length; i++) {
+    for (var j = 0; j < objs[i].node.childNodes.length; j++) {
       var child = objs[i].node.childNodes.item(j);
-      if (child.tagName == "member")
-      {
+      if (child.tagName == "member") {
         var name = child.getAttribute("name");
         objs[i].obj[name] = Seam.Remoting.unmarshalValue(child.firstChild, refs);
       }
@@ -889,12 +661,10 @@
   }
 }
 
-Seam.Remoting.unmarshalValue = function(element, refs)
-{
+Seam.Remoting.unmarshalValue = function(element, refs) {
   var tag = element.tagName;
 
-  switch (tag)
-  {
+  switch (tag) {
     case "bool": return element.firstChild.nodeValue == "true";
     case "number":
       if (element.firstChild.nodeValue.indexOf(".") == -1)
@@ -903,41 +673,35 @@
         return parseFloat(element.firstChild.nodeValue);
     case "str":
       var data = "";
-      for (var i = 0; i < element.childNodes.length; i++)
-      {
-        if (element.childNodes[i].nodeType == 3) // NODE_TEXT
+      for (var i = 0; i < element.childNodes.length; i++) {
+        if (element.childNodes[i].nodeType == 3)
           data += element.childNodes[i].nodeValue;
       }
       return decodeURIComponent(data);
     case "ref": return refs[parseInt(element.getAttribute("id"))];
     case "bag":
       var value = new Array();
-      for (var i = 0; i < element.childNodes.length; i++)
-      {
+      for (var i = 0; i < element.childNodes.length; i++) {
         if (element.childNodes.item(i).tagName == "element")
           value[value.length] = Seam.Remoting.unmarshalValue(element.childNodes.item(i).firstChild, refs);
       }
       return value;
     case "map":
       var map = new Seam.Remoting.Map();
-      for (var i = 0; i < element.childNodes.length; i++)
-      {
+      for (var i = 0; i < element.childNodes.length; i++) {
         var childNode = element.childNodes.item(i);
-        if (childNode.tagName == "element")
-        {
+        if (childNode.tagName == "element") {
           var key = null
           var value = null;
 
-          for (var j = 0; j < childNode.childNodes.length; j++)
-          {
+          for (var j = 0; j < childNode.childNodes.length; j++) {
             if (key == null && childNode.childNodes.item(j).tagName == "k")
               key = Seam.Remoting.unmarshalValue(childNode.childNodes.item(j).firstChild, refs);
             else if (value == null && childNode.childNodes.item(j).tagName == "v")
               value = Seam.Remoting.unmarshalValue(childNode.childNodes.item(j).firstChild, refs);
           }
 
-          if (key != null)
-            map.put(key, value);
+          if (key != null) map.put(key, value);
         }
       }
       return map;
@@ -946,8 +710,7 @@
   }
 }
 
-Seam.Remoting.deserializeDate = function(val)
-{
+Seam.Remoting.deserializeDate = function(val) {
   var dte = new Date();
   dte.setFullYear(parseInt(val.substring(0,4), 10),
                   parseInt(val.substring(4,6), 10) - 1,
@@ -961,38 +724,33 @@
 
 Seam.Remoting.loadingMsgDiv = null;
 Seam.Remoting.loadingMessage = "Please wait...";
-Seam.Remoting.displayLoadingMessage = function()
-{
-  if (!Seam.Remoting.loadingMsgDiv)
-  {
+Seam.Remoting.displayLoadingMessage = function() {
+  if (!Seam.Remoting.loadingMsgDiv) {
     Seam.Remoting.loadingMsgDiv = document.createElement('div');
-    var msgDiv = Seam.Remoting.loadingMsgDiv;
-    msgDiv.setAttribute('id', 'loadingMsg');
+    var d = Seam.Remoting.loadingMsgDiv;
+    d.setAttribute('id', 'loadingMsg');
+    d.style.position = "absolute";
+    d.style.top = "0px";
+    d.style.right = "0px";
+    d.style.background = "red";
+    d.style.color = "white";
+    d.style.fontFamily = "Verdana,Helvetica,Arial";
+    d.style.fontSize = "small";
+    d.style.padding = "2px";
+    d.style.border = "1px solid black";
 
-    msgDiv.style.position = "absolute";
-    msgDiv.style.top = "0px";
-    msgDiv.style.right = "0px";
-    msgDiv.style.background = "red";
-    msgDiv.style.color = "white";
-    msgDiv.style.fontFamily = "Verdana,Helvetica,Arial";
-    msgDiv.style.fontSize = "small";
-    msgDiv.style.padding = "2px";
-    msgDiv.style.border = "1px solid black";
+    document.body.appendChild(d);
 
-    document.body.appendChild(msgDiv);
-
     var text = document.createTextNode(Seam.Remoting.loadingMessage);
-    msgDiv.appendChild(text);
+    d.appendChild(text);
   }
-  else
-  {
+  else {
     Seam.Remoting.loadingMsgDiv.innerHTML = Seam.Remoting.loadingMessage;
     Seam.Remoting.loadingMsgDiv.style.visibility = 'visible';
   }
 }
 
-Seam.Remoting.hideLoadingMessage = function()
-{
+Seam.Remoting.hideLoadingMessage = function() {
   if (Seam.Remoting.loadingMsgDiv)
     Seam.Remoting.loadingMsgDiv.style.visibility = 'hidden';
 }
@@ -1003,22 +761,18 @@
 Seam.Remoting.pollTimeout = 0; // Default timeout of 0 seconds
 Seam.Remoting.polling = false;
 
-Seam.Remoting.setPollInterval = function(interval)
-{
+Seam.Remoting.setPollInterval = function(interval) {
   Seam.Remoting.pollInterval = interval;
 }
 
-Seam.Remoting.setPollTimeout = function(timeout)
-{
+Seam.Remoting.setPollTimeout = function(timeout) {
   Seam.Remoting.pollTimeout = timeout;
 }
 
 Seam.Remoting.subscriptionRegistry = new Array();
 
-Seam.Remoting.subscribe = function(topicName, callback)
-{
-  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++)
-  {
+Seam.Remoting.subscribe = function(topicName, callback) {
+  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++) {
     if (Seam.Remoting.subscriptionRegistry[i].topic == topicName)
       return;
   }
@@ -1029,41 +783,32 @@
   Seam.Remoting.sendAjaxRequest(env, Seam.Remoting.PATH_SUBSCRIPTION, Seam.Remoting.subscriptionCallback, false);
 }
 
-Seam.Remoting.unsubscribe = function(topicName)
-{
+Seam.Remoting.unsubscribe = function(topicName) {
   var token = null;
 
-  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++)
-  {
-    if (Seam.Remoting.subscriptionRegistry[i].topic == topicName)
-    {
+  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++) {
+    if (Seam.Remoting.subscriptionRegistry[i].topic == topicName) {
       token = Seam.Remoting.subscriptionRegistry[i].token;
       Seam.Remoting.subscriptionRegistry.splice(i, 1);
     }
   }
 
-  if (token)
-  {
+  if (token) {
     var body = "<unsubscribe token=\"" + token + "\"/>";
     var env = Seam.Remoting.createEnvelope(null, body);
     Seam.Remoting.sendAjaxRequest(env, Seam.Remoting.PATH_SUBSCRIPTION, null, false);
   }
 }
 
-Seam.Remoting.subscriptionCallback = function(doc)
-{
+Seam.Remoting.subscriptionCallback = function(doc) {
   var body = doc.documentElement.firstChild;
-  for (var i = 0; i < body.childNodes.length; i++)
-  {
+  for (var i = 0; i < body.childNodes.length; i++) {
     var node = body.childNodes.item(i);
-    if (node.tagName == "subscription")
-    {
+    if (node.tagName == "subscription") {
       var topic = node.getAttribute("topic");
       var token = node.getAttribute("token");
-      for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++)
-      {
-        if (Seam.Remoting.subscriptionRegistry[i].topic == topic)
-        {
+      for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++) {
+        if (Seam.Remoting.subscriptionRegistry[i].topic == topic) {
           Seam.Remoting.subscriptionRegistry[i].token = token;
           Seam.Remoting.poll();
           break;
@@ -1075,24 +820,20 @@
 
 Seam.Remoting.pollTimeoutFunction = null;
 
-Seam.Remoting.poll = function()
-{
-  if (Seam.Remoting.polling)
-    return;
+Seam.Remoting.poll = function() {
+  if (Seam.Remoting.polling) return;
 
   Seam.Remoting.polling = true;
   clearTimeout(Seam.Remoting.pollTimeoutFunction);
 
   var body = "";
 
-  if (Seam.Remoting.subscriptionRegistry.length == 0)
-  {
+  if (Seam.Remoting.subscriptionRegistry.length == 0) {
     Seam.Remoting.polling = false;
     return;
   }
 
-  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++)
-  {
+  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++) {
     body += "<poll token=\"" + Seam.Remoting.subscriptionRegistry[i].token + "\" ";
     body += "timeout=\"" + Seam.Remoting.pollTimeout + "\"/>";
   }
@@ -1101,13 +842,11 @@
   Seam.Remoting.sendAjaxRequest(env, Seam.Remoting.PATH_POLL, Seam.Remoting.pollCallback, true);
 }
 
-Seam.Remoting.pollCallback = function(doc)
-{
+Seam.Remoting.pollCallback = function(doc) {
   Seam.Remoting.polling = false;
 
   var body = doc.documentElement.firstChild;
-  for (var i = 0; i < body.childNodes.length; i++)
-  {
+  for (var i = 0; i < body.childNodes.length; i++) {
     var node = body.childNodes.item(i);
     if (node.tagName == "messages")
       Seam.Remoting.processMessages(node);
@@ -1118,13 +857,11 @@
   Seam.Remoting.pollTimeoutFunction = setTimeout("Seam.Remoting.poll()", Math.max(Seam.Remoting.pollInterval * 1000, 1000));
 }
 
-Seam.Remoting.processMessages = function(messages)
-{
+Seam.Remoting.processMessages = function(messages) {
   var token = messages.getAttribute("token");
 
   var callback = null;
-  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++)
-  {
+  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++) {
     if (Seam.Remoting.subscriptionRegistry[i].token == token)
     {
       callback = Seam.Remoting.subscriptionRegistry[i].callback;
@@ -1132,23 +869,19 @@
     }
   }
 
-  if (callback != null)
-  {
-    var messageNode = null;
-
-    var children = messages.childNodes;
-    for (var i = 0; i < children.length; i++)
-    {
-      if (children.item(i).tagName == "message")
+  if (callback != null) {
+    var m = null;
+    var c = messages.childNodes;
+    for (var i = 0; i < c.length; i++) {
+      if (c.item(i).tagName == "message")
       {
-        messageNode = children.item(i);
-        var messageType = messageNode.getAttribute("type");
+        m = c.item(i);
+        var messageType = m.getAttribute("type");
 
         var valueNode = null;
         var refsNode = null;
-        for (var j = 0; j < messageNode.childNodes.length; j++)
-        {
-          var node = messageNode.childNodes.item(j);
+        for (var j = 0; j < m.childNodes.length; j++) {
+          var node = m.childNodes.item(j);
           if (node.tagName == "value")
             valueNode = node;
           else if (node.tagName == "refs")
@@ -1156,35 +889,26 @@
         }
 
         var refs = new Array();
-        if (refsNode)
-          Seam.Remoting.unmarshalRefs(refsNode, refs);
-
-        var value = Seam.Remoting.unmarshalValue(valueNode.firstChild, refs);
-
-        callback(Seam.Remoting.createMessage(messageType, value));
+        if (refsNode) Seam.Remoting.unmarshalRefs(refsNode, refs);
+        var v = Seam.Remoting.unmarshalValue(valueNode.firstChild, refs);
+        callback(Seam.Remoting.createMessage(messageType, v));
       }
     }
   }
 }
 
-Seam.Remoting.processErrors = function(errors)
-{
-  var token = errors.getAttribute("token");
+Seam.Remoting.processErrors = function(errors) {
+  var t = errors.getAttribute("token");
 
-  // Unsubscribe to the topic
-  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++)
-  {
-    if (Seam.Remoting.subscriptionRegistry[i].token == token)
-    {
+  for (var i = 0; i < Seam.Remoting.subscriptionRegistry.length; i++) {
+    if (Seam.Remoting.subscriptionRegistry[i].token == t) {
       Seam.Remoting.subscriptionRegistry.splice(i, 1);
       break;
     }
   }
 
-  for (var i = 0; i < errors.childNodes.length; i++)
-  {
-    if (errors.childNodes.item(i).tagName == "error")
-    {
+  for (var i = 0; i < errors.childNodes.length; i++) {
+    if (errors.childNodes.item(i).tagName == "error") {
       var errorNode = errors.childNodes.item(i);
       var code = errorNode.getAttribute("code");
       var message = errorNode.firstChild.nodeValue;
@@ -1197,40 +921,32 @@
   }
 }
 
-Seam.Remoting.ObjectMessage = function()
-{
+Seam.Remoting.ObjectMessage = function() {
   this.value = null;
 
-  Seam.Remoting.ObjectMessage.prototype.getValue = function()
-  {
+  Seam.Remoting.ObjectMessage.prototype.getValue = function() {
     return this.value;
   }
 
-  Seam.Remoting.ObjectMessage.prototype.setValue = function(value)
-  {
+  Seam.Remoting.ObjectMessage.prototype.setValue = function(value) {
     this.value = value;
   }
 }
 
-Seam.Remoting.TextMessage = function()
-{
+Seam.Remoting.TextMessage = function() {
   this.text = null;
 
-  Seam.Remoting.TextMessage.prototype.getText = function()
-  {
+  Seam.Remoting.TextMessage.prototype.getText = function() {
     return this.text;
   }
 
-  Seam.Remoting.TextMessage.prototype.setText = function(text)
-  {
+  Seam.Remoting.TextMessage.prototype.setText = function(text) {
     this.text = text;
   }
 }
 
-Seam.Remoting.createMessage = function(messageType, value)
-{
-  switch (messageType)
-  {
+Seam.Remoting.createMessage = function(messageType, value) {
+  switch (messageType) {
     case "object":
       var msg = new Seam.Remoting.ObjectMessage();
       msg.setValue(value);



More information about the seam-commits mailing list