[jboss-cvs] JBossAS SVN: r92821 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/src: test/java/org/jboss/test/osgi/bundle/test and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 26 05:48:25 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-08-26 05:48:25 -0400 (Wed, 26 Aug 2009)
New Revision: 92821
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java
Log:
[JBOSGI-138] Proper system BundleContext implementation
Throw NIE and add test stubs
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java 2009-08-26 07:12:08 UTC (rev 92820)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java 2009-08-26 09:48:25 UTC (rev 92821)
@@ -63,7 +63,6 @@
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.BundleListener;
-import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
@@ -405,8 +404,7 @@
return null;
}
- @SuppressWarnings("unchecked")
- public Class loadClass(String name) throws ClassNotFoundException
+ public Class<?> loadClass(String name) throws ClassNotFoundException
{
checkInstalled();
checkAdminPermission(AdminPermission.CLASS);
@@ -758,7 +756,7 @@
String bundleActivatorClassName = metaData.getBundleActivator();
if (bundleActivatorClassName != null)
{
- ClassLoader classLoader = unit.getClassLoader();
+ ClassLoader classLoader = getDeploymentUnit().getClassLoader();
DeploymentControllerContext deploymentControllerContext = getDeploymentUnit().getAttachment(ControllerContext.class.getName(),
DeploymentControllerContext.class);
@@ -771,7 +769,7 @@
if (result instanceof BundleActivator == false)
throw new BundleException(bundleActivatorClassName + " is not an implementation of " + BundleActivator.class.getName());
BundleActivator bundleActivator = (BundleActivator)result;
- unit.addAttachment(BundleActivator.class, bundleActivator);
+ getDeploymentUnit().addAttachment(BundleActivator.class, bundleActivator);
bundleActivator.start(bundleContext);
}
@@ -823,7 +821,7 @@
Throwable rethrow = null;
try
{
- BundleActivator bundleActivator = unit.getAttachment(BundleActivator.class);
+ BundleActivator bundleActivator = getDeploymentUnit().getAttachment(BundleActivator.class);
BundleContext bundleContext = this.bundleContext;
if (bundleActivator != null && bundleContext != null)
{
@@ -874,7 +872,7 @@
if (getState() == STOPPING)
changeState(RESOLVED);
bundleContext = null;
- unit.removeAttachment(BundleActivator.class);
+ getDeploymentUnit().removeAttachment(BundleActivator.class);
}
if (rethrow != null)
@@ -1226,7 +1224,7 @@
*
* @throws IllegalStateException when the bundle is not installed
*/
- private void checkInstalled()
+ protected void checkInstalled()
{
if ((getState() & Bundle.UNINSTALLED) != 0)
throw new IllegalStateException("Bundle " + getCanonicalName() + " is not installed");
@@ -1238,7 +1236,7 @@
* @return the bundle context
* @throws IllegalArgumentException when the context is no longer valid
*/
- private synchronized BundleContext checkValidBundleContext()
+ protected synchronized BundleContext checkValidBundleContext()
{
BundleContext result = this.bundleContext;
if (result == null)
@@ -1252,7 +1250,7 @@
* @param what what permission to check
* @throws SecurityException when the caller does not have the AdminPermission and a security manager is installed
*/
- private void checkAdminPermission(String what)
+ protected void checkAdminPermission(String what)
{
SecurityManager sm = System.getSecurityManager();
if (sm != null)
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java 2009-08-26 07:12:08 UTC (rev 92820)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiSystemBundle.java 2009-08-26 09:48:25 UTC (rev 92821)
@@ -23,7 +23,9 @@
import java.io.InputStream;
+import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.metadata.OSGiMetaData;
+import org.osgi.framework.AdminPermission;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -51,6 +53,12 @@
return Constants.SYSTEM_BUNDLE_LOCATION;
}
+ public Class<?> loadClass(String name) throws ClassNotFoundException
+ {
+ // [JBOSGI-138] Proper system BundleContext implementation
+ throw new NotImplementedException();
+ }
+
@Override
public void stop(int options) throws BundleException
{
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java 2009-08-26 07:12:08 UTC (rev 92820)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java 2009-08-26 09:48:25 UTC (rev 92821)
@@ -121,4 +121,34 @@
{
assertEquals(Constants.SYSTEM_BUNDLE_LOCATION, systemBundle.getLocation());
}
+
+ public void testGetEntry()
+ {
+ // TODO [JBOSGI-138] Proper system BundleContext implementation
+ }
+
+ public void testGetEntryPath()
+ {
+ // TODO [JBOSGI-138] Proper system BundleContext implementation
+ }
+
+ public void testFindEntries()
+ {
+ // TODO [JBOSGI-138] Proper system BundleContext implementation
+ }
+
+ public void testLoadClass()
+ {
+ // TODO [JBOSGI-138] Proper system BundleContext implementation
+ }
+
+ public void testGetResource()
+ {
+ // TODO [JBOSGI-138] Proper system BundleContext implementation
+ }
+
+ public void testGetResources()
+ {
+ // TODO [JBOSGI-138] Proper system BundleContext implementation
+ }
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java 2009-08-26 07:12:08 UTC (rev 92820)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java 2009-08-26 09:48:25 UTC (rev 92821)
@@ -24,14 +24,17 @@
//$Id$
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.jboss.osgi.spi.testing.OSGiBundle;
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.jboss.osgi.spi.util.ServiceLoader;
+import org.jboss.test.osgi.integration.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;
@@ -55,12 +58,22 @@
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);
+
+ ServiceReference sref = bndContext.getServiceReference(SimpleService.class.getName());
+ assertNotNull("ServiceReference not null", sref);
+
+ // [TODO] getServiceReference from system context
+ //sref = sysContext.getServiceReference(SimpleService.class.getName());
+ //assertNotNull("ServiceReference not null", sref);
+
bundle.uninstall();
assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
More information about the jboss-cvs-commits
mailing list