adding new felix archetype and making some touchups to osgi archetype
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@432848 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/maven2/felix-archetype/pom.xml b/tools/maven2/felix-archetype/pom.xml
new file mode 100644
index 0000000..d0d4e5d
--- /dev/null
+++ b/tools/maven2/felix-archetype/pom.xml
@@ -0,0 +1,8 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.felix.archetypes</groupId>
+ <artifactId>felix-archetype</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>1.0</version>
+</project>
diff --git a/tools/maven2/felix-archetype/src/main/resources/META-INF/archetype.xml b/tools/maven2/felix-archetype/src/main/resources/META-INF/archetype.xml
new file mode 100644
index 0000000..73b3df3
--- /dev/null
+++ b/tools/maven2/felix-archetype/src/main/resources/META-INF/archetype.xml
@@ -0,0 +1,6 @@
+<archetype>
+ <id>felix-archetype</id>
+ <sources>
+ <source>src/main/java/Activator.java</source>
+ </sources>
+</archetype>
\ No newline at end of file
diff --git a/tools/maven2/felix-archetype/src/main/resources/archetype-resources/pom.xml b/tools/maven2/felix-archetype/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..e9a8ddd
--- /dev/null
+++ b/tools/maven2/felix-archetype/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,71 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <packaging>osgi-bundle</packaging>
+ <version>${version}</version>
+ <name>Simple Bundle Project</name>
+ <url>http://incubator.apache.org/felix</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <!-- Uncomment to override default bundle jar naming convention
+ <finalName>my-bundle</finalName>
+ -->
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix.plugins</groupId>
+ <artifactId>maven-felix-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>run</id>
+ <configuration>
+ <felixCacheDir>${basedir}/target/.felix</felixCacheDir>
+ <exclusions>
+ <exclusion>junit:junit</exclusion>
+ </exclusions>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix.plugins</groupId>
+ <artifactId>maven-osgi-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <!-- Uncomment to specify a manifest file to merge
+ <manifestFile>path/to/manifest.mf</manifestFile>
+ -->
+ <osgiManifest>
+ <bundleName>Simple Bundle</bundleName>
+ <bundleActivator>${groupId}.Activator</bundleActivator>
+ <bundleVendor>Apache Software Foundation</bundleVendor>
+ <importBundle>
+ ${groupId}
+ </importBundle>
+ </osgiManifest>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/tools/maven2/felix-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java b/tools/maven2/felix-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
new file mode 100644
index 0000000..f8b93c1
--- /dev/null
+++ b/tools/maven2/felix-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
@@ -0,0 +1,94 @@
+/*
+ * 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 ${groupId};
+
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+
+
+/**
+ * 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.
+ */
+public class Activator implements BundleActivator, ServiceListener
+{
+ /**
+ * Put your bundle initialization code here...
+ *
+ * Implements <code>BundleActivator.start()</code>. Prints a message
+ * and adds itself to the bundle context as a service listener.
+ *
+ * @param bundleContext the framework context for the bundle
+ * @throws Exception
+ */
+ public void start( BundleContext bundleContext ) throws Exception
+ {
+ System.out.println( "Starting to listen for service events." );
+ bundleContext.addServiceListener( this );
+ }
+
+
+ /**
+ * Put your bundle finalization code here...
+ *
+ * Implements <code>BundleActivator.stop()</code>. Prints a message
+ * and removes itself from the bundle context as a service listener.
+ *
+ * @param bundleContext the framework context for the bundle
+ * @throws Exception
+ */
+ public void stop( BundleContext bundleContext ) throws Exception
+ {
+ bundleContext.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 <code>ServiceListener.serviceChanges()</code>. 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" );
+
+ switch( event.getType() )
+ {
+ case( ServiceEvent.REGISTERED ):
+ System.out.println( "SimpleBundle: Service of type " + objectClass[0] + " registered." );
+ break;
+ case( ServiceEvent.UNREGISTERED ):
+ System.out.println( "SimpleBundle: Service of type " + objectClass[0] + " unregistered." );
+ break;
+ case( ServiceEvent.MODIFIED ):
+ System.out.println( "SimpleBundle: Service of type " + objectClass[0] + " modified." );
+ break;
+ default:
+ break;
+ }
+ }
+}
diff --git a/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml b/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
index e9f3898..a723a26 100644
--- a/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
+++ b/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
@@ -7,6 +7,16 @@
<version>${version}</version>
<name>Simple Bundle Project</name>
<url>http://incubator.apache.org/felix</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi</artifactId>
+ <version>3.0</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
<build>
<!--
***********************************************************
@@ -19,7 +29,7 @@
<groupId>org.apache.felix.plugins</groupId>
<artifactId>maven-osgi-plugin</artifactId>
<extensions>true</extensions>
- <version>0.3.0</version>
+ <version>0.8.0-SNAPSHOT</version>
<configuration>
<!--
*************************************************
@@ -38,17 +48,12 @@
<bundleName>Simple Bundle</bundleName>
<bundleActivator>${groupId}.Activator</bundleActivator>
<bundleVendor>Apache Software Foundation</bundleVendor>
+ <importPackage>
+ ${groupId}
+ </importPackage>
</osgiManifest>
</configuration>
</plugin>
</plugins>
</build>
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi</artifactId>
- <version>3.0</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
</project>
\ No newline at end of file