org.jmage.resource
Class DefaultImageFactory

java.lang.Object
  extended by org.jmage.resource.DefaultImageFactory
All Implemented Interfaces:
Configurable, ResourceFactory

public class DefaultImageFactory
extends java.lang.Object
implements ResourceFactory

DefaultImageFactory loads images as resources from system environment.


Field Summary
protected  ApplicationContext applicationContext
           
protected static DefaultImageFactory defaultImageFactory
           
protected  java.util.List imageTypes
           
protected static org.apache.log4j.Logger log
           
protected  java.util.List schemeTypes
           
protected  javax.servlet.ServletContext servletContext
           
 
Constructor Summary
DefaultImageFactory()
          Create a DefaultimageFactory
 
Method Summary
 boolean canHandle(java.net.URI resource)
          Tests whether the ImageFactory can handle a particular resource URI.
 void configure(ApplicationContext context)
          Configures the ImageFactory with ApplicationContext
 void configureRequestProperties(java.util.Properties properties)
          Initialize the ResourceFactory with extra Properties needed
 java.lang.Object createFrom(java.net.URI resource)
          Create an object resource from a resource URI
protected  javax.media.jai.PlanarImage getAbsoluteFile(java.io.File file)
          Get the absolute file from the file system
protected  javax.media.jai.PlanarImage getClassPathResource(java.io.File file)
          Get the file from the classpath as a system resource
protected  javax.media.jai.PlanarImage getCurrentDirFile(java.io.File file)
          Get the file from the current application directory.
protected  javax.media.jai.PlanarImage getFile(java.io.File file)
          Get the image resource from a file.
protected  javax.media.jai.PlanarImage getJMAGEResourceDirFile(java.io.File file)
          Get the file from the dir specified trough the resourcedir property
protected  javax.media.jai.PlanarImage getServletContainerResource(java.io.File file)
          Get the file from the ServletContainer as a system resource.
protected  javax.media.jai.PlanarImage getURL(java.net.URL url)
          Get the image from an URL
protected  java.net.URL locateOnClassPath(java.lang.String path, java.lang.ClassLoader classLoader)
           
protected  java.io.ByteArrayOutputStream readFromUrl(java.net.URL url)
          Read an image from a URL using http
 void removeRequestProperties(java.util.Properties properties)
          Lifecycle method for removing per request properties
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultImageFactory

protected static DefaultImageFactory defaultImageFactory

log

protected static org.apache.log4j.Logger log

imageTypes

protected java.util.List imageTypes

schemeTypes

protected java.util.List schemeTypes

applicationContext

protected ApplicationContext applicationContext

servletContext

protected javax.servlet.ServletContext servletContext
Constructor Detail

DefaultImageFactory

public DefaultImageFactory()
Create a DefaultimageFactory

Method Detail

configure

public void configure(ApplicationContext context)
Configures the ImageFactory with ApplicationContext

Specified by:
configure in interface Configurable
Parameters:
context - the ApplicationContext

configureRequestProperties

public void configureRequestProperties(java.util.Properties properties)
Description copied from interface: ResourceFactory
Initialize the ResourceFactory with extra Properties needed

Specified by:
configureRequestProperties in interface ResourceFactory

removeRequestProperties

public void removeRequestProperties(java.util.Properties properties)
Description copied from interface: ResourceFactory
Lifecycle method for removing per request properties

Specified by:
removeRequestProperties in interface ResourceFactory

canHandle

public boolean canHandle(java.net.URI resource)
Tests whether the ImageFactory can handle a particular resource URI.

Specified by:
canHandle in interface ResourceFactory
Parameters:
resource -
Returns:
true | false

createFrom

public java.lang.Object createFrom(java.net.URI resource)
                            throws ResourceException
Create an object resource from a resource URI

Specified by:
createFrom in interface ResourceFactory
Parameters:
resource - the resource URI
Returns:
the object
Throws:
ResourceException

getFile

protected javax.media.jai.PlanarImage getFile(java.io.File file)
                                       throws ResourceException
Get the image resource from a file.

Parameters:
file - the file
Returns:
the image
Throws:
ResourceException

getClassPathResource

protected javax.media.jai.PlanarImage getClassPathResource(java.io.File file)
                                                    throws ResourceException
Get the file from the classpath as a system resource

Parameters:
file -
Returns:
true | false
Throws:
ResourceException

locateOnClassPath

protected java.net.URL locateOnClassPath(java.lang.String path,
                                         java.lang.ClassLoader classLoader)

getCurrentDirFile

protected javax.media.jai.PlanarImage getCurrentDirFile(java.io.File file)
Get the file from the current application directory.

Parameters:
file - the file
Returns:
the image

getJMAGEResourceDirFile

protected javax.media.jai.PlanarImage getJMAGEResourceDirFile(java.io.File file)
Get the file from the dir specified trough the resourcedir property

Parameters:
file - the file
Returns:
the image or null

getServletContainerResource

protected javax.media.jai.PlanarImage getServletContainerResource(java.io.File file)
Get the file from the ServletContainer as a system resource.

Parameters:
file - the file
Returns:
the image

getAbsoluteFile

protected javax.media.jai.PlanarImage getAbsoluteFile(java.io.File file)
Get the absolute file from the file system

Parameters:
file - the file
Returns:
the image

getURL

protected javax.media.jai.PlanarImage getURL(java.net.URL url)
                                      throws ResourceException
Get the image from an URL

Parameters:
url - the url
Returns:
the image
Throws:
ResourceException

readFromUrl

protected java.io.ByteArrayOutputStream readFromUrl(java.net.URL url)
                                             throws java.io.IOException
Read an image from a URL using http

Parameters:
url - the url
Returns:
the image stream
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2004-2008 Sourceforge. All Rights Reserved.