Author: donsez
Date: Tue Jan 15 07:22:32 2008
New Revision: 612135
URL: http://svn.apache.org/viewvc?rev=612135&view=rev
Log:
creation of the "Simple Consumer" bundle : a simple Consumer service which
prints consumed Position, Measurement and String on console.
Added:
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/pom.xml (with props)
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/simpleconsumer/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/simpleconsumer/SimpleConsumer.java
(with props)
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/resources/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/site/
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/site/readme.html
(with props)
Added: felix/sandbox/donsez/wireadmin.sample.simpleconsumer/pom.xml
URL:
http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.simpleconsumer/pom.xml?rev=612135&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.simpleconsumer/pom.xml (added)
+++ felix/sandbox/donsez/wireadmin.sample.simpleconsumer/pom.xml Tue Jan 15
07:22:32 2008
@@ -0,0 +1,71 @@
+<!--
+ 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.apache.org/~donsez/dev/felix/sandbox/</repositoryLocation>
+ <description>provides a example of a Consumer for the Wire
Admin service.</description>
+ </properties>
+
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>Simple Consumer</name>
+ <description>${description}</description>
+ <groupId>org.apache.felix.sandbox</groupId>
+ <version>0.1.0-SNAPSHOT</version>
+ <artifactId>wireadmin.sample.simpleconsumer</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>0.9.0-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Import-Package>*</Import-Package>
+ <Private-Package>
+ ${pom.groupId}.${pom.artifactId}
+ </Private-Package>
+
<Bundle-Activator>${pom.groupId}.${pom.artifactId}.SimpleConsumer</Bundle-Activator>
+
+ <!-- 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 -->
+
<Export-Service>org.osgi.service.wireadmin.Consumer</Export-Service>
+
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: felix/sandbox/donsez/wireadmin.sample.simpleconsumer/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/simpleconsumer/SimpleConsumer.java
URL:
http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/simpleconsumer/SimpleConsumer.java?rev=612135&view=auto
==============================================================================
---
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/simpleconsumer/SimpleConsumer.java
(added)
+++
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/simpleconsumer/SimpleConsumer.java
Tue Jan 15 07:22:32 2008
@@ -0,0 +1,139 @@
+/*
+ * 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.simpleconsumer;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+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;
+
+/**
+ * this class provides a wireadmin' consumer sample.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Felix Project Team</a>
+ */
+public class SimpleConsumer implements BundleActivator, Consumer {
+
+ private BundleContext bundleContext;
+ private ServiceRegistration serviceRegistration = null;
+ private Wire[] wires = null;
+
+ /**
+ * called upon starting of the bundle. This method invokes configure()
which
+ * load the configuration file, registers the services
+ *
+ * @param bundleContext The bundle bundleContext passed by the
framework
+ * @exception Exception
+ * @see
org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ this.bundleContext=bundleContext;
+ Dictionary registrationProperties=new Hashtable();
+ registrationProperties.put(
+ Constants.SERVICE_PID,
+
"org.apache.felix.sandbox.wireadmin.sample.simpleconsumer");
+ registrationProperties.put(
+ WireConstants.WIREADMIN_CONSUMER_FLAVORS,
+ new Class[] {
+ Position.class, Measurement.class,
String.class
+ }
+ );
+
serviceRegistration=bundleContext.registerService(Consumer.class.getName(),
this, registrationProperties);
+ }
+
+ /**
+ * Called upon stopping of the bundle. This method unregisters the
registered services
+ * @param bundleContext The bundle bundleContext passed by the
framework
+ * @exception Exception
+ * @see
org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ serviceRegistration.unregister();
+ }
+
+ /**
+ * set the new set of Wires connected to this consumer. This method is
invoked by the WireAdmin service each time a wire is created or removed
+ * @see
org.osgi.service.wireadmin.Consumer#producersConnected(org.osgi.service.wireadmin.Wire[])
+ */
+ public void producersConnected(Wire[] wires) {
+ Wire[] oldWires=this.wires;
+ this.wires = wires;
+ if(wires!=null){
+ for (int i = 0; wires != null && i < wires.length; i++)
{
+ Wire w = wires[i];
+ if (w.isValid() && w.isConnected()) {
+ int o = 0;
+ for (; oldWires != null && o <
oldWires.length; o++) {
+ if(w.equals(oldWires[o])) break;
+ }
+ if(o==oldWires.length) { // the
consumer polls the producer because the Wire has been just created !
+ updated(w,w.poll());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * invoke by the WireAdmin when the producer pushes an object
+ * @see
org.osgi.service.wireadmin.Consumer#updated(org.osgi.service.wireadmin.Wire,
java.lang.Object)
+ */
+ public void updated(Wire wire, Object object) {
+
+ // TODO: do nothing to avoid trace
+ if(object!=null) {
+ if (object instanceof String) {
+ trace(
+ this.getClass().getName()
+ + ": updated object \""
+ + (String) object
+ + "\" on wire "
+ + wire.toString());
+ } else {
+ trace(
+ this.getClass().getName()
+ + ": updated object \""
+ + object.toString()
+ + "\" on wire "
+ + wire.toString());
+ }
+ } else {
+ trace(
+ this.getClass().getName()
+ + ": updated null object "
+ + " on wire "
+ + wire.toString());
+ }
+ }
+
+ private void trace(String msg) {
+ if (true)
+ System.out.println(msg);
+ }
+}
+
+
Propchange:
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/main/java/org/apache/felix/sandbox/wireadmin/sample/simpleconsumer/SimpleConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/site/readme.html
URL:
http://svn.apache.org/viewvc/felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/site/readme.html?rev=612135&view=auto
==============================================================================
--- felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/site/readme.html
(added)
+++ felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/site/readme.html
Tue Jan 15 07:22:32 2008
@@ -0,0 +1,85 @@
+<html>
+<head>
+<title>Simple Consumer</title>
+</head>
+<body>
+
+<!-- Start of Felix Bundle Documentation -->
+<hr width="100%" size="2">
+<h1><i><a name="wireadmin.sample.simpleconsumer"></a><font
color="#0000aa">Simple Consumer</font></i></h1>
+
+<p>
+<b>Description</b><br>
+This bundle provides a simple Consumer service which prints consumed Position,
Measurement and String.
+</p>
+
+<p>
+<b>Contributors</b><br>
+<ul>
+<li>Author:<a href="[EMAIL PROTECTED]">Felix Project Team</a></li>
+</ul>
+</p>
+
+<p>
+<b>License</b><br>
+ASL2
+</p>
+
+<p>
+<b>Services</b><br>
+<code>org.osgi.service.wireadmin.Consumer</code>
+</p>
+
+<p>
+<b>Properties</b><br>
+<ul>
+<li><code>service.pid=org.apache.felix.wireadmin.sample.simpleconsumer</code></li>
+<li><code>wireadmin.consumer.flavors=[class
org.osgi.util.position.Position,class
org.osgi.util.measurement.Measurement,class java.lang.String]</code><li>
+</ul>
+</p>
+
+<p><b>Requirements</b><br>
+<ul>
+<li><code>org.osgi.service.wireadmin; specification-version=1.0.0</code></li>
+<li><code>org.osgi.util.measurement; specification-version=1.0.0</code></li>
+<li><code>org.osgi.util.position; specification-version=1.0.0</code></li>
+</ul>
+</p>
+
+
+<!-- End of Felix Bundle Documentation -->
+
+<hr width="100%" size="2">
+
+<!-- Start of extra information -->
+
+<p>
+<b>Build</b><br>
+<ol>
+<li>build with <code>mvn clean install</code></li>
+</ol>
+</p>
+
+<b>Test</b><br>
+Launch commands in <a
href="http://www.apache.org/~donsez/dev/osgi/script/wa.txt">http://www.apache.org/~donsez/dev/osgi/script/wa.txt</a>
+</p>
+
+<p id="gateways">
+<b>Tested gateways</b><br>
+<ul>
+<li><a href="http//oscar.objectweb.org/">OSCAR</a> (done)</li>
+<li><a href="http://cwiki.apache.org/FELIX/">Felix</a> (done)</li>
+<li><a href="http://www.knopflerfish.org">Knopflerfish OSGi</a> (to do)</li>
+<li>Equinox (to do)</li>
+<li>Prosyst mbs pro(to do)</li>
+</ul>
+</p>
+
+<p>
+<b>TODO (contributions are welcome)</b><br>
+<ul>
+</ul>
+</p>
+
+</body>
+</html>
Propchange:
felix/sandbox/donsez/wireadmin.sample.simpleconsumer/src/site/readme.html
------------------------------------------------------------------------------
svn:eol-style = native