org.bbqjs.spring.debug
Class ImageServingServlet

java.lang.Object
  extended by org.bbqjs.spring.debug.ImageServingServlet
All Implemented Interfaces:
org.springframework.web.context.ServletContextAware

@Controller
public class ImageServingServlet
extends Object
implements org.springframework.web.context.ServletContextAware

Serves images out of one or more directories on the classpath. The intention is you set sourceRoots to include the src/main/css directory as well as src/main/webapps/images in order to serve resources while in development which would normally be copied into the target folder by the bbq-resources-maven-plugin. Not meant to be used in production. Example Spring configuration:


 <bean id="imageController" class="org.bbqjs.spring.debug.ImageServingServlet">
     <property name="path" value="/images" />
     <property name="sourceRoots">
         <list>
             <value>src/main/css</value>
             <value>src/main/webapp/images</value>
         </list>
     </property>
 </bean>
 


Constructor Summary
ImageServingServlet()
           
 
Method Summary
 void serveImage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          The controller method.
 void setPath(String path)
          If this controller listens on http://www.example.org/images, this should be set to "/images"
 void setServletContext(javax.servlet.ServletContext servletContext)
           
 void setSourceRoots(String[] sourceRoots)
          Where to load images from.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageServingServlet

public ImageServingServlet()
Method Detail

serveImage

@RequestMapping(method={POST,GET})
public void serveImage(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response)
                throws Exception
The controller method. Receives urls such as http://www.example.org/images/foo/bar.gif, turns it into /foo/bar.gif and searches the sourceRoots for the requested image, serving it if found.

Parameters:
request -
response -
Throws:
Exception

setServletContext

public void setServletContext(javax.servlet.ServletContext servletContext)
Specified by:
setServletContext in interface org.springframework.web.context.ServletContextAware

setPath

public void setPath(String path)
If this controller listens on http://www.example.org/images, this should be set to "/images"

Parameters:
path -

setSourceRoots

public void setSourceRoots(String[] sourceRoots)
Where to load images from. Suggested values are src/main/css and src/main/webapp/images

Parameters:
sourceRoots -


Copyright © 2012. All Rights Reserved.