background image

SJSXP Factories Implementation

<< Reporting CDATA Events | Sample Code Organization >>
<< Reporting CDATA Events | Sample Code Organization >>
98
S
TREAMING
API
FOR
XML
SJSXP Factories Implementation
Most applications do not need to know the factory implementation class name.
Just adding the
javaee.jar
and
appserv-ws.jar
files to the classpath is suffi-
cient for most applications because these two jars supply the factory implemen-
tation classname for various SJSXP properties under the
META-INF/services
directory--for
example,
javax.xml.stream.XMLInputFactory
,
javax.xml.stream.XMLOutputFactory
, and
javax.xml.stream.XMLEvent-
Factory
--which is the third step of a lookup operation when an application asks
for the factory instance. See the javadoc for the
XMLInputFactory.newIn-
stance()
method for more information about the lookup mechanism.
However, there may be scenarios when an application would like to know about
the factory implementation class name and set the property explicitly. These sce-
narios could include cases where there are multiple JSR 173 implementations in
the classpath and the application wants to choose one, perhaps one that has supe-
rior performance, contains a crucial bug fix, or suchlike.
If an application sets the
SystemProperty
, it is the first step in a lookup opera-
tion, and so obtaining the factory instance would be fast compared to other
options; for example:
javax.xml.stream.XMLInputFactory -->
com.sun.xml.stream.ZephyrParserFactory
javax.xml.stream.XMLOutputFactory -->
com.sun.xml.stream.ZephyrWriterFactor
javax.xml.stream.XMLEventFactory -->
com.sun.xml.stream.events.ZephyrEventFactory