jvanzyl     01/06/14 07:45:11

  Modified:    src/java/org/apache/turbine/services/velocity
                        TurbineVelocityService.java
  Log:
  - updating service as per notes.
  
  Revision  Changes    Path
  1.48      +21 -33    
jakarta-turbine/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java
  
  Index: TurbineVelocityService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/velocity/TurbineVelocityService.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- TurbineVelocityService.java       2001/06/05 15:35:19     1.47
  +++ TurbineVelocityService.java       2001/06/14 14:45:10     1.48
  @@ -61,16 +61,13 @@
   import java.io.OutputStream;
   import java.io.OutputStreamWriter;
   import java.io.ByteArrayOutputStream;
  -import javax.servlet.ServletConfig;
   
   import org.apache.velocity.Template;
   import org.apache.velocity.VelocityContext;
   import org.apache.velocity.app.Velocity;
   import org.apache.velocity.context.Context;
  -import org.apache.velocity.runtime.configuration.Configuration;
   
   import org.apache.turbine.util.ContentURI;
  -import org.apache.turbine.util.Log;
   import org.apache.turbine.util.RunData;
   import org.apache.turbine.util.StringUtils;
   import org.apache.turbine.util.TurbineConfig;
  @@ -80,7 +77,6 @@
   
   import org.apache.turbine.services.InitializationException;
   import org.apache.turbine.services.pull.TurbinePull;
  -import org.apache.turbine.services.servlet.TurbineServlet;
   
   import org.apache.turbine.services.template.TurbineTemplate;
   import org.apache.turbine.services.template.BaseTemplateEngineService;
  @@ -102,9 +98,10 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Sean Legassick</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @version $Id: TurbineVelocityService.java,v 1.47 2001/06/05 15:35:19 ilkka Exp $
  + * @version $Id: TurbineVelocityService.java,v 1.48 2001/06/14 14:45:10 jvanzyl Exp 
$
    */
  -public class TurbineVelocityService extends BaseTemplateEngineService
  +public class TurbineVelocityService 
  +    extends BaseTemplateEngineService
       implements VelocityService
   {
       /**
  @@ -138,7 +135,7 @@
       /**
        * Performs early initialization of this Turbine service.
        */
  -    public void init(ServletConfig config) throws InitializationException
  +    public void init() throws InitializationException
       {
           try
           {
  @@ -154,9 +151,7 @@
               if (TurbinePull.isRegistered())
               {
                   globalContext = TurbinePull.getGlobalContext();
  -                            
                   pullModelActive = true;
  -                    
                   refreshToolsPerRequest = TurbinePull.refreshToolsPerRequest();
               }
   
  @@ -323,9 +318,10 @@
            */
           String charset;
           String encoding;
  +        
           Object data = context.get("data");
  -        if ((data != null) &&
  -            (data instanceof RunData))
  +        
  +        if ((data != null) && (data instanceof RunData))
           {
               charset = ((RunData) data).getCharSet();
               if (charset == null)
  @@ -390,11 +386,11 @@
        * @exception TurbineException Thrown every time.  Adds additional
        *                             information to <code>e</code>.
        */
  -    private static final void renderingError(String filename, Exception e)
  +    private final void renderingError(String filename, Exception e)
           throws TurbineException
       {
           String err = "Error rendering Velocity template: " + filename;
  -        Log.error(err + ": " + e.getMessage());
  +        getCategory().error(err + ": " + e.getMessage());
           throw new TurbineException(err, e);
       }
   
  @@ -407,29 +403,21 @@
       private void initVelocity() throws InitializationException
       {
           /*
  -         * Get the configuration for this service.
  -         */
  -        Configuration configuration = getConfiguration();
  -
  -        /*
            * Now we have to perform a couple of path translations
            * for our log file and template paths.
            */
  -        String path = TurbineServlet.getRealPath
  -            (configuration.getString(Velocity.RUNTIME_LOG, null));
  +        String path = getRealPath
  +            (getConfiguration().getString(Velocity.RUNTIME_LOG, null));
  +        
           if (StringUtils.isValid(path))
           {
  -            configuration.setProperty(Velocity.RUNTIME_LOG, path);
  +            getConfiguration().setProperty(Velocity.RUNTIME_LOG, path);
           }
           else
           {
               String msg = VelocityService.SERVICE_NAME + " runtime log file " +
                   "is misconfigured: '" + path + "' is not a valid log file";
  -            if (TurbineServlet.getServletConfig() instanceof TurbineConfig)
  -            {
  -                msg += ": TurbineConfig users must use a path relative to " +
  -                    "web application root";
  -            }
  +            
               throw new Error(msg);
           }
   
  @@ -441,7 +429,7 @@
            */
           String key;
           Vector keys = new Vector();
  -        for (Iterator i = configuration.getKeys(); i.hasNext();)
  +        for (Iterator i = getConfiguration().getKeys(); i.hasNext();)
           {
               key = (String) i.next();
               if (key.endsWith(RESOURCE_LOADER_PATH))
  @@ -460,11 +448,11 @@
           for (Iterator i = keys.iterator(); i.hasNext();)
           {
               key = (String) i.next();
  -            paths = configuration.getVector(key,null);
  +            paths = getConfiguration().getVector(key,null);
               if (paths != null)
               {
                   Velocity.clearProperty(key);
  -                configuration.clearProperty(key);
  +                getConfiguration().clearProperty(key);
   
                   for (Iterator j = paths.iterator(); j.hasNext();)
                   {
  @@ -487,26 +475,26 @@
                               path = path.substring(9);
                           }
                           path = "jar:file:" +
  -                            TurbineServlet.getRealPath(path) + entry;
  +                            getRealPath(path) + entry;
                       }
                       else if (!path.startsWith("jar:"))
                       {
                           /*
                            * But we don't translate remote jar URLs.
                            */
  -                        path = TurbineServlet.getRealPath(path);
  +                        path = getRealPath(path);
                       }
                       /*
                        *  Put the translated paths back to the configuration.
                        */
  -                    configuration.addProperty(key,path);
  +                    getConfiguration().addProperty(key,path);
                   }
               }
           }
           
           try
           {
  -            Velocity.setConfiguration(configuration);
  +            Velocity.setConfiguration(getConfiguration());
               Velocity.init();
           }
           catch(Exception e)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to