[jboss-cvs] JBossAS SVN: r85100 - in projects/jboss-osgi/trunk/testsuite/src/test: java/org/jboss/test/osgi/jbosgi38/bundleA and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 2 08:58:48 EST 2009


Author: thomas.diesler at jboss.com
Date: 2009-03-02 08:58:48 -0500 (Mon, 02 Mar 2009)
New Revision: 85100

Added:
   projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java
Modified:
   projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
   projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java
   projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd
   projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd
   projects/jboss-osgi/trunk/testsuite/src/test/resources/jboss-osgi-beans.xml
Log:
[JBOSGI-38] Add ServiceActivators

Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java	2009-03-02 13:47:12 UTC (rev 85099)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/OSGI38TestCase.java	2009-03-02 13:58:48 UTC (rev 85100)
@@ -199,6 +199,9 @@
          bundleX = sysContext.installBundle(getTestArchiveURL("jbosgi38-bundleX.jar").toExternalForm());
          assertEquals("Bundle installed", Bundle.INSTALLED, bundleX.getState());
 
+         bundleB.start();
+         assertEquals("Bundle active", Bundle.ACTIVE, bundleB.getState());
+         
          bundleA.start();
          assertEquals("Bundle active", Bundle.ACTIVE, bundleA.getState());
       }

Modified: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java	2009-03-02 13:47:12 UTC (rev 85099)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceA.java	2009-03-02 13:58:48 UTC (rev 85100)
@@ -25,6 +25,9 @@
 
 import org.jboss.test.osgi.jbosgi38.bundleB.ServiceB;
 import org.jboss.test.osgi.jbosgi38.bundleX.SomePojo;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
 
 /**
  * ServiceA has a dependency on ServiceB, both have a dependency on SomePojo
@@ -34,10 +37,18 @@
  */
 public class ServiceA
 {
-   private ServiceB serviceB;
-
-   public String callServiceB()
+   ServiceA(BundleContext context)
    {
-      return serviceB.doStuffInB(new SomePojo("hello"));
+      ServiceTracker tracker = new ServiceTracker(context, ServiceB.class.getName(), null)
+      {
+         @Override
+         public Object addingService(ServiceReference sref)
+         {
+            ServiceB serviceB = (ServiceB)super.addingService(sref);
+            serviceB.doStuffInB(new SomePojo("hello"));
+            return serviceB;
+         }
+      };
+      tracker.open();
    }
 }

Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java	2009-03-02 13:58:48 UTC (rev 85100)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.jbosgi38.bundleA;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class ServiceActivator implements BundleActivator
+{
+   private ServiceRegistration registration;
+
+   public void start(BundleContext context)
+   {
+      ServiceA service = new ServiceA(context);
+      registration = context.registerService(ServiceA.class.getName(), service, null);
+   }
+
+   public void stop(BundleContext context)
+   {
+      if (registration != null)
+      {
+         registration.unregister();
+         registration = null;
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java	2009-03-02 13:58:48 UTC (rev 85100)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.jbosgi38.bundleB;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class ServiceActivator implements BundleActivator
+{
+   private ServiceRegistration registration;
+
+   public void start(BundleContext context)
+   {
+      ServiceB service = new ServiceB();
+      registration = context.registerService(ServiceB.class.getName(), service, null);
+   }
+
+   public void stop(BundleContext context)
+   {
+      if (registration != null)
+      {
+         registration.unregister();
+         registration = null;
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/testsuite/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd	2009-03-02 13:47:12 UTC (rev 85099)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleA.bnd	2009-03-02 13:58:48 UTC (rev 85100)
@@ -1,6 +1,6 @@
 # bnd build -classpath target/test-classes -output target/test-libs/jbosgi38-bundleA.jar src/test/resources/jbosgi38/bundleA.bnd
 
 Bundle-SymbolicName: jbosgi38-bundleA
+Bundle-Activator: org.jboss.test.osgi.jbosgi38.bundleA.ServiceActivator
 Export-Package: org.jboss.test.osgi.jbosgi38.bundleA
-Import-Package: org.jboss.test.osgi.jbosgi38.bundleB, org.jboss.test.osgi.jbosgi38.bundleX 
 

Modified: projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd	2009-03-02 13:47:12 UTC (rev 85099)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jbosgi38/bundleB.bnd	2009-03-02 13:58:48 UTC (rev 85100)
@@ -1,6 +1,6 @@
 # bnd build -classpath target/test-classes -output target/test-libs/jbosgi38-bundleB.jar src/test/resources/jbosgi38/bundleB.bnd
 
 Bundle-SymbolicName: jbosgi38-bundleB
+Bundle-Activator: org.jboss.test.osgi.jbosgi38.bundleB.ServiceActivator
 Export-Package: org.jboss.test.osgi.jbosgi38.bundleB
-Import-Package: org.jboss.test.osgi.jbosgi38.bundleX 
 

Modified: projects/jboss-osgi/trunk/testsuite/src/test/resources/jboss-osgi-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/src/test/resources/jboss-osgi-beans.xml	2009-03-02 13:47:12 UTC (rev 85099)
+++ projects/jboss-osgi/trunk/testsuite/src/test/resources/jboss-osgi-beans.xml	2009-03-02 13:58:48 UTC (rev 85100)
@@ -8,6 +8,13 @@
   <property name="felixProperties">
    <map keyClass="java.lang.String" valueClass="java.lang.String">
     <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+    <entry>
+      <key>org.osgi.framework.system.packages</key>
+      <value>
+        org.osgi.framework; version=1.4,
+        org.osgi.util.tracker
+      </value>
+    </entry>
    </map>
   </property>
  </bean>




More information about the jboss-cvs-commits mailing list