コード例 #1
0
ファイル: MarkupCache.java プロジェクト: jmireles/wicket
  /**
   * Loads markup from a resource stream.
   *
   * @param container The original requesting markup container
   * @param markupResourceStream The markup resource stream to load
   * @param enforceReload The cache will be ignored and all, including inherited markup files, will
   *     be reloaded. Whatever is in the cache, it will be ignored
   * @return The markup. Markup.NO_MARKUP, if not found.
   */
  private final Markup loadMarkup(
      final MarkupContainer container,
      final MarkupResourceStream markupResourceStream,
      final boolean enforceReload) {
    String cacheKey = markupResourceStream.getCacheKey();
    String locationString = markupResourceStream.locationAsString();
    if (locationString == null) {
      // set the cache key as location string, because location string
      // couldn't be resolved.
      locationString = cacheKey;
    }

    Markup markup = MarkupFactory.get().loadMarkup(container, markupResourceStream, enforceReload);
    if (markup != null) {
      if (cacheKey != null) {
        String temp = markup.locationAsString();
        if (temp != null) {
          locationString = temp;
        }

        // add the markup to the cache.
        markupKeyCache.put(cacheKey, locationString);
        return putIntoCache(locationString, container, markup);
      }
      return markup;
    }

    // In case the markup could not be loaded (without exception) then ..
    if (cacheKey != null) {
      removeMarkup(cacheKey);
    }

    return Markup.NO_MARKUP;
  }
コード例 #2
0
ファイル: MarkupCache.java プロジェクト: jmireles/wicket
  private void removeMarkupWhereBaseMarkupIsNoLongerInTheCache() {
    // Repeat until all dependent resources have been removed (count == 0)
    int count = 1;
    while (count > 0) {
      // Reset prior to next round
      count = 0;

      // Iterate though all entries of the cache
      Iterator<Markup> iter = markupCache.getValues().iterator();
      while (iter.hasNext()) {
        Markup markup = iter.next();

        if ((markup != null) && (markup != Markup.NO_MARKUP)) {
          // Check if the markup associated with key has a base markup. And if yes, test
          // if that is cached. If the base markup has been removed, than remove the
          // derived markup as well.

          MarkupResourceStream resourceStream = markup.getMarkupResourceStream();
          if (resourceStream != null) {
            resourceStream = resourceStream.getBaseMarkupResourceStream();
          }

          // Is the base markup available in the cache?
          if ((resourceStream != null) && !isMarkupCached(resourceStream)) {
            iter.remove();
            count++;

            if (log.isDebugEnabled()) {
              log.debug("Removed derived markup from cache: " + markup.getMarkupResourceStream());
            }
          }
        }
      }
    }
  }
コード例 #3
0
 @Test
 public void testWithMarkups() {
   Markup markup = new Markup();
   markup.setStart(13);
   Sequence withMarkups = sequence.withMarkups(ImmutableList.of(markup));
   assertNotNull(withMarkups.getMarkups());
   assertEquals(2, withMarkups.getMarkups().size());
   for (Markup m : withMarkups.getMarkups()) {
     assertTrue(m.getStart() == 13 || m.getStart() == 24);
   }
 }
コード例 #4
0
 @Before
 public void setUp() {
   sequence = new Sequence();
   sequence.setLength(42);
   Options options = new Options();
   options.setBaseUrl("baseUrl");
   sequence.setOptions(options);
   Markup markup = new Markup();
   markup.setStart(24);
   sequence.setMarkups(ImmutableList.of(markup));
   Map<String, Object> metadata = newHashMap();
   metadata.put("key", "value");
   sequence.setMetadata(metadata);
   Motif motif = new Motif();
   motif.setStart(24);
   sequence.setMotifs(ImmutableList.of(motif));
   Region region = new Region();
   region.setStart(24);
   sequence.setRegions(ImmutableList.of(region));
 }
コード例 #5
0
ファイル: MarkupClp.java プロジェクト: yurize/Liferay-plugins
  public int compareTo(Markup markup) {
    long pk = markup.getPrimaryKey();

    if (getPrimaryKey() < pk) {
      return -1;
    } else if (getPrimaryKey() > pk) {
      return 1;
    } else {
      return 0;
    }
  }
コード例 #6
0
 public IMarkupFragment getMarkup() {
   IMarkupFragment enclosureMarkup = null;
   if (this.enclosureMarkupAsString == null) {
     final IMarkupFragment markup = super.getMarkup();
     if (markup != null && markup != Markup.NO_MARKUP) {
       enclosureMarkup = markup;
       this.enclosureMarkupAsString = markup.toString(true);
     }
   } else {
     enclosureMarkup = Markup.of(this.enclosureMarkupAsString);
   }
   return enclosureMarkup;
 }