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 2008/11/10 11:23:24 UTC

svn commit: r712641 - in /felix/sandbox/donsez/wireadminbinder: pom.xml src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java src/main/java/org/apache/felix/sandbox/wireadminbinder/WireSetManager.java src/site/readme.html

Author: donsez
Date: Mon Nov 10 02:23:23 2008
New Revision: 712641

URL: http://svn.apache.org/viewvc?rev=712641&view=rev
Log:
made changes on the BaseActivator in order to support exetnder model

Modified:
    felix/sandbox/donsez/wireadminbinder/pom.xml
    felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java
    felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/WireSetManager.java
    felix/sandbox/donsez/wireadminbinder/src/site/readme.html

Modified: felix/sandbox/donsez/wireadminbinder/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadminbinder/pom.xml?rev=712641&r1=712640&r2=712641&view=diff
==============================================================================
--- felix/sandbox/donsez/wireadminbinder/pom.xml (original)
+++ felix/sandbox/donsez/wireadminbinder/pom.xml Mon Nov 10 02:23:23 2008
@@ -18,7 +18,6 @@
 -->
 <project>
 	<properties>
-		<repositoryLocation>http://www-adele.imag.fr/users/Didier.Donsez/dev/felix/sandbox/</repositoryLocation>
 		<description>automates the creation and deletion of wires between WireAdmin producers and consumers.</description>
 	</properties>  
 
@@ -28,7 +27,7 @@
   <name>Apache Felix Wire Admin Binder</name>
   <artifactId>org.apache.felix.sandbox.wireadminbinder</artifactId>
   <groupId>org.apache.felix.sandbox</groupId>
-  <version>0.1.0</version>
+  <version>0.2.0</version>
   <description>${description}</description>
 
   <dependencies>
@@ -36,19 +35,19 @@
 	<dependency>
 		<groupId>org.apache.felix</groupId>
 		<artifactId>org.osgi.core</artifactId>
-  		<version>1.1.0-SNAPSHOT</version>
+  		<version>1.0.0</version>
 	</dependency>
 	
 	<dependency>
 		<groupId>org.apache.felix</groupId>
 		<artifactId>org.osgi.compendium</artifactId>
-  		<version>0.9.0-SNAPSHOT</version>
+  		<version>1.0.0</version>
 	</dependency>
         
 	<dependency>
 		<groupId>org.apache.felix</groupId>
 		<artifactId>org.apache.felix.bundlerepository</artifactId>
-  		<version>1.1.0-SNAPSHOT</version>
+  		<version>1.0.0</version>
 	</dependency>
 
   </dependencies>
@@ -58,12 +57,11 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
-        <version>1.1.0-SNAPSHOT</version>
-        <extensions>true</extensions>
+         <extensions>true</extensions>
         <configuration>
           <instructions>
             <Export-Package>
-                ${artifactId}; version=1.0
+                ${artifactId}; version=1.0.0
             </Export-Package>
             
             <Import-Package>
@@ -80,7 +78,7 @@
             		org.kxml2.io,org.xmlpull.*,org.apache.felix.bundlerepository.metadataparser.*             		
             </Private-Package>
                                 
-            <Bundle-Activator>${pom.groupId}.${pom.artifactId}.Extender</Bundle-Activator>
+            <Bundle-Activator>${pom.artifactId}.Extender</Bundle-Activator>
                                 
                                     
           </instructions>

Modified: felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java?rev=712641&r1=712640&r2=712641&view=diff
==============================================================================
--- felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java (original)
+++ felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/BaseActivator.java Mon Nov 10 02:23:23 2008
@@ -30,10 +30,12 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
+import org.osgi.service.wireadmin.Wire;
 import org.osgi.service.wireadmin.WireAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 
@@ -47,6 +49,8 @@
 public class BaseActivator implements BundleActivator, ServiceListener {
 	
 	public static final String WAB_MANIFEST_ENTRY="WireAdminBinder-Metadata";
+	public static final String WAB_CREATIONTIME="WireAdminBinder-CreationTime";
+
 	
 	// this bundle's context
 	private BundleContext bundleContext;
@@ -74,19 +78,42 @@
 	
 	protected List wireApps=new ArrayList();
 
+	private static long startupTimestamp;
+	
+	static {
+		startupTimestamp=System.currentTimeMillis();
+	}
+	
+	/**
+	 * WAB activator for descriptors described in the Manifest entry (WAB_MANIFEST_ENTRY)
+	 */
 	public BaseActivator() {
 	}
 
+	/**
+	 * WAB activator for a descriptor passed in the input stream
+	 */
 	public BaseActivator(InputStream inputStream) {
 		this.inputStream = inputStream;
 	}
 
+	/**
+	 * WAB activator for a descriptor passed in the array of input streams
+	 */
 	public BaseActivator(InputStream[] inputStream) {
 		error("Not implemented",null);
 	}
 
+//	/**
+//	 * WAB activator for a descriptor passed as a DOM element representing the WireApp metadata
+//	 * @param domElementOfAWireApp the DOM element representing the WireApp metadata
+//	 */
+//	public BaseActivator(org.w3c.dom.Element domElementOfAWireApp) {
+//		error("Not implemented",null);
+//	}
+	
 	/**
-	 * 
+	 * activator start method
 	 */
 	public void start(BundleContext bundleContext) throws Exception {
 		init(bundleContext);
@@ -99,6 +126,15 @@
 	}
 
 	/**
+	 * activator stop method
+	 */
+	public void stop(BundleContext bundleContext) {
+		fini();
+	}
+
+
+	
+	/**
 	 * init log service
 	 * 
 	 * @param bundleContext
@@ -142,11 +178,32 @@
 			error("No WireAdmin service available",null);
 			return;
 		}
+		
+		garbageRemainingWires();
+		
 		bundleContext.addServiceListener(this);
 		
 	}
 
 	/**
+	 * remove all the remaining wires created by the WAB before a framework crash
+	 */
+	private void garbageRemainingWires() {
+		try {
+			Wire[] wires=wireAdmin.getWires("(!("+WAB_CREATIONTIME+">="+startupTimestamp+"))");
+			if(wires!=null && wires.length>0) {
+				trace("Removed "+wires.length+" remaining wires", null);
+				for (int i = 0; i < wires.length; i++) {
+					Wire wire = wires[i];
+					wireAdmin.deleteWire(wire);
+				}
+			}
+		} catch (InvalidSyntaxException e) {
+			e.printStackTrace();
+		}		
+	}
+
+	/**
 	 * fini log service
 	 */
 	private void fini() {
@@ -276,10 +333,6 @@
 		}
 	}
 
-	public void stop(BundleContext bundleContext) {
-		fini();
-	}
-
 	/**
 	 * Method to display traces
 	 * 

Modified: felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/WireSetManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/WireSetManager.java?rev=712641&r1=712640&r2=712641&view=diff
==============================================================================
--- felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/WireSetManager.java (original)
+++ felix/sandbox/donsez/wireadminbinder/src/main/java/org/apache/felix/sandbox/wireadminbinder/WireSetManager.java Mon Nov 10 02:23:23 2008
@@ -281,8 +281,12 @@
                     }
                 }
                 
+		        // keep the creation time in order to track wires created by the WAB
+                if(!wireSet.getRemovepolicy().equals(WireSet.REMOVE_POLICY_KEEPALIVE)) {
+                	wireSetManager.wiresCreationProperties.put(BaseActivator.WAB_CREATIONTIME, new Long(System.currentTimeMillis()));
+                }
                 // create wire with each producer
-                Iterator iter = wireSetManager.producersSet.iterator();
+                Iterator iter = wireSetManager.producersSet.iterator();                
                 while (iter.hasNext()) {
                     ServiceReference prodservref = (ServiceReference) iter.next();
                     Wire wire = wireAdmin.createWire(

Modified: felix/sandbox/donsez/wireadminbinder/src/site/readme.html
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadminbinder/src/site/readme.html?rev=712641&r1=712640&r2=712641&view=diff
==============================================================================
--- felix/sandbox/donsez/wireadminbinder/src/site/readme.html (original)
+++ felix/sandbox/donsez/wireadminbinder/src/site/readme.html Mon Nov 10 02:23:23 2008
@@ -1,19 +1,19 @@
 <html>
 <head>
-<title>WireAdmin Binder</title>
+<title>Apache Felix WireAdminBinder (Sandbox)</title>
 </head>
 <body>
 
 <!-- Start of Bundle Documentation -->
 <hr width="100%" size="2">
-<h1><i><a name="org.osgi.felix.sandbox.wireadminbinder"></a><font color="#0000aa">WireAdminBinder</font></i></h1>
+<h1><i><a name="org.osgi.felix.sandbox.wireadminbinder"></a><font color="#0000aa">Apache Felix WireAdminBinder (Sandbox)</font></i></h1>
 
 <p>
 <b>Description</b><br>
 automates the creation and deletion of wires between producers and consumers
 <br><br>
 <font size="-1"><i>
-The OSGi WireAdmin service supports the
+The <a href="http://www.osgi.org/javadoc/r4/org/osgi/service/wireadmin/package-summary.html">OSGi WireAdmin</a> Service supports the
 construction of dynamic sensor-based applications. However, it has
 several limitations. The first one is that wires are inextricably
 tied to specific consumers and producers via persistent and
@@ -63,15 +63,18 @@
 <p>
 <b>Properties</b><br>
 <ul>
-<li>org.apache.felix.sandbox.wireadminbinder.trace=true|false</li>
+<li>org.apache.felix.sandbox.wireadminbinder.showtrace=true|false</li>
+<li>org.apache.felix.sandbox.wireadminbinder.showerrors=true|false</li>
+<li>org.apache.felix.sandbox.wireadminbinder.showversion=true|false</li>
 </ul>
 </p>
 
 <p><b>Requirements</b><br>
 <li>org.osgi.service.wireadmin; specification-version=1.0.0<li>
+<li>org.osgi.service.log; specification-version=1.1.0<li>
 </p>
 
-<!-- End of OSCAR Bundle Documentation -->
+<!-- End of Felix Bundle Documentation -->
 
 <hr width="100%" size="2">
 
@@ -120,8 +123,24 @@
 <li>WireAdminBinder wired application can be build with the <a href="../../../wireadminbinder.cmd">Apache Felix WireAdminBinder Command</a>
 </li>
 <li>WireAdminBinder' BaseActivator could be embedded inside others bundles
-(that provide consumer services, producer services or none) see the bundle <a href="../../../wireadmin.sample.consumerservlet">Apache Felix Consumer Servlet</a> and the <a href="../../../wireadminbinder.cmd">Apache Felix WireAdminBinder Command</a>.<br>
+(that provide consumer services, producer services or none) see the bundle <a href="../../../wireadmin.sample.consumerservlet">Apache Felix Consumer Servlet</a> and the <a href="../../../wireadminbinder.cmd">Apache Felix WireAdminBinder Command</a>. For instance:<br>
 </li>
+<pre>
+    ...
+	private BaseActivator baseActivator;
+	private void activateWAB(BundleContext bundleContext) throws Exception {
+		InputStream inputStream = bundleContext.getBundle().getResource("WAB-INF/wadl.xml").openStream();
+		baseActivator = new BaseActivator(inputStream);
+		baseActivator.start(bundleContext);
+	}
+
+	private void deactivateWAB(BundleContext bundleContext) throws Exception {
+		if(baseActivator!=null) baseActivator.stop(bundleContext);
+	}
+	...
+</pre>
+
+
 <li>WireAdminBinder wired application could be build (soon) according to the extender model.</li>
 </ul>
 </p>
@@ -131,7 +150,8 @@
 <ul>
 <li>Objectweb/OW2 Oscar (done)</li>
 <li>Apache Felix (done)</li>
-<li>Equinox (to do)</li>
+<li>Eclipse Equinox (to do)</li>
+<li>Knopflerfish (to do)</li>
 </ul>
 </p>
 
@@ -139,7 +159,7 @@
 <b>Tested WireAdmin implementations</b><br>
 <ul>
 <li>Apache Felix WireAdmin (done)</li>
-<li>Equinox WireAdmin (to do)</li>
+<li>Eclipse Equinox WireAdmin (to do)</li>
 </ul>
 </p>
 
@@ -155,6 +175,13 @@
 <p id="todo">
 <b>TODO (contributions are welcome)</b><br>
 <ul>
+<li>DONE with Solution 2. 2008-04-06: since Wires created by the WAB are persistent, a crash implies that those wires are not removed by the WAB. Solution 1: Make persistent the wires created by a instance of WAB BaseActivator. Solution 2: add a special property (WAB_CREATIONTIME) to the wire at creation time and remove wires created before framework startup.</li>
+<li>2008-04-02: add hierarchical wireapps (as in hierarchical component models)</li>
+<li>2008-04-02: add a Management API to list wires managed by a wireset, a wireapp, ...</li>
+<li>2008-04-02: add timeout on keepAlive, whileConsumer and whileProducer policies</li>
+<li>2008-04-02: build descriptor from a org.w3c.dom.Element</li>
+<li>2008-04-02: support XML namespaces</li>
+<li>2008-04-02: send EventAdmin events related to wireapp and wireset lifecycles</li>
 <li>2008-03-26: adapt the WAB Eclipse plugin to the new metadata DTD/schema</li>
 <li>2008-01-12: add a extended model to start and stop wired applications described in other bundles manifest</li>
 <li>2007-12-19: add consumersFilter and producersFilter elements to set LDAP filters in CDATA section</li>
@@ -168,7 +195,7 @@
 <b>Links</b><br>
 <ul>
 <li>WireAdminBinder was presented at CCNC08:
-Humberto Cervantes, Didier Donsez, Lionel Touseau, "An Architecture Description Language for Dynamic Sensor-Based Applications", 5th IEEE Consumer Communications and Networking Conference (CCNC) 2008, http://www.ieee-ccnc.org/ doi:<a href="http://dx.doi.org/10.1109/ccnc08.2007.40">10.1109/ccnc08.2007.40</a></li> 
+Humberto Cervantes, Didier Donsez, Lionel Touseau, "An Architecture Description Language for Dynamic Sensor-Based Applications", 5th IEEE Consumer Communications and Networking Conference (CCNC) 2008, http://www.ieee-ccnc.org/ doi:<a href="http://dx.doi.org/10.1109/ccnc08.2007.40">10.1109/ccnc08.2007.40</a> (<a href="http://www-adele.imag.fr/users/Didier.Donsez/pub/publi/ccnc08-wadl-pres.pdf">presentation</a>)</li> 
 </ul>
 </p>