Fix FELIX-2624 Support multiple whiteboards using annotations

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1032253 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/handler/whiteboard/metadata.xml b/ipojo/handler/whiteboard/metadata.xml
index d9c1c53..88eec46 100644
--- a/ipojo/handler/whiteboard/metadata.xml
+++ b/ipojo/handler/whiteboard/metadata.xml
@@ -6,9 +6,9 @@
 	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

@@ -21,4 +21,10 @@
 		classname="org.apache.felix.ipojo.handler.wbp.WhiteBoardPatternHandler"

 		name="wbp" namespace="org.apache.felix.ipojo.whiteboard">

 	</handler>

+

+	<!-- Alternative handler for component using the @Whiteboards annotation -->

+	<handler

+		classname="org.apache.felix.ipojo.handler.wbp.WhiteBoardPatternHandler"

+		name="whiteboards" namespace="org.apache.felix.ipojo.whiteboard">

+	</handler>

 </ipojo>
\ No newline at end of file
diff --git a/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java b/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java
index 778eae7..70a880e 100644
--- a/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java
+++ b/ipojo/handler/whiteboard/src/main/java/org/apache/felix/ipojo/handler/wbp/WhiteBoardPatternHandler.java
@@ -53,7 +53,27 @@
      * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)
      */
     public void configure(Element elem, Dictionary dict) throws ConfigurationException {
+
+    	// There is two way to configure the handler :
+    	// - the wbp elements
+    	// - the whiteboards elements
         Element[] elems = elem.getElements("wbp", NAMESPACE);
+
+        if (elems == null  || elems.length == 0) {
+        	// Alternative way
+        	Element[] whiteboards = elem.getElements("whiteboards", NAMESPACE);
+        	if (whiteboards == null) {
+        		throw new ConfigurationException("Cannot configure the whiteboard pattern handler - no suitable configuration found");
+        	} else {
+        		elems = whiteboards[0].getElements("wbp", NAMESPACE);
+        	}
+        }
+
+        // Last check.
+        if (elems == null) {
+        	throw new ConfigurationException("Cannot configure the whiteboard pattern handler - no suitable configuration found");
+        }
+
         for (int i = 0; i < elems.length; i++) {
             String filter = elems[i].getAttribute("filter");
             String onArrival = elems[i].getAttribute("onArrival");