Package org.apache.shindig.gadgets.preload

Examples of org.apache.shindig.gadgets.preload.Preloads


    try {
      View view = gadget.getCurrentView();
      GadgetContext context = gadget.getContext();
      GadgetSpec spec = gadget.getSpec();

      Preloads preloads = preloader.preload(context, spec);
      gadget.setPreloads(preloads);

      if (view.getHref() == null) {
        return rewriter.rewriteGadget(gadget, view.getContent());
      } else {
View Full Code Here


   *
   * If preloading fails for any reason, we just output an empty object.
   */
  private void injectPreloads(Gadget gadget, Node scriptTag) {
    JSONObject preload = new JSONObject();
    Preloads preloads = gadget.getPreloads();

    for (String name : preloads.getKeys()) {
      try {
        preload.put(name, preloads.getData(name).toJson());
      } catch (PreloadException e) {
        // This will be thrown in the event of some unexpected exception. We can move on.
        LOG.log(Level.WARNING, "Unexpected error attempting to preload " + name, e);
      } catch (JSONException e) {
        // Shouldn't ever happen. Probably indicates a big problem, so we'll abort.
View Full Code Here

    // Other types are supported (anything valid for org.json.JSONObject), but equality comparisons
    // are more complicated because JSON doesn't implement interfaces like Collection or Map, or
    // implementing equals.

    Preloads preloads = new Preloads() {

      public PreloadedData getData(final String key) {
        return new PreloadedData() {
          public Object toJson() {
            return preloadData.get(key);
View Full Code Here

    }
  }

  @Test
  public void failedPreloadHandledGracefully() throws Exception {
    Preloads preloads = new Preloads() {
      public PreloadedData getData(final String key) throws PreloadException {
        throw new PreloadException("broken");
      }
      public Set<String> getKeys() {
        return ImmutableSortedSet.of("foo");
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.preload.Preloads

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.