public class XmlFieldFactory extends Object
This factory is thread safe and can be configured to use ThreadLocal to reuse XmlField instances for performance reasons.
When using ThreadLocal, configuration ( parserConfiguration and getter cache) is unique (static) across all XmlFieldFactory instances.
CleanThreadLocalFilter
Constructor and Description |
---|
XmlFieldFactory() |
XmlFieldFactory(boolean useThreadLocal) |
Modifier and Type | Method and Description |
---|---|
void |
cleanThreadLocal()
Clean the XmlField instance of the current thread.
|
XmlField |
getXmlField()
Get a new XmlField instance, or the instance associated with the current
thread if
#setUseThreadLocal(boolean) is enabled. |
void |
setGetterCache(boolean enabled)
Enable Getter cache.
|
void |
setParserConfiguration(Map<String,String> configuration)
Set parser configuration.
|
public XmlFieldFactory()
public XmlFieldFactory(boolean useThreadLocal)
useThreadLocal
- When enabled, the factory will create only one XmlField object
per thread and reuse it each time getXmlField()
is
called.
This improves performance if getXmlField()
is called
several times in the same thread. But it is still better to
keep the XmlField object and reuse it because it it not
subject to synchronization.
When used in a web application, it is recommended to use a servlet filter which clears the context after each call to prevent leaks in application servers.
CleanThreadLocalFilter
public void cleanThreadLocal()
public XmlField getXmlField()
#setUseThreadLocal(boolean)
is enabled.public void setGetterCache(boolean enabled)
enabled
- XmlField.setGetterCache(boolean)
Copyright © 2011–2014. All rights reserved.