com.cc.framework.resource
Class ResourceManager

java.lang.Object
  extended bycom.cc.framework.resource.ResourceManager

public final class ResourceManager
extends java.lang.Object

The resource manager manages resources in the application, session or request scope.

Since:
1.0
Version:
$Revision: 1.21 $
Author:
Harald Schulz

Field Summary
private static java.lang.String cacheDir
          Directory for the Resource Cache
private static org.apache.commons.logging.Log log
          Logging instance
 
Constructor Summary
private ResourceManager()
          Constructor for ResourceManager
 
Method Summary
static java.lang.String getCacheDir()
          Returns the directory used to cache resources.
static Resource getResource(javax.servlet.http.HttpServletRequest request, HttpScope scope, java.lang.String key)
          Returns a registered resource out of the cache
private static java.util.Hashtable getResourceCache(javax.servlet.http.HttpServletRequest request, HttpScope scope, boolean create)
          Returns the hashtable with resources in the specified scope
private static java.util.Hashtable getResourceCache(javax.servlet.ServletContext context, boolean create)
          Returns the hashtable with resources in the application scope
static Resource getResourceFromURI(javax.servlet.http.HttpServletRequest request, java.lang.String uri)
          Returns a registered resource from the request cache.
static java.lang.String getResourceURI(javax.servlet.jsp.PageContext ctx, HttpScope scope, java.lang.String key, Cachable cacheInfo)
          Returns a URI for the specified resource This can be the filename, which is used to store the file on the disk
static java.lang.String getResourceURI(javax.servlet.jsp.PageContext ctx, HttpScope scope, java.lang.String key, Cachable cacheInfo, boolean contextRelative)
          Returns a URI for the specified resource This can be the filename, which is used to store the file on the disk
static boolean isUpToDate(javax.servlet.http.HttpServletRequest request, HttpScope scope, java.lang.String key, Cachable cacheInfo)
          Checks if a registered resource is up to date
static void registerResource(javax.servlet.http.HttpServletRequest request, HttpScope scope, java.lang.String key, java.awt.image.BufferedImage image, Cachable cacheInfo)
          Registers a JPEG resource
static void registerResource(javax.servlet.http.HttpServletRequest request, HttpScope scope, java.lang.String key, MimeType type, byte[] body, Cachable cacheInfo)
          Registers a binary resource
static void registerResource(javax.servlet.http.HttpServletRequest request, HttpScope scope, java.lang.String key, MimeType type, java.lang.String bodyStream, Cachable cacheInfo)
          Registers a binary resource
static void registerResource(javax.servlet.http.HttpServletRequest request, HttpScope scope, java.lang.String key, java.lang.Object object, Cachable cacheInfo)
          Registers a object resource
static void registerResource(javax.servlet.http.HttpServletRequest request, HttpScope scope, java.lang.String key, Resource resource)
          Register a resource in the specified scope
static void registerResource(javax.servlet.ServletContext context, java.lang.String key, Resource resource)
          Register a resource in the application scope
static void setCacheDir(java.lang.String newCacheDir)
          Sets the directory which should be used to cache resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log
Logging instance


cacheDir

private static java.lang.String cacheDir
Directory for the Resource Cache

Constructor Detail

ResourceManager

private ResourceManager()
Constructor for ResourceManager

Method Detail

registerResource

public static void registerResource(javax.servlet.http.HttpServletRequest request,
                                    HttpScope scope,
                                    java.lang.String key,
                                    java.awt.image.BufferedImage image,
                                    Cachable cacheInfo)
Registers a JPEG resource

Parameters:
request - HttpServletRequest
scope - The scope where to register the Resource
key - The resource key
image - the image to register
cacheInfo - optional caching information

registerResource

public static void registerResource(javax.servlet.http.HttpServletRequest request,
                                    HttpScope scope,
                                    java.lang.String key,
                                    MimeType type,
                                    byte[] body,
                                    Cachable cacheInfo)
Registers a binary resource

Parameters:
request - HttpServletRequest
scope - HttpScope
key - Key
type - MimeType
body - Resource to register
cacheInfo - Cachable

registerResource

public static void registerResource(javax.servlet.http.HttpServletRequest request,
                                    HttpScope scope,
                                    java.lang.String key,
                                    MimeType type,
                                    java.lang.String bodyStream,
                                    Cachable cacheInfo)
Registers a binary resource

Parameters:
request - HttpServletRequest
scope - HttpScope
key - Key
type - MimeType
bodyStream - Object to register
cacheInfo - Cachable

registerResource

public static void registerResource(javax.servlet.http.HttpServletRequest request,
                                    HttpScope scope,
                                    java.lang.String key,
                                    java.lang.Object object,
                                    Cachable cacheInfo)
Registers a object resource

Parameters:
request - HttpServletRequest
scope - HttpScope
key - Key
object - Object to register
cacheInfo - Cachable

registerResource

public static void registerResource(javax.servlet.http.HttpServletRequest request,
                                    HttpScope scope,
                                    java.lang.String key,
                                    Resource resource)
Register a resource in the specified scope

Parameters:
request - HttpServletRequest
scope - HttpScope
key - Key
resource - Resource

registerResource

public static void registerResource(javax.servlet.ServletContext context,
                                    java.lang.String key,
                                    Resource resource)
Register a resource in the application scope

Parameters:
context - ServletContext
key - Key
resource - Resource

getResourceURI

public static java.lang.String getResourceURI(javax.servlet.jsp.PageContext ctx,
                                              HttpScope scope,
                                              java.lang.String key,
                                              Cachable cacheInfo)
Returns a URI for the specified resource This can be the filename, which is used to store the file on the disk

Parameters:
ctx - PageContext
scope - HttpScope
key - Key
cacheInfo - Caching Information about the Resource or null
Returns:
String

getResourceURI

public static java.lang.String getResourceURI(javax.servlet.jsp.PageContext ctx,
                                              HttpScope scope,
                                              java.lang.String key,
                                              Cachable cacheInfo,
                                              boolean contextRelative)
Returns a URI for the specified resource This can be the filename, which is used to store the file on the disk

Parameters:
ctx - PageContext
scope - HttpScope
key - Key
cacheInfo - Caching Information about the Resource or null
contextRelative -
  • when set to true the applications context path will not be added to the URI.
  • When set to false the applications context path (= context absolute) will be added to the URI
Returns:
String

isUpToDate

public static boolean isUpToDate(javax.servlet.http.HttpServletRequest request,
                                 HttpScope scope,
                                 java.lang.String key,
                                 Cachable cacheInfo)
Checks if a registered resource is up to date

Parameters:
request - The HttpServletRequest
scope - HttpScope
key - Key
cacheInfo - Cachable
Returns:
boolean

getResourceFromURI

public static Resource getResourceFromURI(javax.servlet.http.HttpServletRequest request,
                                          java.lang.String uri)
Returns a registered resource from the request cache. The URI follows the syntax: .../[scope]/[key].res

Parameters:
request - The HttpServletRequest
uri - The URI for the registered resource
Returns:
Resource the registered resource for the requested URI

getResource

public static Resource getResource(javax.servlet.http.HttpServletRequest request,
                                   HttpScope scope,
                                   java.lang.String key)
Returns a registered resource out of the cache

Parameters:
request - The HttpServletRequest
scope - HttpScope
key - Key
Returns:
Resource

getResourceCache

private static java.util.Hashtable getResourceCache(javax.servlet.http.HttpServletRequest request,
                                                    HttpScope scope,
                                                    boolean create)
Returns the hashtable with resources in the specified scope

Parameters:
request - HttpServletRequest
scope - HttpScope
create - true, if a new Resource table should be created
Returns:
Hashtable

getResourceCache

private static java.util.Hashtable getResourceCache(javax.servlet.ServletContext context,
                                                    boolean create)
Returns the hashtable with resources in the application scope

Parameters:
context - ServletContext
create - true, if a new Resource table should be created
Returns:
Hashtable

getCacheDir

public static java.lang.String getCacheDir()
Returns the directory used to cache resources.

Returns:
String the cache directory

setCacheDir

public static void setCacheDir(java.lang.String newCacheDir)
Sets the directory which should be used to cache resources.

Parameters:
newCacheDir - The cache directory


Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.