felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r982991 - in /felix/trunk/fileinstall: pom.xml src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
Date Fri, 06 Aug 2010 14:33:43 GMT
Author: cziegeler
Date: Fri Aug  6 14:33:43 2010
New Revision: 982991

URL: http://svn.apache.org/viewvc?rev=982991&view=rev
Log:
FELIX-2513 :  Support richer format for configurations

Modified:
    felix/trunk/fileinstall/pom.xml
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java

Modified: felix/trunk/fileinstall/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/pom.xml?rev=982991&r1=982990&r2=982991&view=diff
==============================================================================
--- felix/trunk/fileinstall/pom.xml (original)
+++ felix/trunk/fileinstall/pom.xml Fri Aug  6 14:33:43 2010
@@ -42,6 +42,12 @@
       <artifactId>org.osgi.compendium</artifactId>
       <version>4.1.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.configadmin</artifactId>
+      <version>1.2.4</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>
@@ -68,6 +74,9 @@
             <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
             <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
             <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
+            <Embed-Dependency>
+                org.apache.felix.configadmin;inline="org/apache/felix/cm/file/ConfigurationHandler.*"
+            </Embed-Dependency>
           </instructions>
         </configuration>
       </plugin>

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java?rev=982991&r1=982990&r2=982991&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/ConfigInstaller.java
Fri Aug  6 14:33:43 2010
@@ -18,13 +18,10 @@
  */
 package org.apache.felix.fileinstall.internal;
 
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.Hashtable;
-import java.util.Properties;
+import java.io.*;
+import java.util.*;
 
+import org.apache.felix.cm.file.ConfigurationHandler;
 import org.apache.felix.fileinstall.ArtifactInstaller;
 import org.apache.felix.fileinstall.internal.Util.Logger;
 import org.osgi.framework.BundleContext;
@@ -48,7 +45,8 @@ public class ConfigInstaller implements 
 
     public boolean canHandle(File artifact)
     {
-        return artifact.getName().endsWith(".cfg");
+        return artifact.getName().endsWith(".cfg")
+            || artifact.getName().endsWith(".config");
     }
 
     public void install(File artifact) throws Exception
@@ -79,29 +77,43 @@ public class ConfigInstaller implements 
      * @return
      * @throws Exception
      */
-    boolean setConfig(File f) throws Exception
+    boolean setConfig(final File f) throws Exception
     {
-        Properties p = new Properties();
-        InputStream in = new BufferedInputStream(new FileInputStream(f));
+        final Hashtable ht = new Hashtable();
+        final InputStream in = new BufferedInputStream(new FileInputStream(f));
         try
         {
-            in.mark(1);
-            boolean isXml = in.read() == '<';
-            in.reset();
-            if (isXml) {
-                p.loadFromXML(in);
-            } else {
-                p.load(in);
+            if ( f.getName().endsWith(".cfg") )
+            {
+                final Properties p = new Properties();
+                in.mark(1);
+                boolean isXml = in.read() == '<';
+                in.reset();
+                if (isXml) {
+                    p.loadFromXML(in);
+                } else {
+                    p.load(in);
+                }
+                Util.performSubstitution(p);
+                ht.putAll(p);
+            }
+            else
+            {
+                final Dictionary config = ConfigurationHandler.read(in);
+                final Enumeration i = config.keys();
+                while ( i.hasMoreElements() )
+                {
+                    final Object key = i.nextElement();
+                    ht.put(key, config.get(key));
+                }
             }
         }
         finally
         {
             in.close();
         }
-        Util.performSubstitution(p);
+
         String pid[] = parsePid(f.getName());
-        Hashtable ht = new Hashtable();
-        ht.putAll(p);
         ht.put(DirectoryWatcher.FILENAME, f.getName());
         Configuration config = getConfiguration(pid[0], pid[1]);
         if (config.getBundleLocation() != null)



Mime
View raw message