Overview
This Service functions as a repository for Parser components.
It is written for use in Turbine but it can be used in any container compatible with Avalon's ECM container.
Configuration
Role Configuration
<role name="org.apache.fulcrum.parser.ParserService" shorthand="parser" default-class="org.apache.fulcrum.parser.DefaultParserService"/>
Component Configuration
Item | Datatype | Cardinality | Description |
---|---|---|---|
urlCaseFolding | String | [0|1] |
This setting controls how parameter names are to be folded during
processing. Valid values are none (no folding),
upper (all names upper case) and lower
(all names lower case). The default is none .
|
parameterEncoding | String | [0|1] |
The parameter encoding to use when converting strings to bytes or
vice versa. This encoding is used when no explicit encoding is specified.
This must be a valid encoding string for the JVM in use. The default is
iso-8859-1 .
|
automaticUpload | boolean | [0|1] |
If set to true , parsing the multipart request for attachments
will be performed automatically. Otherwise, the request may be parsed manually
by calling parseUpload(HttpServletRequest) . The default value is
false . When set to true, the component must have the
Fulcrum Upload Service
available to parse the request.
|
pool2 | list | * |
Wrapper for commons pool2 parameters (child components) maxTotal with value -1 =no limit, other plausible values 1024, 2048.
blockWhenExhausted (by default true ), maxWaitMillis by default 0 , testOnBorrow , testOnCreate , testOnReturn ,maxIdle and minIdle .
The parameter values are the same as for commons.pool2,
compare the defaults (upper case and underscore-separated)
here
look for org.apache.commons.pool2.impl.BaseObjectPoolConfig and BaseGenericObjectPool.
|
Component Configuration Example
<parser> <urlCaseFolding>lower</urlCaseFolding> <parameterEncoding>utf-8</parameterEncoding> <automaticUpload>true</automaticUpload> <pool2> <maxTotal>2048</maxTotal><!-- default 8 --> <blockWhenExhausted>true</blockWhenExhausted><!-- default is true --> <maxWaitMillis>350</maxWaitMillis><!-- default is -1L --> </pool2> </parser>
Usage
You get a parser from the service like this:
ValueParser parser; try { // Get a ValueParser instance parser = parserService.getParser(BaseValueParser.class); parser.add(...); Double d = parser.getDoubleObject(...); } finally { // Return the instance to the service if (parser != null) { parserService.putParser(parser); } }
Parsers are pooled inside the service. You can use this service to manage any types of parsers, you just need to provide the class you want to manage. If the parser class implements LogEnabled it will get an (Avalon) logger injected. If the parser class implements ParserServiceSupport it will get an instance of this service injected.