You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by do...@apache.org on 2009/07/01 06:58:04 UTC

svn commit: r790039 - in /felix/sandbox/donsez/upnp.heartbeat: generation/ generation/res/service/ src/main/java/org/apache/felix/upnp/heartbeat/controlpoint/ src/main/java/org/apache/felix/upnp/heartbeat/impl/ src/main/java/org/apache/felix/upnp/heart...

Author: donsez
Date: Wed Jul  1 04:58:04 2009
New Revision: 790039

URL: http://svn.apache.org/viewvc?rev=790039&view=rev
Log:
change attribute LiveID to LifeID in the service definition

Modified:
    felix/sandbox/donsez/upnp.heartbeat/generation/build.xml
    felix/sandbox/donsez/upnp.heartbeat/generation/res/service/HeartBeat1.xml
    felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/controlpoint/HeartBeatProxyImpl.java
    felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/impl/HeartBeatModelImpl.java
    felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/model/HeartBeatModel.java
    felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/service/HeartBeat.java

Modified: felix/sandbox/donsez/upnp.heartbeat/generation/build.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/upnp.heartbeat/generation/build.xml?rev=790039&r1=790038&r2=790039&view=diff
==============================================================================
--- felix/sandbox/donsez/upnp.heartbeat/generation/build.xml (original)
+++ felix/sandbox/donsez/upnp.heartbeat/generation/build.xml Wed Jul  1 04:58:04 2009
@@ -1,9 +1,25 @@
+<?xml version="1.0"?>
 <project name="OSGi UPnP Device Driver Source Generation" default="main" basedir=".">
 
-	<target name="main" depends="init, generate.class">
+	<target name="main" depends="init, compile.xalan.utilclasses, generate.class">
+	</target>
+
+	<target name="compile.xalan.utilclasses">
+		<javac destdir=".">
+   		 	<src path="."/>
+    			<include name="*.java"/>
+		</javac>
 	</target>
 
 	<target name="init">
+		<!-- TODO check the presence of xalan -->
+		<echo>
+Xalan java must be installed and setted up in your CLASSPATH
+For instance:
+set XALAN_HOME=E:\devtools\xalan-j_2_7_0
+set CLASSPATH=%XALAN_HOME%\xalan.jar;%XALAN_HOME%\xercesImpl.jar;%XALAN_HOME%\xml-apis.jar
+		</echo>
+
 		<mkdir dir="generated"/>
 	</target>
 

Modified: felix/sandbox/donsez/upnp.heartbeat/generation/res/service/HeartBeat1.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/upnp.heartbeat/generation/res/service/HeartBeat1.xml?rev=790039&r1=790038&r2=790039&view=diff
==============================================================================
--- felix/sandbox/donsez/upnp.heartbeat/generation/res/service/HeartBeat1.xml (original)
+++ felix/sandbox/donsez/upnp.heartbeat/generation/res/service/HeartBeat1.xml Wed Jul  1 04:58:04 2009
@@ -1,3 +1,4 @@
+<?xml version="1.0"?>
 <scpd>
     <!-- Service to monitor the avaibility of an UPnP device -->
     <!-- The variables are not persistent to the device reinits.  -->
@@ -6,8 +7,8 @@
    
       <stateVariable>
           <!-- random number renewed each time the device reboots/reinits or left a network -->
-         <name>LiveID</name>  <!-- TODO changes LiveID into LifeID -->
-         <sendEventsAttribute>yes</sendEventsAttribute>
+         <name>LifeID</name>
+         <sendEventsAttribute>no</sendEventsAttribute>
          <dataType>i4</dataType> <!-- A 32bit random number seems enough -->
       </stateVariable>
       
@@ -46,9 +47,9 @@
                <retval/>
             </argument>
             <argument>
-               <name>LiveID</name>
+               <name>LifeID</name>
                <direction>out</direction>
-               <relatedStateVariable>LiveID</relatedStateVariable>
+               <relatedStateVariable>LifeID</relatedStateVariable>
             </argument>
             <argument>
                <name>StartTime</name>

Modified: felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/controlpoint/HeartBeatProxyImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/controlpoint/HeartBeatProxyImpl.java?rev=790039&r1=790038&r2=790039&view=diff
==============================================================================
--- felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/controlpoint/HeartBeatProxyImpl.java (original)
+++ felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/controlpoint/HeartBeatProxyImpl.java Wed Jul  1 04:58:04 2009
@@ -1,190 +1,167 @@
+
 /*
- __BANNER__
- */
-// this file was generated at 30-June-2009 12:18 PM by ${author}
+__BANNER__
+*/
+// this file was generated at 1-July-2009 06:34 AM by ${author}
 package org.apache.felix.upnp.heartbeat.controlpoint;
 
+import org.apache.felix.upnp.devicegen.holder.*;
+import org.apache.felix.upnp.heartbeat.model.*;
+
 import java.util.Dictionary;
 import java.util.Hashtable;
-
-import org.apache.felix.upnp.devicegen.holder.DateHolder;
-import org.apache.felix.upnp.devicegen.holder.IntegerHolder;
-import org.apache.felix.upnp.heartbeat.model.HeartBeatModel;
 import org.osgi.service.upnp.UPnPAction;
 import org.osgi.service.upnp.UPnPException;
 import org.osgi.service.upnp.UPnPService;
 
-public class HeartBeatProxyImpl implements HeartBeatModel {
+	
+public class HeartBeatProxyImpl implements HeartBeatModel {		
 
 	private UPnPService upnpService;
-
-	HeartBeatProxyImpl(UPnPService upnpService) {
+	HeartBeatProxyImpl(UPnPService upnpService){
 		super();
-		this.upnpService = upnpService;
+		this.upnpService=upnpService;
 	}
 
+	
 	/**
-	 * This method is "add description here" currentUpTime out parameter
-	 * 
-	 * liveID out parameter
-	 * 
-	 * startTime out parameter
-	 * 
-	 * currentBeatPeriod out parameter
-	 * 
-	 * 
-	 */
-	public void getUpTime(IntegerHolder currentUpTime,
+	 * This method is "add description here"	
+ * currentUpTime out  parameter
+
+ * lifeID out  parameter
 
-	IntegerHolder liveID,
+ * startTime out  parameter
 
-	DateHolder startTime,
+ * currentBeatPeriod out  parameter
 
-	IntegerHolder currentBeatPeriod) throws UPnPException {
 
+	 */
+	public void getUpTime(
+		IntegerHolder currentUpTime,
+
+IntegerHolder lifeID,
+
+DateHolder startTime,
+
+IntegerHolder currentBeatPeriod
+	) throws UPnPException {
+		
 		UPnPAction upnpAction = upnpService.getAction("getUpTime");
 
 		Dictionary _parameters = new Hashtable();
-
+		
 		// TODO _parameters.put("InParam", inparam);
 
 		Dictionary _result;
 		try {
-			_result = upnpAction.invoke(_parameters);
+				_result = upnpAction.invoke(_parameters);
 		} catch (UPnPException e) {
 			throw e;
 		} catch (Exception e) {
-			throw new UPnPException(UPnPException.DEVICE_INTERNAL_ERROR, e
-					.getMessage());
+			throw new UPnPException(UPnPException.DEVICE_INTERNAL_ERROR,e.getMessage());
 		}
 
 		// TODO outparam.setType((Type) _result.get("OutParam"));
 	}
 
+
 	/**
-	 * This method is "add description here" currentBeatPeriod out parameter
-	 * 
-	 * 
-	 */
-	public void getBeatPeriod(IntegerHolder currentBeatPeriod)
-			throws UPnPException {
+	 * This method is "add description here"	
+ * currentBeatPeriod out  parameter
+
 
+	 */
+	public void getBeatPeriod(
+		IntegerHolder currentBeatPeriod
+	) throws UPnPException {
+		
 		UPnPAction upnpAction = upnpService.getAction("getBeatPeriod");
 
 		Dictionary _parameters = new Hashtable();
-
+		
 		// TODO _parameters.put("InParam", inparam);
 
 		Dictionary _result;
 		try {
-			_result = upnpAction.invoke(_parameters);
+				_result = upnpAction.invoke(_parameters);
 		} catch (UPnPException e) {
 			throw e;
 		} catch (Exception e) {
-			throw new UPnPException(UPnPException.DEVICE_INTERNAL_ERROR, e
-					.getMessage());
+			throw new UPnPException(UPnPException.DEVICE_INTERNAL_ERROR,e.getMessage());
 		}
 
 		// TODO outparam.setType((Type) _result.get("OutParam"));
 	}
 
+
 	/**
-	 * This method is "add description here" newBeatPeriod in parameter
-	 * 
-	 * 
-	 */
-	public void setBeatPeriod(int newBeatPeriod) throws UPnPException {
+	 * This method is "add description here"	
+ * newBeatPeriod in  parameter
 
+
+	 */
+	public void setBeatPeriod(
+		int newBeatPeriod
+	) throws UPnPException {
+		
 		UPnPAction upnpAction = upnpService.getAction("setBeatPeriod");
 
 		Dictionary _parameters = new Hashtable();
-
+		
 		// TODO _parameters.put("InParam", inparam);
 
 		Dictionary _result;
 		try {
-			_result = upnpAction.invoke(_parameters);
+				_result = upnpAction.invoke(_parameters);
 		} catch (UPnPException e) {
 			throw e;
 		} catch (Exception e) {
-			throw new UPnPException(UPnPException.DEVICE_INTERNAL_ERROR, e
-					.getMessage());
+			throw new UPnPException(UPnPException.DEVICE_INTERNAL_ERROR,e.getMessage());
 		}
 
 		// TODO outparam.setType((Type) _result.get("OutParam"));
 	}
 
-	// Those listeners are used for the subscription to state variable change
-
-	// TODO current listeners list
-
-	public void addListenerOnLiveIDStateVariableValue(/*
-														 * TODO Listener
-														 * listener
-														 */) {
-		// TODO java.lang.Integer
-		return;
-	}
-
-	public void removeListenerOnLiveIDStateVariableValue(/*
-															 * TODO Listener
-															 * listener
-															 */) {
-		// TODO
-		return;
-	}
-
-	// TODO current listeners list
-
-	public void addListenerOnUpTimeStateVariableValue(/*
-														 * TODO Listener
-														 * listener
-														 */) {
-		// TODO java.lang.Integer
-		return;
-	}
-
-	public void removeListenerOnUpTimeStateVariableValue(/*
-															 * TODO Listener
-															 * listener
-															 */) {
-		// TODO
-		return;
-	}
-
-	// TODO current listeners list
-
-	public void addListenerOnBeatPeriodStateVariableValue(/*
-															 * TODO Listener
-															 * listener
-															 */) {
-		// TODO java.lang.Integer
-		return;
-	}
-
-	public void removeListenerOnBeatPeriodStateVariableValue(/*
-																 * TODO Listener
-																 * listener
-																 */) {
-		// TODO
-		return;
-	}
+	
 
+	// Those listeners are used for the subscription to state variable change
+	
+		// TODO current listeners list
+		
+		public void addListenerOnUpTimeStateVariableValue(/*TODO Listener listener*/){
+			// TODO java.lang.Integer
+			return;
+		}		
+		public void removeListenerOnUpTimeStateVariableValue(/*TODO Listener listener*/){
+			// TODO
+			return;
+		}		
+		
+		// TODO current listeners list
+		
+		public void addListenerOnBeatPeriodStateVariableValue(/*TODO Listener listener*/){
+			// TODO java.lang.Integer
+			return;
+		}		
+		public void removeListenerOnBeatPeriodStateVariableValue(/*TODO Listener listener*/){
+			// TODO
+			return;
+		}		
+			
+	
+	
 	// Those getters are used for ??? may be not useful !!!
-
-	public java.lang.Integer getLiveIDStateVariableValue() {
-		// TODO
-		return null;
-	}
-
-	public java.lang.Integer getUpTimeStateVariableValue() {
-		// TODO
-		return null;
-	}
-
-	public java.lang.Integer getBeatPeriodStateVariableValue() {
-		// TODO
-		return null;
-	}
-
+	
+		public java.lang.Integer getUpTimeStateVariableValue(){
+			// TODO
+			return null;
+		}		
+		
+		public java.lang.Integer getBeatPeriodStateVariableValue(){
+			// TODO
+			return null;
+		}		
+			
+	
+	
 }

Modified: felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/impl/HeartBeatModelImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/impl/HeartBeatModelImpl.java?rev=790039&r1=790038&r2=790039&view=diff
==============================================================================
--- felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/impl/HeartBeatModelImpl.java (original)
+++ felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/impl/HeartBeatModelImpl.java Wed Jul  1 04:58:04 2009
@@ -31,7 +31,6 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.service.upnp.UPnPException;
 
-
 /**
  * This class implements the model of the UPnP HeartBeat service
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
@@ -56,12 +55,12 @@
 	/**
 	 * randomly generated life id
 	 */
-	private int liveID;
+	private int lifeID;
 
 	/**
 	 * beat period in seconds
 	 */
-	private int beatPeriod=300;
+	private int beatPeriod=20; // 20 seconds for demo purpose
 
 	private Thread beatThread;
 
@@ -70,17 +69,17 @@
 	/**
 	 * get the uptime + other related infos
 	 * 
-	 * @param liveID out parameter 
+	 * @param lifeID out parameter 
 	 * @param startTime out parameter
 	 * @param currentBeatPeriod out parameter
 	 * 
 	 * 
 	 */
-	public void getUpTime(IntegerHolder currentUpTime, IntegerHolder liveID,
+	public void getUpTime(IntegerHolder currentUpTime, IntegerHolder lifeID,
 			DateHolder startTime, IntegerHolder currentBeatPeriod)
 			throws UPnPException {
 		currentUpTime.setValue(upTime());
-		liveID.setValue(this.liveID);
+		lifeID.setValue(this.lifeID);
 		startTime.setValue(this.startTimeInDate);
 		currentBeatPeriod.setValue(beatPeriod);
 	}
@@ -102,6 +101,9 @@
 			int oldBeatPeriod=beatPeriod;
 			beatPeriod=newBeatPeriod;
 			notifyBeatPeriodChange(oldBeatPeriod,newBeatPeriod);
+			if(newBeatPeriod<oldBeatPeriod) {
+				Thread.interrupted();
+			}
 		} else {	
 			throw new UPnPException(UPnPException.INVALID_ARGS,
 				"BeatPeriod must strictly possitive");
@@ -111,7 +113,11 @@
 	// Those getters are used for the first notification just after a subscription
 
 	public java.lang.Integer getLiveIDStateVariableValue() {
-		return new Integer(liveID);
+		return getLifeIDStateVariableValue();
+	}
+
+	public java.lang.Integer getLifeIDStateVariableValue() {
+		return new Integer(lifeID);
 	}
 
 	public java.lang.Integer getUpTimeStateVariableValue() {
@@ -128,6 +134,7 @@
 	
 	public void run() {
 		while (!end) {
+			// TODO test if it is time for the next beat (since the thread could be interrupted by the setBeatPeriod 
 			// notify the beat to all subscribers
 			notifyHeartBeat();
 			try { // TODO interupt if new beat period is before the next beat 
@@ -145,13 +152,12 @@
 		
 		SecureRandom rng = SecureRandom.getInstance("SHA1PRNG");
 	    rng.setSeed(711);
-	    liveID=rng.nextInt();
+	    lifeID=rng.nextInt();
 
 		startTimeInDate=new Date();
 		
 		beatThread = new Thread(this);
-		beatThread.setName(bundleContext.getBundle().getSymbolicName()
-				+ "#" + "heartbeat");
+		beatThread.setName(bundleContext.getBundle().getSymbolicName() + "#" + "heartbeat");
 		beatThread.start();
 	}
 

Modified: felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/model/HeartBeatModel.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/model/HeartBeatModel.java?rev=790039&r1=790038&r2=790039&view=diff
==============================================================================
--- felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/model/HeartBeatModel.java (original)
+++ felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/model/HeartBeatModel.java Wed Jul  1 04:58:04 2009
@@ -2,7 +2,7 @@
 /*
 __BANNER__
 */
-// this file was generated at 30-June-2009 12:18 PM by ${author}
+// this file was generated at 1-July-2009 06:34 AM by ${author}
 package org.apache.felix.upnp.heartbeat.model;
 
 import org.apache.felix.upnp.devicegen.holder.*;
@@ -15,7 +15,7 @@
 	 * This method is "add description here"	
  * currentUpTime out  parameter
 
- * liveID out  parameter
+ * lifeID out  parameter
 
  * startTime out  parameter
 
@@ -26,7 +26,7 @@
 	public void getUpTime(
 		IntegerHolder currentUpTime,
 
-IntegerHolder liveID,
+IntegerHolder lifeID,
 
 DateHolder startTime,
 
@@ -62,8 +62,6 @@
 
 	// Those getters are used for the first notification just after a subscription
 	
-		public java.lang.Integer getLiveIDStateVariableValue();		
-		
 		public java.lang.Integer getUpTimeStateVariableValue();		
 		
 		public java.lang.Integer getBeatPeriodStateVariableValue();		

Modified: felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/service/HeartBeat.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/service/HeartBeat.java?rev=790039&r1=790038&r2=790039&view=diff
==============================================================================
--- felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/service/HeartBeat.java (original)
+++ felix/sandbox/donsez/upnp.heartbeat/src/main/java/org/apache/felix/upnp/heartbeat/service/HeartBeat.java Wed Jul  1 04:58:04 2009
@@ -2,7 +2,7 @@
 /*
 __BANNER__
 */
-// this file was generated at 30-June-2009 12:18 PM by ${author}
+// this file was generated at 1-July-2009 06:34 AM by ${author}
 package org.apache.felix.upnp.heartbeat.service;
 
 import java.util.Dictionary;
@@ -49,8 +49,8 @@
 
 	
 	stateVariables.put(
-		"LiveID",
-		new LiveIDStateVariable(this,model)
+		"LifeID",
+		new LifeIDStateVariable(this,model)
 	);
 
 
@@ -103,19 +103,19 @@
 	
 	
 
-// class LiveIDStateVariable
-public class LiveIDStateVariable
+// class LifeIDStateVariable
+public class LifeIDStateVariable
   extends AbstractUPnPStateVariable
 			
-	  implements UPnPStateVariableDescriptor{
+	{
 
-	public final static String NAME="LiveID";
+	public final static String NAME="LifeID";
 	public final static String DATATYPE="i4";
 	
 	// HERE specific state variable members
 	private HeartBeatModel model;
 	
-	public LiveIDStateVariable(
+	public LifeIDStateVariable(
 		UPnPService upnpService,
 		HeartBeatModel model
 	){	
@@ -129,7 +129,7 @@
 					null, // TODO minimum changed for 
 					null, // TODO maximum changed for 
 					// sendEventsAttribute
-	true,
+	false,
 					true  // TODO required changed for  OR 
 		);
 		
@@ -154,9 +154,7 @@
 	 * @see it.cnr.isti.niche.osgi.upnp.util.UPnPStateVariableDescriptor#getValue()
 	 */
 	public Object getValue(){
-	
-		return model.getLiveIDStateVariableValue();
-		
+	return null;
 	}
 };
 
@@ -360,8 +358,8 @@
 			);
 		
 			addOutArg(
-				"LiveID",
-				upnpService.getStateVariable("LiveID")
+				"LifeID",
+				upnpService.getStateVariable("LifeID")
 			);
 		
 			addOutArg(
@@ -382,7 +380,7 @@
 	public Dictionary invoke(Dictionary _args) throws Exception {
 
 	IntegerHolder currentUpTime = new IntegerHolder();
-		IntegerHolder liveID = new IntegerHolder();
+		IntegerHolder lifeID = new IntegerHolder();
 		DateHolder startTime = new DateHolder();
 		IntegerHolder currentBeatPeriod = new IntegerHolder();
 		
@@ -392,7 +390,7 @@
 		 model.getUpTime(
 			currentUpTime,
 
-liveID,
+lifeID,
 
 startTime,
 
@@ -404,7 +402,7 @@
 		
 			_result.put("CurrentUpTime",currentUpTime.getObject());
 			// java.lang.Integer
-			_result.put("LiveID",liveID.getObject());
+			_result.put("LifeID",lifeID.getObject());
 			// java.lang.Integer
 			_result.put("StartTime",startTime.getObject());
 			// java.util.Date