org.apache.shindig.gadgets.servlet
Class JsHandler

java.lang.Object
  extended by org.apache.shindig.gadgets.servlet.JsHandler

public class JsHandler
extends Object

Provide processing logic for the JsServlet to serve the JavsScript as features request. This class will allow separation of flow and serving logic for easy customization.


Nested Class Summary
protected static class JsHandler.JsGadgetContext
          GadgetContext for JsHandler called by FeatureRegistry when fetching the resources.
static class JsHandler.JsHandlerResponse
          Define the response data from JsHandler.
 
Field Summary
protected  Map<String,ConfigContributor> configContributors
           
protected  ContainerConfig containerConfig
           
protected  FeatureRegistry registry
           
 
Constructor Summary
JsHandler(FeatureRegistry registry, ContainerConfig containerConfig, Map<String,ConfigContributor> configContributors)
           
 
Method Summary
protected  JsHandler.JsHandlerResponse getFeatureResourcesContent(javax.servlet.http.HttpServletRequest req, GadgetContext ctx, Set<String> needed)
          Get the content of the feature resources and push it to jsData.
protected  Set<String> getFeaturesNeeded(javax.servlet.http.HttpServletRequest req)
          Get the Set of feature names from the request.
protected  GadgetContext getGadgetContext(javax.servlet.http.HttpServletRequest req)
          Get the GadgetContext to be used when calling FeatureRegistry.getFeatureResources.
 JsHandler.JsHandlerResponse getJsContent(javax.servlet.http.HttpServletRequest req)
          Get the JavaScript content from the feature name aliases.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registry

protected final FeatureRegistry registry

containerConfig

protected final ContainerConfig containerConfig

configContributors

protected final Map<String,ConfigContributor> configContributors
Constructor Detail

JsHandler

@Inject
public JsHandler(FeatureRegistry registry,
                        ContainerConfig containerConfig,
                        Map<String,ConfigContributor> configContributors)
Method Detail

getJsContent

public JsHandler.JsHandlerResponse getJsContent(javax.servlet.http.HttpServletRequest req)
Get the JavaScript content from the feature name aliases.

Parameters:
req - the HttpRequest object.
Returns:
JsHandlerResponse object that contains JavaScript data and cacheable flag.

getFeaturesNeeded

protected Set<String> getFeaturesNeeded(javax.servlet.http.HttpServletRequest req)
Get the Set of feature names from the request.

Parameters:
req - the HttpServletRequest object.
Returns:
Set of names of needed JavaScript as feature aliases from the request.

getGadgetContext

protected GadgetContext getGadgetContext(javax.servlet.http.HttpServletRequest req)
Get the GadgetContext to be used when calling FeatureRegistry.getFeatureResources.

Parameters:
req - the HttpServletRequest object.
Returns:
GadgetContext instance.

getFeatureResourcesContent

protected JsHandler.JsHandlerResponse getFeatureResourcesContent(javax.servlet.http.HttpServletRequest req,
                                                                 GadgetContext ctx,
                                                                 Set<String> needed)
Get the content of the feature resources and push it to jsData.

Parameters:
req - The HttpServletRequest object.
ctx - GadgetContext object.
needed - Set of requested feature names.
Returns:
JsHandlerResponse object that contains JavaScript data and cacheable flag.


Copyright © 2007-2012. All Rights Reserved.