felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbenn...@apache.org
Subject svn commit: r398362 - in /incubator/felix/sandbox/tbennett: echo-server/src/main/java/org/safehaus/osgi/ my-bundle/ my-bundle/src/ my-bundle/src/main/ my-bundle/src/main/java/ my-bundle/src/main/java/org/ my-bundle/src/main/java/org/promptcritical/ my-...
Date Sun, 30 Apr 2006 16:03:01 GMT
Author: tbennett
Date: Sun Apr 30 09:02:59 2006
New Revision: 398362

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

Added:
    incubator/felix/sandbox/tbennett/my-bundle/
    incubator/felix/sandbox/tbennett/my-bundle/pom.xml   (with props)
    incubator/felix/sandbox/tbennett/my-bundle/src/
    incubator/felix/sandbox/tbennett/my-bundle/src/main/
    incubator/felix/sandbox/tbennett/my-bundle/src/main/java/
    incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/
    incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/
    incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/osgi/
    incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/osgi/Activator.java
  (with props)
Modified:
    incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java

Modified: incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java?rev=398362&r1=398361&r2=398362&view=diff
==============================================================================
--- incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
(original)
+++ incubator/felix/sandbox/tbennett/echo-server/src/main/java/org/safehaus/osgi/ReverseServerActivator.java
Sun Apr 30 09:02:59 2006
@@ -26,15 +26,19 @@
 
 public class ReverseServerActivator implements BundleActivator {
     private static final int PORT = 8192;
+    private ServiceRegistry registry;
+    private Service service;
 
     public void start(BundleContext bundleContext) throws Exception {
-        ServiceRegistry registry = new SimpleServiceRegistry();
-        Service service = new Service("reverse", TransportType.SOCKET, PORT);
+        registry = new SimpleServiceRegistry();
+        service = new Service("reverse", TransportType.SOCKET, PORT);
         registry.bind(service, new ReverseProtocolHandler());
         System.out.println("Listening on port " + PORT);
     }
 
     public void stop(BundleContext bundleContext) throws Exception {
-        // Put code here to finalize your bundle...
+        registry.unbind(service);
+        service = null;
+        registry = null;
     }
 }

Added: incubator/felix/sandbox/tbennett/my-bundle/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/tbennett/my-bundle/pom.xml?rev=398362&view=auto
==============================================================================
--- incubator/felix/sandbox/tbennett/my-bundle/pom.xml (added)
+++ incubator/felix/sandbox/tbennett/my-bundle/pom.xml Sun Apr 30 09:02:59 2006
@@ -0,0 +1,54 @@
+<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.promptcritical.osgi</groupId>
+  <artifactId>my-bundle</artifactId>
+  <packaging>osgi-bundle</packaging>
+  <version>1.0-SNAPSHOT</version>
+  <name>Simple Bundle Project</name>
+  <url>http://incubator.apache.org/felix</url>
+  <build>
+    <!--
+    ***********************************************************
+    * Uncomment out to override default jar naming convention *
+    ***********************************************************
+    <finalName>my-bundle</finalName>
+    -->
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix.plugins</groupId>
+        <artifactId>maven-osgi-plugin</artifactId>
+        <extensions>true</extensions>
+        <version>0.3.0</version>
+        <configuration>
+          <!--
+          *************************************************
+          * Uncomment to specify a manifest file to merge *
+          *************************************************
+          <manifestFile>path/to/manifest.mf</manifestFile>
+          -->
+
+          <!--
+          *******************************************************************
+          * See the following link for entry specification                  *
+          * http://docs.safehaus.org/display/OSGI/OSGi+Plugin+for+Maven+2.0 *
+          *******************************************************************
+          -->
+          <osgiManifest>
+            <bundleName>Simple Bundle</bundleName>
+            <bundleActivator>org.promptcritical.osgi.Activator</bundleActivator>
+            <bundleVendor>Apache Software Foundation</bundleVendor>
+          </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

Propchange: incubator/felix/sandbox/tbennett/my-bundle/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/osgi/Activator.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/osgi/Activator.java?rev=398362&view=auto
==============================================================================
--- incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/osgi/Activator.java
(added)
+++ incubator/felix/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/osgi/Activator.java
Sun Apr 30 09:02:59 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 org.promptcritical.osgi;
+
+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/sandbox/tbennett/my-bundle/src/main/java/org/promptcritical/osgi/Activator.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message