felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1437372 - in /felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml: ComponentDescriptorIO.java IOUtils.java MetaTypeIO.java
Date Wed, 23 Jan 2013 13:00:46 GMT
Author: cziegeler
Date: Wed Jan 23 13:00:46 2013
New Revision: 1437372

URL: http://svn.apache.org/viewvc?rev=1437372&view=rev
Log:
FELIX-3867 :  Drop support for JDK 1.4 completely 

Modified:
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
    felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=1437372&r1=1437371&r2=1437372&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
Wed Jan 23 13:00:46 2013
@@ -20,6 +20,7 @@ package org.apache.felix.scrplugin.xml;
 
 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 @@ public class ComponentDescriptorIO {
     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 @@ public class ComponentDescriptorIO {
                 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 @@ public class ComponentDescriptorIO {
             }
             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);
             }

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java?rev=1437372&r1=1437371&r2=1437372&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
Wed Jan 23 13:00:46 2013
@@ -64,29 +64,23 @@ public class IOUtils {
      * 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");
-
-            transformer.setOutputProperties(format);
-
-            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);
-        }
+        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);
+
+        transformerHandler.setResult(new StreamResult(writer));
+
+        return transformerHandler;
     }
 
     /**

Modified: felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java?rev=1437372&r1=1437371&r2=1437372&view=diff
==============================================================================
--- felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
(original)
+++ felix/trunk/scrplugin/generator/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
Wed Jan 23 13:00:46 2013
@@ -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 @@ public class MetaTypeIO {
             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);
         }



Mime
View raw message