public class BasicParserPool extends Object implements ParserPool
DocumentBuilder
s.
This implementation of ParserPool
allows its properties to be modified over
time and versions the builders it manages appropriately. There are certain performance penalties
for doing this. For a more performant implementation that does not support versioning or property
modification over time, see StaticBasicParserPool
.
This is a pool implementation of the caching factory variety, and as such imposes no upper bound
on the number of DocumentBuilders allowed to be concurrently checked out and in use. It does however
impose a limit on the size of the internal cache of idle builder instances via the value configured
via setMaxPoolSize(int)
.
Builders retrieved from this pool may (but are not required to) be returned to the pool with the method
returnBuilder(DocumentBuilder)
. Builders checked out prior to a change in the pool's properties will not be
effected by the change and will be appropriately dealt with when they are returned.
References to builders are kept by way of SoftReference
so that the garbage collector
may reap the builders if the system is running out of memory.
修飾子とタイプ | クラスと説明 |
---|---|
protected class |
BasicParserPool.DocumentBuilderProxy
A proxy that prevents the manages document builders retrieved from the parser pool.
|
コンストラクタと説明 |
---|
BasicParserPool()
Constructor.
|
修飾子とタイプ | メソッドと説明 |
---|---|
protected DocumentBuilder |
createBuilder()
Creates a new document builder.
|
DocumentBuilder |
getBuilder()
Gets a builder from the pool.
|
Map<String,Object> |
getBuilderAttributes()
Gets the builder attributes used when creating builders.
|
Map<String,Boolean> |
getBuilderFeatures()
Gets the builders' features.
|
boolean |
getCreateBuildersAtPoolLimit()
推奨されていません。
|
boolean |
getIgnoreComments()
Gets whether the builders ignore comments.
|
int |
getMaxPoolSize()
Gets the max number of builders the pool will hold.
|
protected int |
getPoolSize()
Gets the size of the current pool storage.
|
protected long |
getPoolVersion()
Gets the current pool version.
|
Schema |
getSchema()
Gets the schema builders use to validate.
|
protected void |
initializePool()
Initializes the pool with a new set of configuration options.
|
boolean |
isCoalescing()
Gets whether the builders are coalescing.
|
boolean |
isDTDValidating()
Gets whether the builders are validating.
|
boolean |
isExpandEntityReferences()
Gets whether builders expand entity references.
|
boolean |
isIgnoreElementContentWhitespace()
Get whether the builders ignore element content whitespace.
|
boolean |
isNamespaceAware()
Gets whether the builders are namespace aware.
|
boolean |
isXincludeAware()
Gets whether the builders are XInclude aware.
|
Document |
newDocument()
Convience method for creating a new document with a pooled builder.
|
Document |
parse(InputStream input)
Convience method for parsing an XML file using a pooled builder.
|
Document |
parse(Reader input)
Convience method for parsing an XML file using a pooled builder.
|
void |
returnBuilder(DocumentBuilder builder)
Returns a builder to the pool.
|
protected void |
setAttributes(DocumentBuilderFactory factory,
Map<String,Object> attributes)
Sets document builder attributes.
|
void |
setBuilderAttributes(Map<String,Object> newAttributes)
Sets the builder attributes used when creating builders.
|
void |
setBuilderFeatures(Map<String,Boolean> newFeatures)
Sets the the builders' features.
|
void |
setCoalescing(boolean isCoalescing)
Sets whether the builders are coalescing.
|
void |
setCreateBuildersAtPoolLimit(boolean createBuilders)
推奨されていません。
|
void |
setDTDValidating(boolean isValidating)
Sets whether the builders are validating.
|
void |
setExpandEntityReferences(boolean expand)
Sets whether builders expand entity references.
|
protected void |
setFeatures(DocumentBuilderFactory factory,
Map<String,Boolean> features)
Sets document builder features.
|
void |
setIgnoreComments(boolean ignore)
Sets whether the builders ignore comments.
|
void |
setIgnoreElementContentWhitespace(boolean ignore)
Sets whether the builders ignore element content whitespace.
|
void |
setMaxPoolSize(int newSize)
Sets the max number of builders the pool will hold.
|
void |
setNamespaceAware(boolean isNamespaceAware)
Sets whether the builders are namespace aware.
|
void |
setSchema(Schema newSchema)
Sets the schema builders use to validate.
|
void |
setXincludeAware(boolean isXIncludeAware)
Sets whether the builders are XInclude aware.
|
public DocumentBuilder getBuilder() throws XMLParserException
getBuilder
インタフェース内 ParserPool
XMLParserException
- thrown if the document builder factory is misconfiguredpublic void returnBuilder(DocumentBuilder builder)
returnBuilder
インタフェース内 ParserPool
builder
- the builder to returnpublic Document newDocument() throws XMLParserException
newDocument
インタフェース内 ParserPool
XMLParserException
- thrown if there is a problem retrieving a builderpublic Document parse(InputStream input) throws XMLParserException
parse
インタフェース内 ParserPool
input
- XML to parseXMLParserException
- thrown if there is a problem retrieving a builder, the input stream can not be read,
or the XML was invalidpublic Document parse(Reader input) throws XMLParserException
parse
インタフェース内 ParserPool
input
- XML to parseXMLParserException
- thrown if there is a problem retrieving a builder, the input stream can not be read,
or the XML was invalidpublic int getMaxPoolSize()
public void setMaxPoolSize(int newSize)
newSize
- max number of builders the pool will holdpublic boolean getCreateBuildersAtPoolLimit()
Note this method is deprecated and will be removed in the next release. It is also currently functionally non-operational.
public void setCreateBuildersAtPoolLimit(boolean createBuilders)
Note this method is deprecated and will be removed in the next release. It is also currently functionally non-operational.
createBuilders
- whether new builders will be created when the max pool size is reachedpublic Map<String,Object> getBuilderAttributes()
public void setBuilderAttributes(Map<String,Object> newAttributes)
newAttributes
- builder attributes used when creating builderspublic boolean isCoalescing()
public void setCoalescing(boolean isCoalescing)
isCoalescing
- whether the builders are coalescingpublic boolean isExpandEntityReferences()
public void setExpandEntityReferences(boolean expand)
expand
- whether builders expand entity referencespublic Map<String,Boolean> getBuilderFeatures()
public void setBuilderFeatures(Map<String,Boolean> newFeatures)
newFeatures
- the builders' featurespublic boolean getIgnoreComments()
public void setIgnoreComments(boolean ignore)
ignore
- The ignoreComments to set.public boolean isIgnoreElementContentWhitespace()
public void setIgnoreElementContentWhitespace(boolean ignore)
ignore
- whether the builders ignore element content whitespacepublic boolean isNamespaceAware()
public void setNamespaceAware(boolean isNamespaceAware)
isNamespaceAware
- whether the builders are namespace awarepublic Schema getSchema()
getSchema
インタフェース内 ParserPool
public void setSchema(Schema newSchema)
setSchema
インタフェース内 ParserPool
newSchema
- the schema builders use to validatepublic boolean isDTDValidating()
public void setDTDValidating(boolean isValidating)
isValidating
- whether the builders are validatingpublic boolean isXincludeAware()
public void setXincludeAware(boolean isXIncludeAware)
isXIncludeAware
- whether the builders are XInclude awareprotected long getPoolVersion()
protected int getPoolSize()
protected void initializePool() throws XMLParserException
XMLParserException
- thrown if there is a problem initialzing the poolprotected void setAttributes(DocumentBuilderFactory factory, Map<String,Object> attributes)
factory
- document builder factory upon which the attribute will be setattributes
- the set of attributes to be setprotected void setFeatures(DocumentBuilderFactory factory, Map<String,Boolean> features)
factory
- document builder factory upon which the attribute will be setfeatures
- the set of features to be setprotected DocumentBuilder createBuilder() throws XMLParserException
XMLParserException
- thrown if their is a configuration error with the builder factoryCopyright © 2012. All Rights Reserved.