ResourceManager

ResourceManager is used to avoid multiple HTTP requests when loading resources like Javascript or CSS files. It uses one Servlet that receives the name of all wanted files, load and process them. The response can be sent in two formats: all resources concatenated in a single result or a JSON array containing each resource associated with its path.

  • Language: Java
  • Released: Feb 11, 2011
    Last Update: Feb 11, 2011

The ResourceManager is composed by one ContextListener that holds all resources that were already loaded and processed. It is also responsible for loading new resources needed.

Loaders are used to load resources from any place. This module comes with two implementations: WebApplicationFileLoader and ClasspathLoader. The first one loads resources contained in the application directory. The second loads resources that were added to the classpath (through a jar or whatever).
To add a new Loader to the application, just implement the interface and set it up as a service.

Before being handled to the servlet resources can be processed (compressed, obfuscated, etc.) by Processors. Processors can also be registered as services and will be loaded automatically just by adding them to the classpath. No processor is included in this module.

Another feature that was added to this module is a tag that configure a link to the servlet automatically. In the last two screenshots there is an example of how to use it and what is generated.

Hide

Installation

Step 0 - This module depends on the Jackson JSON Processor to create JSON outputs. Download and add it to your project before continuing.

Step 1 - Add the jar that comes inside the zip file into your WEB-INF/lib directory.

Step 2 - Configure the ResourceContextListener just add a listener element to your web.xml file:

   
        br.com.depasser.web.resource.ResourceContextListener
   

Step 3 - Add the servlet and servlet mappings:

   
       
        ResourceServlet
        ResourceServlet
        br.com.depasser.web.resource.ResourceServlet
   

   
        ResourceServlet
        /resources.do
   

   
        ResourceServlet
        /resources.json
   

That's it, you can start using it!

You need to log-in or create an account
  • Create an account
  • Log-in

Please use your real name.

Activation link will be sent to this address.

Minimum 8 characters

Enter your password again

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

X

Save your watchlist

Fill your details below to receive project updates from your watch list - including new versions, price changes and discounts.

I agree to the terms of use and privacy policy.

License » MIT license Download
Post a comment

Or enter your name and Email
No comments have been posted yet.