Moved the method getPropertyDefault() to Basedriver Activator and deleted Util.java
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@607734 13f79535-47bb-0310-9956-ffa450edef68
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 cb1b5cd..63bc6de 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
@@ -36,7 +36,6 @@
import org.apache.felix.upnp.basedriver.importer.core.event.thread.Notifier;
import org.apache.felix.upnp.basedriver.importer.core.event.thread.SubScriber;
import org.apache.felix.upnp.basedriver.tool.Logger;
-import org.apache.felix.upnp.basedriver.tool.Util;
import org.apache.felix.upnp.extra.controller.DevicesInfo;
import org.apache.felix.upnp.extra.controller.DriverController;
@@ -79,29 +78,29 @@
//
// Debugger configuration
//
- String levelStr = Util.getPropertyDefault(context,BASEDRIVER_LOG_PROP,"2");
+ String levelStr = getPropertyDefault(context,BASEDRIVER_LOG_PROP,"2");
Activator.logger = new Logger(levelStr);
- String cyberLog = Util.getPropertyDefault(context,CYBERDOMO_LOG_PROP,"false");
+ String cyberLog = getPropertyDefault(context,CYBERDOMO_LOG_PROP,"false");
Activator.logger.setCyberDebug(cyberLog);
//
// NET configuration
//
- String useOnlyIPV4 = Util.getPropertyDefault(context,NET_ONLY_IPV4_PROP,"true");
+ String useOnlyIPV4 = getPropertyDefault(context,NET_ONLY_IPV4_PROP,"true");
if (useOnlyIPV4.equalsIgnoreCase("true"))
UPnP.setEnable(UPnP.USE_ONLY_IPV4_ADDR);
else
UPnP.setDisable(UPnP.USE_ONLY_IPV4_ADDR);
- String useOnlyIPV6 = Util.getPropertyDefault(context,NET_ONLY_IPV6_PROP,"false");
+ String useOnlyIPV6 = getPropertyDefault(context,NET_ONLY_IPV6_PROP,"false");
if (useOnlyIPV6.equalsIgnoreCase("true"))
UPnP.setEnable(UPnP.USE_ONLY_IPV6_ADDR);
else
UPnP.setDisable(UPnP.USE_ONLY_IPV6_ADDR);
- String useLoopback = Util.getPropertyDefault(context,NET_USE_LOOPBACK_PROP,"false");
+ String useLoopback = getPropertyDefault(context,NET_USE_LOOPBACK_PROP,"false");
if (useLoopback.equalsIgnoreCase("true"))
UPnP.setEnable(UPnP.USE_LOOPBACK_ADDR);
else
@@ -110,7 +109,7 @@
//
// Exporter configuration
//
- String useExporter = Util.getPropertyDefault(context,EXPORTER_ENABLED_PROP,"true");
+ String useExporter = getPropertyDefault(context,EXPORTER_ENABLED_PROP,"true");
if (useExporter.equalsIgnoreCase("true")){
//Setting up Base Driver Exporter
this.queue = new RootDeviceExportingQueue();
@@ -123,7 +122,7 @@
//
// Importer configuration
//
- String useImporter = Util.getPropertyDefault(context,IMPORTER_ENABLED_PROP,"true");
+ String useImporter = getPropertyDefault(context,IMPORTER_ENABLED_PROP,"true");
if (useImporter.equalsIgnoreCase("true")){
//Setting up Base Driver Importer
this.notifierQueue = new NotifierQueue();
@@ -182,4 +181,12 @@
Activator.logger=null;
Activator.bc = null;
}
+
+ public final String getPropertyDefault(BundleContext bc, String propertyName, String defaultValue ){
+ String value = bc.getProperty(propertyName);
+ if(value == null)
+ return defaultValue;
+ return value;
+ }
+
}
diff --git a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/tool/Util.java b/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/tool/Util.java
deleted file mode 100644
index 29a42f3..0000000
--- a/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/tool/Util.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.felix.upnp.basedriver.tool;
-
-import java.io.File;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.upnp.UPnPDevice;
-
-/*
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class Util {
-
- public static boolean isUPnPDevice(ServiceReference sr){
- String[] aux = (String[]) sr.getProperty(Constants.OBJECTCLASS);
- String val=UPnPDevice.class.getName();
- int i;
- for (i = 0; i < aux.length; i++) {
- if(aux[i].equals(val)) break;
- }
- if(i==aux.length) return false;
- aux = (String[]) sr.getProperty(org.osgi.service.device.Constants.DEVICE_CATEGORY);
- val=UPnPDevice.DEVICE_CATEGORY;
- for (i = 0; i < aux.length; i++) {
- if(aux[i].equals(val))
- return true;
- }
- return false;
- }
-
- public static final boolean isRootDevice(ServiceReference sr){
- return (sr.getProperty(UPnPDevice.PARENT_UDN)==null)
- && isUPnPDevice(sr);
- }
-
- public static final String getPropertyDefault(BundleContext bc, String propertyName, String defaultValue ){
- String value = bc.getProperty(propertyName);
- if(value == null)
- return defaultValue;
- return value;
- }
-
- public static boolean makeParentPath(String filePath){
- int l=filePath.lastIndexOf(File.separator);
- filePath=filePath.substring(0,l);
- File p=new File(filePath);
- if(p.exists())
- return true;
- return p.mkdirs();
- }
-
- /**
- * @param d
- */
- public static boolean deleteRecursive(File d) {
- if(!d.delete()){
- if(d.isDirectory()){
- File[] subs = d.listFiles();
- for (int i = 0; i < subs.length; i++) {
- if(!deleteRecursive(subs[i]))
- return false;
- }
- return d.delete();
- }else{
- return false;
- }
- }
- return true;
- }
-
-}