You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jv...@apache.org on 2001/07/16 17:34:34 UTC

cvs commit: jakarta-turbine/src/java/org/apache/turbine/modules/screens TemplateScreen.java TemplateSecureScreen.java

jvanzyl     01/07/16 08:34:34

  Modified:    src/java/org/apache/turbine/modules Module.java
               src/java/org/apache/turbine/modules/actions
                        TemplateAction.java
               src/java/org/apache/turbine/modules/screens
                        TemplateScreen.java TemplateSecureScreen.java
  Log:
  - turbine code will use the TemplateContext class from the org.apache.turbine
    API package, but i created an adapter so that we can cooperate with
    the services with requiring client turbine code to use the services
    namespace. this protects turbine client code from changes in
    the services and the use of the template services is actually hidden
    from client turbine code.
  
    i wanted to the template services to be useful in their own right
    without binding them to turbine. i had previously been using
    the org.apache.turbine API interfaces in the template services
    which is bad. now services reference only classes within
    the service code namespace, and the turbine code proper
    references the service requirements via an adapter so the
    fact the a service is being used is hidden.
  
    The upshot is the services will compile without reference
    to turbine and client code can use:
  
    org.apache.turbine.TemplateContext
  
    instead of
  
    org.apache.turbine.services.template.TemplateContext
  
    which I think is awful.
  
  Revision  Changes    Path
  1.5       +8 -1      jakarta-turbine/src/java/org/apache/turbine/modules/Module.java
  
  Index: Module.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/Module.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Module.java	2001/07/14 04:14:43	1.4
  +++ Module.java	2001/07/16 15:34:33	1.5
  @@ -55,6 +55,8 @@
    */
   
   import org.apache.turbine.RunData;
  +import org.apache.turbine.TemplateContext;
  +import org.apache.turbine.services.template.TurbineTemplate;
   
   /**
    * This is an interface that defines what a Module is. All the
  @@ -62,7 +64,7 @@
    * future use is yet to be determined.
    *
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  - * @version $Id: Module.java,v 1.4 2001/07/14 04:14:43 jvanzyl Exp $
  + * @version $Id: Module.java,v 1.5 2001/07/16 15:34:33 jvanzyl Exp $
    */
   public class Module
   {
  @@ -105,5 +107,10 @@
           throws Exception
       {
           doBuild(data);
  +    }
  +
  +    public static TemplateContext getTemplateContext(RunData data)
  +    {
  +        return new ContextAdapter(TurbineTemplate.getTemplateContext(data));
       }
   }
  
  
  
  1.6       +1 -13     jakarta-turbine/src/java/org/apache/turbine/modules/actions/TemplateAction.java
  
  Index: TemplateAction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/actions/TemplateAction.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TemplateAction.java	2001/07/13 23:04:42	1.5
  +++ TemplateAction.java	2001/07/16 15:34:34	1.6
  @@ -78,7 +78,7 @@
    *
    * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
  - * @version $Id: TemplateAction.java,v 1.5 2001/07/13 23:04:42 jvanzyl Exp $
  + * @version $Id: TemplateAction.java,v 1.6 2001/07/16 15:34:34 jvanzyl Exp $
    */
   public abstract class TemplateAction 
       extends ActionEvent
  @@ -195,17 +195,5 @@
       public void setTarget(RunData data, String template)
       {
           data.setTarget(template);
  -    }
  -
  -    /**
  -     * Return the Context needed by Velocity.
  -     *
  -     * @param RunData data
  -     * @return Context, a context for web pages.
  -     */
  -    protected org.apache.turbine.TemplateContext getTemplateContext(RunData data)
  -    {
  -        return (org.apache.turbine.TemplateContext)
  -            TurbineTemplate.getTemplateContext(data);
       }
   }
  
  
  
  1.17      +3 -9      jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateScreen.java
  
  Index: TemplateScreen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateScreen.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- TemplateScreen.java	2001/07/14 04:12:53	1.16
  +++ TemplateScreen.java	2001/07/16 15:34:34	1.17
  @@ -55,8 +55,8 @@
    */
   
   import org.apache.turbine.Turbine;
  -import org.apache.turbine.TemplateContext;
   import org.apache.turbine.RunData;
  +import org.apache.turbine.TemplateContext;
   import org.apache.turbine.modules.Module;
   import org.apache.turbine.services.template.TurbineTemplate;
   
  @@ -73,7 +73,7 @@
    * going on there (it is quite simple really).
    *
    * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
  - * @version $Id: TemplateScreen.java,v 1.16 2001/07/14 04:12:53 jvanzyl Exp $
  + * @version $Id: TemplateScreen.java,v 1.17 2001/07/16 15:34:34 jvanzyl Exp $
    */
   public class TemplateScreen 
       extends Module
  @@ -93,7 +93,7 @@
       protected void doBuildTemplate( RunData data )
           throws Exception
       {
  -        doBuildTemplate(data, TurbineTemplate.getTemplateContext(data));
  +        doBuildTemplate(data, getTemplateContext(data));
       }
   
   
  @@ -173,10 +173,4 @@
       {
           data.setTarget(template);
       }        
  -
  -    public org.apache.turbine.TemplateContext getTemplateContext(RunData data)
  -    {
  -        return (org.apache.turbine.TemplateContext)
  -            TurbineTemplate.getTemplateContext(data);
  -    }
   }
  
  
  
  1.3       +2 -2      jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateSecureScreen.java
  
  Index: TemplateSecureScreen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/modules/screens/TemplateSecureScreen.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TemplateSecureScreen.java	2001/07/12 20:22:06	1.2
  +++ TemplateSecureScreen.java	2001/07/16 15:34:34	1.3
  @@ -70,7 +70,7 @@
    * your base screen.
    *
    * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
  - * @version $Id: TemplateSecureScreen.java,v 1.2 2001/07/12 20:22:06 jvanzyl Exp $
  + * @version $Id: TemplateSecureScreen.java,v 1.3 2001/07/16 15:34:34 jvanzyl Exp $
    */
   public abstract class TemplateSecureScreen 
       extends TemplateScreen
  @@ -87,7 +87,7 @@
       {
           if (isAuthorized(data))
           {
  -            doBuildTemplate( data, TurbineTemplate.getTemplateContext( data ) );
  +            doBuildTemplate( data, getTemplateContext( data ) );
           }
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org