You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2019/06/04 13:54:35 UTC
svn commit: r1860617 - in /turbine/fulcrum/trunk/parser: pom.xml
src/java/org/apache/fulcrum/parser/DefaultParserService.java
src/java/org/apache/fulcrum/parser/ParserService.java
src/test/TestComponentConfig.xml
Author: gk
Date: Tue Jun 4 13:54:35 2019
New Revision: 1860617
URL: http://svn.apache.org/viewvc?rev=1860617&view=rev
Log:
- update parent
- allow more pool2 configuration (overwrite common-pool defaults)
Modified:
turbine/fulcrum/trunk/parser/pom.xml
turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java
turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java
turbine/fulcrum/trunk/parser/src/test/TestComponentConfig.xml
Modified: turbine/fulcrum/trunk/parser/pom.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/pom.xml?rev=1860617&r1=1860616&r2=1860617&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/pom.xml (original)
+++ turbine/fulcrum/trunk/parser/pom.xml Tue Jun 4 13:54:35 2019
@@ -19,7 +19,7 @@
<parent>
<groupId>org.apache.turbine</groupId>
<artifactId>turbine-parent</artifactId>
- <version>5</version>
+ <version>6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java?rev=1860617&r1=1860616&r2=1860617&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java (original)
+++ turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/DefaultParserService.java Tue Jun 4 13:54:35 2019
@@ -68,11 +68,6 @@ public class DefaultParserService
* The parameter encoding to use when parsing parameter strings
*/
private String parameterEncoding = PARAMETER_ENCODING_DEFAULT;
-
- /**
- * The default pool capacity.
- */
- int DEFAULT_POOL_CAPACITY = 1024;
/**
* Use commons pool to manage value parsers
@@ -93,7 +88,7 @@ public class DefaultParserService
{
// Define the default configuration
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
- config.setMaxIdle(1);
+ config.setMaxIdle(DEFAULT_MAX_IDLE);
config.setMaxTotal(DEFAULT_POOL_CAPACITY);
// init the pool
@@ -115,7 +110,6 @@ public class DefaultParserService
valueParserPool
= new BaseValueParserPool(new BaseValueParserFactory(), config);
- // init the pool
parameterParserPool
= new DefaultParameterParserPool(new DefaultParameterParserFactory(), config);
}
@@ -364,7 +358,47 @@ public class DefaultParserService
.getValue(PARAMETER_ENCODING_DEFAULT).toLowerCase();
automaticUpload = conf.getChild(AUTOMATIC_KEY).getValueAsBoolean(AUTOMATIC_DEFAULT);
-
+
+
+ Configuration[] poolChildren = conf.getChild(POOL_KEY).getChildren();
+ if (poolChildren.length > 0) {
+ GenericObjectPoolConfig genObjPoolConfig = new GenericObjectPoolConfig();
+ genObjPoolConfig.setMaxIdle(DEFAULT_MAX_IDLE);
+ genObjPoolConfig.setMaxTotal(DEFAULT_POOL_CAPACITY);
+ for (Configuration poolConf : poolChildren) {
+ // use common pool2 configuration names
+ switch (poolConf.getName()) {
+ case "maxTotal":
+ int defaultCapacity = poolConf.getValueAsInteger();
+ genObjPoolConfig.setMaxTotal(defaultCapacity);
+ break;
+ case "maxWaitMillis":
+ int maxWaitMillis = poolConf.getValueAsInteger();
+ genObjPoolConfig.setMaxWaitMillis(maxWaitMillis);
+ break;
+ case "blockWhenExhausted":
+ boolean blockWhenExhausted = poolConf.getValueAsBoolean();
+ genObjPoolConfig.setBlockWhenExhausted(blockWhenExhausted);
+ break;
+ case "maxIdle":
+ int maxIdle = poolConf.getValueAsInteger();
+ genObjPoolConfig.setMaxIdle(maxIdle);
+ break;
+ case "minIdle":
+ int minIdle = poolConf.getValueAsInteger();
+ genObjPoolConfig.setMinIdle(minIdle);
+ break;
+ default:
+ break;
+ }
+ }
+ // reinit the pools
+ valueParserPool.setConfig(genObjPoolConfig);
+ parameterParserPool.setConfig(genObjPoolConfig);
+ cookieParserPool.setConfig(genObjPoolConfig);
+ }
+
+ getLogger().debug(valueParserPool.toString());
}
// ---------------- Avalon Lifecycle Methods ---------------------
@@ -378,6 +412,7 @@ public class DefaultParserService
@Override
public void service(ServiceManager manager) throws ServiceException
{
+ // no need to call internal service
// if (manager.hasService(PoolService.ROLE))
// {
// poolService = (PoolService)manager.lookup(PoolService.ROLE);
Modified: turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java?rev=1860617&r1=1860616&r2=1860617&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java (original)
+++ turbine/fulcrum/trunk/parser/src/java/org/apache/fulcrum/parser/ParserService.java Tue Jun 4 13:54:35 2019
@@ -50,6 +50,8 @@ public interface ParserService
/** Parse file upload items automatically */
String AUTOMATIC_KEY = "automaticUpload";
+
+ String POOL_KEY = "pool";
/**
* <p> The default value of 'automaticUpload' property
@@ -61,6 +63,18 @@ public interface ParserService
* parseRequest} manually.
*/
boolean AUTOMATIC_DEFAULT = false;
+
+ /**
+ * <p> The default value of 'maxTotal' property in 'pool'
+ * (<code>1024</code>). The default pool capacity.
+ */
+ int DEFAULT_POOL_CAPACITY = 1024;
+
+ /**
+ * <p> The default value of 'maxIdle' property in 'pool'
+ * (<code>2</code>). The default maximum idle object.
+ */
+ int DEFAULT_MAX_IDLE = 2;
/**
* Get the parameter encoding that has been configured as default for
Modified: turbine/fulcrum/trunk/parser/src/test/TestComponentConfig.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/parser/src/test/TestComponentConfig.xml?rev=1860617&r1=1860616&r2=1860617&view=diff
==============================================================================
--- turbine/fulcrum/trunk/parser/src/test/TestComponentConfig.xml (original)
+++ turbine/fulcrum/trunk/parser/src/test/TestComponentConfig.xml Tue Jun 4 13:54:35 2019
@@ -21,5 +21,11 @@
<parser>
<parameterEncoding>utf-8</parameterEncoding>
<automaticUpload>true</automaticUpload>
+ <pool>
+ <!-- cft. defaults in org.apache.commons.pool2.impl.BaseObjectPoolConfig and GenericKeyedObjectPoolConfig -->
+ <maxTotal>2048</maxTotal>
+ <blockWhenExhausted>false</blockWhenExhausted>
+ <maxWaitMillis>100</maxWaitMillis>
+ </pool>
</parser>
</componentConfig>