You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fu...@apache.org on 2008/01/07 15:34:05 UTC
svn commit: r609615 - in /felix/trunk/upnp:
basedriver/src/main/java/org/apache/felix/upnp/basedriver/
basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/
samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/
Author: furfari
Date: Mon Jan 7 06:34:03 2008
New Revision: 609615
URL: http://svn.apache.org/viewvc?rev=609615&view=rev
Log:
Reorganized basedriver initialization
added time to string conversion to device
Modified:
felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java
felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Constants.java
felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java
felix/trunk/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
Modified: felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java?rev=609615&r1=609614&r2=609615&view=diff
==============================================================================
--- felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java (original)
+++ felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/Activator.java Mon Jan 7 06:34:03 2008
@@ -39,20 +39,13 @@
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.util.Converter;
+import org.apache.felix.upnp.basedriver.util.Constants;
/*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class Activator implements BundleActivator {
- public final static String BASEDRIVER_LOG_PROP = "felix.upnpbase.log";
- public final static String CYBERDOMO_LOG_PROP = "felix.upnpbase.cyberdomo.log";
- public final static String EXPORTER_ENABLED_PROP = "felix.upnpbase.exporter.enabled";
- public final static String IMPORTER_ENABLED_PROP = "felix.upnpbase.importer.enabled";
- public final static String NET_ONLY_IPV4_PROP = "felix.upnpbase.cyberdomo.net.onlyIPV4";
- public final static String NET_ONLY_IPV6_PROP = "felix.upnpbase.cyberdomo.net.onlyIPV6";
- public final static String NET_USE_LOOPBACK_PROP = "felix.upnpbase.cyberdomo.net.loopback";
public static BundleContext bc;
public static Logger logger;
@@ -69,12 +62,6 @@
private DriverControllerImpl drvController;
private ServiceRegistration drvControllerRegistrar;
- private boolean useExporter = true;
- private boolean useImporter = true;
-
- private boolean useOnlyIPV4 = true;
- private boolean useOnlyIPV6 = false;
- private boolean useLoopback = false;
/**
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
@@ -84,7 +71,7 @@
Activator.bc = context;
- doInitProperties();
+ doInitLogger();
doInitUPnPStack();
@@ -130,53 +117,19 @@
return value;
}
-
-
/**
- * Method used for initilizing the Import component of the UPnP Base Driver
+ * Method used for initilizing the general properties of the UPnP Base Driver
*
* @since 0.3
*/
- private void doInitImporter() {
- if (!useImporter) return;
-
-
- //Setting up Base Driver Importer
- this.notifierQueue = new NotifierQueue();
- this.subQueue = new SubscriptionQueue();
- ctrl = new MyCtrlPoint(Activator.bc, subQueue, notifierQueue);
+ private void doInitLogger() {
- //Enable CyberLink re-new for Event
- ctrl.setNMPRMode(true);
-
- this.monitor=new Monitor();
- this.notifier = new Notifier(notifierQueue,monitor);
- this.subScriber = new SubScriber(ctrl, subQueue,monitor);
+ String levelStr = getPropertyDefault(Activator.bc,Constants.BASEDRIVER_LOG_PROP,"2");
+ Activator.logger = new Logger(levelStr);
- ctrl.start();
- subScriber.start();
- notifier.start();
- }
+ String cyberLog = getPropertyDefault(Activator.bc,Constants.CYBERDOMO_LOG_PROP,"false");
+ Activator.logger.setCyberDebug(cyberLog);
- /**
- /**
- * Method used for initilizing the Exporter component of the UPnP Base Driver
- * @throws InvalidSyntaxException
- *
- * @since 0.3
- * @throws InvalidSyntaxException
- */
- private void doInitExporter() throws InvalidSyntaxException {
- if (!useExporter) return;
-
-
- //Setting up Base Driver Exporter
- this.queue = new RootDeviceExportingQueue();
- this.producerDeviceToExport = new RootDeviceListener(queue);
- producerDeviceToExport.activate();
- consumerDeviceToExport = new ThreadExporter(queue);
- new Thread(consumerDeviceToExport, "upnp.basedriver.Exporter").start();
-
}
/**
@@ -185,84 +138,68 @@
* @since 0.3
*/
private void doInitUPnPStack() {
-
+ Boolean useOnlyIPV4 = Boolean.valueOf(getPropertyDefault(Activator.bc,Constants.NET_ONLY_IPV4_PROP,"true"));
if (useOnlyIPV4) UPnP.setEnable(UPnP.USE_ONLY_IPV4_ADDR);
else UPnP.setDisable(UPnP.USE_ONLY_IPV4_ADDR);
+ Boolean useOnlyIPV6 = Boolean.valueOf(getPropertyDefault(Activator.bc,Constants.NET_ONLY_IPV6_PROP,"true"));
if (useOnlyIPV6) UPnP.setEnable(UPnP.USE_ONLY_IPV6_ADDR);
else UPnP.setDisable(UPnP.USE_ONLY_IPV6_ADDR);
+ Boolean useLoopback = Boolean.valueOf(getPropertyDefault(Activator.bc,Constants.NET_USE_LOOPBACK_PROP,"true"));
if (useLoopback) UPnP.setEnable(UPnP.USE_LOOPBACK_ADDR);
else UPnP.setDisable(UPnP.USE_LOOPBACK_ADDR);
}
/**
- * Method used for initilizing the general properties of the UPnP Base Driver
+ /**
+ * Method used for initilizing the Exporter component of the UPnP Base Driver
+ * @throws InvalidSyntaxException
+ *
+ * @since 0.3
+ * @throws InvalidSyntaxException
+ */
+ private void doInitExporter() throws InvalidSyntaxException {
+ Boolean useExporter = Boolean.valueOf(getPropertyDefault(Activator.bc,Constants.EXPORTER_ENABLED_PROP,"true"));
+ if (!useExporter) return;
+
+ this.queue = new RootDeviceExportingQueue();
+ this.producerDeviceToExport = new RootDeviceListener(queue);
+ producerDeviceToExport.activate();
+ consumerDeviceToExport = new ThreadExporter(queue);
+ new Thread(consumerDeviceToExport, "upnp.basedriver.Exporter").start();
+
+ }
+
+ /**
+ * Method used for initilizing the Import component of the UPnP Base Driver
*
* @since 0.3
*/
- private void doInitProperties() {
+ private void doInitImporter() {
+ Boolean useImporter = Boolean.valueOf(getPropertyDefault(Activator.bc,Constants.IMPORTER_ENABLED_PROP,"true"));
+ if (!useImporter) return;
+
+
+ //Setting up Base Driver Importer
+ this.notifierQueue = new NotifierQueue();
+ this.subQueue = new SubscriptionQueue();
+ ctrl = new MyCtrlPoint(Activator.bc, subQueue, notifierQueue);
- //
- // Debugger configuration
- //
- String levelStr = getPropertyDefault(Activator.bc,BASEDRIVER_LOG_PROP,"2");
- Activator.logger = new Logger(levelStr);
+ //Enable CyberLink re-new for Event
+ ctrl.setNMPRMode(true);
+
+ this.monitor=new Monitor();
+ this.notifier = new Notifier(notifierQueue,monitor);
+ this.subScriber = new SubScriber(ctrl, subQueue,monitor);
- String cyberLog = getPropertyDefault(Activator.bc,CYBERDOMO_LOG_PROP,"false");
- Activator.logger.setCyberDebug(cyberLog);
-
- //
- // NET configuration
- //
- try {
- useOnlyIPV4 = ((Boolean) Converter.parseString(
- getPropertyDefault(Activator.bc,NET_ONLY_IPV4_PROP,"true"),"boolean"
- )).booleanValue();
- } catch (Exception e) {
- logger.WARNING(NET_ONLY_IPV4_PROP+" initialized with wrong value, using default "+useOnlyIPV4);
- }
-
- try {
- useOnlyIPV6 = ((Boolean) Converter.parseString(
- getPropertyDefault(Activator.bc,NET_ONLY_IPV6_PROP,"false"),"boolean"
- )).booleanValue();
- } catch (Exception e) {
- logger.WARNING(NET_ONLY_IPV6_PROP+" initialized with wrong value, using default "+useOnlyIPV6);
- }
-
- try {
- useLoopback = ((Boolean) Converter.parseString(
- getPropertyDefault(Activator.bc,NET_USE_LOOPBACK_PROP,"false"),"boolean"
- )).booleanValue();
- } catch (Exception e) {
- logger.WARNING(NET_USE_LOOPBACK_PROP+" initialized with wrong value, using default "+useLoopback);
- }
-
- //
- // Exporter configuration
- //
- try {
- useExporter = ((Boolean) Converter.parseString(
- getPropertyDefault(Activator.bc,EXPORTER_ENABLED_PROP,"true"),"boolean"
- )).booleanValue();
- } catch (Exception e) {
- logger.WARNING(EXPORTER_ENABLED_PROP+" initialized with wrong value, using default "+useExporter);
- }
-
- //
- // Importer configuration
- //
- try {
- useImporter = ((Boolean) Converter.parseString(
- getPropertyDefault(Activator.bc,IMPORTER_ENABLED_PROP,"true"),"boolean"
-
- )).booleanValue();
- } catch (Exception e) {
- logger.WARNING(IMPORTER_ENABLED_PROP+" initialized with wrong value, using default "+useImporter);
- }
+ ctrl.start();
+ subScriber.start();
+ notifier.start();
}
+
+
private void doControllerRegistration() {
drvController = new DriverControllerImpl(ctrl);
Modified: felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Constants.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Constants.java?rev=609615&r1=609614&r2=609615&view=diff
==============================================================================
--- felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Constants.java (original)
+++ felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Constants.java Mon Jan 7 06:34:03 2008
@@ -29,4 +29,13 @@
* The name of the property is "UPnP.device.import".
*/
public final static String UPNP_IMPORT = "UPnP.device.imported";
+
+ public final static String BASEDRIVER_LOG_PROP = "felix.upnpbase.log";
+ public final static String CYBERDOMO_LOG_PROP = "felix.upnpbase.cyberdomo.log";
+ public final static String EXPORTER_ENABLED_PROP = "felix.upnpbase.exporter.enabled";
+ public final static String IMPORTER_ENABLED_PROP = "felix.upnpbase.importer.enabled";
+ public final static String NET_ONLY_IPV4_PROP = "felix.upnpbase.cyberdomo.net.onlyIPV4";
+ public final static String NET_ONLY_IPV6_PROP = "felix.upnpbase.cyberdomo.net.onlyIPV6";
+ public final static String NET_USE_LOOPBACK_PROP = "felix.upnpbase.cyberdomo.net.loopback";
+
}
Modified: felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java?rev=609615&r1=609614&r2=609615&view=diff
==============================================================================
--- felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java (original)
+++ felix/trunk/upnp/basedriver/src/main/java/org/apache/felix/upnp/basedriver/util/Converter.java Mon Jan 7 06:34:03 2008
@@ -204,9 +204,9 @@
} else if (upnpType.equals("boolean")) {
if(value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true")
|| value.equalsIgnoreCase("1"))
- return new Boolean(true);
+ return Boolean.TRUE;
else
- return new Boolean(false);
+ return Boolean.FALSE;
} else if (upnpType.equals("bin.base64")) {
return Base64.decode(value);
} else if (upnpType.equals("bin.hex")) {
Modified: felix/trunk/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java
URL: http://svn.apache.org/viewvc/felix/trunk/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java?rev=609615&r1=609614&r2=609615&view=diff
==============================================================================
--- felix/trunk/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java (original)
+++ felix/trunk/upnp/samples/tv/src/main/java/org/apache/felix/upnp/sample/tv/TvDevice.java Mon Jan 7 06:34:03 2008
@@ -21,6 +21,7 @@
import java.awt.Component;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Dictionary;
import java.util.Properties;
@@ -250,8 +251,10 @@
public void notifyUPnPEvent(String deviceId, String serviceId, Dictionary events) {
if( !LinkedDevices.contains(deviceId))
LinkedDevices.add(deviceId);
- if (deviceId.indexOf("Clock") != -1)
- clockTime = (String) events.get("Time");
+ if (deviceId.indexOf("Clock") != -1){
+ Long time = (Long) events.get("Time");
+ clockTime = new Date(time).toString();
+ }
else if (deviceId.indexOf("AirCon") != -1)
airconTemp = (String) events.get("Temp");
else if (deviceId.indexOf("Washer") != -1)