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/04/03 01:37:33 UTC

svn commit: r644109 - in /felix/sandbox/donsez/wireadmin.sample.consumerservlet: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/felix/ src/main/java/org/apache/felix/sandbox/ src/main/java/org/apa...

Author: donsez
Date: Wed Apr  2 16:37:24 2008
New Revision: 644109

URL: http://svn.apache.org/viewvc?rev=644109&view=rev
Log:
creation of the consumerservlet bundle : a example of a consumer for the Wire Admin service. This servlet displays (in HTML) the objects updated from producers

Added:
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/pom.xml   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/graph/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/GenericHttpContext.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/MIMETypeUtil.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/image/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/load/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/load/LoadUtils.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementFormat.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementUtil.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionFormat.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionUtil.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/consumerservlet/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/consumerservlet/ConsumerServlet.java   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/OSGI-INF/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/OSGI-INF/component.xml   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WAB-INF/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WAB-INF/wadl.xml   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WEB-INF/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WEB-INF/mimetype.txt   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/geolocation.js   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/logo.png   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement.xml   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement2html.xsl   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/script.js   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/style.css   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/warning.png   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/readme.html   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample.png   (with props)
    felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample2.png   (with props)

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/pom.xml?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/pom.xml (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/pom.xml Wed Apr  2 16:37:24 2008
@@ -0,0 +1,98 @@
+<!--
+ 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.
+-->
+<project>
+	
+	<properties>
+		<repositoryLocation>http://people.imag.fr/~donsez/dev/felix/sandbox/</repositoryLocation>
+		<description>provides a HTML GUI to display values pushed by producers.</description>
+		<felixPomVersion>1.0.0</felixPomVersion>
+	</properties>
+
+	<modelVersion>4.0.0</modelVersion>
+	<packaging>bundle</packaging>
+	<name>Apache Felix Consumer Servlet</name>
+	<groupId>org.apache.felix.sandbox</groupId>
+	<artifactId>wireadmin.sample.consumerservlet</artifactId>
+	<version>0.1.0</version>
+	<description>${description}</description>
+	<dependencies>
+
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.core</artifactId>
+	  		<version>${felixPomVersion}</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+	  		<version>${felixPomVersion}</version>
+		</dependency>
+   
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>javax.servlet</artifactId>
+	  		<version>${felixPomVersion}</version>
+		</dependency>
+
+		<dependency>
+			  <artifactId>org.apache.felix.sandbox.wireadminbinder</artifactId>
+			  <groupId>org.apache.felix.sandbox</groupId>
+			  <version>0.1.0</version>
+		</dependency>    
+    
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>          
+          				<!--
+          					docs in http://cwiki.apache.org/FELIX/bundle-plugin-for-maven-bnd.html
+          					and http://cwiki.apache.org/FELIX/osgi-plugin-for-maven-2.html
+          				-->
+
+			            <Import-Package>*</Import-Package>
+			            <Private-Package>
+			              ${pom.groupId}.${pom.artifactId},
+			              ${pom.groupId}.util.*
+			            </Private-Package>
+			            
+			            <!-- docs in http://cwiki.apache.org/FELIX/bundle-plugin-for-maven-bnd.html and http://cwiki.apache.org/FELIX/osgi-plugin-for-maven-2.html -->
+			  
+						<Import-Service>org.osgi.service.http.HttpService</Import-Service>
+						<Export-Service>org.osgi.service.wireadmin.Consumer</Export-Service>
+
+						<Service-Component>
+							OSGI-INF/component.xml
+						</Service-Component>
+						<WireAdminBinder-Metadata>WAB-INF/wadl.xml</WireAdminBinder-Metadata>
+
+						<Bundle-Description>${description}</Bundle-Description>
+
+					</instructions>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/GenericHttpContext.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/GenericHttpContext.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/GenericHttpContext.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/GenericHttpContext.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,100 @@
+/*
+ * 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.sandbox.util.http;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osgi.service.http.HttpContext;
+
+/**
+ * provides a generic Http Context to register servlets and static docs
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class GenericHttpContext implements HttpContext {
+
+	
+	private Map extensionToMimeTypeMap;
+	// TODO 
+	private Map credentials;
+	
+	/**
+	 * @param is
+	 */
+	public GenericHttpContext(InputStream is){
+		extensionToMimeTypeMap=MIMETypeUtil.getExtensionToMimeTypeMap(is);
+	}
+
+	public GenericHttpContext(){
+		extensionToMimeTypeMap=MIMETypeUtil.getExtensionToMimeTypeMap();
+	}
+
+
+	public void resetExtensionToMimeTypeMap() {
+		extensionToMimeTypeMap=MIMETypeUtil.getExtensionToMimeTypeMap();
+	}
+
+	public void setExtensionToMimeTypeMap(InputStream stream) {
+		Map temp=MIMETypeUtil.getExtensionToMimeTypeMap(stream);
+		if(temp==null) return; // do nothing
+		extensionToMimeTypeMap=temp;
+	}
+
+	public void addExtensionToMimeType(String extension, String mimetype) {
+		extensionToMimeTypeMap.put(extension,mimetype);
+	}
+
+	public void removeExtensionToMimeType(String extension) {
+		extensionToMimeTypeMap.remove(extension);
+	}
+
+	public void removeAllExtensionToMimeTypes() {
+		extensionToMimeTypeMap=new HashMap();
+	}
+
+	
+	public String getMimeType(String name) {
+		int pos=name.lastIndexOf('.');
+		if(pos==-1 || pos==0 || pos==name.length()-1)
+			return null;
+		String extension=name.substring(pos+1);
+		return (String)extensionToMimeTypeMap.get(extension);
+		
+	}
+
+	/**
+	 * TODO add a simple textfile security realm 
+	 * for instance http://httpd.apache.org/docs/2.0/howto/htaccess.html
+	 */
+	public boolean handleSecurity(
+		HttpServletRequest req,
+		HttpServletResponse resp) {
+		return true;
+	}
+
+	public URL getResource(String name) {
+		URL u = this.getClass().getResource(name);
+		return u;
+	}
+}

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/GenericHttpContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/MIMETypeUtil.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/MIMETypeUtil.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/MIMETypeUtil.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/MIMETypeUtil.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,84 @@
+/*
+ * 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.sandbox.util.http;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+/**
+ * TODO
+ * <p>For more information about MIME types
+ * please read RFC 2045, 2046, 2047, 2048, and 2077. 
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ *
+ */
+public class MIMETypeUtil {
+
+	static public Map getExtensionToMimeTypeMap(InputStream inputStream){
+		// TODO skip #, "", ...
+		Map map=new HashMap();
+		BufferedReader bf=null;
+		try {
+			bf= new BufferedReader(new InputStreamReader(inputStream) );
+			String line;
+			while ((line = bf.readLine())!=null){
+				// TODO skip #, "", ...
+				if(line.length()==0 || line.startsWith("#") || line.startsWith(" "))
+					continue;
+				StringTokenizer st=new StringTokenizer(line," \t");
+				if(st.countTokens()==1)
+					continue;
+				String mimetype=st.nextToken();
+				while(st.hasMoreTokens()){
+					map.put(st.nextToken(),mimetype);
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace(System.err);
+			return null;
+		} finally {
+			try {
+				bf.close();
+			} catch (Exception e) {
+				e.printStackTrace();
+			}
+		}
+		return map;
+	}
+
+	static public Map getExtensionToMimeTypeMap(){
+		Map map=new HashMap();
+		map.put("htm","text/html");
+		map.put("html","text/html");
+		map.put("xml","text/xml");
+		map.put("xsl","text/xml");
+		map.put("css","text/css");
+		map.put("js","text/javascript");
+		map.put("jpg","image/jpeg");
+		map.put("jpeg","image/jpeg");
+		map.put("png","image/png");
+		map.put("gif","image/gif");
+		return map;
+	}
+}

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/http/MIMETypeUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/load/LoadUtils.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/load/LoadUtils.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/load/LoadUtils.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/load/LoadUtils.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,138 @@
+/*
+ * 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.sandbox.util.load;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Utility class to load text from URL or Ressources
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class LoadUtils {
+
+	/**
+	 * Load the text from a document located at an URL
+	 * @param urlStr the string url of the document to load
+	 * @return the text contained in the document
+	 * @throws Exception
+	 */
+	public static String loadAsUrl(String urlStr) throws Exception {
+		URL url = null;
+		url = new URL(urlStr);
+		return loadAsUrl(url);
+	}
+	
+	
+	/**
+	 * Load the text from a document located at an URL
+	 * @param url the url of the document to load
+	 * @return the text contained in the document
+	 * @throws Exception
+	 */
+	public static String loadAsUrl(URL url) throws Exception {
+		InputStream inputStream = null;
+		BufferedInputStream bufferedInputStream = null;
+		ByteArrayOutputStream byteArrayOutputStream = null;
+
+		try {
+			inputStream = url.openStream();
+			bufferedInputStream = new BufferedInputStream(inputStream);
+			byteArrayOutputStream = new ByteArrayOutputStream();
+			int n;
+			byte[] buffer = new byte[512];
+			while ((n = bufferedInputStream.read(buffer)) != -1) {
+				byteArrayOutputStream.write(buffer, 0, n);
+			}
+			bufferedInputStream.close();
+			inputStream=null;
+			bufferedInputStream=null;
+
+			String res = new String(byteArrayOutputStream.toByteArray());
+			return res;
+		} finally {
+			if (bufferedInputStream != null)
+				try {
+					bufferedInputStream.close();
+					inputStream = null;
+				} catch (IOException e) {
+				}
+			if (inputStream != null)
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+				}
+			if (byteArrayOutputStream != null)
+				try {
+					byteArrayOutputStream.close();
+				} catch (IOException e) {
+				}
+		}
+	}
+
+	/**
+	 * Load the text from a ressource
+	 * @param classLoader classLoader from which the ressource is accessible
+	 * @param path path of the ressource
+	 * @return the text contained in the ressource
+	 * @throws Exception
+	 */public static String loadAsRessource(ClassLoader classLoader, String path)
+	 throws Exception {
+		InputStream inputStream = null;
+		BufferedInputStream bufferedInputStream = null;
+		ByteArrayOutputStream byteArrayOutputStream = null;
+
+		try {
+			inputStream = classLoader.getResourceAsStream(path);
+			bufferedInputStream = new BufferedInputStream(inputStream);
+			byteArrayOutputStream = new ByteArrayOutputStream();
+			int n;
+			byte[] buffer = new byte[512];
+			while ((n = bufferedInputStream.read(buffer)) != -1) {
+				byteArrayOutputStream.write(buffer, 0, n);
+			}
+			bufferedInputStream.close();
+			inputStream=null;
+			bufferedInputStream=null;
+
+			String res = new String(byteArrayOutputStream.toByteArray());
+			return res;
+		} finally {
+			if (bufferedInputStream != null)
+				try {
+					bufferedInputStream.close();
+					inputStream = null;
+				} catch (IOException e) {
+				}
+			if (inputStream != null)
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+				}
+			if (byteArrayOutputStream != null)
+				try {
+					byteArrayOutputStream.close();
+				} catch (IOException e) {
+				}
+		}
+	}
+}

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/load/LoadUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementFormat.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementFormat.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementFormat.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementFormat.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,55 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.sandbox.util.measurement;
+
+import java.text.FieldPosition;
+import java.text.Format;
+import java.text.ParsePosition;
+
+/**
+ *
+ */
+public class MeasurementFormat extends Format {
+
+	/**
+	 * 
+	 */
+	public MeasurementFormat() {
+		super();
+		// TODO Raccord de constructeur auto-généré
+	}
+
+	/* (non-Javadoc)
+	 * @see java.text.Format#parseObject(java.lang.String, java.text.ParsePosition)
+	 */
+	public Object parseObject(String arg0, ParsePosition arg1) {
+		// TODO Raccord de méthode auto-généré
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
+	 */
+	public StringBuffer format(
+		Object arg0,
+		StringBuffer arg1,
+		FieldPosition arg2) {
+		// TODO Raccord de méthode auto-généré
+		return null;
+	}
+
+}

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementFormat.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementUtil.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementUtil.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementUtil.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementUtil.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,80 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.sandbox.util.measurement;
+
+import java.util.Date;
+
+import org.osgi.util.measurement.Measurement;
+
+/**
+ * This class provides formatting utilities for measurement
+ * However this class should be redesigned as a class
+ * extending java.text.Format such as java.text.NumberFormat
+ * or java.text.DateFormat
+ */
+public class MeasurementUtil {
+
+	public static StringBuffer toText(StringBuffer sb, Measurement measurement) {
+		if (sb == null) {
+			sb = new StringBuffer();
+		}
+		sb.append("Measurement[");
+		if(measurement==null) {
+			sb.append((String)null);
+		} else {
+			sb.append(measurement.getValue());
+			sb.append(" ");
+			sb.append(measurement.getUnit());
+			sb.append(" (+/-");			
+			sb.append(measurement.getError());
+			sb.append(" ");
+			sb.append(measurement.getUnit());
+			sb.append(") ");			
+			long time=measurement.getTime();
+			if(time!=0)
+				sb.append((new Date(time)).toString());	// TODO: replace by java.text.DateFormat		
+		}
+		sb.append(']');
+		return sb;
+	}
+
+	public static StringBuffer toJSON(StringBuffer sb, Measurement measurement) {
+		if (sb == null) {
+			sb = new StringBuffer();
+		}
+		sb.append("{");
+		if(measurement==null) {
+			sb.append((String)null);
+		} else {
+			sb.append("\"value\":").append(measurement.getValue());
+			sb.append(",");
+			sb.append("\"unit\":\"").append(measurement.getUnit());
+			sb.append("\",");			
+			sb.append("\"error\":").append(measurement.getError());
+			long time=measurement.getTime();
+			if(time!=0) {
+				sb.append(",");			
+				sb.append((new Date(time)).toString());	// TODO: replace by java.text.DateFormat		
+			}
+		}
+		sb.append('}');
+		return sb;
+	}
+
+}
+
+

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/measurement/MeasurementUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionFormat.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionFormat.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionFormat.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionFormat.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,47 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.sandbox.util.position;
+
+import java.text.FieldPosition;
+import java.text.Format;
+import java.text.ParsePosition;
+
+/**
+ */
+public class PositionFormat extends Format {
+
+	/* (non-Javadoc)
+	 * @see java.text.Format#parseObject(java.lang.String, java.text.ParsePosition)
+	 */
+	public Object parseObject(String arg0, ParsePosition arg1) {
+		// TODO Raccord de méthode auto-généré
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see java.text.Format#format(java.lang.Object, java.lang.StringBuffer, java.text.FieldPosition)
+	 */
+	public StringBuffer format(
+		Object arg0,
+		StringBuffer arg1,
+		FieldPosition arg2) {
+		// TODO Raccord de méthode auto-généré
+		return null;
+	}
+
+}

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionFormat.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionUtil.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionUtil.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionUtil.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionUtil.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,216 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed 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.sandbox.util.position;
+
+import org.apache.felix.sandbox.util.measurement.MeasurementUtil;
+import org.osgi.util.measurement.Measurement;
+import org.osgi.util.position.Position;
+
+
+/**
+ * This class provides formatting utilities for position
+ * However this class should be redesigned as a class
+ * extending java.text.Format such as java.text.NumberFormat
+ * or java.text.DateFormat
+ */
+public class PositionUtil {
+
+	public static StringBuffer toText(StringBuffer sb, Position position) {
+		if (sb == null) {
+			sb = new StringBuffer();
+		}
+		sb.append("Position[");
+		if(position==null) {
+			sb.append((String)null);
+		} else {
+			Measurement lat=position.getLatitude();
+			sb.append("latitude:");
+			sb.append(lat);
+			if(lat!=null)
+				sb.append("(").append(convertWG84toLattitudeDDDMMSSH(convertRadtoWG84(lat.getValue()))).append(")");
+			sb.append(',');
+			Measurement lon=position.getLongitude();
+			sb.append("longitude:");
+			sb.append(lon);
+			if(lon!=null)
+				sb.append("(").append(convertWG84toLongitudeDDDMMSSH(convertRadtoWG84(lon.getValue()))).append(")");
+			sb.append(',');
+			sb.append("altitude:").append(position.getAltitude()).append(',');
+			sb.append("speed:").append(position.getSpeed()).append(',');
+			sb.append("track:").append(position.getTrack());
+		}
+		sb.append(']');
+		return sb;
+	}
+
+	public static StringBuffer toJSON(StringBuffer sb, Position position) {
+		if (sb == null) {
+			sb = new StringBuffer();
+		}		
+		if(position!=null) {
+			sb.append('{');
+			sb.append("\"latitude\":");
+			MeasurementUtil.toJSON(sb,position.getLatitude());
+			sb.append(',');
+			sb.append("\"longitude\":");
+			MeasurementUtil.toJSON(sb,position.getLongitude());
+			sb.append(',');
+			sb.append("\"altitude\":");
+			MeasurementUtil.toJSON(sb,position.getAltitude());
+			sb.append(',');
+			sb.append("\"speed\":");
+			MeasurementUtil.toJSON(sb,position.getSpeed());
+			sb.append(',');
+			sb.append("\"track\":");
+			MeasurementUtil.toJSON(sb,position.getTrack());
+			sb.append('}');
+		}
+		return sb;
+	}
+
+	
+	// get degrees (DDD) of a WG84 angle
+	public static int convertWG84toDDD(double wg84) {
+		if(wg84<0.0d) wg84=-wg84;
+		return (int)Math.round(Math.floor(wg84));
+	}
+
+	// get minutes (MM) of a WG84 angle
+	public static int convertWG84toMM(double wg84) {
+		if(wg84<0.0d) wg84=-wg84;
+		return (int)(Math.round((Math.floor((wg84-Math.floor(wg84))*60))));
+	}
+
+	// get seconds (SS) of a WG84 angle
+	public static int convertWG84toSS(double wg84) {
+		if(wg84<0.0d) wg84=-wg84;
+		double deg=(wg84-Math.floor(wg84))*60;
+		return (int)(Math.round(Math.floor((deg-Math.floor(deg))*60)));
+	}
+
+	// get hemisphere (H) of a WG84 angle
+
+	public final static boolean LATTITUDE_N=true;
+	public final static boolean LATTITUDE_S=false;
+
+	public final static boolean LONGITUDE_E=true;
+	public final static boolean LONGITUDE_W=false;
+
+	// converts a WG84 angle in H
+	public static boolean convertWG84toH(double wg84) {
+		return (wg84>0)?LATTITUDE_N:LATTITUDE_S;
+		// or return (wg84>0)?LONGITUDE_E:LONGITUDE_W;
+	}
+
+	// converts a WG84 angle in an DDD MM SS string
+	public static String convertWG84toDDDMMSS(double angleInwg84) {
+		if(angleInwg84==Double.NaN) return Double.toString(Double.NaN);
+		return 		convertWG84toDDD(angleInwg84)+"° "
+		         +	convertWG84toMM(angleInwg84)+"' "
+		         +	convertWG84toSS(angleInwg84)+"''";
+	}
+
+	// converts a lattitude WG84 angle in an DDD MM SS H string
+	public static String convertWG84toLattitudeDDDMMSSH(double angleInwg84) {
+		if(angleInwg84==Double.NaN) return Double.toString(Double.NaN);
+		return 		convertWG84toDDDMMSS(angleInwg84)
+		         +	(convertWG84toH(angleInwg84)?" N":" S");
+	}
+
+	// converts a longitude WG84 angle in an DDD MM SS H string
+	public static String convertWG84toLongitudeDDDMMSSH(double angleInwg84) {
+		if(angleInwg84==Double.NaN) return Double.toString(Double.NaN);
+		return 		convertWG84toDDDMMSS(angleInwg84)
+		         +	(convertWG84toH(angleInwg84)?" E":" W");
+	}
+
+	// converts DDD MM SS H in a WG84 angle
+	public static double convertDDDMMSSHtoWG84(int degrees, int minutes,int seconds, boolean h) {
+		return (degrees+(minutes/60.0d)+(seconds/3600.0d))*(h?1.0d:-1.0d);
+	}
+
+	// converts a WG84 angle in Rad
+	public static double convertWG84toRad(double angleInwg84) {
+		if(angleInwg84==Double.NaN) return Double.NaN;
+		return Math.toRadians(angleInwg84);
+	}
+
+	// converts a Rad angle in WG84
+	public static double convertRadtoWG84(double angleInRad) {
+		if(angleInRad==Double.NaN) return Double.NaN;
+		return Math.toDegrees(angleInRad);
+	}
+
+	public static String convertRadtoHeading(double angleInRad) {
+		if(angleInRad==Double.NaN) return "___";
+		double frontier=Math.PI/16;
+		final double incr=Math.PI/8;
+
+		if(angleInRad<frontier) return "N";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "NNE";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "NE";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "ENE";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "E";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "ESE";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "SE";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "SSE";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "S";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "SSW";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "SW";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "WSW";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "W";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "WNW";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "NW";
+		frontier+=incr;
+
+		if(angleInRad<frontier) return "NNW";
+		frontier+=incr;
+
+		return "N";
+
+	}	
+}
+
+

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/util/position/PositionUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/consumerservlet/ConsumerServlet.java
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/consumerservlet/ConsumerServlet.java?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/consumerservlet/ConsumerServlet.java (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/consumerservlet/ConsumerServlet.java Wed Apr  2 16:37:24 2008
@@ -0,0 +1,548 @@
+/*
+ * 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.sandbox.wireadmin.sample.consumerservlet;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.sandbox.util.http.GenericHttpContext;
+import org.apache.felix.sandbox.util.measurement.MeasurementUtil;
+import org.apache.felix.sandbox.util.position.PositionUtil;
+import org.apache.felix.sandbox.wireadminbinder.BaseActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.log.LogService;
+import org.osgi.service.wireadmin.Consumer;
+import org.osgi.service.wireadmin.Wire;
+import org.osgi.service.wireadmin.WireConstants;
+import org.osgi.util.measurement.Measurement;
+import org.osgi.util.position.Position;
+
+/**
+ * Servlet display polled objects (psoitions, measurements) from connected
+ * wires. It is also a SCR component.
+ * 
+ * @TODO: Renderer to display polled objects
+ * @TODO: keep the history of polled objects and display it with a graphlet
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class ConsumerServlet extends HttpServlet implements Consumer {
+
+	private static final boolean TRACE=true;
+	
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	private final static String WEBROOT = "/webroot";
+	private final static String WEBROOT_ALIAS = "/wa";
+	private final static String SERVLET_ALIAS = "/wa/poll";
+	
+	// set in activate() !!
+	private BundleContext bundleContext;
+	
+    private HttpService httpService=null;
+    private Servlet myServlet=null;
+    private Dictionary myServletInitParams=null;
+
+    private HttpContext myHttpContext=null;
+
+    // set in init()
+    private ServletConfig servletConfig=null;    
+    
+    public ConsumerServlet() {
+        myServlet=this;
+
+        myServletInitParams=new Hashtable();
+        // there are only samples !
+        myServletInitParams.put("webinf.dir","/WEB-INF");
+        myServletInitParams.put("webroot.dir","/webroot");
+        myServletInitParams.put("mimetype.file","/WEB-INF/mimetype.txt");
+        myServletInitParams.put("htaccess.file","/WEB-INF/.htaccess");
+        myServletInitParams.put("icons.uri","icons");
+        
+        myHttpContext = new GenericHttpContext();
+        // MIME types defined in /WEB-INF/mimetype.txt are loaded
+        // during activate() call just after bindHttpService() calls
+    }
+    
+    // callback methods for <requires
+	// service="org.osgi.service.http.HttpService" ...
+    
+    public void bindHttpService(HttpService ref){
+    	httpService=ref;
+    	try {    		
+    		// remark: before activate() invocation, myHttpContext does not deal
+    		// with the MIME type defined in /WEB-INF/mimetype.txt
+    		// This is a limit of the SCR !
+	    	httpService.registerServlet(SERVLET_ALIAS, myServlet, myServletInitParams, myHttpContext);
+	    	httpService.registerResources(WEBROOT_ALIAS, WEBROOT, myHttpContext);
+    	} catch (Exception e) {
+    		if(logService!=null) {
+    			logService.log(LogService.LOG_ERROR,"error while servlet registration",e);
+    		} else {
+    			e.printStackTrace(System.err);
+    		}
+    	}
+    }
+
+    public void unbindHttpService(HttpService ref){
+    	httpService.unregister(SERVLET_ALIAS);
+    	httpService.unregister(WEBROOT_ALIAS);
+    	httpService=null;
+    }
+
+    // callback methods for <requires service="org.osgi.service.log.LogService"
+	// ...
+    private LogService logService = null;
+
+    public void bindLogService(LogService ref){
+    	logService=ref;
+    }
+
+    public void unbindLogService(LogService ref){
+    	logService=null;
+    }
+        
+	/**
+	 * @param componentContext
+	 */
+	public void activate(ComponentContext componentContext) {
+		trace(this.toString()+": call activate()");
+		bundleContext=componentContext.getBundleContext();
+		try {
+			((GenericHttpContext)myHttpContext).setExtensionToMimeTypeMap(bundleContext.getBundle().getResource("/WEB-INF/mimetype.txt").openStream());			
+			activateConsumer();
+			activateWAB();
+		} catch(Exception e) {
+			trace(e.getMessage());
+		}
+	}
+
+	/**
+	 * @param componentContext
+	 */
+	public void deactivate(ComponentContext componentContext) {
+		trace(this.toString()+": call desactivate()");
+		try {
+			deactivateWAB();
+			deactivateConsumer();
+		} catch (Exception e) {
+			trace(e.getMessage());
+		}
+	}
+
+	
+	private BaseActivator baseActivator;
+	private void activateWAB() throws Exception {
+		InputStream inputStream = bundleContext.getBundle().getResource("WAB-INF/wadl.xml").openStream();
+		baseActivator = new BaseActivator(inputStream);
+		baseActivator.start(bundleContext);
+	}
+
+	private void deactivateWAB() throws Exception {
+		if(baseActivator!=null) baseActivator.stop(bundleContext);
+	}
+	
+	
+	private ServiceRegistration consumerServiceRegistration;
+	private void activateConsumer() throws Exception {
+		Hashtable registrationProperties = new Hashtable();
+		registrationProperties.put(
+			Constants.SERVICE_PID,
+			bundleContext.getBundle().getSymbolicName());
+		registrationProperties.put(
+			WireConstants.WIREADMIN_CONSUMER_FLAVORS,
+			new Class[] {
+				org.osgi.util.position.Position.class,
+				org.osgi.util.measurement.Measurement.class,
+				// java.awt.Image.class,
+				java.util.Date.class,
+				java.lang.String.class });
+		consumerServiceRegistration=bundleContext.registerService(Consumer.class.getName(), this, registrationProperties);
+	}
+
+	public void deactivateConsumer() throws Exception {
+		consumerServiceRegistration.unregister();
+	}
+
+	/**
+	 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
+	 */
+	public void init(ServletConfig servletConfig){
+		trace(this.toString()+": call init()");
+		Enumeration enumeration=servletConfig.getInitParameterNames();
+		if(!enumeration.hasMoreElements())
+			trace(this.toString()+": no init parameters");
+		else {
+			trace(this.toString()+": init parameters are :");
+			while(enumeration.hasMoreElements()){
+				String name=(String) enumeration.nextElement();
+				trace(name+"="+servletConfig.getInitParameter(name));				
+			}
+		}
+	}
+	
+	/**
+	 * @see javax.servlet.Servlet#destroy()
+	 */
+	public void destroy(){
+		trace(this.toString()+": call destroy()");
+		// make persistent some variables by using
+		// bundleContext.getDataFile("/STATE-INF/state.save.txt") !
+		// here or in deactivate()
+	}
+	
+	/**
+	 * Handle a GET call from the client
+	 * 
+	 * @param request
+	 *            HTTP request information from the client
+	 * @param response
+	 *            HTTP channel back to the client browser
+	 * @throws IOException
+	 *             If there is an IO problem
+	 * @throws ServletException
+	 *             if there is a proble with the servlet processing
+	 */
+	public void doGet(HttpServletRequest request, HttpServletResponse response)
+		throws IOException, ServletException {
+		trace(this.toString()+": call doGet()");
+		doPostGet(request, response);
+	}
+
+	/**
+	 * Handle a POST call from the client
+	 * 
+	 * @param request
+	 *            HTTP request information from the client
+	 * @param response
+	 *            HTTP channel back to the client browser
+	 * @throws IOException
+	 *             If there is an IO problem
+	 * @throws ServletException
+	 *             if there is a proble with the servlet processing
+	 */
+	public void doPost(
+			HttpServletRequest request,
+			HttpServletResponse response)
+			throws IOException, ServletException {
+		trace(this.toString()+": call doPost()");
+		doPostGet(request, response);
+	}
+	
+		
+	/**
+	 * Handle a POST and GET call from the client
+	 * 
+	 * @param request
+	 *            HTTP request information from the client
+	 * @param response
+	 *            HTTP channel back to the client browser
+	 * @throws IOException
+	 *             If there is an IO problem
+	 * @throws ServletException
+	 *             if there is a proble with the servlet processing
+	 */
+	protected void doPostGet(
+		HttpServletRequest request,
+		HttpServletResponse response)
+		throws IOException, ServletException {
+		String wireadminPid = request.getParameter(WireConstants.WIREADMIN_PID);
+		String title = request.getParameter("title");
+		String css = request.getParameter("css"); // only with text/html
+		String mimetype = request.getParameter("mimetype");
+		String refresh = request.getParameter("refresh");
+
+		if (refresh != null && !refresh.equals("no")) {
+			response.setHeader("Refresh", refresh);
+		}
+		response.setHeader("Cache-Control", "no-cache");
+
+		// display the list of polled objects from connected wires
+		response.setContentType("text/html");
+
+		PrintWriter pw = response.getWriter();
+		pw.println("<html>");
+		pw.println("<head>");
+		if(title!=null){
+		    pw.print("<title>");
+		    pw.print(title);
+		    pw.println("</title>");
+		} else {
+		    pw.println("<title>Apache Felix Consumer Servlet</title>");			    
+		}
+		if (css != null)
+			pw.println(
+				"<link rel='stylesheet' type='text/css' href='"
+					+ css
+					+ "'>");
+		
+		String script = "script.js";
+		pw.println(
+			"<script language='Javascript' src='" + script + "'>\n\n</script>");
+
+		
+		pw.println("</head>");
+		pw.println("<body>");
+
+		if(title!=null){
+			pw.println("<h1 align='center'><img src='logo.png'> ");
+		    pw.print(title);
+			pw.println("</h1>");
+		} else {
+			pw.println("<h1 align='center'><img src='logo.png'> Apache Felix Consumer Servlet</h1>");
+		}
+
+		pw.println(
+			"<table border='0' width='100%'><tr><td align='left'><font size='-2'>");
+		// system date
+		Date systemTime = new Date();
+		pw.println("Gateway time:");
+		// TODO: display a CountDown timer (javascript timer)
+		// TODO: refresh button
+		pw.println(systemTime.toString());
+
+		// refresh form
+		pw.println("</font></td><td align='right'>");
+
+		pw.println(
+			"<form action='"
+				+ request.getRequestURI()
+// + request.getContextPath()
+// + request.getServletPath()
+				+ "' method='GET'><font size='-2'>");
+		pw.println(
+			"Auto-Refresh: <select name='refresh' onchange='javascript:this.form.submit()' title='Refresh period'>");
+		printOption(pw, refresh, "no");
+		printOption(pw, refresh, "5");
+		printOption(pw, refresh, "10");
+		printOption(pw, refresh, "20");
+		printOption(pw, refresh, "30");
+		printOption(pw, refresh, "60");
+		pw.println("</select>");
+						
+		if (css != null)
+			pw.println(
+				"<input name='css' value='" + css + "' type='hidden'>");
+		pw.println("</font></form>");
+		pw.println("</td></tr></table>");
+
+
+		for (int i = 0; wires != null && i < wires.length; i++) {
+			Wire w = wires[i];
+
+			pw.println("<table align='center' border='1' width='100%'>");
+
+			pw.println("<tr><td class='producer' colspan='2'>");
+
+			Dictionary props = w.getProperties();
+			String currentWireAdminPid=(String) props.get(WireConstants.WIREADMIN_PID);
+			String orig =
+					 currentWireAdminPid
+					+ " (producer:"
+					+ (String) props.get(WireConstants.WIREADMIN_PRODUCER_PID)
+					+ ")";
+			pw.println(orig);
+
+			pw.println("</td></tr><tr><td class='value'>");
+
+			if (w.isValid() && w.isConnected()) {
+				Object o = w.poll();
+				if (o == null) {
+					StringBuffer sb = new StringBuffer();
+
+					sb.append("<script language=\"JavaScript\">\n\n");
+
+					sb.append("printPollNull();\n\n");
+
+					sb.append("</script>\n\n");
+
+					pw.println(sb.toString());
+					continue;
+				} else if (o instanceof org.osgi.util.position.Position) {
+					StringBuffer sb = new StringBuffer();
+					Position position=(Position) o;
+					PositionUtil.toText(sb, position);
+					sb.append(" <a href='http://maps.google.com/?ie=UTF8&om=1&ll=");
+					sb.append(PositionUtil.convertRadtoWG84(position.getLatitude().getValue()));
+					sb.append(",");
+					sb.append(PositionUtil.convertRadtoWG84(position.getLongitude().getValue()));
+					sb.append("&spn=0.006472,0.014462'>map</a>");
+					
+					pw.println(sb.toString());
+					
+				} else if (o instanceof org.osgi.util.measurement.Measurement) {
+					StringBuffer sb = new StringBuffer();
+
+					// MeasurementUtil.toText(sb, (Measurement) o);
+					Measurement measurement = (Measurement) o;
+
+					// min and max
+			        double min;
+			        double max;
+				    if(minimums==null){
+				        minimums=new HashMap();
+				        maximums=new HashMap();
+				        min=max=measurement.getValue();
+				        minimums.put(currentWireAdminPid,new Double(min));
+				        maximums.put(currentWireAdminPid,new Double(max));
+				    } else {
+				        Double dmin=((Double)minimums.get(currentWireAdminPid));
+				        if(dmin==null) {
+				            min=measurement.getValue();
+					        minimums.put(currentWireAdminPid,new Double(min));					            
+				        } else {
+				            min=dmin.doubleValue();	
+					        if(min>measurement.getValue()) {
+					            min=measurement.getValue();
+						        minimums.put(currentWireAdminPid,new Double(min));
+					        }
+				        }
+
+				        Double dmax=((Double)maximums.get(currentWireAdminPid));
+				        if(dmax==null) {
+				            max=measurement.getValue();
+					        maximums.put(currentWireAdminPid,new Double(max));					            
+				        } else {
+				            max=dmax.doubleValue();	
+					        if(max<measurement.getValue()) {
+					            max=measurement.getValue();
+						        maximums.put(currentWireAdminPid,new Double(max));
+					        }
+				        }
+				    }
+					MeasurementUtil.toText(sb, measurement);
+						
+					pw.println(sb.toString());
+				} else if (o instanceof java.util.Date) {
+					StringBuffer sb = new StringBuffer();
+
+					Date d = (Date) o;
+					sb.append("<script language=\"JavaScript\">\n\n");
+
+					sb
+						.append("printDate(\"")
+						.append(d.getTime())
+						.append("\",\"")
+						.append(d.toString())
+						.append("\");\n\n");
+
+					sb.append("</script>\n\n");
+
+					pw.println(sb.toString());
+				} else {
+					pw.println(o.toString());
+				}
+			} else {
+				StringBuffer sb = new StringBuffer();
+
+				sb.append("<script language=\"JavaScript\">\n\n");
+
+				sb.append("printUnvalidDisconnected();\n\n");
+
+				sb.append("</script>\n\n");
+
+				pw.println(sb.toString());
+			}
+
+			pw.println("</td></tr>");
+
+			pw.println("</table>");
+
+			pw.println("<br>");
+		}
+		pw.println("</body></html>");
+	}
+	
+
+	private Wire[] wires = null;
+	private Map minimums = null; // for the meters and history graphes
+	private Map maximums = null; // for the meters and history graphes
+	
+	public void updated(Wire wire, Object o) {
+		// TODO: do nothing to avoid trace
+		if (o instanceof String) {
+			trace(
+				this.getClass().getName()
+					+ ": updated object \""
+					+ (String) o
+					+ "\" on wire "
+					+ wire.toString());
+		} else {
+			trace(
+				this.getClass().getName()
+					+ ": updated object \""
+					+ o.toString()
+					+ "\" on wire "
+					+ wire.toString());
+		}
+
+	}
+
+	public void producersConnected(Wire[] wires) {
+		this.wires = wires;
+	}
+
+	
+	// should be replaced by the log !!
+	private void trace(String message){
+		if(TRACE)
+			System.out.println(message);
+	}
+	
+	private static void printOption(
+			PrintWriter pw,
+			String refresh,
+			String optionValue) {
+			pw.print("<option value='");
+			pw.print(optionValue);
+			pw.print("'");
+			if (refresh != null && refresh.equals(optionValue)) {
+				pw.println(" selected");
+			}
+			pw.print(">");
+			pw.print(optionValue);
+			pw.print("</option>");
+		}	
+
+}
+

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/java/org/apache/felix/sandbox/wireadmin/sample/consumerservlet/ConsumerServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/OSGI-INF/component.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/OSGI-INF/component.xml?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/OSGI-INF/component.xml (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/OSGI-INF/component.xml Wed Apr  2 16:37:24 2008
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component name="Consumer.Servlet" immediate="true">
+	<!-- for immediate="true", see 112.5.4 Delayed Component -->
+
+	<implementation class="org.apache.felix.sandbox.wireadmin.sample.consumerservlet.ConsumerServlet"/>
+
+	<!--
+		provides also 1 Consumer service
+		but it is registered directly by the instance
+		since SCR can not supports properties with Class[] type
+	-->
+
+	<!-- Referenced services -->
+
+	<reference
+		name="HTTP"
+		interface="org.osgi.service.http.HttpService"
+		cardinality="1..1"
+		policy="static"
+		bind="bindHttpService" 
+		unbind="unbindHttpService"
+	/>
+	
+	<reference
+		name="LOG"
+		interface="org.osgi.service.log.LogService"
+		cardinality="0..1"
+		policy="dynamic"
+	/>
+	
+</component>
+
+

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/OSGI-INF/component.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WAB-INF/wadl.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WAB-INF/wadl.xml?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WAB-INF/wadl.xml (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WAB-INF/wadl.xml Wed Apr  2 16:37:24 2008
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+<!DOCTYPE wireadminbinder SYSTEM "wireapp.dtd">
+-->
+
+<!--
+ 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.
+-->
+
+<!--
+  descriptor sample for org.apache.felix.sandbox.wireadminbinder
+
+  Author : Felix Project Team
+-->
+<wireapp 
+	id="org.apache.felix.sandbox.wireadmin.sample.consumerservlet.wab"
+	description="A Wired application with Consumer Servlet">
+	<!-- a many-to-one wireset without wire properties -->
+	<!-- + whileConsumer remove policy -->
+	<wireset
+		id="many2consumerservlet" 
+		description="all producer and the consumer servlet"
+		producersFilter="(|(|(|(|(|(wireadmin.producer.flavors=*org.osgi.util.position.Position)(wireadmin.producer.flavors=*org.osgi.util.measurement.Measurement))(wireadmin.producer.flavors=*java.lang.Long))(wireadmin.producer.flavors=*java.lang.Double))(wireadmin.producer.flavors=*java.awt.Image))(wireadmin.producer.flavors=*java.util.Date))"
+		consumerPID="org.apache.felix.sandbox.wireadmin.sample.consumerservlet"
+		removepolicy="whileConsumer"
+	/>
+</wireapp>

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WAB-INF/wadl.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WEB-INF/mimetype.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WEB-INF/mimetype.txt?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WEB-INF/mimetype.txt (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WEB-INF/mimetype.txt Wed Apr  2 16:37:24 2008
@@ -0,0 +1,135 @@
+# This is a dump of a typical MIME type file on a Linux/Unix server. This file controls what MIME types are sent to the client for the given file extensions. Sending the correct MIME type to the client is important so they know how to handle the content of the file. Extra types can either be added here or by using an AddType directive in your config files.
+# For more information about MIME types
+# please read RFC 2045, 2046, 2047, 2048, and 2077. 
+
+# see http://fr.selfhtml.org/divers/typesmime.htm
+
+# MIME type Extension
+application/activemessage
+application/andrew-inset
+application/applefile
+application/atomicmail
+application/dca-rft
+application/dec-dx
+application/mac-binhex40 hqx
+application/mac-compactpro cpt
+application/macwriteii
+application/msword doc
+application/news-message-id
+application/news-transmission
+application/octet-stream bin dms lha lzh exe class
+application/oda oda
+application/pdf pdf
+application/postscript ai eps ps
+application/powerpoint ppt
+application/remote-printing
+application/rtf rtf
+application/slate
+application/smil smi smil sml
+application/wita
+application/wordperfect5.1
+application/x-bcpio bcpio
+application/x-cdlink vcd
+application/x-compress
+application/x-cpio cpio
+application/x-csh csh
+application/x-director dcr dir dxr
+application/x-dvi dvi
+application/x-gtar gtar
+application/x-gzip
+application/x-hdf hdf
+application/x-javascript js
+application/x-koan skp skd skt skm
+application/x-latex latex
+application/x-mif mif
+application/x-netcdf nc cdf
+application/x-sh sh
+application/x-shar shar
+application/x-stuffit sit
+application/x-sv4cpio sv4cpio
+application/x-sv4crc sv4crc
+application/x-tar tar
+application/x-tcl tcl
+application/x-tex tex
+application/x-texinfo texinfo texi
+application/x-troff t tr roff
+application/x-troff-man man
+application/x-troff-me me
+application/x-troff-ms ms
+application/x-ustar ustar
+application/x-wais-source src
+application/zip zip
+audio/basic au snd
+audio/midi midi kar
+audio/x-midi mid
+audio/mpeg mpga mp2 mp3
+audio/x-aiff aif aiff aifc
+audio/x-pn-realaudio ram
+audio/x-pn-realaudio-plugin rpm
+audio/x-realaudio ra
+audio/x-wav wav
+chemical/x-pdb pdb xyz
+image/gif gif
+image/ief ief
+image/jpeg jpeg jpg jpe
+image/png png
+image/tiff tiff tif
+image/x-cmu-raster ras
+image/x-portable-anymap pnm
+image/x-portable-bitmap pbm
+image/x-portable-graymap pgm
+image/x-portable-pixmap ppm
+image/x-rgb rgb
+image/x-xbitmap xbm
+image/x-xpixmap xpm
+image/x-xwindowdump xwd
+message/external-body
+message/news
+message/partial
+message/rfc822
+model/iges igs iges
+model/vrml wrl vrml
+model/mesh msh mesh silo
+multipart/alternative
+multipart/appledouble
+multipart/digest
+multipart/mixed
+multipart/parallel
+text/css css
+text/html html htm
+text/plain txt
+text/richtext rtx
+text/tab-separated-values tsv
+text/x-setext etx
+text/x-sgml sgml sgm
+text/xml xml dtd
+video/mpeg mpeg mpg mpe
+video/quicktime qt mov
+video/x-msvideo avi
+video/x-sgi-movie movie
+x-conference/x-cooltalk ice
+
+# More mapping !
+
+application/x-shockwave-flash swf
+
+text/javascript js
+# application/x-javascript js
+
+text/json json
+# text/x-json json
+# application/json
+
+text/csv csv
+# text/comma-separated-values 
+# application/csv 
+# application/excel 
+# application/vnd.ms-excel 
+# application/vnd.msexcel 
+
+# WAP forum
+text/vnd.wap.wml wml 
+text/vnd.wap.wmlscript wmls 
+image/vnd.wap.wbmp wbmp 
+application/vnd.wap.wmlc wmlc 
+application/vnd.wap.wmlscriptc wmlsc 

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/WEB-INF/mimetype.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/geolocation.js
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/geolocation.js?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/geolocation.js (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/geolocation.js Wed Apr  2 16:37:24 2008
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+// @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+
+
+// get degrees (DDD) of a WG84 angle
+function convertWG84toDDD(wg84) {
+	return Math.floor(wg84);
+}
+
+// get minutes (MM) of a WG84 angle
+function convertWG84toMM(wg84) {
+	return Math.floor((wg84-Math.floor(wg84))*60);
+}
+
+// get seconds (SS) of a WG84 angle
+function convertWG84toSS(wg84) {
+	var deg=(wg84-Math.floor(wg84))*60;
+	return Math.floor((deg-Math.floor(deg))*60);
+}
+
+// get hemisphere (H) of a WG84 angle
+//	lattitude "N" == 1
+//	lattitude "S" == -1
+//	lattitude "E" == 1
+//	lattitude "W" == -1
+
+function convertWG84toH(wg84) {
+	return (wg84<0)?1:-1;
+}
+
+// converts DDD MM SS in a WG84 angle
+function convertDDDMMSSHtoWG84(degrees,minutes,seconds,h) {
+	return (degrees+(minutes/60)+(seconds/3600))*h*1.0;
+}
+
+function printWG84inDDDMMSSH(latitude,longitude) {
+	document.print("Latitude: ");
+	if(convertWG84toH(latitude)>0) {
+		document.print("N ");
+	} else {
+		document.print("S ");
+	}
+	document.print(convertWG84toDDD(latitude));
+	document.print("° ");
+	document.print(convertWG84toMM(latitude));
+	document.print("' ");
+	document.print(convertWG84toSS(latitude));
+	document.print("\"");
+	document.println();
+	
+	document.print("Longitude:");
+	if(convertWG84toH(longitude)>0) {
+		document.print("E ");
+	} else {
+		document.print("W ");
+	}
+	document.print(convertWG84toDDD(longitude));
+	document.print("° ");
+	document.print(convertWG84toMM(longitude));
+	document.print("' ");
+	document.print(convertWG84toSS(longitude));
+	document.print("\"");
+	document.println();
+}

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/geolocation.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/logo.png
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/logo.png?rev=644109&view=auto
==============================================================================
Binary file - no diff available.

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/logo.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement.xml?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement.xml (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement.xml Wed Apr  2 16:37:24 2008
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="measurement2html.xsl"?>
+<measurements 
+	xmlns="http://www-adele.imag.org/sensorwarehouse/1.0/"
+	xmlns:osgi="http://www.osgi.org/util/measurement/1.0/"
+>
+	<sensor id="CapteurTemperature2emeEtage">
+		<osgi:measurement>
+			<osgi:value>290.5</osgi:value>
+			<osgi:accuracy>0.5</osgi:accuracy>
+			<osgi:unit>K</osgi:unit>
+			<osgi:timestamp>12/09/2003 9:47:37,70 GMT+1</osgi:timestamp>
+		</osgi:measurement>
+
+		<osgi:measurement>
+			<osgi:value>300.5</osgi:value>
+			<osgi:accuracy>0.5</osgi:accuracy>
+			<osgi:unit>K</osgi:unit>
+			<osgi:timestamp>12/09/2003 9:57:20,60 GMT+1</osgi:timestamp>
+		</osgi:measurement>
+	</sensor>
+</measurements>
\ No newline at end of file

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement2html.xsl
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement2html.xsl?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement2html.xsl (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement2html.xsl Wed Apr  2 16:37:24 2008
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0"
+  	xmlns="http://www.w3.org/1999/xhtml"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  	xmlns:w="http://www-adele.imag.org/sensorwarehouse/1.0/"
+	xmlns:osgi="http://www.osgi.org/util/measurement/1.0/"
+
+>
+  <xsl:template match="/">
+      <html>
+      <head></head>
+      <body>
+        <xsl:apply-templates/>
+      </body>
+      </html>
+  </xsl:template>
+
+  <xsl:template match="w:measurements">
+      <table border="1">
+      	<tr><th>Value</th><th>Error +/-</th><th>Unit (SI)</th><th>Timestamp</th></tr>
+        <xsl:apply-templates select="w:sensor"/>
+      </table>
+  </xsl:template>
+  
+  <xsl:template match="w:measurements[not(w:sensor)]">
+      No sensor
+  </xsl:template>
+  
+  <xsl:template match="w:sensor">
+    <tr>
+      <td colspan="4"><xsl:value-of select="@id"/></td>
+    </tr>
+    <xsl:apply-templates/>
+  </xsl:template>
+
+    <xsl:template match="osgi:measurement">
+    <tr>
+    <xsl:apply-templates/>
+    </tr>
+  </xsl:template>
+
+  
+  <xsl:template match="*">
+  	<td><xsl:value-of select="."/></td>
+  </xsl:template>
+<!--
+  <xsl:template match="*">
+  </xsl:template>
+-->
+
+</xsl:stylesheet>

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/measurement2html.xsl
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/script.js
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/script.js?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/script.js (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/script.js Wed Apr  2 16:37:24 2008
@@ -0,0 +1,137 @@
+/*
+ * 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.
+ */
+
+// @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+
+
+
+// contains scripts for render values
+
+function printProducer(producerPid,wireadminPid){
+	document.write(
+		"<tr><td class='producer'>"
+	);
+	document.write(
+		"producer \""
+	+	producerPid
+	+	"\"<br>on wireadmin \""
+	+	wireadminPid
+	+	"\""
+	);
+	document.write(
+		"</td><td class='value'>"
+	);
+}
+
+function printImage(src){
+	document.write(
+		"<img src=\""
+	+	src
+	+	"\" alt=\"Image polled by producer\">"
+	);
+
+}
+
+function printWarning(message){
+	document.write("<center>");
+	document.write("<img src='warning.png' alt='");
+	document.write(message);
+	document.write("'>");
+	document.write("<br>");
+	document.write(message);
+	document.write("<center>");
+}
+
+function printUnvalidDisconnected(){
+	printWarning("unvalid or disconnected wire");
+}
+
+function printPollNull(){
+	printWarning("polls a null object");
+}
+
+
+function printMeasurement(value,unit,error,datestr,min,max){
+	if(unit=="K") {
+		printTemperature(value,unit,error,datestr,min,max);
+	} else 	if(unit=="V") {
+		printVoltage(value,unit,error,datestr,min,max);
+	} else 	if(unit=="A") {
+		printPower(value,unit,error,datestr,min,max);
+	} else {
+		printGenericMeasurement(value,unit,error,datestr,min,max);		
+	}
+}
+
+function printTemperature(value,unit,error,datestr,min,max){
+	document.write("<center>");
+	printMeterString(value,unit,min,max,"Temperature");
+	document.write("<br>");
+	document.write(datestr);
+	document.write("</center>");
+}
+
+function printPower(value,unit,error,datestr,min,max){
+	document.write("<center>");
+	printMeterString(value,unit,min,max,"Power");
+	document.write("<br>");
+	document.write(datestr);
+	document.write("</center>");
+}
+
+function printVoltage(value,unit,error,datestr,min,max){
+	document.write("<center>");
+	printMeterString(value,unit,min,max,"Voltage");
+	document.write("<br>");
+	document.write(datestr);
+	document.write("</center>");
+}
+
+
+function printPosition(value,unit,error,datestr){
+
+}
+
+function printDate(timestamp,datestr){
+	document.write("<center>");
+	document.write(datestr);
+	document.write("</center>");
+}
+
+function printClock(timestamp){
+    document.write("<applet code='Clock.class' width='170' height='150'>");
+    document.write("<param name='bgcolor'  value='ffff99'>");
+    document.write("<param name='fgcolor1' value='000000'>");
+    document.write("<param name='fgcolor2' value='0000ff'>");
+    document.write("<param name='fixedtimestamp' value='");
+    document.write(timestamp);
+    document.write("'>");
+    document.write("</applet>");
+}
+
+function printGenericMeasurement(value,unit,error,datestr,min,max){
+	document.write("<center>");
+	printMeterString(value,unit,error,min,max,"Measurement");
+	document.write("</center>");
+}
+
+function printMeterString(value,unit,min,max,title){
+	document.write(title+": "+value+" "+unit+"(min: "+min+", max: "+max+")");
+}
+

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/script.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/style.css
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/style.css?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/style.css (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/style.css Wed Apr  2 16:37:24 2008
@@ -0,0 +1,47 @@
+BODY {
+		background-color: #ccccff;
+		color: black;
+		font-family: verdana, helvetica, arial, sans-serif
+}
+
+P {
+		font-family: verdana, helvetica, arial, sans-serif
+}
+
+UL {
+		font-family: verdana, helvetica, arial, sans-serif;
+		margin-left: 5%
+}
+
+H1, H2, H3, H4, H5, H6 {
+		font-family: verdana, helvetica, arial, sans-serif
+}
+
+
+.banner {
+	margin-right: 10%;
+	text-align: right
+}
+
+.title {
+	background-color: #cc99ff;
+	border-color: black;
+	border-style: solid;
+	border-width: medium;
+	font-size: 1.5em;
+	margin-right: 10%;
+	padding: .5%;
+	text-align: left
+}
+
+.producer {
+	font-size: 0.7em;
+}
+
+.value {
+	font-size: 0.7em;
+}
+
+IMG {
+	background-color: #ccccff
+}

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/style.css
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/warning.png
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/warning.png?rev=644109&view=auto
==============================================================================
Binary file - no diff available.

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/main/resources/webroot/warning.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/readme.html
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/readme.html?rev=644109&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/readme.html (added)
+++ felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/readme.html Wed Apr  2 16:37:24 2008
@@ -0,0 +1,152 @@
+<html>
+<head>
+<title>Consumer Servlet</title>
+</head>
+<body>
+
+<!-- Start of Felix Bundle Documentation -->
+<hr width="100%" size="2">
+<h1><i><a name="consumerservlet"></a><font color="#0000aa">consumerservlet.jar</font></i></h1>
+
+<p>
+<b>Description</b><br>
+This bundle provides a org.osgi.service.wireadmin.Consumer to illustrate WireAdmin services (@see chapter 16 in OSGi specification release 3). It updates regulary java.lang.String objects on connected wires<br>
+</p>
+
+<p>
+<b>Authors/Contributors</b><br>
+<a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+</p>
+
+<p>
+<b>License</b><br>
+ASL2.0
+</p>
+
+<p>
+<b>Services</b><br>
+<code>org.osgi.service.wireadmin.Consumer</code>
+</p>
+
+<p>
+<b>Properties</b><br>
+<ul>
+<li>service.pid=fr.imag.adele.osgi.util.StringConsumer</li>
+<li>wireadmin.consumer.flavors=new { class org.osgi.util.position.Position, class org.osgi.util.measurement.Measurement, class java.awt.Image, class java.util.Date, class java.lang.String }</li>
+</ul>
+</p>
+
+<p><b>Requirements</b><br>
+<ul>
+<li>org.osgi.service.wireadmin</li>
+<li>org.osgi.util.measurement</li>
+<li>org.osgi.util.position</li>
+<li>org.osgi.service.http</li>
+<li>javax.servlet</li>
+<li>javax.servlet.http</li>
+<li>org.apache.felix.scr</li>
+</ul>
+</p>
+
+<!-- End of Felix Bundle Documentation -->
+
+<hr width="100%" size="2">
+
+<!-- Start of extra information  -->
+
+<p id="download">
+<b>Download</b><br>
+<ul>
+<li><a href='http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/consumerservlet/consumerservlet.jar'>Bundle binaries</a></li>
+<li><a href='http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/consumerservlet/consumerservlet-src.jar'>Bundle sources</a></li>
+<li><a href='http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/consumerservlet/readme.html'>The latest version of this documentation</a></li>
+<li><a href='http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/consumerservlet/obr.txt'>The OBR descriptor (text format)</a></li>
+</ul>
+</p>
+
+<p id="build">
+<b>Build</b><br>
+<ol>
+<li>configure the build properties in build.xml</li>
+<li>then build with ant</li>
+</ol>
+</p>
+
+<p id="usage">
+<b>Usage</b><br>
+install and start the dependencies<br>
+<pre>
+obr start "HTTP Service"
+obr start "Service Component Runtime"
+obr start "Service Component Runtime"
+start http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/osgi3spec/osgi3spec.jar
+start http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/consumerservlet/consumerservlet.jar
+</pre>
+OK, now you can check available producers and create wires between the servlet and them
+<pre>
+start http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/wireadmincmd/wireadmincmd.jar
+start http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/wireadmin/wireadmin.jar
+wa
+wa -lp
+wa -lc
+</pre>
+Create wires between the servlet and them
+<pre>
+start http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/dateproducer/dateproducer.jar	
+wa -c fr.imag.adele.osgi.util.clock fr.imag.adele.osgi.util.consumerservlet
+wa -w
+</pre>
+<br>Those commands create the following architecture:
+<center><img alt="Wire Admin application architecture" src="wasample.png"></center>
+Then browse this URL <a href="http://localhost/wa/poll?css=style.css&refresh=20">http://localhost/wa/poll?css=style.css</a>
+<br>You should see the following document:
+<center><img alt="Wire Admin Customer Servlet snapshop" src="wa.jpg"></center>
+<br>For a more complex demo, follows the instruction of the <a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/webcamproducer/readme.html#rundemo">WebCam Producer demo</a>
+</p>
+
+<p>
+<b>Servlet parameters</b><br>
+<ul>
+	<li>mimetype: MIME type of the returned document (possible values: text/html, text/xml (TODO), text/vnd.wap.wml (TODO), text/csv(TODO (ie Column Separated Values)), text/plain(TODO) )</li>
+	<li>css: CSS stylesheet (only with mimetype=text/html)</li>
+	<li>xslt: XSLT stylesheet for the client-side transformation (only with mimetype=text/xml)</li>
+	<li>refresh: delay in secondes between document refreshs</li>
+</ul>
+</p>
+
+<p id="gateways">
+<b>Tested gateways</b><br>
+<ul>
+<li><a href="http://incubator.apache.org/felix">Felix</a></li>
+</ul>
+</p>
+
+<p id="todo">
+<b>TODO (contributions are welcome)</b><br>
+<ul>
+<li>use table inside item lists</li>	
+<li>automate wire creations/deletions between this servlet and the registered producers (with <a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/wireadminbinder/readme.html">WireAdminBinder</a>)</li>	
+<li>support MIME types : text/xml (TODO), application/x-shockwave-flash (TODO), text/vnd.wap.wml (TODO), text/csv(TODO (ie Column Separated Values)), text/plain(TODO)</li>	
+<li>customizable bounds in applets and histories</li>	
+<li>color range in applets and histories according to values</li>	
+<li>use Flash to display gauge and histograms</li>
+<li>use AJAX for refreshing (<a href="https://blueprints.dev.java.net/ajax-faq.html">https://blueprints.dev.java.net/ajax-faq.html</a>)</li>	
+</ul>
+</p>
+
+<p id="links">
+<b>Links</b><br>
+<ul>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/wireadmin/readme.html">My Wire Admin Implementation</a></li>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/wireadmincmd/readme.html">The OSCAR shell command for the wire admin</a></li>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/wireadminbinder/readme.html">The WireAdminBinder</a></li>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/dateproducer/readme.html">A simple Date Producer</a></li>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/webcamproducer/readme.html">A WebCam Producer (requires a USB WebCam !)</a></li>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/onewireproducer/readme.html">A OneWire Producer (requires iButtons !)</a></li>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/gpspositionproducer/readme.html">A GPS Position Producer (requires a serial GPS/NMEA0183 receiver !)</a></li>
+<li><a href="http://www-adele.imag.fr/users/Didier.Donsez/dev/osgi/">My Bundle Farm</a></li>
+</ul>
+</p>
+
+</body>
+</html>

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/readme.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample.png
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample.png?rev=644109&view=auto
==============================================================================
Binary file - no diff available.

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Added: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample2.png
URL: http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample2.png?rev=644109&view=auto
==============================================================================
Binary file - no diff available.

Propchange: felix/sandbox/donsez/wireadmin.sample.consumerservlet/src/site/wasample2.png
------------------------------------------------------------------------------
    svn:mime-type = image/png