Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(787)

Issue 143046: Feature/JS System Rework (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 10 months ago by johnfargo
Modified:
15 years, 10 months ago
Reviewers:
Jon Weygandt, shindig.remailer, Jasvir
Base URL:
http://svn.apache.org/repos/asf/incubator/shindig/trunk/
Visibility:
Public.

Description

The feature.xml and JS system has served us well, yet various new requirements/requests have arisen that have stressed the current implementation. Among them: * Ability to cleanly represent "code" features and "JS" features in a dependency tree w/ one another. This allows, for instance, a clean way for "opensocial" to depend on "security-token" (not yet introduced), which in turn depends on "locked-domain" to ensure token security. * Ability to let a gadget opt out of all "core" JavaScript, instead only including sub-components that are used, to shrink render size. * Ability to serve JS in a context-sensitive fashion ie. browser-specific code. * Ability to serve JS in a feature-sensitive fashion ie. only inject certain code when feature="caja" is enabled/active. * Ability in development mode to easily serve JS that changes when edits are made on it. For these and general code-cleanup purposes, I've rewritten the Feature/JS inclusion implementation as presented in this CL. This implementation is functionally 100% backward-compatible with its predecessor. It is only NOT backward-compatible with existing extensions (outside of Shindig's code base) that override JsFeatureLoader/GadgetFeatureRegistry. With this change, the unit of extension in the features system becomes the <script ...> line in a feature.xml. The processor for this line is a FeatureResourceLoader, for which a default implementation is provided. Each <script> line yields a FeatureResource object, which is in turn used to resolve content and debugContent by rendering/JS code. Other components are overridable/subclassable as well, but to date I've yet to hear a JS/features extension use case that does not fit in the ResourceLoader model (or, in the current model with dynamically register()'ed features). Hopefully that's right. An overview of the implementation follows. FeatureRegistry - Replaces GadgetFeatureRegistry and JsFeatureLoader - Performs both register() and getFeaturesXXX() functions - Does NOT implicitly include "core*" APIs anymore! These are included in the dependency tree. @see GadgetSpec for more below. - register(...) + Registers one or more features in the system, incorporating them into the list of known features and building a validated dependency tree with them. If a circular dependency exists, an error is thrown. + Method may be called at ANY time -- the registry is not programmatically locked. This allows (though this use is not tested!) for dynamic feature injection at some later point. - getFeatureResources(...) + Queries the feature tree for resources matching the specified context (GADGET || CONTAINER), which satisfy all the needed dependencies given in the query. Optionally, fills in unknown/unsupported features from the needed list. - getFeatures(List<String>) + Returns feature strings in dependency order that satisfy the given needed features. FeatureResourceLoader - @Injected into FeatureRegistry, main extension point for feature system. - Loads a given FeatureResource from a feature.xml <script src="..."/> line (inline features are handled by FeatureRegistry). - Key API: load(URI, Map<String,String> attribs) + URI is pre-resolved to be absolute by FeatureParser (relative to parent, if a relative URI in feature.xml) + "attribs" allows for arbitrary context-sensitive extensions. Example to come soon: limiting by feature="..." to include Caja tamings.js per-feature only when Caja is available. FeatureParser - Mostly an implementation detail of FeatureRegistry for now (package-private). - Parses a String into an intermediary object for further processing. - Resolves URIs of Resources relative to parent. GadgetSpec - If no feature is explicitly <Optional> or <Require>'d starting with "core", automatically inserts the "core" feature for backward compatibility. - No way (in this CL) to include "absolutely no core" yet. Gadget - Modified how addFeature and removeFeature work. They now manage a "directlyRequestedDeps" list, which in turn is used by rendering/processing code for feature resolution. RenderingGadgetRewriter - Update injectFeatureLibraries(...) to use new API. - Hopefully more straightforward: obtain resources requested by the gadget, and resources specified externally. Subtract latter from the former and inline those. Extern the rest. No "core" assumptions, as "core" will be included by the GadgetSpec if needed. Core features - Break "core" into core.config, core.json, core.prefs et al. - "core" now an aggregating feature that has no JS of its own but includes all sub-libs. All other features - Specific assignment of dependencies on core libs. Other - feature.xml updates, pom.xml updates for separated core libs - test updates across the board for all affected classes

Patch Set 1 #

Patch Set 2 : Attempt to fix missing code errors in CR tool. #

Total comments: 4

Patch Set 3 : Cleaner patch (hopefully) #

Patch Set 4 : Source control and patch don't play very nicely at all in anything but M situations. Trying again. #

Patch Set 5 : Integrates Jon Weygandt's changes from http://codereview.appspot.com/144055 #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+4425 lines, -3822 lines) Patch
features/pom.xml View 1 2 1 chunk +6 lines, -6 lines 0 comments Download
features/src/main/javascript/features/analytics/feature.xml View 1 2 1 chunk +1 line, -1 line 0 comments Download
features/src/main/javascript/features/auth-refresh/feature.xml View 1 2 1 chunk +1 line, -0 lines 0 comments Download
features/src/main/javascript/features/core.auth/auth.js View 1 chunk +193 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.auth/auth-init.js View 1 chunk +28 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.auth/feature.xml View 1 chunk +27 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.config/config.js View 1 chunk +238 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.config/feature.xml View 1 chunk +24 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.io/feature.xml View 1 2 1 chunk +3 lines, -4 lines 0 comments Download
features/src/main/javascript/features/core.json/feature.xml View 1 chunk +27 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.json/json.js View 1 chunk +192 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.legacy/feature.xml View 1 chunk +28 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.legacy/legacy.js View 1 chunk +318 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.log/feature.xml View 1 chunk +27 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.log/log.js View 1 chunk +129 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.prefs/feature.xml View 1 chunk +25 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.prefs/prefs.js View 1 chunk +296 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.util/feature.xml View 1 chunk +28 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core.util/util.js View 1 chunk +328 lines, -0 lines 0 comments Download
features/src/main/javascript/features/core/auth.js View 1 2 1 chunk +0 lines, -193 lines 0 comments Download
features/src/main/javascript/features/core/auth-init.js View 1 2 1 chunk +0 lines, -28 lines 0 comments Download
features/src/main/javascript/features/core/config.js View 1 2 1 chunk +0 lines, -238 lines 0 comments Download
features/src/main/javascript/features/core/core.js View 1 2 1 chunk +0 lines, -20 lines 0 comments Download
features/src/main/javascript/features/core/feature.xml View 1 2 1 chunk +14 lines, -18 lines 0 comments Download
features/src/main/javascript/features/core/json.js View 1 2 1 chunk +0 lines, -192 lines 0 comments Download
features/src/main/javascript/features/core/legacy.js View 1 2 1 chunk +0 lines, -318 lines 0 comments Download
features/src/main/javascript/features/core/log.js View 1 2 1 chunk +0 lines, -127 lines 0 comments Download
features/src/main/javascript/features/core/prefs.js View 1 2 1 chunk +0 lines, -296 lines 0 comments Download
features/src/main/javascript/features/core/util.js View 1 2 1 chunk +0 lines, -328 lines 0 comments Download
features/src/main/javascript/features/features.txt View 1 2 1 chunk +7 lines, -0 lines 0 comments Download
features/src/main/javascript/features/flash/feature.xml View 1 2 1 chunk +1 line, -0 lines 0 comments Download
features/src/main/javascript/features/i18n/feature.xml View 1 2 1 chunk +0 lines, -2 lines 0 comments Download
features/src/main/javascript/features/opensocial-0.6/feature.xml View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
features/src/main/javascript/features/opensocial-current/feature.xml View 1 2 1 chunk +1 line, -0 lines 0 comments Download
features/src/main/javascript/features/opensocial-data/feature.xml View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
features/src/main/javascript/features/opensocial-jsonrpc/feature.xml View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
features/src/main/javascript/features/opensocial-reference/feature.xml View 1 2 1 chunk +1 line, -0 lines 0 comments Download
features/src/main/javascript/features/osapi/feature.xml View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
features/src/main/javascript/features/rpc/feature.xml View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
features/src/main/javascript/features/setprefs/feature.xml View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
features/src/main/javascript/features/skins/feature.xml View 1 2 1 chunk +2 lines, -0 lines 0 comments Download
features/src/main/javascript/features/views/feature.xml View 1 2 1 chunk +3 lines, -1 line 0 comments Download
java/common/src/main/java/org/apache/shindig/common/Pair.java View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/BrowserSpecificRpcJsFeatureLoader.java View 1 2 1 chunk +0 lines, -198 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/DefaultUrlGenerator.java View 1 2 3 chunks +5 lines, -5 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/Gadget.java View 1 2 6 chunks +13 lines, -39 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/GadgetFeature.java View 1 2 1 chunk +0 lines, -137 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/GadgetFeatureRegistry.java View 1 2 1 chunk +0 lines, -191 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/JsFeatureLoader.java View 1 2 1 chunk +0 lines, -358 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/JsLibrary.java View 1 2 1 chunk +0 lines, -314 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/BrowserSpecificFeatureResource.java View 1 2 1 chunk +277 lines, -0 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureParser.java View 1 chunk +168 lines, -0 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java View 1 2 3 4 1 chunk +543 lines, -0 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureResource.java View 1 chunk +75 lines, -0 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureResourceLoader.java View 1 chunk +198 lines, -0 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/process/Processor.java View 1 2 3 chunks +5 lines, -5 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/render/OpenSocialI18NGadgetRewriter.java View 1 2 4 chunks +12 lines, -21 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java View 1 2 3 4 14 chunks +96 lines, -120 lines 1 comment Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/JsServlet.java View 1 2 3 chunks +31 lines, -22 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/Feature.java View 1 2 1 chunk +9 lines, -0 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/ModulePrefs.java View 1 2 1 chunk +7 lines, -2 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/spec/Preload.java View 1 2 1 chunk +0 lines, -1 line 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandler.java View 1 2 5 chunks +10 lines, -15 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/BrowserSpecificRpcJsFeatureLoaderTest.java View 1 2 1 chunk +0 lines, -46 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/DefaultUrlGeneratorTest.java View 1 2 3 chunks +4 lines, -2 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/GadgetFeatureRegistryTest.java View 1 2 1 chunk +0 lines, -134 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/GadgetTest.java View 1 2 2 chunks +13 lines, -33 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/HashLockedDomainServiceTest.java View 1 2 3 chunks +8 lines, -7 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/JsFeatureLoaderTest.java View 1 2 1 chunk +0 lines, -190 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/JsLibraryTest.java View 1 2 1 chunk +0 lines, -105 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureParserTest.java View 1 chunk +121 lines, -0 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureRegistryTest.java View 1 chunk +499 lines, -0 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/features/FeatureResourceLoaderTest.java View 1 chunk +197 lines, -0 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/render/OpenSocialI18NGadgetRewriterTest.java View 2 chunks +0 lines, -2 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriterTest.java View 1 2 3 4 25 chunks +132 lines, -80 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/PipelineDataGadgetRewriterTest.java View 1 2 3 chunks +2 lines, -6 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/rewrite/TemplateRewriterTest.java View 1 2 1 chunk +4 lines, -4 lines 0 comments Download
java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/tags/FlashTagHandlerTest.java View 1 2 7 chunks +25 lines, -13 lines 0 comments Download

Messages

Total messages: 14
johnfargo
15 years, 10 months ago (2009-10-28 00:59:10 UTC) #1
johnfargo
Attempt to fix missing code errors in CR tool.
15 years, 10 months ago (2009-10-28 02:13:52 UTC) #2
Jon Weygandt
On 2009/10/28 02:13:52, johnfargo wrote: > Attempt to fix missing code errors in CR tool. ...
15 years, 10 months ago (2009-10-28 17:51:21 UTC) #3
Jon Weygandt
http://codereview.appspot.com/143046/diff/80/1043 File java/gadgets/src/main/java/org/apache/shindig/gadgets/features/FeatureRegistry.java (right): http://codereview.appspot.com/143046/diff/80/1043#newcode177 Line 177: public List<FeatureResource> getFeatureResources( See details in SHINDIG-1183 I ...
15 years, 10 months ago (2009-10-28 17:52:58 UTC) #4
johnfargo
Thanks for the comments, Jon. I'll update a patch shortly that incorporates your fixes. What ...
15 years, 10 months ago (2009-10-28 20:15:18 UTC) #5
Jon Weygandt
I just tried to "svn update" and apply the patch. There are issues with the ...
15 years, 10 months ago (2009-10-28 23:15:09 UTC) #6
johnfargo
Cleaner patch (hopefully)
15 years, 10 months ago (2009-10-29 01:00:39 UTC) #7
Jon Weygandt
On 2009/10/29 01:00:39, johnfargo wrote: > Cleaner patch (hopefully) The patch applied cleanly, but seem ...
15 years, 10 months ago (2009-10-29 15:55:06 UTC) #8
johnfargo
Source control and patch don't play very nicely at all in anything but M situations. ...
15 years, 10 months ago (2009-10-29 16:42:20 UTC) #9
Jon Weygandt
On 2009/10/29 16:42:20, johnfargo wrote: > Source control and patch don't play very nicely at ...
15 years, 10 months ago (2009-10-29 22:23:06 UTC) #10
Jon Weygandt
On 2009/10/29 22:23:06, Jon Weygandt wrote: > On 2009/10/29 16:42:20, johnfargo wrote: > > Source ...
15 years, 10 months ago (2009-10-29 22:30:13 UTC) #11
johnfargo
Integrates Jon Weygandt's changes from http://codereview.appspot.com/144055
15 years, 10 months ago (2009-10-30 01:12:53 UTC) #12
Jon Weygandt
http://codereview.appspot.com/143046/diff/2111/2134 File java/gadgets/src/main/java/org/apache/shindig/gadgets/render/RenderingGadgetRewriter.java (right): http://codereview.appspot.com/143046/diff/2111/2134#newcode330 Line 330: private String getLibraryConfig(Gadget gadget, List<String> reqs) Can this ...
15 years, 10 months ago (2009-10-30 18:21:08 UTC) #13
johnfargo
15 years, 10 months ago (2009-11-02 20:39:51 UTC) #14
Committed the latest patch in this review, as I'd not received any negative
reviews, and incorporated all of Jon's feedback except the very last note (happy
to make that method protected in a separate followup btw).

This commit broke taming of core APIs - I'm working with Jas to get that
remedied. I committed as seen here to avoid what was continuing to become a
worse merge situation.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b