Package org.apache.wicket.util.resource

Examples of org.apache.wicket.util.resource.IResourceStream


      {
        IPropertiesLoader loader = iter.next();
        String fullPath = path + "." + loader.getFileExtension();

        // If not in the cache than try to load properties
        IResourceStream resourceStream = context.getResourceStreamLocator()
          .locate(clazz, fullPath);
        if (resourceStream == null)
        {
          continue;
        }
View Full Code Here


    Application app = Application.get();
    TextTemplateCache cache = (TextTemplateCache)app.getMetaData(TEXT_TEMPLATE_CACHE_KEY);
    // TODO implement cache

    // first try default class loading locator to find the resource
    IResourceStream stream = new ResourceStreamLocator().locate(clazz, path);

    if (stream == null)
    {
      // if default locator couldnt find the resource allow the application specific one to
      // try
      stream = Application.get().getResourceSettings().getResourceStreamLocator().locate(
        clazz, path);
    }

    if (stream == null)
    {
      throw new IllegalArgumentException("resource " + fileName + " not found for scope " +
        clazz + " (path = " + path + ")");
    }

    try
    {
      if (encoding != null)
      {
        buffer.append(Streams.readString(stream.getInputStream(), encoding));
      }
      else
      {
        buffer.append(Streams.readString(stream.getInputStream()));
      }
    }
    catch (IOException e)
    {
      throw new RuntimeException(e);
    }
    catch (ResourceStreamNotFoundException e)
    {
      throw new RuntimeException(e);
    }
    finally
    {
      try
      {
        stream.close();
      }
      catch (IOException e)
      {
        log.error(e.getMessage(), e);
      }
View Full Code Here

            .decode(request);
          // Set parameters from servlet request
          resource.setParameters(rp.getParameters());

          // Get resource stream
          IResourceStream stream = resource.getResourceStream();

          // Get last modified time from stream
          Time time = stream.lastModifiedTime();

          try
          {
            stream.close();
          }
          catch (IOException e)
          {
            // ignore
          }
View Full Code Here

      }
      else
      {
        final Page page = container.getPage();
        final String pageClassName = (page != null) ? page.getClass().getName() : "unknown";
        final IResourceStream stream = markupStream.getResource();
        final String streamName = (stream != null) ? stream.toString() : "unknown";

        throw new MarkupException(
          "Mis-placed <wicket:head>. <wicket:head> must be outside of <wicket:panel>, <wicket:border>, and <wicket:extend>. Error occured while rendering page: " +
            pageClassName + " using markup stream: " + streamName);
      }
View Full Code Here

   *            throw an AbortException when resource does not exist
   */
  public IResourceStream getResourceStream(boolean failOnError)
  {
    // Locate resource
    IResourceStream resourceStream = Application.get()
      .getResourceSettings()
      .getResourceStreamLocator()
      .locate(getScope(), absolutePath, style, locale, null);

    // Check that resource was found
    if (resourceStream == null)
    {
      if (!failOnError)
      {
        // Do not abort the request, as we are not yet serving the resource
        return null;
      }

      String msg = "Unable to find package resource [path = " + absolutePath + ", style = " +
        style + ", locale = " + locale + "]";
      log.warn(msg);
      if (RequestCycle.get() instanceof WebRequestCycle)
      {
        throw new AbortWithWebErrorCodeException(HttpServletResponse.SC_NOT_FOUND, msg);
      }
      else
      {
        throw new AbortException();
      }
    }

    locale = resourceStream.getLocale();

    if (resourceStream != null)
    {
      lastModifiedTime = resourceStream.lastModifiedTime();
      lastModifiedTimeUpdate = System.currentTimeMillis();
    }

    return resourceStream;
  }
View Full Code Here

    /**
     * @return compressed content
     */
    private byte[] getCompressedContent()
    {
      IResourceStream stream = getOriginalResourceStream();
      try
      {
        byte ret[];
        if (cache != null)
        {
          ret = (byte[])cache.get();
          if (ret != null && timeStamp != null)
          {
            if (timeStamp.equals(stream.lastModifiedTime()))
            {
              return ret;
            }
          }
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        GZIPOutputStream zout = new GZIPOutputStream(out);
        Streams.copy(stream.getInputStream(), zout);
        zout.close();
        stream.close();
        ret = out.toByteArray();
        timeStamp = stream.lastModifiedTime();
        cache = new SoftReference(ret);
        return ret;
      }
      catch (IOException e)
      {
View Full Code Here

    Class containerClass = getClass();

    while (!(containerClass.equals(MarkupComponentBorder.class)))
    {
      String path = containerClass.getName().replace('.', '/');
      IResourceStream resourceStream = locator.locate(containerClass, path, style, locale,
        markupType);

      // Did we find it already?
      if (resourceStream != null)
      {
View Full Code Here

        log.debug("Load markup: cacheKey=" + cacheKey);
      }

      // Who is going to provide the markup resource stream?
      // And ask the provider to locate the markup resource stream
      final IResourceStream resourceStream = getMarkupResourceStreamProvider(container).getMarkupResourceStream(
        container, containerClass);

      // Found markup?
      if (resourceStream != null)
      {
View Full Code Here

    Properties properties = (Properties)propertiesCache.get(path);

    if (properties == null)
    {
      // If not in the cache than try to load properties
      IResourceStream stream = application.getResourceSettings()
        .getResourceStreamLocator()
        .locate(clazz, path);
      if (stream != null)
      {
        // Load the properties from the stream
View Full Code Here

  }

  @Override
  public Serializable getCacheKey()
  {
    IResourceStream stream = getCacheableResourceStream();

    // if resource stream can not be found do not cache
    if (stream == null)
    {
      return null;
    }

    return new CacheKey(scopeName, absolutePath, stream.getLocale(), stream.getStyle(),
      stream.getVariation());
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.resource.IResourceStream

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.