You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ak...@apache.org on 2006/03/07 05:51:45 UTC
svn commit: r383778 - in /incubator/felix/trunk: ./
org.apache.felix.examples.eventlistener/
org.apache.felix.examples.eventlistener/src/
org.apache.felix.examples.eventlistener/src/main/
org.apache.felix.examples.eventlistener/src/main/java/ org.apach...
Author: akarasulu
Date: Mon Mar 6 20:51:43 2006
New Revision: 383778
URL: http://svn.apache.org/viewcvs?rev=383778&view=rev
Log:
adding first example of tutorial using the new maven-osgi-plugin
Added:
incubator/felix/trunk/org.apache.felix.examples.eventlistener/ (with props)
incubator/felix/trunk/org.apache.felix.examples.eventlistener/pom.xml
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/examples/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/examples/eventlistener/
incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/examples/eventlistener/Activator.java
Modified:
incubator/felix/trunk/pom.xml
Propchange: incubator/felix/trunk/org.apache.felix.examples.eventlistener/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 6 20:51:43 2006
@@ -0,0 +1,11 @@
+target
+*.ipr
+*.iws
+*.iml
+.classpath
+.project
+.settings
+.deployables
+.wtpmodules
+*.log
+
Added: incubator/felix/trunk/org.apache.felix.examples.eventlistener/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.examples.eventlistener/pom.xml?rev=383778&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.examples.eventlistener/pom.xml (added)
+++ incubator/felix/trunk/org.apache.felix.examples.eventlistener/pom.xml Mon Mar 6 20:51:43 2006
@@ -0,0 +1,43 @@
+<project>
+ <parent>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>felix</artifactId>
+ <version>0.8-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>osgi-bundle</packaging>
+ <name>Apache Felix Examples: Service Event Listener</name>
+ <artifactId>org.apache.felix.examples.eventlistener</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.osgi</artifactId>
+ <version>${pom.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix.plugins</groupId>
+ <artifactId>maven-osgi-plugin</artifactId>
+ <version>${pom.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <osgiManifest>
+ <bundleName>Service listener example</bundleName>
+ <bundleDescription>
+ Bundle listening for service events: displays a message on startup and when service events occur.
+ </bundleDescription>
+ <bundleActivator>
+ org.apache.felix.examples.eventlistener.Activator
+ </bundleActivator>
+ <bundleSymbolicName>
+ org.apache.felix.examples.eventlistener
+ </bundleSymbolicName>
+ </osgiManifest>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/examples/eventlistener/Activator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/examples/eventlistener/Activator.java?rev=383778&view=auto
==============================================================================
--- incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/examples/eventlistener/Activator.java (added)
+++ incubator/felix/trunk/org.apache.felix.examples.eventlistener/src/main/java/org/apache/felix/examples/eventlistener/Activator.java Mon Mar 6 20:51:43 2006
@@ -0,0 +1,90 @@
+/*
+ * 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.examples.eventlistener;
+
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceEvent;
+
+
+/**
+ * This class implements a simple bundle that utilizes the OSGi framework's
+ * event mechanism to listen for service events. Upon receiving a service event,
+ * it prints out the event's details.
+ *
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Felix Project Team</a>
+ */
+public class Activator implements BundleActivator, ServiceListener
+{
+ /**
+ * Implements BundleActivator.start(). Prints a message and adds itself to
+ * the bundle context as a service listener.
+ *
+ * @param context
+ * the framework context for the bundle.
+ */
+ public void start( BundleContext context )
+ {
+ System.out.println( "Starting to listen for service events." );
+ context.addServiceListener( this );
+ }
+
+
+ /**
+ * Implements BundleActivator.stop(). Prints a message and removes itself
+ * from the bundle context as a service listener.
+ *
+ * @param context
+ * the framework context for the bundle.
+ */
+ public void stop( BundleContext context )
+ {
+ context.removeServiceListener( this );
+ System.out.println( "Stopped listening for service events." );
+
+ // Note: It is not required that we remove the listener here,
+ // since the framework will do it automatically anyway.
+ }
+
+
+ /**
+ * Implements ServiceListener.serviceChanged(). Prints the details of any
+ * service event from the framework.
+ *
+ * @param event
+ * the fired service event.
+ */
+ public void serviceChanged( ServiceEvent event )
+ {
+ String[] objectClass = ( String[] ) event.getServiceReference().getProperty( "objectClass" );
+
+ if ( event.getType() == ServiceEvent.REGISTERED )
+ {
+ System.out.println( "Ex1: Service of type " + objectClass[0] + " registered." );
+ }
+ else if ( event.getType() == ServiceEvent.UNREGISTERING )
+ {
+ System.out.println( "Ex1: Service of type " + objectClass[0] + " unregistered." );
+ }
+ else if ( event.getType() == ServiceEvent.MODIFIED )
+ {
+ System.out.println( "Ex1: Service of type " + objectClass[0] + " modified." );
+ }
+ }
+}
Modified: incubator/felix/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/pom.xml?rev=383778&r1=383777&r2=383778&view=diff
==============================================================================
--- incubator/felix/trunk/pom.xml (original)
+++ incubator/felix/trunk/pom.xml Mon Mar 6 20:51:43 2006
@@ -14,6 +14,7 @@
<module>org.apache.felix.shell.tui</module>
<module>org.apache.felix.daemon</module>
<module>org.apache.felix.main</module>
+ <module>org.apache.felix.examples.eventlistener</module>
</modules>
<repositories>
@@ -40,7 +41,7 @@
</snapshotRepository>
<repository>
<name>ASF Mirrored M2 Distributions</name>
- <id>apache.snapshots</id>
+ <id>apache.releases</id>
<url>
scpexe://minotaur.apache.org/www/www.apache.org/dist/maven-repository
</url>
@@ -52,7 +53,7 @@
<id>apache.snapshots</id>
<name>snapshot plugins</name>
<url>
- scpexe://apache.org/www/cvs.apache.org/maven-snapshot-repository
+ http://cvs.apache.org/maven-snapshot-repository
</url>
</pluginRepository>
</pluginRepositories>