FELIX-3867 : Drop support for JDK 1.4 completely
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1437372 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
index 95f5b12..1ae4d3a 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
@@ -20,6 +20,7 @@
import java.awt.Component;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.security.Provider.Service;
import java.util.ArrayList;
@@ -183,7 +184,7 @@
protected static void generateXML(final DescriptionContainer module,
final List<ComponentContainer> components,
final File descriptorFile,
- final Log logger) throws SAXException {
+ final Log logger) throws SAXException, IOException, TransformerException {
logger.info("Writing " + components.size() + " Service Component Descriptors to "
+ descriptorFile);
final ContentHandler contentHandler = IOUtils.getSerializer(descriptorFile);
@@ -767,6 +768,10 @@
final File file = new File(descriptorDir, component.getClassDescription().getDescribedClass().getName() + ".xml");
try {
ComponentDescriptorIO.generateXML(module, Collections.singletonList(component), file, logger);
+ } catch (final IOException e) {
+ throw new SCRDescriptorException("Unable to generate xml", file.toString(), e);
+ } catch (final TransformerException e) {
+ throw new SCRDescriptorException("Unable to generate xml", file.toString(), e);
} catch (final SAXException e) {
throw new SCRDescriptorException("Unable to generate xml", file.toString(), e);
}
@@ -778,6 +783,10 @@
}
try {
ComponentDescriptorIO.generateXML(module, components, descriptorFile, logger);
+ } catch (final IOException e) {
+ throw new SCRDescriptorException("Unable to generate xml", descriptorFile.toString(), e);
+ } catch (final TransformerException e) {
+ throw new SCRDescriptorException("Unable to generate xml", descriptorFile.toString(), e);
} catch (final SAXException e) {
throw new SCRDescriptorException("Unable to generate xml", descriptorFile.toString(), e);
}
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
index fb26f9b..85c011b 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
@@ -64,29 +64,23 @@
* Get a serializer to write XML to a file.
*/
public static ContentHandler getSerializer(final File file)
- throws SAXException {
- try {
- final Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
+ throws TransformerException, IOException {
+ final Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
- final TransformerHandler transformerHandler = FACTORY.newTransformerHandler();
- final Transformer transformer = transformerHandler.getTransformer();
+ final TransformerHandler transformerHandler = FACTORY.newTransformerHandler();
+ final Transformer transformer = transformerHandler.getTransformer();
- final Properties format = new Properties();
- format.put(OutputKeys.METHOD, "xml");
- format.put(OutputKeys.OMIT_XML_DECLARATION, "no");
- format.put(OutputKeys.ENCODING, "UTF-8");
- format.put(OutputKeys.INDENT, "yes");
+ final Properties format = new Properties();
+ format.put(OutputKeys.METHOD, "xml");
+ format.put(OutputKeys.OMIT_XML_DECLARATION, "no");
+ format.put(OutputKeys.ENCODING, "UTF-8");
+ format.put(OutputKeys.INDENT, "yes");
- transformer.setOutputProperties(format);
+ transformer.setOutputProperties(format);
- transformerHandler.setResult(new StreamResult(writer));
+ transformerHandler.setResult(new StreamResult(writer));
- return transformerHandler;
- } catch (final IOException se) {
- throw new SAXException("Unable to open file for writing: " + file, se);
- } catch (final TransformerException se) {
- throw new SAXException("Unable to create xml writer for: " + file, se);
- }
+ return transformerHandler;
}
/**
diff --git a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
index 8f21922..4d5dcbe 100644
--- a/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
+++ b/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
@@ -19,12 +19,15 @@
package org.apache.felix.scrplugin.xml;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import javax.xml.transform.TransformerException;
+
import org.apache.felix.scrplugin.Log;
import org.apache.felix.scrplugin.Options;
import org.apache.felix.scrplugin.SCRDescriptorException;
@@ -153,6 +156,10 @@
IOUtils.newline(contentHandler);
contentHandler.endPrefixMapping(PREFIX);
contentHandler.endDocument();
+ } catch (final IOException e) {
+ throw new SCRDescriptorException("Unable to generate xml", file.toString(), e);
+ } catch (final TransformerException e) {
+ throw new SCRDescriptorException("Unable to generate xml", file.toString(), e);
} catch (final SAXException e) {
throw new SCRDescriptorException("Unable to generate xml", file.toString(), e);
}