Package org.apache.shindig.gadgets.uri.JsUriManager

Examples of org.apache.shindig.gadgets.uri.JsUriManager.JsUri


    }
  }

  public boolean process(JsRequest request, JsResponseBuilder builder)
      throws JsException {
    JsUri jsUri = request.getJsUri();

    // Don't emit the JS itself; instead emit JS loader script that loads
    // versioned JS. The loader script is much smaller and cacheable for a
    // configurable amount of time.
    if (jsUri.isJsload()) {
      // Require users to specify &onload=. This ensures a reliable continuation
      // of JS execution. IE asynchronously loads script, before it loads
      // source-scripted and inlined JS.
      if (requireOnload && jsUri.getOnload() == null) {
        throw new JsException(HttpServletResponse.SC_BAD_REQUEST, JSLOAD_ONLOAD_ERROR);
      }

      int refresh = getCacheTtlSecs(jsUri);
      builder.setCacheTtlSecs(refresh);
View Full Code Here


      Provider<GadgetContext> context) {
    super(featureRegistryProvider, context);
  }

  public boolean process(JsRequest jsRequest, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = jsRequest.getJsUri();
    ImmutableList.Builder<JsContent> resp = ImmutableList.builder();
    FeatureRegistry featureRegistry = getFeatureRegistry(jsUri);

    boolean needDefers = false;
    if (jsUri.isJsload()) {
      // append all exports for deferred symbols
      List<FeatureBundle> bundles = getSupportDeferBundles(featureRegistry, jsRequest);
      for (FeatureBundle bundle : bundles) {
        needDefers |= appendDeferJsStatements(resp, jsRequest.getJsUri(), bundle);
      }
View Full Code Here

      Provider<GadgetContext> context) {
    super(featureRegistryProvider, context);
  }

  public boolean process(JsRequest jsRequest, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = jsRequest.getJsUri();
    ImmutableList.Builder<JsContent> resp = ImmutableList.builder();
    FeatureRegistry featureRegistry = getFeatureRegistry(jsUri);

    boolean needExports = false;
    FeatureBundle last = null;
    if (!jsUri.isJsload()) {
      for (JsContent jsc : builder.build().getAllJsContent()) {
        FeatureBundle current = jsc.getFeatureBundle();
        if (last != null && current != last) {
          needExports |= appendExportJsStatements(resp, jsUri, last);
        }
View Full Code Here

    this.registryProvider = registryProvider;
    this.configProcessor = configProcessor;
  }

  public boolean process(JsRequest request, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = request.getJsUri();
    GadgetContext ctx = new JsGadgetContext(jsUri);
    FeatureRegistry registry;
    try {
      registry = registryProvider.get(jsUri.getRepository());
    } catch (GadgetException e) {
      throw new JsException(e.getHttpStatusCode(), e.getMessage());
    }

    // Append gadgets.config initialization if not in standard gadget mode.
    if (ctx.getRenderingContext() != RenderingContext.GADGET) {
      List<String> allReq = registry.getFeatures(jsUri.getLibs());
      Collection<String> loaded = jsUri.getLoadedLibs();

      // Only inject config for features not already present and configured.
      List<String> newReq = subtractCollection(allReq, loaded);

      Map<String, Object> config = configProcessor.getConfig(
View Full Code Here

  @VisibleForTesting
  static final String TEMPLATE =
      "window['___jsl']['l'] = (window['___jsl']['l'] || []).concat(%s);";

  public boolean process(JsRequest jsRequest, JsResponseBuilder builder) throws JsException {
    JsUri jsUri = jsRequest.getJsUri();
    if (!jsUri.isNohint()) {
      Set<String> result = getBundleNames(jsUri, false);
      result.removeAll(getBundleNames(jsUri, true));
      String array = toArrayString(result);
      builder.appendJs(String.format(TEMPLATE, array), CODE_ID);
    }
View Full Code Here

  public AddJslInfoVariableProcessor(JsUriManager jsUriManager) {
    this.jsUriManager = jsUriManager;
  }

  public boolean process(JsRequest jsRequest, JsResponseBuilder builder) {
    JsUri jsUri = jsRequest.getJsUri();
    if (!jsUri.isNohint()) {
      String uri = StringEscapeUtils.escapeEcmaScript(getUri(jsUri));
      String features = getFeatures(jsUri);
      builder.prependJs(String.format(FEATURES_HINT_TEMPLATE, features), CODE_ID);
      if (uri != null && !"".equals(uri)) {
        builder.prependJs(String.format(URL_HINT_TEMPLATE, uri), CODE_ID);
View Full Code Here

  }

  protected String getUri(JsUri jsUri) {
    Uri uri = jsUri.getOrigUri();
    if (uri == null || jsUri.isJsload()) {
      JsUri auxUri = new JsUri(jsUri);
      auxUri.setJsload(false);
      if (jsUri.isJsload()) {
        auxUri.setNohint(true);
      }
      uri = jsUriManager.makeExternJsUri(auxUri);
    }
    return uri.toString();
  }
View Full Code Here

  public GadgetsHandlerApi.JsResponse getJs(GadgetsHandlerApi.JsRequest request)
      throws ProcessingException {
    verifyBaseParams(request, false);
    Set<String> fields = beanFilter.processBeanFields(request.getFields());

    JsUri jsUri = createJsUri(request);
    Uri servedUri = jsUriManager.makeExternJsUri(jsUri);

    String content = null;
    Long expireMs = null;
    if (isFieldIncluded(fields, "jsContent")) {
View Full Code Here

    (request.getContext() != null ?
        // TODO: Figure out why maven complain about casting and clean the dummy cast
        (Object) beanDelegator.convertEnum(request.getContext())
        : RenderingContext.GADGET);

    return new JsUri(request.getRefresh(), request.getDebug(), request.getIgnoreCache(),
        request.getContainer(), request.getGadget(), request.getFeatures(),
        request.getLoadedFeatures(), request.getOnload(), false, false, context, request.getUrl(),
        request.getRepository());
  }
View Full Code Here

      Gadget gadget, Node headTag, Node firstHeadChild, String extraContent)
      throws GadgetException {

    GadgetContext context = gadget.getContext();
    // Gadget is not specified in request in order to support better caching
    JsUri jsUri = new JsUri(null, context.getDebug(), false, context.getContainer(), null,
        libs, loaded, null, false, false, RenderingContext.getDefault(), null,
        getFeatureRepositoryId(gadget));
    jsUri.setCajoleContent(gadget.requiresCaja());

    String content = "";
    if (!inline) {
      String jsUrl = new UriBuilder(jsUriManager.makeExternJsUri(jsUri))
          // Avoid jsload by adding jsload=0
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.uri.JsUriManager.JsUri

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.