Everit - WebResource

An extender component to be able to serve static resources (css, javascript, gif, ...) via HTTP

License

License

GroupId

GroupId

org.everit.osgi
ArtifactId

ArtifactId

org.everit.osgi.webresource
Last Version

Last Version

2.0.2
Release Date

Release Date

Type

Type

bundle
Description

Description

Everit - WebResource
An extender component to be able to serve static resources (css, javascript, gif, ...) via HTTP
Project URL

Project URL

https://github.com/everit-org/webresource
Project Organization

Project Organization

Everit Kft.
Source Code Management

Source Code Management

https://github.com/everit-org/webresource

Download org.everit.osgi.webresource

Dependencies

compile (1)

Group / Artifact Type Version
org.everit.osgi.bundles : org.everit.osgi.bundles.org.apache.felix.utils jar 1.6.0

provided (3)

Group / Artifact Type Version
org.osgi : org.osgi.core jar 6.0.0
org.osgi : org.osgi.compendium jar 4.3.1
javax.servlet : javax.servlet-api jar 3.1.0

Project Modules

There are no modules declared in this project.

webresource

Introduction

Webresources are small static files that are downloaded during rendering a website. E.g.: CSS, Javascript, images, ...

Basic usage

  • Install the org.everit.osgi.webresource module into your OSGi container.
  • Install the WebResourceServlet (that is provided as an OSGi service) into your ServletContext.
  • Use CommonContextWebResourceURIGenerator to generate URIs that point to WebResources. This class will pick up the URIGenerator(s) registered by WebResourceServlet within the same ServletContext.

You can also install custom WebResourceURIGenerator implementations in the servletContext. In this case:

  • Get the Collection of WebResourceGenerators from the servlet context by calling WebResourceUtil.getUriGeneratorsOfServletContext(context);
  • Add your generator to the collection

Create WebResource packages

To make an OSGi bundle also a WebResource package the everit.webresource capability must be provided. The capability can have the following attributes:

  • resourceFolder: The folder in the bundle where the resources are located.
  • libraryPrefix: A prefix that should be pasted in front of the folder structure in the URL. E.g.: "foo/bar"
  • version: Optional attribute that can define the version of the webresources. If not defined, the version of the bundle will be used.

Version handling

The webresource_version can be specified as a parameter of the servlet request. Using ranges in the version expression is allowed. Examples:

  • /alias/jquery/jquer.js?webresource_version=2.1.0
  • /alias/jquery/jquer.js?webresource_version=[2.1.0,3)

Cache

There is a primitive, in-memory cache. The GZIP, Deflate and RAW data is stored in cache after the first request. When a bundle is stopped, all webresources are removed from the cache that came from that bundle.

WebConsole Plugin

There is a WebConsole plugin that is registered when the Extender component is started. It shows the registered webresources and the state of the caches.

Content-Encoding

GZIP, Deflate and RAW content encodings are supported.

ETag support

SHA-256 hash of the RAW content is concatenated with the last modification date of the webresource file.

Logging

Java Util Logger is used to log errors during transferring data. Such errors may happen if the connection is broken. The name of the logger is org.everit.osgi.webresource.stream.

Minimum requirements

  • OSGi 6: WebResourceServlet is registered with prototype service scope. Luckily Felix and Equinox has OSGi 6 support now.
  • Servlet 3.1: WebResourceUtil writes the content of the WebResources using asynchronous IO if possible.
  • Java 8: Many of the features of Java 8 is used (time, optional, ...)
org.everit.osgi

Everit Kft.

Open source projects of Everit Kft.

Versions

Version
2.0.2
2.0.1
2.0.0
1.0.0-alpha2