You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Serge Knystautas (JIRA)" <ji...@apache.org> on 2006/03/04 22:28:40 UTC

[jira] Updated: (VELOCITY-434) Commons pool implementation of the parser pool

     [ http://issues.apache.org/jira/browse/VELOCITY-434?page=all ]

Serge Knystautas updated VELOCITY-434:
--------------------------------------

    Attachment: CommonsParserPool.java
                CommonsParserPoolFactory.java

> Commons pool implementation of the parser pool
> ----------------------------------------------
>
>          Key: VELOCITY-434
>          URL: http://issues.apache.org/jira/browse/VELOCITY-434
>      Project: Velocity
>         Type: Improvement
>   Components: Source
>     Reporter: Serge Knystautas
>     Priority: Minor
>  Attachments: CommonsParserPool.java, CommonsParserPoolFactory.java
>
> Now that with [Velocity-433] we can swap out the parser pool, here is a parser pool that uses commons-pool (http://jakarta.apache.org/commons/pool/).
> It is very primitive configuration and uses the same configuration name (parser.pool.size) for maximum number of elements in the pool.  It is also configured to grow when the maximum number is exhausted, which means that it scales the same way as the original parser, while actually providing some better pool support.
> One of the nicest parts about this is that you can set your maximum instances to 0 and still get great performance.  The first time you need a parser, it will still add one even though the max is reached (since grow when exhausted is set).  Assuming the second time you need a parser is within a few seconds, that first instance is still there.
> Here is some sample code of how to use it your app.
> Properties configuration = new Properties();
> configuration.put("parser.pool.class", "com.lokitech.util.pool.CommonsParserPool");
> configuration.put("parser.pool.size", "0");
> Velocity.init(configuration);
> Since Velocity does not have an existing dependency on commons pool, I'm not sure this code will get packaged into the main distribution.  This code is licensed using ASL 2.0, so please reuse however you want as long as attribution is kept per the license.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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