[jboss-cvs] JBossAS SVN: r102773 - in projects/jboss-osgi/projects/runtime/framework/trunk/bundle: src/test/java/org/jboss/test/osgi and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 23 07:38:06 EDT 2010
Author: thomas.diesler at jboss.com
Date: 2010-03-23 07:38:05 -0400 (Tue, 23 Mar 2010)
New Revision: 102773
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleActivator.java
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple-logservice.bnd
projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple.bnd
Log:
Move integration.simple to simple
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml 2010-03-23 11:25:18 UTC (rev 102772)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/scripts/antrun-test-jars.xml 2010-03-23 11:38:05 UTC (rev 102773)
@@ -82,8 +82,8 @@
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-nativecode.jar" files="${tests.resources.dir}/nativecode/simple-nativecode.bnd" />
<!-- simple -->
- <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-bundle.jar" files="${tests.resources.dir}/integration/simple/simple.bnd" />
- <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-logservice-bundle.jar" files="${tests.resources.dir}/integration/simple/simple-logservice.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-bundle.jar" files="${tests.resources.dir}/simple/simple.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-logservice-bundle.jar" files="${tests.resources.dir}/simple/simple-logservice.bnd" />
<!-- Please add alphabetically -->
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java (from rev 102690, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,101 @@
+/*
+ * 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.simple;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiRuntimeHelper;
+import org.jboss.test.osgi.simple.bundleA.SimpleService;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Aug-2009
+ */
+public class SimpleBundleTestCase
+{
+ @Test
+ public void testBundleInstallLauchAPI() throws Exception
+ {
+ // Uses the OSGi Framework launch API
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ Framework framework = factory.newFramework(null);
+ framework.start();
+
+ OSGiRuntimeHelper helper = new OSGiRuntimeHelper();
+
+ BundleContext sysContext = framework.getBundleContext();
+ Bundle bundle = sysContext.installBundle(helper.getTestArchivePath("simple-bundle.jar"));
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ BundleContext bndContext = bundle.getBundleContext();
+ assertNotNull("BundleContext not null", bndContext);
+
+ // getServiceReference from bundle context
+ ServiceReference sref = bndContext.getServiceReference(SimpleService.class.getName());
+ assertNotNull("ServiceReference not null", sref);
+
+ // getServiceReference from system context
+ sref = sysContext.getServiceReference(SimpleService.class.getName());
+ assertNotNull("ServiceReference not null", sref);
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ framework.stop();
+ }
+
+ @Test
+ public void testBundleInstallRuntimeAPI() throws Exception
+ {
+ // Uses the JBossOSGi SPI provided runtime abstraction
+ OSGiRuntime runtime = new OSGiRuntimeHelper().getEmbeddedRuntime();
+ OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ runtime.shutdown();
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java (from rev 102752, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/SimpleLogServiceTestCase.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,171 @@
+/*
+ * 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.simple;
+
+//$Id$
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.jboss.osgi.testing.OSGiFrameworkTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Aug-2009
+ */
+public class SimpleLogServiceTestCase extends OSGiFrameworkTest
+{
+ @Before
+ public void setUp()
+ {
+ System.clearProperty("simple-logservice-bundle");
+ }
+
+ @Test
+ public void testNoLogService() throws Exception
+ {
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
+ fail("Unresolved package contstraint on [org.osgi.service.log] expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+
+ @Test
+ public void testLogServiceFromThirdParty() throws Exception
+ {
+ Bundle logBundle = context.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar"));
+ try
+ {
+ logBundle.start();
+
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ try
+ {
+ bundle.start();
+ fail("Expected UNRESOLVED OSGiPackageRequirement{org.osgi.util.tracker [0.0.0,?)}");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ logBundle.uninstall();
+ }
+ }
+
+ @Test
+ public void testLogServiceFromCompendium() throws Exception
+ {
+ Bundle cmpnBundle = context.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
+ try
+ {
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
+
+ // The bundle activator is expected to set this property
+ String result = System.getProperty(bundle.getSymbolicName());
+ assertNotNull("Result property not null", result);
+
+ assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
+ assertFalse("getService", result.indexOf("getService") > 0);
+ assertFalse("addingService", result.indexOf("addingService") > 0);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ cmpnBundle.uninstall();
+ }
+ }
+
+ @Test
+ public void testLogServiceFromTwoExporters() throws Exception
+ {
+ Bundle cmpnBundle = context.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar"));
+ try
+ {
+ Bundle logBundle = context.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar"));
+ try
+ {
+ logBundle.start();
+
+ Bundle bundle = context.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ try
+ {
+ bundle.start();
+
+ // The bundle activator is expected to set this property
+ String result = System.getProperty(bundle.getSymbolicName());
+ assertNotNull("Result property not null", result);
+
+ assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
+ assertTrue("getService", result.indexOf("getService") > 0);
+ assertTrue("addingService", result.indexOf("addingService") > 0);
+ }
+ finally
+ {
+ bundle.uninstall();
+ }
+ }
+ finally
+ {
+ logBundle.uninstall();
+ }
+ }
+ finally
+ {
+ cmpnBundle.uninstall();
+ }
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA (from rev 102678, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleActivator.java 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleActivator.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -19,7 +19,7 @@
* 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.integration.simple.bundleA;
+package org.jboss.test.osgi.simple.bundleA;
//$Id$
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -1,44 +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.integration.simple.bundleA;
-
-//$Id$
-
-import org.osgi.framework.BundleContext;
-
-/**
- * A SimpleService
- *
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class SimpleService
-{
- public SimpleService(BundleContext context)
- {
- }
-
- public String echo(String msg)
- {
- return msg;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java (from rev 102690, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleA/SimpleService.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,44 @@
+/*
+ * 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.simple.bundleA;
+
+//$Id$
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * A SimpleService
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleService
+{
+ public SimpleService(BundleContext context)
+ {
+ }
+
+ public String echo(String msg)
+ {
+ return msg;
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB (from rev 102678, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB)
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -1,79 +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.integration.simple.bundleB;
-
-//$Id$
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A Service Activator
- *
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class SimpleLogServiceActivator implements BundleActivator
-{
- public void start(BundleContext context)
- {
- final String symName = context.getBundle().getSymbolicName();
- addMessage(symName, "startBundleActivator");
-
- ServiceReference sref = context.getServiceReference(LogService.class.getName());
- if (sref != null)
- {
- LogService service = (LogService)context.getService(sref);
- String message = "getService: " + service.getClass().getName();
- addMessage(symName, message);
- }
-
- ServiceTracker tracker = new ServiceTracker(context, LogService.class.getName(), null)
- {
- @Override
- public Object addingService(ServiceReference reference)
- {
- LogService service = (LogService)super.addingService(reference);
- String message = "addingService: " + service.getClass().getName();
- addMessage(symName, message);
- return service;
- }
- };
- tracker.open();
- }
-
- public void stop(BundleContext context)
- {
- String symName = context.getBundle().getSymbolicName();
- addMessage(symName, "stopBundleActivator");
- }
-
- private void addMessage(String propName, String message)
- {
- String previous = System.getProperty(propName, ":");
- System.setProperty(propName, previous + message + ":");
- //System.out.println(message);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java (from rev 102690, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/java/org/jboss/test/osgi/simple/bundleB/SimpleLogServiceActivator.java 2010-03-23 11:38:05 UTC (rev 102773)
@@ -0,0 +1,79 @@
+/*
+ * 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.simple.bundleB;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleLogServiceActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ final String symName = context.getBundle().getSymbolicName();
+ addMessage(symName, "startBundleActivator");
+
+ ServiceReference sref = context.getServiceReference(LogService.class.getName());
+ if (sref != null)
+ {
+ LogService service = (LogService)context.getService(sref);
+ String message = "getService: " + service.getClass().getName();
+ addMessage(symName, message);
+ }
+
+ ServiceTracker tracker = new ServiceTracker(context, LogService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ LogService service = (LogService)super.addingService(reference);
+ String message = "addingService: " + service.getClass().getName();
+ addMessage(symName, message);
+ return service;
+ }
+ };
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ String symName = context.getBundle().getSymbolicName();
+ addMessage(symName, "stopBundleActivator");
+ }
+
+ private void addMessage(String propName, String message)
+ {
+ String previous = System.getProperty(propName, ":");
+ System.setProperty(propName, previous + message + ":");
+ //System.out.println(message);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple (from rev 102678, projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/simple)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple-logservice.bnd
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/simple/simple-logservice.bnd 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple-logservice.bnd 2010-03-23 11:38:05 UTC (rev 102773)
@@ -2,5 +2,5 @@
Bundle-SymbolicName: simple-logservice-bundle
-Bundle-Activator: org.jboss.test.osgi.integration.simple.bundleB.SimpleLogServiceActivator
-Private-Package: org.jboss.test.osgi.integration.simple.bundleB
+Bundle-Activator: org.jboss.test.osgi.simple.bundleB.SimpleLogServiceActivator
+Private-Package: org.jboss.test.osgi.simple.bundleB
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple.bnd
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/integration/simple/simple.bnd 2010-03-21 05:05:14 UTC (rev 102678)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/bundle/src/test/resources/simple/simple.bnd 2010-03-23 11:38:05 UTC (rev 102773)
@@ -2,5 +2,5 @@
Bundle-SymbolicName: simple-bundle
-Bundle-Activator: org.jboss.test.osgi.integration.simple.bundleA.SimpleActivator
-Export-Package: org.jboss.test.osgi.integration.simple.bundleA
+Bundle-Activator: org.jboss.test.osgi.simple.bundleA.SimpleActivator
+Export-Package: org.jboss.test.osgi.simple.bundleA
More information about the jboss-cvs-commits
mailing list