jvanzyl     01/07/16 08:45:20

  Modified:    src/adapter/org/apache/turbine/util/velocity
                        VelocityHtmlEmail.java
               src/java/org/apache/turbine TemplateContext.java
               src/java/org/apache/turbine/pipeline ClassicPipeline.java
  Log:
  - trying to match my changes with martin's
  
  Revision  Changes    Path
  1.2       +25 -22    
jakarta-turbine/src/adapter/org/apache/turbine/util/velocity/VelocityHtmlEmail.java
  
  Index: VelocityHtmlEmail.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/adapter/org/apache/turbine/util/velocity/VelocityHtmlEmail.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- VelocityHtmlEmail.java    2001/07/10 00:38:39     1.1
  +++ VelocityHtmlEmail.java    2001/07/16 15:45:18     1.2
  @@ -56,19 +56,17 @@
   
   import java.net.URL;
   import java.util.Hashtable;
  -
   import javax.mail.MessagingException;
   
  -import org.apache.turbine.services.velocity.TurbineVelocity;
  -import org.apache.turbine.services.velocity.VelocityService;
  -
   import org.apache.turbine.util.Log;
   import org.apache.turbine.RunData;
   import org.apache.turbine.util.mail.HtmlEmail;
   import org.apache.turbine.util.mail.MultiPartEmail;
   import org.apache.turbine.util.template.TemplateInfo;
   
  -import org.apache.velocity.context.Context;
  +import org.apache.turbine.services.template.TurbineTemplate;
  +import org.apache.turbine.services.template.TemplateService;
  +import org.apache.turbine.services.template.TemplateContext;
   
   /**
    * This is a simple class for sending html email from within Velocity.
  @@ -104,7 +102,7 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Andre Schild</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
  - * @version $Id: VelocityHtmlEmail.java,v 1.1 2001/07/10 00:38:39 jvanzyl Exp $
  + * @version $Id: VelocityHtmlEmail.java,v 1.2 2001/07/16 15:45:18 jvanzyl Exp $
    */
   public class VelocityHtmlEmail
       extends HtmlEmail
  @@ -119,7 +117,7 @@
        * A Context object which stores the information
        * needed to construct the email.
        */
  -    private Context context = null;
  +    private TemplateContext context = null;
   
       /**
        * A Context object which stores the information
  @@ -157,7 +155,7 @@
        * @param data A Velocity Context object.
        * @exception MessagingException.
        */
  -    public VelocityHtmlEmail(Context context)
  +    public VelocityHtmlEmail(TemplateContext context)
           throws MessagingException
       {
           super.init();
  @@ -203,7 +201,7 @@
       {
           if (data != null)
           {
  -            context = getContext(data);
  +            context = getTemplateContext(data);
           }
           context.put("mail",this);
   
  @@ -213,12 +211,17 @@
           // Process the templates.
           try
           {
  -            if( htmlTemplate != null )
  -                htmlbody = TurbineVelocity.handleRequest(context,
  -                                                         htmlTemplate);
  -            if( textTemplate != null )
  -                textbody = TurbineVelocity.handleRequest(context,
  -                                                         textTemplate);
  +            if(htmlTemplate != null)
  +            {
  +                htmlbody = TurbineTemplate.handleRequest(
  +                    context, htmlTemplate);
  +            }
  +            
  +            if(textTemplate != null)
  +            {
  +                textbody = TurbineTemplate.handleRequest(
  +                    context, textTemplate);
  +            }                    
           }
           catch( Exception e)
           {
  @@ -292,18 +295,18 @@
        * @param data A Turbine RunData object.
        * @return A Context.
        */
  -    private static Context getContext(RunData data)
  +    private static TemplateContext getTemplateContext(RunData data)
       {
           // Attempt to get it from the RunData first.  If it doesn't
           // exist, create it and then stuff it into the RunData.
  -        Context vc = (Context)data.getTemplateInfo()
  -            .getTemplateContext(VelocityService.CONTEXT);
  +        TemplateContext vc = (TemplateContext)data.getTemplateInfo()
  +            .getTemplateContext(TemplateService.CONTEXT);
  +        
           if (vc == null)
           {
  -            vc = TurbineVelocity.getContext(data);
  -            data.getTemplateInfo()
  -                .setTemplateContext(VelocityService.CONTEXT,
  -                                    vc);
  +            vc = TurbineTemplate.getTemplateContext(data);
  +            data.getTemplateInfo().setTemplateContext(
  +                TemplateService.CONTEXT,vc);
           }
           return vc;
       }
  
  
  
  1.2       +4 -36     jakarta-turbine/src/java/org/apache/turbine/TemplateContext.java
  
  Index: TemplateContext.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/TemplateContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemplateContext.java      2001/07/10 01:09:18     1.1
  +++ TemplateContext.java      2001/07/16 15:45:19     1.2
  @@ -55,44 +55,12 @@
    */
   
   /**
  + * A completely minimal interface for the time being
  + * to allow the decoupling of the template services
  + * from client turbine code.
    */
   public interface TemplateContext
   {
  -    /**
  -     * Adds a name/value pair to the context.
  -     *
  -     * @param key   The name to key the provided value with.
  -     * @param value The corresponding value.
  -     */
  -    public void put(String key, Object value);
  -
  -    /**
  -     * Gets the value corresponding to the provided key from the context.
  -     *
  -     * @param key The name of the desired value.
  -     * @return    The value corresponding to the provided key.
  -     */
  +    public Object put(String key, Object value);
       public Object get(String key);
  - 
  -    /**
  -     * Indicates whether the specified key is in the context.
  -     *
  -     * @param key The key to look for.
  -     * @return    Whether the key is in the context.
  -     */
  -    public boolean containsKey(Object key);
  -
  -    /**
  -     * Get all the keys for the values in the context
  -     */
  -    public Object[] getKeys();
  -
  -    /**
  -     * Removes the value associated with the specified key from the context.
  -     *
  -     * @param key The name of the value to remove.
  -     * @return    The value that the key was mapped to, or <code>null</code> 
  -     *            if unmapped.
  -     */
  -    public Object remove(Object key);
   }
  
  
  
  1.7       +4 -2      
jakarta-turbine/src/java/org/apache/turbine/pipeline/ClassicPipeline.java
  
  Index: ClassicPipeline.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/pipeline/ClassicPipeline.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ClassicPipeline.java      2001/07/13 22:41:02     1.6
  +++ ClassicPipeline.java      2001/07/16 15:45:20     1.7
  @@ -57,8 +57,9 @@
   import org.apache.turbine.Turbine;
   import org.apache.turbine.Pipeline;
   import org.apache.turbine.RunData;
  -import org.apache.turbine.TemplateContext;
  +import org.apache.turbine.modules.Module;
   import org.apache.turbine.modules.ModuleLoader;
  +import org.apache.turbine.services.template.TemplateContext;
   import org.apache.turbine.services.template.TurbineTemplate;
   
   /**
  @@ -160,7 +161,8 @@
           // like /layouts/layouts/Default.vm which obviously doesn't
           // work.
           //data.getOut().print(r.render("layouts", data, layoutTemplate));
  -        data.getOut().print(TurbineTemplate.handleRequest(context, layoutTemplate));
  +        data.getOut().print(TurbineTemplate.handleRequest(
  +            context, layoutTemplate));
       }
       
       public void finished(RunData data)
  
  
  

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

Reply via email to