magoffin.matt.ma2.support
Class MimeTypeMediaHandlerDelegate

java.lang.Object
  extended by magoffin.matt.ma2.support.MimeTypeMediaHandlerDelegate
All Implemented Interfaces:
MediaHandlerDelegate

public class MimeTypeMediaHandlerDelegate
extends java.lang.Object
implements MediaHandlerDelegate

Implementation of MediaHandlerDelegate that uses a MIME type mapping to delegate to any number of different MediaHandlerDelegate implementations.

The configurable properties of this class are:

delegateMap
A Map with String keys representing MIME types and corresponding MediaHandlerDelegate implementations to handle requests of that MIME type. The handleDelegateMediaRequest(org.springframework.core.io.Resource, java.lang.String, magoffin.matt.ma2.domain.MediaItem, magoffin.matt.ma2.MediaRequest, magoffin.matt.ma2.MediaResponse) method will look up MIME types in this map and delegate to the matching handler.

Version:
$Revision: 43 $ $Date: 2007-10-21 11:10:01 +1300 (Sun, 21 Oct 2007) $
Author:
Matt Magoffin (spamsqr@msqr.us)

Constructor Summary
MimeTypeMediaHandlerDelegate()
           
 
Method Summary
 java.lang.String getDelegateFileExtension(org.springframework.core.io.Resource mediaResource, java.lang.String mimeType, MediaItem item, MediaRequest request)
          Get the preferred file extension for this handler.
 java.util.Map<java.lang.String,MediaHandlerDelegate> getDelegateMap()
           
 void handleDelegateMediaRequest(org.springframework.core.io.Resource mediaResource, java.lang.String mimeType, MediaItem item, MediaRequest request, MediaResponse response)
          Handle a delegate media request.
 void setDelegateMap(java.util.Map<java.lang.String,MediaHandlerDelegate> delegateMap)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeTypeMediaHandlerDelegate

public MimeTypeMediaHandlerDelegate()
Method Detail

handleDelegateMediaRequest

public void handleDelegateMediaRequest(org.springframework.core.io.Resource mediaResource,
                                       java.lang.String mimeType,
                                       MediaItem item,
                                       MediaRequest request,
                                       MediaResponse response)
Description copied from interface: MediaHandlerDelegate
Handle a delegate media request.

The mediaResource is not the original MediaItem resource, rather it is the media resource extracted from the MediaItem, e.g. the metadata resource.

Specified by:
handleDelegateMediaRequest in interface MediaHandlerDelegate
Parameters:
mediaResource - the media data to process
mimeType - the MIME type of the media data in mediaResource
item - the MediaItem being processed
request - the request
response - the response

getDelegateFileExtension

public java.lang.String getDelegateFileExtension(org.springframework.core.io.Resource mediaResource,
                                                 java.lang.String mimeType,
                                                 MediaItem item,
                                                 MediaRequest request)
Description copied from interface: MediaHandlerDelegate
Get the preferred file extension for this handler.

The mediaResource is not the original MediaItem resource, rather it is the media resource extracted from the MediaItem, e.g. the metadata resource.

Some handlers might return a different file extension for a given request then the default file extension for their type (for example a PNG image handler that returns JPEG images when resizing the images.

Specified by:
getDelegateFileExtension in interface MediaHandlerDelegate
Parameters:
mediaResource - the media data to process
mimeType - the MIME type of the media data in mediaResource
item - the MediaItem being processed
request - the request
Returns:
a file extension, without the period

getDelegateMap

public java.util.Map<java.lang.String,MediaHandlerDelegate> getDelegateMap()
Returns:
the delegateMap

setDelegateMap

public void setDelegateMap(java.util.Map<java.lang.String,MediaHandlerDelegate> delegateMap)
Parameters:
delegateMap - the delegateMap to set