Author: dkulp
Date: Fri Aug 21 15:46:00 2009
New Revision: 806606
URL: http://svn.apache.org/viewvc?rev=806606&view=rev
Log:
Merged revisions 806020 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r806020 | dkulp | 2009-08-19 22:08:03 -0400 (Wed, 19 Aug 2009) | 1 line
[CXF-2397] Make loading of xmlfi optional if fastinfoset isn't there.
........
Modified:
cxf/branches/2.2.x-fixes/ (props changed)
cxf/branches/2.2.x-fixes/rt/core/pom.xml
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
cxf/branches/2.2.x-fixes/systests/pom.xml
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 21 15:46:00 2009
@@ -1 +1 @@
-/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
4,798654,798748-798749,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803419,803460,803493,803689,804002,804175,804276,805784,805907,805909
+/cxf/trunk:782728-782730,783097,783294,783396,784059,784181-784184,784893,784895,785279-785282,785468,785621,785624,785651,785734,785866,786142,786271-786272,786395,786512,786514,786582-786583,786638,786647,786850,787200,787269,787277-787279,787290-787291,787305,787323,787366,787849,788030,788060,788187,788444,788451,788703,788752,788774,788819-788820,789013,789371,789387,789420,789527-789530,789704-789705,789788,789811,789896-789901,790074,790094,790134,790188,790294,790553,790637-790644,790868,791301,791354,791538,791753,791947,792007,792096,792183,792261-792265,792271,792604,792683-792685,792975,792985,793059,793570,794297,794396,794680,794728,794771,794778-794780,794892,795044,795104,795160,795583,795907,796022-796023,796352,796593,796741,796780,796994-796997,797117,797159,797192,797194,797231-797233,797442,797505,797517,797534,797581-797583,797587,797640,797651,797699,797882-797883,798344-798346,798363,798461,798479,798533,798551,798557,798561-798562,798570,798573,79858
4,798654,798748-798749,798816,798891,798929-798930,799245,799267,799439,799448,799637,799723-799724,799792,800453,800497-800498,801380-801381,801447,801962,802892,803056,803129,803419,803460,803493,803689,804002,804175,804276,805784,805907,805909,806020
Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: cxf/branches/2.2.x-fixes/rt/core/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/pom.xml?rev=806606&r1=806605&r2=806606&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/core/pom.xml (original)
+++ cxf/branches/2.2.x-fixes/rt/core/pom.xml Fri Aug 21 15:46:00 2009
@@ -59,11 +59,11 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
</dependency>
- <dependency>
- <groupId>xml-resolver</groupId>
+ <dependency>
+ <groupId>xml-resolver</groupId>
<artifactId>xml-resolver</artifactId>
<optional>true</optional>
- </dependency>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -76,11 +76,11 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.sun.xml.fastinfoset</groupId>
- <artifactId>FastInfoset</artifactId>
+ <dependency>
+ <groupId>com.sun.xml.fastinfoset</groupId>
+ <artifactId>FastInfoset</artifactId>
+ <optional>true</optional>
</dependency>
-
</dependencies>
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java?rev=806606&r1=806605&r2=806606&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
Fri Aug 21 15:46:00 2009
@@ -82,7 +82,8 @@
super(beanFactory);
tunedDocumentLoader = new TunedDocumentLoader();
this.setDocumentLoader(tunedDocumentLoader);
- noFastinfoset = System.getProperty("org.apache.cxf.nofastinfoset") !=
null;
+ noFastinfoset = System.getProperty("org.apache.cxf.nofastinfoset") !=
null
+ || !TunedDocumentLoader.hasFastInfoSet();
}
@Override
@@ -118,15 +119,16 @@
@Override
public int loadBeanDefinitions(EncodedResource encodedResource) throws
BeanDefinitionStoreException {
- if (noFastinfoset) {
- return super.loadBeanDefinitions(encodedResource);
- }
-
- try {
- return fastInfosetLoadBeanDefinitions(encodedResource);
- } catch (Exception e) {
- return super.loadBeanDefinitions(encodedResource);
+ if (!noFastinfoset) {
+ try {
+ return fastInfosetLoadBeanDefinitions(encodedResource);
+ } catch (BeanDefinitionStoreException bdse) {
+ throw bdse;
+ } catch (Throwable e) {
+ //ignore - just call the super to load them
+ }
}
+ return super.loadBeanDefinitions(encodedResource);
}
private int fastInfosetLoadBeanDefinitions(EncodedResource encodedResource)
@@ -161,7 +163,11 @@
}
Resource newResource = new UrlResource(fixmlUrl);
- Document doc = tunedDocumentLoader.loadFastinfosetDocument(fixmlUrl);
+ Document doc = TunedDocumentLoader.loadFastinfosetDocument(fixmlUrl);
+ if (doc == null) {
+ //something caused FastinfoSet to not be able to read the doc
+ throw new StaleFastinfosetException();
+ }
return registerBeanDefinitions(doc, newResource);
}
Modified:
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java?rev=806606&r1=806605&r2=806606&view=diff
==============================================================================
---
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
(original)
+++
cxf/branches/2.2.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/TunedDocumentLoader.java
Fri Aug 21 15:46:00 2009
@@ -23,16 +23,14 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.logging.Logger;
-import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXSource;
import org.w3c.dom.Document;
@@ -45,6 +43,7 @@
import com.sun.xml.fastinfoset.stax.StAXDocumentParser;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.staxutils.StaxUtils;
import org.apache.cxf.staxutils.W3CDOMStreamWriter;
import org.springframework.beans.factory.xml.DefaultDocumentLoader;
@@ -54,27 +53,25 @@
* A Spring DocumentLoader that uses WoodStox when we are not validating to
speed up the process.
*/
class TunedDocumentLoader extends DefaultDocumentLoader {
+ private static final Logger LOG =
LogUtils.getL7dLogger(TunedDocumentLoader.class);
+
+ private static boolean hasFastInfoSet;
- // DocumentBuilderFactories are somewhat expensive but not thread-safe.
- // We only use this builder with WoodStox, and Fast Infoset
- // and we respect Spring's desire to make new factories
- // when we aren't doing the optimization.
- private static DocumentBuilder documentBuilder;
static {
- try {
- documentBuilder =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- throw new RuntimeException(e);
- }
+ try {
+ ClassLoaderUtils
+ .loadClass("com.sun.xml.fastinfoset.stax.StAXDocumentParser",
+ TunedDocumentLoader.class);
+ hasFastInfoSet = true;
+ } catch (Throwable e) {
+ LOG.fine("FastInfoset not found on classpath. Disabling context
load optimizations.");
+ hasFastInfoSet = false;
+ }
}
- private TransformerFactory transformerFactory;
private SAXParserFactory saxParserFactory;
private SAXParserFactory nsasaxParserFactory;
TunedDocumentLoader() {
- transformerFactory = TransformerFactory.newInstance();
-
try {
Class<?> cls =
ClassLoaderUtils.loadClass("com.ctc.wstx.sax.WstxSAXParserFactory",
TunedDocumentLoader.class);
@@ -93,6 +90,11 @@
} catch (Throwable e) {
//ignore
}
+
+ }
+
+ public static boolean hasFastInfoSet() {
+ return hasFastInfoSet;
}
@Override
@@ -100,7 +102,6 @@
ErrorHandler errorHandler, int
validationMode, boolean namespaceAware)
throws Exception {
if (validationMode == XmlBeanDefinitionReader.VALIDATION_NONE) {
-
SAXParserFactory parserFactory =
namespaceAware ? nsasaxParserFactory : saxParserFactory;
SAXParser parser = parserFactory.newSAXParser();
@@ -108,14 +109,9 @@
reader.setEntityResolver(entityResolver);
reader.setErrorHandler(errorHandler);
SAXSource saxSource = new SAXSource(reader, inputSource);
- Document document;
- // collisions are quite unlikely here, but making
documentBuilderFactory objects is expensive.
- synchronized (documentBuilder) {
- document = documentBuilder.newDocument();
- }
- DOMResult domResult = new DOMResult(document,
inputSource.getSystemId());
- transformerFactory.newTransformer().transform(saxSource,
domResult);
- return document;
+ W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
+ StaxUtils.copy(saxSource, writer);
+ return writer.getDocument();
} else {
return super.loadDocument(inputSource, entityResolver,
errorHandler, validationMode,
namespaceAware);
@@ -136,9 +132,8 @@
return factory;
}
- Document loadFastinfosetDocument(URL url)
+ static Document loadFastinfosetDocument(URL url)
throws IOException, ParserConfigurationException, XMLStreamException {
-
InputStream is = url.openStream();
InputStream in = new BufferedInputStream(is);
XMLStreamReader staxReader = new StAXDocumentParser(in);
Modified: cxf/branches/2.2.x-fixes/systests/pom.xml
URL:
http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/pom.xml?rev=806606&r1=806605&r2=806606&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/pom.xml (original)
+++ cxf/branches/2.2.x-fixes/systests/pom.xml Fri Aug 21 15:46:00 2009
@@ -540,6 +540,10 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.sun.xml.fastinfoset</groupId>
+ <artifactId>FastInfoset</artifactId>
+ </dependency>
<dependency>
<groupId>rhino</groupId>