org.apache.shindig.gadgets.render
Class RenderingGadgetRewriter

java.lang.Object
  extended by org.apache.shindig.gadgets.render.RenderingGadgetRewriter
All Implemented Interfaces:
GadgetRewriter

public class RenderingGadgetRewriter
extends Object
implements GadgetRewriter

Produces a valid HTML document for the gadget output, automatically inserting appropriate HTML document wrapper data as needed. Currently, this is only invoked directly since the rewriting infrastructure doesn't properly deal with uncacheable rewrite operations. TODO: Break this up into multiple rewriters. Should be: - UserPrefs injection - Javascript injection (including configuration) - html document normalization


Field Summary
protected  Map<String,ConfigContributor> configContributors
           
protected  ContainerConfig containerConfig
           
protected static String DEFAULT_CSS
           
protected  Set<String> defaultExternLibs
           
protected  Boolean externalizeFeatures
           
protected  FeatureRegistry featureRegistry
           
protected  JsUriManager jsUriManager
           
protected  MessageBundleFactory messageBundleFactory
           
 
Constructor Summary
RenderingGadgetRewriter(MessageBundleFactory messageBundleFactory, ContainerConfig containerConfig, FeatureRegistry featureRegistry, JsUriManager jsUriManager, Map<String,ConfigContributor> configContributors)
           
 
Method Summary
protected  String getLibraryConfig(Gadget gadget, List<String> reqs)
          Creates a set of all configuration needed to satisfy the requested feature set.
protected  void injectBaseTag(Gadget gadget, Node headTag)
           
protected  void injectDefaultPrefs(Gadget gadget, Node scriptTag)
          Injects default values for user prefs into the gadget output.
protected  void injectFeatureLibraries(Gadget gadget, Node headTag, Node firstHeadChild)
          Injects javascript libraries needed to satisfy feature dependencies.
protected  void injectGadgetBeacon(Gadget gadget, Node headTag, Node firstHeadChild)
           
protected  void injectMessageBundles(MessageBundle bundle, Node scriptTag)
          Injects message bundles into the gadget output.
protected  void injectOnLoadHandlers(Node bodyTag)
           
protected  void injectPreloads(Gadget gadget, Node scriptTag)
          Injects preloads into the gadget output.
 void rewrite(Gadget gadget, MutableContent mutableContent)
          Rewrite the gadget.
 void setDefaultForcedLibs(String forcedLibs)
           
 void setExternalizeFeatureLibs(Boolean externalizeFeatures)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CSS

protected static final String DEFAULT_CSS
See Also:
Constant Field Values

messageBundleFactory

protected final MessageBundleFactory messageBundleFactory

containerConfig

protected final ContainerConfig containerConfig

featureRegistry

protected final FeatureRegistry featureRegistry

jsUriManager

protected final JsUriManager jsUriManager

configContributors

protected final Map<String,ConfigContributor> configContributors

defaultExternLibs

protected Set<String> defaultExternLibs

externalizeFeatures

protected Boolean externalizeFeatures
Constructor Detail

RenderingGadgetRewriter

@Inject
public RenderingGadgetRewriter(MessageBundleFactory messageBundleFactory,
                                      ContainerConfig containerConfig,
                                      FeatureRegistry featureRegistry,
                                      JsUriManager jsUriManager,
                                      Map<String,ConfigContributor> configContributors)
Parameters:
messageBundleFactory - Used for injecting message bundles into gadget output.
Method Detail

setDefaultForcedLibs

@Inject
public void setDefaultForcedLibs(String forcedLibs)

setExternalizeFeatureLibs

@Inject(optional=true)
public void setExternalizeFeatureLibs(Boolean externalizeFeatures)

rewrite

public void rewrite(Gadget gadget,
                    MutableContent mutableContent)
             throws RewritingException
Description copied from interface: GadgetRewriter
Rewrite the gadget.

Specified by:
rewrite in interface GadgetRewriter
Parameters:
gadget - Gadget to rewrite.
mutableContent - the content of the gadget to be manipulated.
Throws:
RewritingException

injectBaseTag

protected void injectBaseTag(Gadget gadget,
                             Node headTag)

injectOnLoadHandlers

protected void injectOnLoadHandlers(Node bodyTag)

injectGadgetBeacon

protected void injectGadgetBeacon(Gadget gadget,
                                  Node headTag,
                                  Node firstHeadChild)
                           throws GadgetException
Throws:
GadgetException

injectFeatureLibraries

protected void injectFeatureLibraries(Gadget gadget,
                                      Node headTag,
                                      Node firstHeadChild)
                               throws GadgetException
Injects javascript libraries needed to satisfy feature dependencies.

Throws:
GadgetException

getLibraryConfig

protected String getLibraryConfig(Gadget gadget,
                                  List<String> reqs)
                           throws GadgetException
Creates a set of all configuration needed to satisfy the requested feature set. Appends special configuration for gadgets.util.hasFeature and gadgets.util.getFeatureParams to the output js. This can't be handled via the normal configuration mechanism because it is something that varies per request.

Parameters:
reqs - The features needed to satisfy the request.
Throws:
GadgetException - If there is a problem with the gadget auth token

injectMessageBundles

protected void injectMessageBundles(MessageBundle bundle,
                                    Node scriptTag)
                             throws GadgetException
Injects message bundles into the gadget output.

Throws:
GadgetException - If we are unable to retrieve the message bundle.

injectDefaultPrefs

protected void injectDefaultPrefs(Gadget gadget,
                                  Node scriptTag)
Injects default values for user prefs into the gadget output.


injectPreloads

protected void injectPreloads(Gadget gadget,
                              Node scriptTag)
Injects preloads into the gadget output. If preloading fails for any reason, we just output an empty object.



Copyright © 2007-2012. All Rights Reserved.