KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.exoplatform.portlet.exomvc.Page;
8 import org.exoplatform.portlet.exomvc.VelocityPage;
9 /**
10  * @author Tuan Nguyen (tuan08@users.sourceforge.net)
11  * @since Nov 11, 2004
12  * @version $Id$
13  */

14 public class VelocityPageConfig extends PageConfig {
15   private String JavaDoc velocityTemplate_ ;
16   private String JavaDoc pageClassName_ = "org.exoplatform.portlet.mvc.VelocityPage";
17   private VelocityPage cache_ ;
18   
19   public String JavaDoc getTemplate() { return velocityTemplate_ ; }
20   public VelocityPageConfig setTemplate(String JavaDoc className) {
21     velocityTemplate_ = className ;
22     return this ;
23   }
24   
25   public String JavaDoc getPageClassName() { return pageClassName_ ; }
26   public VelocityPageConfig setPageClassName(String JavaDoc s) {
27     pageClassName_ = s ;
28     return this ;
29   }
30   
31   public Page getPageObject(Configuration configuration) throws Exception JavaDoc {
32     if(cache_ != null) return cache_ ;
33     synchronized(configuration) {
34       ClassLoader JavaDoc cl = Thread.currentThread().getContextClassLoader() ;
35       Class JavaDoc clazz = cl.loadClass(pageClassName_) ;
36       cache_ = (VelocityPage) clazz.newInstance() ;
37       cache_.setConfiguration(configuration) ;
38       cache_.setPageName(getPageName()) ;
39       cache_.setTemplate(velocityTemplate_) ;
40     }
41     return cache_ ;
42   }
43 }
Popular Tags