Author: mhermanto
Date: Thu Mar 24 17:44:12 2011
New Revision: 1085049

URL: http://svn.apache.org/viewvc?rev=1085049&view=rev
Log:
Separate out base osapi from its transports.
http://codereview.appspot.com/4309044/

Added:
    shindig/trunk/features/src/main/javascript/features/osapi.base/
    shindig/trunk/features/src/main/javascript/features/osapi.base/batch.js
      - copied, changed from r1084472, 
shindig/trunk/features/src/main/javascript/features/osapi/batch.js
    shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml
    shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js
      - copied, changed from r1084472, 
shindig/trunk/features/src/main/javascript/features/osapi/osapi.js
    shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js
Removed:
    shindig/trunk/features/src/main/javascript/features/osapi/batch.js
    shindig/trunk/features/src/main/javascript/features/osapi/osapi.js
Modified:
    shindig/trunk/features/pom.xml
    shindig/trunk/features/src/main/javascript/features/features.txt
    shindig/trunk/features/src/main/javascript/features/osapi/feature.xml
    shindig/trunk/features/src/main/javascript/features/osapi/taming.js
    shindig/trunk/features/src/test/javascript/features/alltests.js

Modified: shindig/trunk/features/pom.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/pom.xml?rev=1085049&r1=1085048&r2=1085049&view=diff
==============================================================================
--- shindig/trunk/features/pom.xml (original)
+++ shindig/trunk/features/pom.xml Thu Mar 24 17:44:12 2011
@@ -166,8 +166,8 @@
                 <source>opensocial-base/jsonmediaitem.js</source> 
                 <source>opensocial-base/jsonperson.js</source>
                 <source>opensocial-jsonrpc/jsonrpccontainer.js</source>
-                <source>osapi/osapi.js</source>
-                <source>osapi/batch.js</source>
+                <source>osapi.base/osapi.js</source>
+                <source>osapi.base/batch.js</source>
                 <source>osapi/jsonrpctransport.js</source>
                 <source>osapi/peoplehelpers.js</source>
                 
<source>../../../../src/test/javascript/lib/testutils.js</source>

Modified: shindig/trunk/features/src/main/javascript/features/features.txt
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/features.txt?rev=1085049&r1=1085048&r2=1085049&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Thu Mar 24 
17:44:12 2011
@@ -58,6 +58,7 @@ features/opensocial-data/feature.xml
 features/opensocial-jsonrpc/feature.xml
 features/opensocial-reference/feature.xml
 features/opensocial-templates/feature.xml
+features/osapi.base/feature.xml
 features/osapi/feature.xml
 features/osml/feature.xml
 features/pubsub/feature.xml

Copied: shindig/trunk/features/src/main/javascript/features/osapi.base/batch.js 
(from r1084472, 
shindig/trunk/features/src/main/javascript/features/osapi/batch.js)
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi.base/batch.js?p2=shindig/trunk/features/src/main/javascript/features/osapi.base/batch.js&p1=shindig/trunk/features/src/main/javascript/features/osapi/batch.js&r1=1084472&r2=1085049&rev=1085049&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/batch.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/osapi.base/batch.js Thu 
Mar 24 17:44:12 2011
@@ -21,9 +21,10 @@
   /**
    * It is common to batch requests together to make them more efficient.
    *
-   * Note: the container config specified endpoints at which services are to 
be found.
-   * When creating a batch, the calls are split out into separate requests 
based on the
-   * transport, as it may get sent to a different server on the backend.
+   * Note: the container config specified endpoints at which services are to be
+   * found. When creating a batch, the calls are split out into separate
+   * requests based on the transport, as it may get sent to a different server
+   * on the backend.
    */
   var newBatch = function() {
     var that = {};
@@ -36,7 +37,7 @@
     //     transport : <rpc dispatcher>
     //  }
     // }
-
+    
     /** @type {Array.<Object>} */
     var keyedRequests = [];
 

Added: 
shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml?rev=1085049&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml 
(added)
+++ shindig/trunk/features/src/main/javascript/features/osapi.base/feature.xml 
Thu Mar 24 17:44:12 2011
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<feature>
+  <name>osapi.base</name>
+  <dependency>globals</dependency>
+  <dependency>core.log</dependency>
+  <dependency>taming</dependency>
+  <all>
+    <script src="batch.js"></script>
+    <script src="osapi.js"></script>
+    <script src="taming.js"></script>    
+    <api>
+      <exports type="js">osapi.newBatch.add</exports>
+      <exports type="js">osapi.newBatch.execute</exports>
+      <exports type="js">osapi._registerMethod</exports>
+    </api>
+  </all>
+</feature>

Copied: shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js 
(from r1084472, 
shindig/trunk/features/src/main/javascript/features/osapi/osapi.js)
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js?p2=shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js&p1=shindig/trunk/features/src/main/javascript/features/osapi/osapi.js&r1=1084472&r2=1085049&rev=1085049&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/osapi.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/osapi.base/osapi.js Thu 
Mar 24 17:44:12 2011
@@ -16,68 +16,66 @@
  * specific language governing permissions and limitations under the License.
  */
 
-(function() {
-  /**
-   * Called by the transports for each service method that they expose
-   * @param {string} method  The method to expose e.g. "people.get".
-   * @param {Object.<string,Object>} transport The transport used to execute a 
call for the method.
-   */
-  osapi._registerMethod = function(method, transport) {
-    var has___ = typeof ___ !== 'undefined';
-
-    // Skip registration of local newBatch implementation.
-    if (method == 'newBatch') {
-      return;
-    }
-
-    // Lookup last method value.
-    var parts = method.split('.');
-    var last = osapi;
-    for (var i = 0; i < parts.length - 1; i++) {
-      last[parts[i]] = last[parts[i]] || {};
-      last = last[parts[i]];
-    }
-
-    // Use the batch as the actual executor of calls.
-    var apiMethod = function(rpc) {
-      var batch = osapi.newBatch();
-      var boundCall = {};
-      boundCall.execute = function(callback) {
-        var feralCallback = has___ ? ___.untame(callback) : callback;
-        var that = has___ ? ___.USELESS : this;
-        batch.add(method, this);
-        batch.execute(function(batchResult) {
-          if (batchResult.error) {
-            feralCallback.call(that, batchResult.error);
-          } else {
-            feralCallback.call(that, batchResult[method]);
-          }
-        });
-      };
-      if (has___) {
-        ___.markInnocent(boundCall.execute, 'execute');
-      }
-      // TODO: This shouldnt really be necessary. The spec should be clear 
enough about
-      // defaults that we dont have to populate this.
-      rpc = rpc || {};
-      rpc['userId'] = rpc['userId'] || '@viewer';
-      rpc['groupId'] = rpc['groupId'] || '@self';
-
-      // Decorate the execute method with the information necessary for 
batching
-      boundCall['method'] = method;
-      boundCall['transport'] = transport;
-      boundCall['rpc'] = rpc;
+/**
+ * Called by the transports for each service method that they expose
+ * @param {string} method  The method to expose e.g. "people.get".
+ * @param {Object.<string,Object>} transport The transport used to execute a 
call for the method.
+ */
+osapi._registerMethod = function(method, transport) {
+  var has___ = typeof ___ !== 'undefined';
 
-      return boundCall;
+  // Skip registration of local newBatch implementation.
+  if (method == 'newBatch') {
+    return;
+  }
+
+  // Lookup last method value.
+  var parts = method.split('.');
+  var last = osapi;
+  for (var i = 0; i < parts.length - 1; i++) {
+    last[parts[i]] = last[parts[i]] || {};
+    last = last[parts[i]];
+  }
+
+  // Use the batch as the actual executor of calls.
+  var apiMethod = function(rpc) {
+    var batch = osapi.newBatch();
+    var boundCall = {};
+    boundCall.execute = function(callback) {
+      var feralCallback = has___ ? ___.untame(callback) : callback;
+      var that = has___ ? ___.USELESS : this;
+      batch.add(method, this);
+      batch.execute(function(batchResult) {
+        if (batchResult.error) {
+          feralCallback.call(that, batchResult.error);
+        } else {
+          feralCallback.call(that, batchResult[method]);
+        }
+      });
     };
-    if (has___ && typeof ___.markInnocent !== 'undefined') {
-      ___.markInnocent(apiMethod, method);
+    if (has___) {
+      ___.markInnocent(boundCall.execute, 'execute');
     }
+    // TODO: This shouldnt really be necessary. The spec should be clear 
enough about
+    // defaults that we dont have to populate this.
+    rpc = rpc || {};
+    rpc['userId'] = rpc['userId'] || '@viewer';
+    rpc['groupId'] = rpc['groupId'] || '@self';
+
+    // Decorate the execute method with the information necessary for batching
+    boundCall['method'] = method;
+    boundCall['transport'] = transport;
+    boundCall['rpc'] = rpc;
 
-    if (last[parts[parts.length - 1]]) {
-      gadgets.warn('Skipping duplicate osapi method definition ' + method + ' 
on transport ' + transport['name']);
-    } else {
-      last[parts[parts.length - 1]] = apiMethod;
-    }
+    return boundCall;
   };
-})();
+  if (has___ && typeof ___.markInnocent !== 'undefined') {
+    ___.markInnocent(apiMethod, method);
+  }
+
+  if (last[parts[parts.length - 1]]) {
+    gadgets.warn('Skipping duplicate osapi method definition ' + method + ' on 
transport ' + transport['name']);
+  } else {
+    last[parts[parts.length - 1]] = apiMethod;
+  }
+};

Added: shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js?rev=1085049&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js 
(added)
+++ shindig/trunk/features/src/main/javascript/features/osapi.base/taming.js 
Thu Mar 24 17:44:12 2011
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @class
+ * Tame and expose core osapi.* API to cajoled gadgets
+ */
+tamings___.push(function(imports) {
+  ___.tamesTo(osapi.newBatch, ___.markFuncFreeze(function() {
+    var result = osapi.newBatch();
+    ___.markInnocent(result['add'], 'add');
+    ___.markInnocent(result['execute'], 'execute');
+    return ___.tame(result);
+  }));
+
+  // OSAPI functions are marked as simple funcs as they are registered
+  imports.outers.osapi = ___.tame(osapi);
+  ___.grantRead(imports.outers, 'osapi');
+});

Modified: shindig/trunk/features/src/main/javascript/features/osapi/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/feature.xml?rev=1085049&r1=1085048&r2=1085049&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/feature.xml 
(original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/feature.xml Thu 
Mar 24 17:44:12 2011
@@ -26,22 +26,13 @@
   <dependency>core.io</dependency>
   <dependency>core.json</dependency>
   <dependency>core.util</dependency>
+  <dependency>osapi.base</dependency>
   <dependency>rpc</dependency>
   <dependency>security-token</dependency>
-  <gadget>
-    <script src="osapi.js"></script>
-    <script src="batch.js"></script>
+  <all>
     <script src="jsonrpctransport.js"></script>
     <script src="gadgetsrpctransport.js"></script>
     <script src="peoplehelpers.js"></script>    
     <script src="taming.js"></script>    
-  </gadget>
-  <container>
-    <script src="osapi.js"></script>
-    <script src="batch.js"></script>
-    <script src="jsonrpctransport.js"></script>
-    <script src="gadgetsrpctransport.js"></script>
-    <script src="peoplehelpers.js"></script>
-    <script src="taming.js"></script>    
-  </container>
+  </all>
 </feature>

Modified: shindig/trunk/features/src/main/javascript/features/osapi/taming.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/osapi/taming.js?rev=1085049&r1=1085048&r2=1085049&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/osapi/taming.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/osapi/taming.js Thu Mar 
24 17:44:12 2011
@@ -19,21 +19,10 @@
 
 /**
  * @class
- * Tame and expose core osapi.* API to cajoled gadgets
+ * Tame and expose people osapi.* API to cajoled gadgets
  */
 tamings___.push(function(imports) {
 
-  ___.tamesTo(osapi.newBatch, ___.markFuncFreeze(function() {
-    var result = osapi.newBatch();
-    ___.markInnocent(result['add'], 'add');
-    ___.markInnocent(result['execute'], 'execute');
-    return ___.tame(result);
-  }));
-
-  // OSAPI functions are marked as simple funcs as they are registered
-  imports.outers.osapi = ___.tame(osapi);
-  ___.grantRead(imports.outers, 'osapi');
-
   // Forced to tame in an onload handler because peoplehelpers does
   // not define some functions till runOnLoadHandlers runs
   var savedImports = imports;

Modified: shindig/trunk/features/src/test/javascript/features/alltests.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/alltests.js?rev=1085049&r1=1085048&r2=1085049&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/alltests.js (original)
+++ shindig/trunk/features/src/test/javascript/features/alltests.js Thu Mar 24 
17:44:12 2011
@@ -73,8 +73,8 @@ if (!this.JsUtil) {
   eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonmediaitem.js'));
   eval(JsUtil.prototype.include(srcDir + '/opensocial-base/jsonperson.js'));
   eval(JsUtil.prototype.include(srcDir + 
'/opensocial-jsonrpc/jsonrpccontainer.js'));
-  eval(JsUtil.prototype.include(srcDir + '/osapi/osapi.js'));
-  eval(JsUtil.prototype.include(srcDir + '/osapi/batch.js'));
+  eval(JsUtil.prototype.include(srcDir + '/osapi.base/osapi.js'));
+  eval(JsUtil.prototype.include(srcDir + '/osapi.base/batch.js'));
   eval(JsUtil.prototype.include(srcDir + '/osapi/jsonrpctransport.js'));
   eval(JsUtil.prototype.include(srcDir + '/osapi/gadgetsrpctransport.js'));
   eval(JsUtil.prototype.include(srcDir + '/osapi/peoplehelpers.js'));


Reply via email to