01: /*
02: * Created on Mar 15, 2003
03: */
04: package net.sf.jportlet.service.ssi;
05:
06: import java.io.FileNotFoundException;
07: import java.io.IOException;
08:
09: import net.sf.jportlet.portlet.PortletContext;
10: import net.sf.jportlet.portlet.PortletRequest;
11: import net.sf.jportlet.portlet.PortletResponse;
12: import net.sf.jportlet.service.PortletServiceException;
13: import net.sf.jportlet.service.velocity.VelocityService;
14:
15: /**
16: * This class includes <a href="http://jakarta.apache.org/velocity">Velocity</a>
17: * files into the portlet response.
18: * This SSI depends on {@link net.sf.jportlet.service.velocity.VelocityService}
19: *
20: * @author <a href="mailto:tchbansi@sourceforge.net">Herve Tchepannou</a>
21: */
22: public class SSIVelocity extends SSIText {
23: //~ Methods ----------------------------------------------------------------
24:
25: /**
26: * @see net.sf.jportal.ssi.SSI#include(java.lang.String, net.sf.jportlet.portlet.PortletRequest, net.sf.jportlet.portlet.PortletResponse)
27: */
28: public void include(String path, PortletContext context,
29: PortletRequest request, PortletResponse response)
30: throws PortletServiceException, IOException {
31: String templatePath = context.getResourcePath(path, request
32: .getClient(), request.getLocale());
33: if (templatePath == null) {
34: throw new FileNotFoundException(path);
35: }
36:
37: getVelocityService().merge(templatePath, request, response);
38: }
39:
40: private VelocityService getVelocityService()
41: throws PortletServiceException {
42: return (VelocityService) _serviceContext
43: .getPortletService(VelocityService.NAME);
44: }
45: }
|