geirm       01/05/20 14:27:32

  Modified:    xdocs    developer-guide.xml
               docs     developer-guide.html
  Log:
  more event-related updates and additions
  
  Revision  Changes    Path
  1.46      +56 -23    jakarta-velocity/xdocs/developer-guide.xml
  
  Index: developer-guide.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/xdocs/developer-guide.xml,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- developer-guide.xml       2001/05/20 20:12:08     1.45
  +++ developer-guide.xml       2001/05/20 21:27:32     1.46
  @@ -1294,7 +1294,7 @@
   EventCartridge acts as the delivery agent from which the Velocity engine will
   access the event handlers at merge time if needed.
   Currently, there are 3 events that can be handled, and all are found in the 
  -<code>org.apache.velocity.context</code> package. [note : they don't belong there ]
  +<code>org.apache.velocity.app.event</code> package.
   </p>
   
   <p>
  @@ -1308,7 +1308,7 @@
   <pre>
   public interface NullSetEventHandler extends EventHandler
   {
  -    public boolean nullSetLogMessage( String reference );
  +    public boolean shouldLogOnNullSet( String lhs, String rhs );
   }   
   </pre>
   </blockquote>
  @@ -1366,30 +1366,63 @@
                                NullSetEventHandler,
                                MethodExceptionEventHandler
   {
  - ...
  -     /*
  -      *  now, it's assumed that Test implements the correct methods to 
  -      *  support the event handler interfaces.  So to use them, first
  -      *  make a new cartridge
  -      */
  -      EventCartridge ec = new EventCartridge();
  +    public void myTest()
  +    {
  +        ....
  +
  +        /*
  +         *  now, it's assumed that Test implements the correct methods to 
  +         *  support the event handler interfaces.  So to use them, first
  +         *  make a new cartridge
  +         */
  +        EventCartridge ec = new EventCartridge();
            
  -      /*
  -       * then register this class as it contains the handlers 
  -       */
  -       ec.addEventHandler(this);
  +        /*
  +         * then register this class as it contains the handlers 
  +         */
  +        ec.addEventHandler(this);
              
  -      /*
  -       * and then finally let it attach itself to the context
  -       */
  -       ec.attachToContext( context );
  -
  -      /*
  -       * now merge your template with the context as you normally
  -       * do
  -       */
  -...
  +        /*
  +         * and then finally let it attach itself to the context
  +         */
  +        ec.attachToContext( context );
  +
  +        /*
  +         * now merge your template with the context as you normally
  +         * do
  +         */
  +          
  +        ....
  +
  +    }
  +      
  +    /*
  +     *  and now the implementations of the event handlers
  +     */
  +
  +    public Object referenceInsert( String reference, Object value  )
  +    {
  +        /*  do something with it */
  +        return value;
  +    }
  +
  +    public boolean shouldLogOnNullSet( String lhs, String rhs )
  +    {
  +        if ( /* whatever rule */ )
  +            return false;
  +        
  +        return true;
  +    }
  +
  +    public Object methodException( Class claz, String method, Exception e )
  +         throws Exception
  +    {
  +        if ( /* whatever rule */ )
  +           return "I should have thrown";
   
  +        throw e;
  +    }
  +}
   ]]></source>
   
   </section>
  
  
  
  1.62      +56 -23    jakarta-velocity/docs/developer-guide.html
  
  Index: developer-guide.html
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/docs/developer-guide.html,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- developer-guide.html      2001/05/20 20:12:10     1.61
  +++ developer-guide.html      2001/05/20 21:27:32     1.62
  @@ -1624,7 +1624,7 @@
   EventCartridge acts as the delivery agent from which the Velocity engine will
   access the event handlers at merge time if needed.
   Currently, there are 3 events that can be handled, and all are found in the 
  -<code>org.apache.velocity.context</code> package. [note : they don't belong there ]
  +<code>org.apache.velocity.app.event</code> package.
   </p>
                                                   <p>
   <i><code>org.apache.velocity.app.event.NullSetEventHandler</code></i>
  @@ -1637,7 +1637,7 @@
   <pre>
   public interface NullSetEventHandler extends EventHandler
   {
  -    public boolean nullSetLogMessage( String reference );
  +    public boolean shouldLogOnNullSet( String lhs, String rhs );
   }   
   </pre>
   </blockquote>
  @@ -1701,30 +1701,63 @@
                                NullSetEventHandler,
                                MethodExceptionEventHandler
   {
  - ...
  -     /*
  -      *  now, it's assumed that Test implements the correct methods to 
  -      *  support the event handler interfaces.  So to use them, first
  -      *  make a new cartridge
  -      */
  -      EventCartridge ec = new EventCartridge();
  +    public void myTest()
  +    {
  +        ....
  +
  +        /*
  +         *  now, it's assumed that Test implements the correct methods to 
  +         *  support the event handler interfaces.  So to use them, first
  +         *  make a new cartridge
  +         */
  +        EventCartridge ec = new EventCartridge();
            
  -      /*
  -       * then register this class as it contains the handlers 
  -       */
  -       ec.addEventHandler(this);
  +        /*
  +         * then register this class as it contains the handlers 
  +         */
  +        ec.addEventHandler(this);
              
  -      /*
  -       * and then finally let it attach itself to the context
  -       */
  -       ec.attachToContext( context );
  -
  -      /*
  -       * now merge your template with the context as you normally
  -       * do
  -       */
  -...
  +        /*
  +         * and then finally let it attach itself to the context
  +         */
  +        ec.attachToContext( context );
  +
  +        /*
  +         * now merge your template with the context as you normally
  +         * do
  +         */
  +          
  +        ....
  +
  +    }
  +      
  +    /*
  +     *  and now the implementations of the event handlers
  +     */
  +
  +    public Object referenceInsert( String reference, Object value  )
  +    {
  +        /*  do something with it */
  +        return value;
  +    }
  +
  +    public boolean shouldLogOnNullSet( String lhs, String rhs )
  +    {
  +        if ( /* whatever rule */ )
  +            return false;
  +        
  +        return true;
  +    }
  +
  +    public Object methodException( Class claz, String method, Exception e )
  +         throws Exception
  +    {
  +        if ( /* whatever rule */ )
  +           return &quot;I should have thrown&quot;;
   
  +        throw e;
  +    }
  +}
   </pre></td>
         <td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" 
height="1" vspace="0" hspace="0" border="0"/></td>
       </tr>
  
  
  

Reply via email to