KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlet > exomvc > config > JSPResourceManager


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlet.exomvc.config;
6
7 import java.io.InputStream JavaDoc;
8 import javax.portlet.PortletContext;
9 import javax.portlet.PortletRequestDispatcher;
10 import javax.portlet.RenderRequest;
11 import javax.portlet.RenderResponse;
12 import org.exoplatform.commons.utils.IOUtil;
13
14 /**
15  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
16  * @since Nov 12, 2004
17  * @version $Id$
18  */

19 public class JSPResourceManager {
20   private String JavaDoc reposistoryPath_ ;
21   private PortletContext context_ ;
22   
23   public JSPResourceManager(PortletContext context, String JavaDoc repo ) throws Exception JavaDoc {
24     reposistoryPath_ = repo + "/jsp/" ;
25     context_ = context ;
26   }
27   
28   public String JavaDoc getJSPReposistory() { return reposistoryPath_ ; }
29   
30   public void dispatch(String JavaDoc page, RenderRequest request, RenderResponse response) throws Exception JavaDoc {
31     PortletRequestDispatcher rd = context_.getRequestDispatcher(reposistoryPath_ + page) ;
32     rd.include(request, response);
33   }
34   
35   public String JavaDoc getResourceAsText(String JavaDoc resource) throws Exception JavaDoc {
36     String JavaDoc path = reposistoryPath_ + resource ;
37     InputStream JavaDoc is = context_.getResourceAsStream(path) ;
38     if(is == null) return "reosurce : " + resource + " is notfound" ;
39     return IOUtil.getStreamContentAsString(is) ;
40   }
41 }
Popular Tags