[jboss-cvs] JBossAS SVN: r89741 - in projects/jboss-osgi/trunk: testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 3 10:44:56 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-06-03 10:44:55 -0400 (Wed, 03 Jun 2009)
New Revision: 89741

Added:
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java
Removed:
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java
Modified:
   projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd
Log:
All chapters except Husky - ok

Modified: projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml
===================================================================
--- projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/docbook/en/modules/ch080-provided-examples.xml	2009-06-03 14:44:55 UTC (rev 89741)
@@ -14,7 +14,7 @@
     and <ulink url="http://www.jboss.org/community/docs/DOC-13420">Hudson QA Environment</ulink>.</para>
     
     <para>The examples can be either run against an embedded OSGi runtime or against
-    a remote runtime. Here is how you build and run the against the embedded runtime.</para>
+    a remote OSGi runtime. Here is how you build and run the against the embedded runtime.</para>
     
     <programlisting>
     [tdiesler at tddell example]$ mvn test
@@ -54,8 +54,9 @@
     
     <para>To run the examples against a remote OSGi Runtime, you need to provide the
     target container that the runtime should connect to. This can be done with the 
-    <emphasis role="bold">target.container</emphasis> system property. 
-    Suported target container values are:</para> 
+    <emphasis role="bold">target.container</emphasis> system property.</para>
+     
+    <para>Suported target container values are:</para> 
     
     <itemizedlist>
       <listitem>runtime</listitem>
@@ -68,19 +69,109 @@
   
   <sect1 xml:id="SecSimpleExample">  
     <title>Simple Example</title>
-    
     <para>The simple example is covered in: <link linked="SecWritingTests">Writing Test Cases</link></para>
-    
   </sect1>
   
   <sect1 xml:id="SecJMXServiceExample">  
     <title>JMX Service Example</title>
-    <para>TODO</para>
+
+    <para>The <emphasis role="bold">example-jmx.jar</emphasis> bundle tracks the MBeanServer service and registers
+    a pojo with JMX. It then verifies the JMX access.
+    </para>
+    
+    <programlisting role="JAVA">
+    public class FooServiceActivator implements BundleActivator
+    {
+       public void start(BundleContext context)
+       {
+          ServiceTracker tracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+          {
+             public Object addingService(ServiceReference reference)
+             {
+                MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
+                registerMBean(mbeanServer);
+                return mbeanServer;
+             }
+    
+             @Override
+             public void removedService(ServiceReference reference, Object service)
+             {
+                unregisterMBean((MBeanServer)service);
+                super.removedService(reference, service);
+             }
+          };
+          tracker.open();
+       }
+    
+       public void stop(BundleContext context)
+       {
+          ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+          if (sref != null)
+          {
+             MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+             unregisterMBean(mbeanServer);
+          }
+       }
+       ...
+    }
+    </programlisting>
+    
+    <programlisting role="JAVA">
+     public void testMBeanAccess() throws Exception
+     {
+        FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, MBEAN_NAME, runtime.getMBeanServer());
+        assertEquals("hello", foo.echo("hello"));
+     }
+    </programlisting>
+    
+    <para>Please note that access to the MBeanServer from the test case is part of the 
+    <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/testing/OSGiRuntime.html">
+    OSGiRuntime</ulink>abstraction.</para>
+    
   </sect1>
   
   <sect1 xml:id="SecJNDIServiceExample">  
     <title>JNDI Service Example</title>
-    <para>TODO</para>
+
+    <para>The <emphasis role="bold">example-jndi.jar</emphasis> bundle gets the InitialContext service and registers
+    a string with JNDI. It then verifies the JNDI access.
+    </para>
+    
+    <programlisting role="JAVA">
+    ServiceReference sref = context.getServiceReference(InitialContext.class.getName());
+    if (sref == null)
+       throw new IllegalStateException("Cannot access the InitialContext");
+    
+    InitialContext iniContext = (InitialContext)context.getService(sref);
+    iniCtx.createSubcontext("test").bind("Foo", new String("Bar"));
+    </programlisting>
+    
+    <programlisting role="JAVA">
+     public void testJNDIAccess() throws Exception
+     {
+        InitialContext iniCtx = runtime.getInitialContext();
+        String lookup = (String)iniCtx.lookup("test/Foo");
+        assertEquals("JNDI bound String expected", "Bar", lookup);
+  
+        // Uninstall should unbind the object
+        bundle.uninstall();
+  
+        try
+        {
+           iniCtx.lookup("test/Foo");
+           fail("NameNotFoundException expected");
+        }
+        catch (NameNotFoundException ex)
+        {
+           // expected
+        }
+     }
+    </programlisting>
+    
+    <para>Please note that access to the InitialContext from the test case is part of the 
+    <ulink url="http://jbmuc.dyndns.org:8280/hudson/job/jbossosgi-jdk16/javadoc/org/jboss/osgi/spi/testing/OSGiRuntime.html">
+    OSGiRuntime</ulink>abstraction.</para>
+    
   </sect1>
   
   <sect1 xml:id="SecHTTPServiceExample">  

Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java (from rev 89712, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/HttpExampleActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,53 @@
+/*
+ * 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.example.http.bundle;
+
+//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler at jboss.com $
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A Service Activator
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 04-Feb-2009
+ */
+public class HttpExampleActivator implements BundleActivator
+{
+  /*
+   * Implements BundleActivator.start(). 
+   * Registers an instance of a HttpEndpoint Service using the bundle context.
+   */
+  public void start(BundleContext context)
+  {
+    EndpointService service = new EndpointService(context);
+    context.registerService(EndpointService.class.getName(), service, null);
+  }
+
+  /*
+   * Implements BundleActivator.stop(). 
+   */
+  public void stop(BundleContext context)
+  {
+  }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,53 +0,0 @@
-/*
- * 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.example.http.bundle;
-
-//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler at jboss.com $
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * A Service Activator
- * 
- * @author thomas.diesler at jboss.com
- * @since 04-Feb-2009
- */
-public class ServiceActivator implements BundleActivator
-{
-  /*
-   * Implements BundleActivator.start(). 
-   * Registers an instance of a HttpEndpoint Service using the bundle context.
-   */
-  public void start(BundleContext context)
-  {
-    EndpointService service = new EndpointService(context);
-    context.registerService(EndpointService.class.getName(), service, null);
-  }
-
-  /*
-   * Implements BundleActivator.stop(). 
-   */
-  public void stop(BundleContext context)
-  {
-  }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,99 +0,0 @@
-/*
- * 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.example.jmx.bundle;
-
-//$Id$
-
-import static org.jboss.test.osgi.example.jmx.bundle.FooMBean.MBEAN_NAME;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A Service Activator
- * 
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class FooServiceActivator implements BundleActivator
-{
-   public void start(BundleContext context)
-   {
-      ServiceTracker tracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
-      {
-         public Object addingService(ServiceReference reference)
-         {
-            MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
-            registerMBean(mbeanServer);
-            return mbeanServer;
-         }
-
-         @Override
-         public void removedService(ServiceReference reference, Object service)
-         {
-            unregisterMBean((MBeanServer)service);
-            super.removedService(reference, service);
-         }
-      };
-      tracker.open();
-   }
-
-   public void stop(BundleContext context)
-   {
-      ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
-      if (sref != null)
-      {
-         MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
-         unregisterMBean(mbeanServer);
-      }
-   }
-
-   private void registerMBean(MBeanServer mbeanServer)
-   {
-      try
-      {
-         mbeanServer.registerMBean(new Foo(), MBEAN_NAME);
-      }
-      catch (JMException ex)
-      {
-         throw new IllegalStateException(ex);
-      }
-   }
-
-   private void unregisterMBean(MBeanServer mbeanServer)
-   {
-      try
-      {
-         if (mbeanServer.isRegistered(MBEAN_NAME))
-            mbeanServer.unregisterMBean(MBEAN_NAME);
-      }
-      catch (JMException ex)
-      {
-         throw new IllegalStateException(ex);
-      }
-   }
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java (from rev 89712, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/FooServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jmx/bundle/JMXExampleActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,99 @@
+/*
+ * 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.example.jmx.bundle;
+
+//$Id$
+
+import static org.jboss.test.osgi.example.jmx.bundle.FooMBean.MBEAN_NAME;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A Service Activator
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class JMXExampleActivator implements BundleActivator
+{
+   public void start(BundleContext context)
+   {
+      ServiceTracker tracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+      {
+         public Object addingService(ServiceReference reference)
+         {
+            MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
+            registerMBean(mbeanServer);
+            return mbeanServer;
+         }
+
+         @Override
+         public void removedService(ServiceReference reference, Object service)
+         {
+            unregisterMBean((MBeanServer)service);
+            super.removedService(reference, service);
+         }
+      };
+      tracker.open();
+   }
+
+   public void stop(BundleContext context)
+   {
+      ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+      if (sref != null)
+      {
+         MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+         unregisterMBean(mbeanServer);
+      }
+   }
+
+   private void registerMBean(MBeanServer mbeanServer)
+   {
+      try
+      {
+         mbeanServer.registerMBean(new Foo(), MBEAN_NAME);
+      }
+      catch (JMException ex)
+      {
+         throw new IllegalStateException(ex);
+      }
+   }
+
+   private void unregisterMBean(MBeanServer mbeanServer)
+   {
+      try
+      {
+         if (mbeanServer.isRegistered(MBEAN_NAME))
+            mbeanServer.unregisterMBean(MBEAN_NAME);
+      }
+      catch (JMException ex)
+      {
+         throw new IllegalStateException(ex);
+      }
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/JNDITestCase.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -47,12 +47,16 @@
 public class JNDITestCase
 {
    private static OSGiRuntime runtime;
+   private static OSGiBundle bundle;
 
    @BeforeClass
    public static void setUpClass() throws Exception
    {
       runtime = new OSGiTestHelper().getDefaultRuntime();
       runtime.addCapability(new JNDICapability());
+      
+      bundle = runtime.installBundle("example-jndi.jar");
+      bundle.start();
    }
 
    @AfterClass
@@ -64,11 +68,6 @@
    @Test
    public void testJNDIAccess() throws Exception
    {
-      OSGiBundle bundle = runtime.installBundle("example-jndi.jar");
-      bundle.start();
-
-      assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
-
       InitialContext iniCtx = runtime.getInitialContext();
       String lookup = (String)iniCtx.lookup("test/Foo");
       assertEquals("JNDI bound String expected", "Bar", lookup);

Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java (from rev 89712, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/JNDIExampleActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,76 @@
+/*
+ * 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.example.jndi.bundle;
+
+//$Id$
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A Service Activator
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 05-May-2009
+ */
+public class JNDIExampleActivator implements BundleActivator
+{
+   public void start(BundleContext context)
+   {
+      try
+      {
+         InitialContext iniCtx = getInitialContext(context);
+         iniCtx.createSubcontext("test").bind("Foo", new String("Bar"));
+      }
+      catch (NamingException ex)
+      {
+         throw new IllegalStateException("Cannot bind to JNDI", ex);
+      }
+   }
+
+   public void stop(BundleContext context)
+   {
+      try
+      {
+         InitialContext iniCtx = getInitialContext(context);
+         iniCtx.unbind("test");
+      }
+      catch (NamingException ex)
+      {
+         throw new IllegalStateException("Cannot unbind from JNDI", ex);
+      }
+   }
+
+   private InitialContext getInitialContext(BundleContext context)
+   {
+      ServiceReference sref = context.getServiceReference(InitialContext.class.getName());
+      if (sref == null)
+         throw new IllegalStateException("Cannot access the InitialContext");
+      
+      InitialContext initContext = (InitialContext)context.getService(sref);
+      return initContext;
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jndi/bundle/ServiceActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,76 +0,0 @@
-/*
- * 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.example.jndi.bundle;
-
-//$Id$
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-
-/**
- * A Service Activator
- * 
- * @author thomas.diesler at jboss.com
- * @since 05-May-2009
- */
-public class ServiceActivator implements BundleActivator
-{
-   public void start(BundleContext context)
-   {
-      try
-      {
-         InitialContext iniCtx = getInitialContext(context);
-         iniCtx.createSubcontext("test").bind("Foo", new String("Bar"));
-      }
-      catch (NamingException ex)
-      {
-         throw new IllegalStateException("Cannot bind to JNDI", ex);
-      }
-   }
-
-   public void stop(BundleContext context)
-   {
-      try
-      {
-         InitialContext iniCtx = getInitialContext(context);
-         iniCtx.unbind("test");
-      }
-      catch (NamingException ex)
-      {
-         throw new IllegalStateException("Cannot unbind from JNDI", ex);
-      }
-   }
-
-   private InitialContext getInitialContext(BundleContext context)
-   {
-      ServiceReference sref = context.getServiceReference(InitialContext.class.getName());
-      if (sref == null)
-         throw new IllegalStateException("Cannot access the InitialContext");
-      
-      InitialContext initContext = (InitialContext)context.getService(sref);
-      return initContext;
-   }
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java (from rev 89723, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogExampleActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -0,0 +1,42 @@
+/*
+ * 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.example.log.bundle;
+
+//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler at jboss.com $
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class LogExampleActivator implements BundleActivator
+{
+   public void start(final BundleContext context)
+   {
+      ServiceA service = new ServiceA(context);
+      context.registerService(ServiceA.class.getName(), service, null);
+   }
+
+   public void stop(BundleContext context)
+   {
+      // Do Nothing. It is unnecessary to unregister services or Framework listeners
+      // because they must be clean up by the Framework anyway.
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/bundle/LogServiceActivator.java	2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,42 +0,0 @@
-/*
- * 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.example.log.bundle;
-
-//$Id: ServiceActivator.java 87329 2009-04-15 10:34:21Z thomas.diesler at jboss.com $
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class LogServiceActivator implements BundleActivator
-{
-   public void start(final BundleContext context)
-   {
-      ServiceA service = new ServiceA(context);
-      context.registerService(ServiceA.class.getName(), service, null);
-   }
-
-   public void stop(BundleContext context)
-   {
-      // Do Nothing. It is unnecessary to unregister services or Framework listeners
-      // because they must be clean up by the Framework anyway.
-   }
-}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/http/example-http.bnd	2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,6 +1,6 @@
 # bnd build -classpath target/test-classes -output target/test-libs/example/example-http.jar src/test/resources/example/http/example-http.bnd
 
 Bundle-SymbolicName: example-http
-Bundle-Activator: org.jboss.test.osgi.example.http.bundle.ServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.http.bundle.HttpExampleActivator
 Export-Package: org.jboss.test.osgi.example.http.bundle
 Include-Resource: res/message.txt=message.txt
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jmx/example-jmx.bnd	2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,5 +1,5 @@
 # bnd build -classpath target/test-classes -output target/test-libs/example-jmx.jar src/test/resources/jmx/example-jmx.bnd
 
 Bundle-SymbolicName: example-jmx
-Bundle-Activator: org.jboss.test.osgi.example.jmx.bundle.FooServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.jmx.bundle.JMXExampleActivator
 Export-Package: org.jboss.test.osgi.example.jmx.bundle 

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jndi/example-jndi.bnd	2009-06-03 14:44:55 UTC (rev 89741)
@@ -1,6 +1,6 @@
 # bnd build -classpath target/test-classes -output target/test-libs/jndi-test.jar src/test/resources/jndi/jndi-test.bnd
 
 Bundle-SymbolicName: example-jndi
-Bundle-Activator: org.jboss.test.osgi.example.jndi.bundle.ServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.jndi.bundle.JNDIExampleActivator
 Export-Package: org.jboss.test.osgi.example.jndi.bundle 
 Import-Package: javax.naming, org.osgi.framework
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd	2009-06-03 14:41:04 UTC (rev 89740)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/log/example-log.bnd	2009-06-03 14:44:55 UTC (rev 89741)
@@ -2,5 +2,5 @@
 
 Bundle-SymbolicName: example-log
 
-Bundle-Activator: org.jboss.test.osgi.example.log.bundle.LogServiceActivator
+Bundle-Activator: org.jboss.test.osgi.example.log.bundle.LogExampleActivator
 Export-Package: org.jboss.test.osgi.example.log.bundle




More information about the jboss-cvs-commits mailing list