1. opensymphony
  2. webwork

Commits

plightbo  committed 8c98001

stop with the lame ass comments! who the fuck did this anyway? :P

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@412573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 87595d4
  • Branches master

Comments (0)

Files changed (1)

File src/java/com/opensymphony/webwork/views/velocity/VelocityManager.java

View file
  */
 package com.opensymphony.webwork.views.velocity;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.context.Context;
-
 import com.opensymphony.webwork.config.Configuration;
 import com.opensymphony.webwork.util.VelocityWebWorkUtil;
 import com.opensymphony.webwork.util.WebWorkUtil;
 import com.opensymphony.xwork.ActionInvocation;
 import com.opensymphony.xwork.ObjectFactory;
 import com.opensymphony.xwork.util.OgnlValueStack;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.context.Context;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
 
 
 /**
     public static final String WEBWORK = "webwork";
     public static final String ACTION = "action";
 
-    /** the parent JSP tag */
+    /**
+     * the parent JSP tag
+     */
     public static final String PARENT = "parent";
 
-    /** the current JSP tag */
+    /**
+     * the current JSP tag
+     */
     public static final String TAG = "tag";
 
     //~ Instance fields ////////////////////////////////////////////////////////
     //~ Methods ////////////////////////////////////////////////////////////////
 
     /**
-* retrieve an instance to the current VelocityManager
-*/
+     * retrieve an instance to the current VelocityManager
+     */
     public synchronized static VelocityManager getInstance() {
         if (instance == null) {
             String classname = VelocityManager.class.getName();
     }
 
     /**
-* @return a reference to the VelocityEngine used by <b>all</b> webwork velocity thingies with the exception of
-* directly accessed *.vm pages
-*/
+     * @return a reference to the VelocityEngine used by <b>all</b> webwork velocity thingies with the exception of
+     *         directly accessed *.vm pages
+     */
     public VelocityEngine getVelocityEngine() {
         return velocityEngine;
     }
 
     /**
-* This method is responsible for creating the standard VelocityContext used by all WW2 velocity views.  The
-* following context parameters are defined:
-* <p>
-* <ul>
-* <li><strong>req</strong> - the current HttpServletRequest</li>
-* <li><strong>res</strong> - the current HttpServletResponse</li>
-* <li><strong>stack</strong> - the current {@link OgnlValueStack}</li>
-* <li><strong>ognl</strong> - an {@link OgnlTool}</li>
-* <li><strong>webwork</strong> - an instance of {@link WebWorkUtil}</li>
-* <li><strong>action</strong> - the current WebWork action</li>
-* </ul>
-*
-* @return a new WebWorkVelocityContext
-*/
+     * This method is responsible for creating the standard VelocityContext used by all WW2 velocity views.  The
+     * following context parameters are defined:
+     * <p/>
+     * <ul>
+     * <li><strong>req</strong> - the current HttpServletRequest</li>
+     * <li><strong>res</strong> - the current HttpServletResponse</li>
+     * <li><strong>stack</strong> - the current {@link OgnlValueStack}</li>
+     * <li><strong>ognl</strong> - an {@link OgnlTool}</li>
+     * <li><strong>webwork</strong> - an instance of {@link WebWorkUtil}</li>
+     * <li><strong>action</strong> - the current WebWork action</li>
+     * </ul>
+     *
+     * @return a new WebWorkVelocityContext
+     */
     public Context createContext(OgnlValueStack stack, HttpServletRequest servletRequest, HttpServletResponse servletResponse) {
         WebWorkVelocityContext context = new WebWorkVelocityContext(chainedContexts, stack);
         context.put(REQUEST, servletRequest);
     }
 
     /**
-* initializes the VelocityManager.  this should be called during the initialization process, say by
-* ServletDispatcher.  this may be called multiple times safely although calls beyond the first won't do anything
-*
-* @param context the current servlet context
-*/
+     * initializes the VelocityManager.  this should be called during the initialization process, say by
+     * ServletDispatcher.  this may be called multiple times safely although calls beyond the first won't do anything
+     *
+     * @param context the current servlet context
+     */
     public synchronized void init(ServletContext context) {
         if (velocityEngine == null) {
             velocityEngine = newVelocityEngine(context);
     }
 
     /**
-* load optional velocity properties using the following loading strategy
-* <ul>
-* <li>relative to the servlet context path</li>
-* <li>relative to the WEB-INF directory</li>
-* <li>on the classpath</li>
-* </ul>
-*
-* @param context the current ServletContext.  may <b>not</b> be null
-* @return the optional properties if webwork.velocity.configfile was specified, an empty Properties file otherwise
-*/
+     * load optional velocity properties using the following loading strategy
+     * <ul>
+     * <li>relative to the servlet context path</li>
+     * <li>relative to the WEB-INF directory</li>
+     * <li>on the classpath</li>
+     * </ul>
+     *
+     * @param context the current ServletContext.  may <b>not</b> be null
+     * @return the optional properties if webwork.velocity.configfile was specified, an empty Properties file otherwise
+     */
     public Properties loadConfiguration(ServletContext context) {
         if (context == null) {
             String gripe = "Error attempting to create a loadConfiguration from a null ServletContext!";
         Properties properties = new Properties();
 
         /**
-* if the user has specified an external velocity configuration file, we'll want to search for it in the
-* following order
-*
-* 1. relative to the context path
-* 2. relative to /WEB-INF
-* 3. in the class path
-*/
+         * if the user has specified an external velocity configuration file, we'll want to search for it in the
+         * following order
+         *
+         * 1. relative to the context path
+         * 2. relative to /WEB-INF
+         * 3. in the class path
+         */
         String configfile;
 
         if (Configuration.isSet("webwork.velocity.configfile")) {
             log.debug("Initializing Velocity with the following properties ...");
 
             for (Iterator iter = properties.keySet().iterator();
-                    iter.hasNext();) {
+                 iter.hasNext();) {
                 String key = (String) iter.next();
                 String value = properties.getProperty(key);
 
     }
 
     /**
-* performs one-time initializations
-*/
+     * performs one-time initializations
+     */
     protected void init() {
         /**
-* allow users to specify via the webwork.properties file a set of additional VelocityContexts to chain to the
-* the WebWorkVelocityContext.  The intent is to allow these contexts to store helper objects that the ui
-* developer may want access to.  Examples of reasonable VelocityContexts would be an IoCVelocityContext, a
-* SpringReferenceVelocityContext, and a ToolboxVelocityContext
-*/
+         * allow users to specify via the webwork.properties file a set of additional VelocityContexts to chain to the
+         * the WebWorkVelocityContext.  The intent is to allow these contexts to store helper objects that the ui
+         * developer may want access to.  Examples of reasonable VelocityContexts would be an IoCVelocityContext, a
+         * SpringReferenceVelocityContext, and a ToolboxVelocityContext
+         */
         if (Configuration.isSet("webwork.velocity.contexts")) {
             // we expect contexts to be a comma separated list of classnames
             String contexts = Configuration.get("webwork.velocity.contexts").toString();
     }
 
     /**
-* <p>
-* Instantiates a new VelocityEngine.
-* </p>
-* <p>
-* The following is the default Velocity configuration
-* </p>
-* <pre>
-*  resource.loader = file, class
-*  file.resource.loader.path = real path of webapp
-*  class.resource.loader.description = Velocity Classpath Resource Loader
-*  class.resource.loader.class = com.opensymphony.webwork.views.velocity.WebWorkResourceLoader
-* </pre>
-* <p>
-* this default configuration can be overridden by specifying a webwork.velocity.configfile property in the
-* webwork.properties file.  the specified config file will be searched for in the following order:
-* </p>
-* <ul>
-* <li>relative to the servlet context path</li>
-* <li>relative to the WEB-INF directory</li>
-* <li>on the classpath</li>
-* </ul>
-*
-* @param context the current ServletContext.  may <b>not</b> be null
-*/
+     * <p/>
+     * Instantiates a new VelocityEngine.
+     * </p>
+     * <p/>
+     * The following is the default Velocity configuration
+     * </p>
+     * <pre>
+     *  resource.loader = file, class
+     *  file.resource.loader.path = real path of webapp
+     *  class.resource.loader.description = Velocity Classpath Resource Loader
+     *  class.resource.loader.class = com.opensymphony.webwork.views.velocity.WebWorkResourceLoader
+     * </pre>
+     * <p/>
+     * this default configuration can be overridden by specifying a webwork.velocity.configfile property in the
+     * webwork.properties file.  the specified config file will be searched for in the following order:
+     * </p>
+     * <ul>
+     * <li>relative to the servlet context path</li>
+     * <li>relative to the WEB-INF directory</li>
+     * <li>on the classpath</li>
+     * </ul>
+     *
+     * @param context the current ServletContext.  may <b>not</b> be null
+     */
     protected VelocityEngine newVelocityEngine(ServletContext context) {
         if (context == null) {
             String gripe = "Error attempting to create a new VelocityEngine from a null ServletContext!";
     }
 
     /**
-* once we've loaded up the user defined configurations, we will want to apply WebWork specification configurations.
-* <ul>
-* <li>if Velocity.RESOURCE_LOADER has not been defined, then we will use the defaults which is a joined file,
-* class loader for unpackaed wars and a straight class loader otherwise</li>
-* <li>we need to define the various WebWork custom user directives such as #param, #tag, and #bodytag</li>
-* </ul>
-*
-* @param context
-* @param p
-*/
+     * once we've loaded up the user defined configurations, we will want to apply WebWork specification configurations.
+     * <ul>
+     * <li>if Velocity.RESOURCE_LOADER has not been defined, then we will use the defaults which is a joined file,
+     * class loader for unpackaed wars and a straight class loader otherwise</li>
+     * <li>we need to define the various WebWork custom user directives such as #param, #tag, and #bodytag</li>
+     * </ul>
+     *
+     * @param context
+     * @param p
+     */
     private void applyDefaultConfiguration(ServletContext context, Properties p) {
         // ensure that caching isn't overly aggressive
 
         /**
-* Load a default resource loader definition if there isn't one present.
-* Ben Hall (22/08/2003)
-*/
+         * Load a default resource loader definition if there isn't one present.
+         * Ben Hall (22/08/2003)
+         */
         if (p.getProperty(Velocity.RESOURCE_LOADER) == null) {
             p.setProperty(Velocity.RESOURCE_LOADER, "wwfile, wwclass");
         }
 
         /**
-* If there's a "real" path add it for the wwfile resource loader.
-* If there's no real path and they haven't configured a loader then we change
-* resource loader property to just use the wwclass loader
-* Ben Hall (22/08/2003)
-*/
+         * If there's a "real" path add it for the wwfile resource loader.
+         * If there's no real path and they haven't configured a loader then we change
+         * resource loader property to just use the wwclass loader
+         * Ben Hall (22/08/2003)
+         */
         if (context.getRealPath("") != null) {
             p.setProperty("wwfile.resource.loader.description", "Velocity File Resource Loader");
             p.setProperty("wwfile.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
         }
 
         /**
-* Refactored the Velocity templates for the WebWork taglib into the classpath from the web path.  This will
-* enable WebWork projects to have access to the templates by simply including the WebWork jar file.
-* Unfortunately, there does not appear to be a macro for the class loader keywords
-* Matt Ho - Mon Mar 17 00:21:46 PST 2003
-*/
+         * Refactored the Velocity templates for the WebWork taglib into the classpath from the web path.  This will
+         * enable WebWork projects to have access to the templates by simply including the WebWork jar file.
+         * Unfortunately, there does not appear to be a macro for the class loader keywords
+         * Matt Ho - Mon Mar 17 00:21:46 PST 2003
+         */
         p.setProperty("wwclass.resource.loader.description", "Velocity Classpath Resource Loader");
         p.setProperty("wwclass.resource.loader.class", "com.opensymphony.webwork.views.velocity.WebWorkResourceLoader");
         p.setProperty("wwclass.resource.loader.modificationCheckInterval", "2");
         p.setProperty("wwclass.resource.loader.cache", "true");
 
         /**
-* the TagDirective and BodyTagDirective must be added to the userdirective
-* TODO: there must be a better place for this... LIKE A CONFIG FILE IN THE JAR
-* TODO: ... also, people must be allowed to define their own config that overrides this
-*/
+         * the TagDirective and BodyTagDirective must be added to the userdirective
+         * TODO: there must be a better place for this... LIKE A CONFIG FILE IN THE JAR
+         * TODO: ... also, people must be allowed to define their own config that overrides this
+         */
         String userdirective = p.getProperty("userdirective");
         String directives = "com.opensymphony.webwork.views.velocity.ParamDirective" + "," + "com.opensymphony.webwork.views.velocity.TagDirective" + "," + "com.opensymphony.webwork.views.velocity.BodyTagDirective";