You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:57:04 UTC

[sling-org-apache-sling-provisioning-model] 08/34: Fully support Apach Felix config file format. Move from properties to getter and setter methods

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.provisioning.model-1.0.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-provisioning-model.git

commit 9857e6cb1f6a8ba3896fdeb85f1716d113f0c8a0
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Sep 24 09:05:18 2014 +0000

    Fully support Apach Felix config file format. Move from properties to getter and setter methods
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/tooling/support/slingstart-model@1627261 13f79535-47bb-0310-9956-ffa450edef68
---
 .../slingstart/model/txt/TXTSSMModelReader.java    |  2 ++
 .../slingstart/model/xml/XMLSSMModelReader.java    | 40 ++++++++++++----------
 .../slingstart/model/xml/XMLSSMModelWriter.java    | 19 +++++-----
 3 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/src/main/java/org/apache/sling/slingstart/model/txt/TXTSSMModelReader.java b/src/main/java/org/apache/sling/slingstart/model/txt/TXTSSMModelReader.java
index fa0f3f4..41b8eb6 100644
--- a/src/main/java/org/apache/sling/slingstart/model/txt/TXTSSMModelReader.java
+++ b/src/main/java/org/apache/sling/slingstart/model/txt/TXTSSMModelReader.java
@@ -148,6 +148,8 @@ public class TXTSSMModelReader {
                     }
                 }
             }
+        } else if ( config.isSpecial() ) {
+            config.addProperty(config.getPid(), textValue);
         } else {
             final LineNumberReader lnr = new LineNumberReader(new StringReader(textValue));
             String line;
diff --git a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
index 609661d..3045e50 100644
--- a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
+++ b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelReader.java
@@ -215,24 +215,28 @@ public class XMLSSMModelReader {
                         if ( prevMode == MODE.STARTLEVEL || prevMode == MODE.FEATURE_STARTLEVEL ) {
                             this.startLevel = 0;
                         } else if ( prevMode == MODE.CONFIGURATION || prevMode == MODE.FEATURE_CONFIGURATION ) {
-                            ByteArrayInputStream bais = null;
-                            try {
-                                bais = new ByteArrayInputStream(textValue.getBytes("UTF-8"));
-                                @SuppressWarnings("unchecked")
-                                final Dictionary<String, Object> props = ConfigurationHandler.read(bais);
-                                final Enumeration<String> e = props.keys();
-                                while ( e.hasMoreElements() ) {
-                                    final String key = e.nextElement();
-                                    this.configuration.addProperty(key, props.get(key));
-                                }
-                            } catch ( final IOException ioe ) {
-                                throw new SAXException(ioe);
-                            } finally {
-                                if ( bais != null ) {
-                                    try {
-                                        bais.close();
-                                    } catch ( final IOException ignore ) {
-                                        // ignore
+                            if ( this.configuration.isSpecial() ) {
+                                this.configuration.addProperty(this.configuration.getPid(), textValue);
+                            } else {
+                                ByteArrayInputStream bais = null;
+                                try {
+                                    bais = new ByteArrayInputStream(textValue.getBytes("UTF-8"));
+                                    @SuppressWarnings("unchecked")
+                                    final Dictionary<String, Object> props = ConfigurationHandler.read(bais);
+                                    final Enumeration<String> e = props.keys();
+                                    while ( e.hasMoreElements() ) {
+                                        final String key = e.nextElement();
+                                        this.configuration.addProperty(key, props.get(key));
+                                    }
+                                } catch ( final IOException ioe ) {
+                                    throw new SAXException(ioe);
+                                } finally {
+                                    if ( bais != null ) {
+                                        try {
+                                            bais.close();
+                                        } catch ( final IOException ignore ) {
+                                            // ignore
+                                        }
                                     }
                                 }
                             }
diff --git a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java
index 510cdb7..2881527 100644
--- a/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java
+++ b/src/main/java/org/apache/sling/slingstart/model/xml/XMLSSMModelWriter.java
@@ -144,15 +144,18 @@ public class XMLSSMModelWriter {
                 pw.print("pid=\"");
                 pw.print(escapeXml(config.getPid()));
                 pw.println("\"><![CDATA[");
-                final ByteArrayOutputStream os = new ByteArrayOutputStream();
-                try {
-                    ConfigurationHandler.write(os , config.getProperties());
-                } finally {
-                    os.close();
+                if ( config.isSpecial() ) {
+                    pw.println(config.getProperties().get(config.getPid()));
+                } else {
+                    final ByteArrayOutputStream os = new ByteArrayOutputStream();
+                    try {
+                        ConfigurationHandler.write(os , config.getProperties());
+                    } finally {
+                        os.close();
+                    }
+                    final String configString = new String(os.toByteArray(), "UTF-8");
+                    pw.println(configString);
                 }
-                final String configString = new String(os.toByteArray(), "UTF-8");
-                pw.println(configString);
-                pw.println(config.getProperties());
                 pw.print(indent);
                 pw.println("]]></configuration>");
             }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.