felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbenn...@apache.org
Subject svn commit: r360549 - in /incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources: META-INF/archetype.xml archetype-resources/pom.xml archetype-resources/src/main/java/Activator.java archetype-resources/src/main/java/MyBundleActivator.java
Date Sun, 01 Jan 2006 20:33:20 GMT
Author: tbennett
Date: Sun Jan  1 12:33:16 2006
New Revision: 360549

URL: http://svn.apache.org/viewcvs?rev=360549&view=rev
Log: (empty)

Added:
    incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
  (with props)
Removed:
    incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/MyBundleActivator.java
Modified:
    incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml
    incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml

Modified: incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml?rev=360549&r1=360548&r2=360549&view=diff
==============================================================================
--- incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml
(original)
+++ incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml
Sun Jan  1 12:33:16 2006
@@ -1,6 +1,6 @@
 <archetype>
   <id>osgi-archetype</id>
   <sources>
-    <source>src/main/java/MyBundleActivator.java</source>
+    <source>src/main/java/Activator.java</source>
   </sources>
 </archetype>

Modified: incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml?rev=360549&r1=360548&r2=360549&view=diff
==============================================================================
--- incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
(original)
+++ incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
Sun Jan  1 12:33:16 2006
@@ -5,8 +5,8 @@
   <artifactId>${artifactId}</artifactId>
   <packaging>osgi-bundle</packaging>
   <version>${version}</version>
-  <name>My Bundle Project Name Here</name>
-  <url>My Organization URL Here</url>
+  <name>Simple Bundle Project</name>
+  <url>http://incubator.apache.org/felix</url>
   <build>
     <!--
     ***********************************************************
@@ -35,9 +35,9 @@
           *******************************************************************
           -->
           <osgiManifest>
-            <bundleName>My Bundle Name</bundleName>
-            <bundleActivator>${groupId}.MyBundleActivator</bundleActivator>
-            <bundleVendor>My Organization Name</bundleVendor>
+            <bundleName>Simple Bundle</bundleName>
+            <bundleActivator>${groupId}.Activator</bundleActivator>
+            <bundleVendor>Apache Software Foundation</bundleVendor>
           </osgiManifest>
         </configuration>
       </plugin>

Added: incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java?rev=360549&view=auto
==============================================================================
--- incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
(added)
+++ incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
Sun Jan  1 12:33:16 2006
@@ -0,0 +1,79 @@
+/*
+ *   Copyright 2004 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");
+        if (event.getType() == ServiceEvent.REGISTERED) {
+            System.out.println("SimpleBundle: Service of type " + objectClass[0] + " registered.");
+        } else if (event.getType() == ServiceEvent.UNREGISTERING) {
+            System.out.println("SimpleBundle: Service of type " + objectClass[0] + " unregistered.");
+        } else if (event.getType() == ServiceEvent.MODIFIED) {
+            System.out.println("SimpleBundle: Service of type " + objectClass[0] + " modified.");
+        }
+    }
+}

Propchange: incubator/felix/trunk/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message