Improved loading of properties in Activator.doInitProperties, now it loads properties from BundleContext
Fixed compilation and run-time issue with JDK13 profile
Almost resolved split-package issue: moved README and upnp.properties
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@609743 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/upnp/basedriver/src/main/resources/README b/upnp/basedriver/README
similarity index 100%
rename from upnp/basedriver/src/main/resources/README
rename to upnp/basedriver/README
diff --git a/upnp/basedriver/pom.xml b/upnp/basedriver/pom.xml
index 8233e71..d7ed87d 100644
--- a/upnp/basedriver/pom.xml
+++ b/upnp/basedriver/pom.xml
@@ -99,15 +99,15 @@
<!--Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive-->
<Export-Package>
- org.apache.felix.upnp.basedriver.controller.*,
- org.apache.felix.upnp.basedriver.util.*,
- org.apache.xerces.impl.dv.util.*
+ org.apache.felix.upnp.basedriver.controller;version=0.1,
+ org.apache.felix.upnp.basedriver.util;version=0.3
</Export-Package>
<Import-Package>org.osgi.*</Import-Package>
<Private-Package>
org.apache.felix.upnp.basedriver.*, org.kxml2.io,
- org.xmlpull.v1, org.cybergarage.*
+ org.xmlpull.v1, org.cybergarage.*,
+ org.apache.xerces.impl.dv.util
</Private-Package>
</instructions>
</configuration>
@@ -155,17 +155,22 @@
org.apache.felix.upnp.basedriver
</Bundle-SymbolicName>
<Export-Package>
- org.apache.felix.upnp.basedriver.controller.*,
- org.apache.felix.upnp.basedriver.util.*,
- org.apache.xerces.impl.dv.util.*
+ org.apache.felix.upnp.basedriver.controller;version=0.1.0,
+ org.apache.felix.upnp.basedriver.util;version=0.3.0
+ org.apache.felix.upnp.basedriver.resources;version=0.3.0
</Export-Package>
<Import-Package>
org.osgi.*, javax.xml.parsers, org.w3c.dom,
org.xml.sax
</Import-Package>
<Private-Package>
- org.apache.felix.upnp.basedriver.*,
- org.cybergarage.*
+ org.apache.felix.upnp.basedriver.controller.impl,
+ org.apache.felix.upnp.basedriver.importer.*,
+ org.apache.felix.upnp.basedriver.export.*,
+ org.apache.felix.upnp.basedriver.tool,
+ org.apache.felix.upnp.basedriver,
+ org.cybergarage.*,
+ org.apache.xerces.impl.dv.util
</Private-Package>
</instructions>
</configuration>
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java
index 80c0e1e..a2fcd97 100644
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java
+++ b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java
@@ -19,10 +19,6 @@
package org.apache.felix.upnp.basedriver;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
import java.util.Enumeration;
import java.util.Properties;
@@ -92,6 +88,10 @@
doControllerRegistration();
+ Activator.logger.DEBUG( "org.apache.felix.upnp.basedriver Configuration:\n"+
+ configuration.toString()
+ );
+
}
@@ -101,20 +101,19 @@
*/
configuration = new Properties();
try {
- configuration.load(Activator.class.getResourceAsStream("upnp.properties"));
+ configuration.load(Activator.class.getResourceAsStream("resources/upnp.properties"));
} catch (Exception ignored) {
- ignored.printStackTrace();
}
/*
- * Overiding default value with the properties defined in the System
+ * Overiding default value with the properties defined in the Bundle/System
*/
Enumeration e = configuration.propertyNames();
- Properties system = System.getProperties();
while (e.hasMoreElements()) {
String name = (String) e.nextElement();
- if(system.containsKey(name)){
- configuration.setProperty(name, system.getProperty(name));
+ String systemValue = Activator.bc.getProperty(name);
+ if(systemValue!=null){
+ configuration.setProperty(name, systemValue);
}
}
@@ -171,11 +170,18 @@
boolean useOnlyIPV4 = Boolean.valueOf(configuration.getProperty(Constants.NET_ONLY_IPV4_PROP,"true")).booleanValue();
if (useOnlyIPV4) UPnP.setEnable(UPnP.USE_ONLY_IPV4_ADDR);
else UPnP.setDisable(UPnP.USE_ONLY_IPV4_ADDR);
-
- boolean useOnlyIPV6 = Boolean.valueOf(configuration.getProperty(Constants.NET_ONLY_IPV6_PROP,"false")).booleanValue();
- if (useOnlyIPV6) UPnP.setEnable(UPnP.USE_ONLY_IPV6_ADDR);
- else UPnP.setDisable(UPnP.USE_ONLY_IPV6_ADDR);
-
+
+ String javaVersion = Activator.bc.getProperty("java.version");
+ if(!(javaVersion == null
+ || javaVersion.startsWith("1.0") || javaVersion.startsWith("1.1")
+ || javaVersion.startsWith("1.2") || javaVersion.startsWith("1.3")
+ ))
+ {
+ boolean useOnlyIPV6 = Boolean.valueOf(configuration.getProperty(Constants.NET_ONLY_IPV6_PROP,"false")).booleanValue();
+ if (useOnlyIPV6) UPnP.setEnable(UPnP.USE_ONLY_IPV6_ADDR);
+ else UPnP.setDisable(UPnP.USE_ONLY_IPV6_ADDR);
+ }
+
boolean useLoopback = Boolean.valueOf(configuration.getProperty(Constants.NET_USE_LOOPBACK_PROP,"false")).booleanValue();
if (useLoopback) UPnP.setEnable(UPnP.USE_LOOPBACK_ADDR);
else UPnP.setDisable(UPnP.USE_LOOPBACK_ADDR);
diff --git a/upnp/basedriver/src/main/resources/org/apache/felix/upnp/basedriver/upnp.properties b/upnp/basedriver/src/main/resources/org/apache/felix/upnp/basedriver/resources/upnp.properties
similarity index 100%
rename from upnp/basedriver/src/main/resources/org/apache/felix/upnp/basedriver/upnp.properties
rename to upnp/basedriver/src/main/resources/org/apache/felix/upnp/basedriver/resources/upnp.properties