seade       2004/05/05 05:10:14

  Modified:    src/java/org/apache/turbine/util/velocity
                        VelocityActionEvent.java
               src/java/org/apache/turbine/modules/actions
                        VelocityAction.java
  Log:
  Patch thanks to Leandro Rodrigo Saad Cruz:

  

  This is just a little enhacement. When I write webapps with turbine I

  usually initialize my modules to get a handle to a ComponentManager or

  any other component that I'd like to use inside that module.

  IMHO, turbine could be changed to handle all modules as Components,

  handling their life cycle and life style.
  
  Revision  Changes    Path
  1.20      +16 -1     
jakarta-turbine-2/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java
  
  Index: VelocityActionEvent.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/velocity/VelocityActionEvent.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- VelocityActionEvent.java  28 Sep 2003 17:35:45 -0000      1.19
  +++ VelocityActionEvent.java  5 May 2004 12:10:14 -0000       1.20
  @@ -90,6 +90,9 @@
       private static final Class [] methodParams
               = new Class [] { RunData.class, Context.class };
   
  +    /** Indicates whether or not this module has been initialized. */
  +     protected boolean initialized = false; 
  +
       /**
        * You need to implement this in your classes that extend this
        * class.
  @@ -101,6 +104,14 @@
               throws Exception;
   
       /**
  +     * Provides a means of initializing the module.
  +     * 
  +     * @throws Exception a generic exception.
  +     */
  +     protected abstract void initialize()
  +             throws Exception;
  +
  +    /**
        * This overrides the default Action.perform() to execute the
        * doEvent() method.  If that fails, then it will execute the
        * doPerform() method instead.
  @@ -113,6 +124,10 @@
       {
           try
           {
  +             if(!initialized)
  +             {
  +                     initialize();
  +             }
               executeEvents(data, TurbineVelocity.getContext(data));
           }
           catch (NoSuchMethodException e)
  
  
  
  1.8       +12 -1     
jakarta-turbine-2/src/java/org/apache/turbine/modules/actions/VelocityAction.java
  
  Index: VelocityAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/modules/actions/VelocityAction.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- VelocityAction.java       28 Sep 2003 17:35:03 -0000      1.7
  +++ VelocityAction.java       5 May 2004 12:10:14 -0000       1.8
  @@ -83,6 +83,17 @@
     {
       doPerform(data, getContext(data));
     }
  +     
  +  /**
  +   * Initialize the module.
  +   * 
  +   * @throws Exception a generic exception.
  +   */
  +     public void initialize()
  +             throws Exception
  +     {
  +                     initialized = true;
  +     }
   
     /**
      * You SHOULD override this method and implement it in your
  
  
  

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

Reply via email to