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:27:10 UTC

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

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


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


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

Posted by Will Glass-Husain <wg...@forio.com>.
Fabulous.

Did "ant test" pass?

On 3/4/06, Serge Knystautas (JIRA) <ji...@apache.org> wrote:
>
> 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
>
>
> 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
>
>


--
_______________________________________
Forio Business Simulations

Will Glass-Husain
phone (415) 440-7500 x89
mobile (415) 235-4293
wglass@forio.com
www.forio.com

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

Posted by "Serge Knystautas (JIRA)" <ji...@apache.org>.
     [ 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


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

Posted by "Serge Knystautas (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-434?page=comments#action_12447337 ] 
            
Serge Knystautas commented on VELOCITY-434:
-------------------------------------------

Yup, all were marked properly (https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12329779).  Enjoy!

> Commons pool implementation of the parser pool
> ----------------------------------------------
>
>                 Key: VELOCITY-434
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-434
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Serge Knystautas
>            Priority: Minor
>             Fix For: 1.5
>
>         Attachments: CommonsParserPool.java, 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


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

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-434?page=comments#action_12449524 ] 
            
Will Glass-Husain commented on VELOCITY-434:
--------------------------------------------

Wait - we did make the parser pool pluggable!  That was Serge's other patch, which I committed.  Velocity-433.

I like this patch, but it doesn't make sense to me to put it in the core and force a dependency on commons-pool.   Unless Henning (or anyone speaks up), I'm going to mark this as WONTFIX.   (though I much appreciate the contribution and hope Serge sticks it in the Wiki).

> Commons pool implementation of the parser pool
> ----------------------------------------------
>
>                 Key: VELOCITY-434
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-434
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Serge Knystautas
>            Priority: Minor
>             Fix For: 1.5
>
>         Attachments: CommonsParserPool.java, 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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


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

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/VELOCITY-434?page=all ]

Will Glass-Husain resolved VELOCITY-434.
----------------------------------------

    Fix Version/s:     (was: 1.5)
       Resolution: Won't Fix

marking WONTFIX for reasons as noted above.  Other committers, please reopen if you think this should be applied.  Thanks again, Serge for the contribution.

> Commons pool implementation of the parser pool
> ----------------------------------------------
>
>                 Key: VELOCITY-434
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-434
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Serge Knystautas
>            Priority: Minor
>         Attachments: CommonsParserPool.java, 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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org


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

Posted by "Henning Schmiedehausen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/VELOCITY-434?page=all ]

Henning Schmiedehausen updated VELOCITY-434:
--------------------------------------------

      Component/s: Engine
                       (was: Source)
    Fix Version/s: 1.5

It might be possible to make the parser pool pluggable and then use the commons-pool implementation. 1.6 stuff. Serge, care to make sure that your patches have the "Contribute to the ASF" radio button set, that would help us very much when integrating the stuff.

> Commons pool implementation of the parser pool
> ----------------------------------------------
>
>                 Key: VELOCITY-434
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-434
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Serge Knystautas
>            Priority: Minor
>             Fix For: 1.5
>
>         Attachments: CommonsParserPool.java, 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


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

Posted by "Henning Schmiedehausen (JIRA)" <de...@velocity.apache.org>.
     [ https://issues.apache.org/jira/browse/VELOCITY-434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henning Schmiedehausen closed VELOCITY-434.
-------------------------------------------


> Commons pool implementation of the parser pool
> ----------------------------------------------
>
>                 Key: VELOCITY-434
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-434
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Serge Knystautas
>            Priority: Minor
>         Attachments: CommonsParserPool.java, 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.
-
You can reply to this email to add a comment to the issue online.


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


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

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-434?page=comments#action_12368924 ] 

Will Glass-Husain commented on VELOCITY-434:
--------------------------------------------

Looks promising.  A quick style note - remember to put braces on their own line.  Let's discuss on the list the point about additional dependencies.  I do worry about this.

> 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, 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


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

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-434?page=comments#action_12370457 ] 

Will Glass-Husain commented on VELOCITY-434:
--------------------------------------------

Thanks for sharing this code.

I've been thinking about this, and I believe the best place for CommonsParserPool is under ContributedCode in the Wiki.  While I think this implementation is a great idea (special benefit to high volume webapps), for most users the default pool implementation is more than sufficient.  I'm reluctant to endorse adding a new compile and run-time dependency for a small audience.  

If anyone wants to make a case for including this in the core- fire away.  But otherwise, Serge, I encourage you to post this to the Wiki so others can take advantage of it.  (I might use it myself, for example).  

If no one objects I'll then resolve this issue after the code is posted to the Wiki.



> 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, 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


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

Posted by "Serge Knystautas (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/VELOCITY-434?page=all ]

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

    Attachment: CommonsParserPool.java

The second CommonsParserPool defaults to 0 (instead of 20) parsers in the pool, which gives reuse of parsers in most cases which greatly reducing the amount of heap space use.  After more testing, just seems like a better default.

> 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, 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


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

Posted by "Will Glass-Husain (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VELOCITY-434?page=comments#action_12449239 ] 
            
Will Glass-Husain commented on VELOCITY-434:
--------------------------------------------

Henning, per your comment above shouldn't this be marked for version 1.6?  Or are you interested in promoting this as 1.5 material.  (I'm reluctant, though could be argued into it).

> Commons pool implementation of the parser pool
> ----------------------------------------------
>
>                 Key: VELOCITY-434
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-434
>             Project: Velocity
>          Issue Type: Improvement
>          Components: Engine
>            Reporter: Serge Knystautas
>            Priority: Minor
>             Fix For: 1.5
>
>         Attachments: CommonsParserPool.java, 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: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org