[jboss-cvs] JBossAS SVN: r92578 - in projects/jboss-osgi: trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 19 10:33:05 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-08-19 10:33:04 -0400 (Wed, 19 Aug 2009)
New Revision: 92578

Added:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java
Removed:
   projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/
Modified:
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
   projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java
Log:
All examples good when run one-by-one. Cleanup issue.

Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java (from rev 92562, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java	                        (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,159 @@
+/*
+ * 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.osgi.spi.util;
+
+//$Id$
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.ServiceEvent;
+
+/**
+ * String representation for common OSGi Constants
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 04-Mar-2009
+ */
+public abstract class ConstantsHelper 
+{
+   /**
+    * Return the string representation of a {@link Bundle} state
+    */
+   public static String bundleState(int bundleState)
+   {
+      String retState = "[" + bundleState + "]";
+      if (Bundle.UNINSTALLED == bundleState)
+         retState = "UNINSTALLED";
+      else if (Bundle.INSTALLED == bundleState)
+         retState = "INSTALLED";
+      else if (Bundle.RESOLVED == bundleState)
+         retState = "RESOLVED";
+      else if (Bundle.STARTING == bundleState)
+         retState = "STARTING";
+      else if (Bundle.STOPPING == bundleState)
+         retState = "STOPPING";
+      else if (Bundle.ACTIVE == bundleState)
+         retState = "ACTIVE";
+      return retState;
+   }
+   
+   /**
+    * Return the string representation of a {@link BundleEvent} type
+    */
+   public static String bundleEvent(int eventType)
+   {
+      String retType = "[" + eventType + "]";
+      if (BundleEvent.INSTALLED == eventType)
+         retType = "INSTALLED";
+      else if (BundleEvent.LAZY_ACTIVATION == eventType)
+         retType = "LAZY_ACTIVATION";
+      else if (BundleEvent.RESOLVED == eventType)
+         retType = "RESOLVED";
+      else if (BundleEvent.STARTING == eventType)
+         retType = "STARTING";
+      else if (BundleEvent.STARTED == eventType)
+         retType = "STARTED";
+      else if (BundleEvent.STOPPING == eventType)
+         retType = "STOPPING";
+      else if (BundleEvent.STOPPED == eventType)
+         retType = "STOPPED";
+      else if (BundleEvent.UNINSTALLED == eventType)
+         retType = "UNINSTALLED";
+      else if (BundleEvent.UNRESOLVED == eventType)
+         retType = "UNRESOLVED";
+      else if (BundleEvent.UPDATED == eventType)
+         retType = "UPDATED";
+      return retType;
+   }
+   
+   /**
+    * Return the string representation of a {@link ServiceEvent} type
+    */
+   public static String serviceEvent(int eventType)
+   {
+      String retType = "[" + eventType + "]";
+      if (ServiceEvent.REGISTERED == eventType)
+         retType = "REGISTERED";
+      else if (ServiceEvent.UNREGISTERING == eventType)
+         retType = "UNREGISTERING";
+      else if (ServiceEvent.MODIFIED == eventType)
+         retType = "MODIFIED";
+      else if (ServiceEvent.MODIFIED_ENDMATCH == eventType)
+         retType = "MODIFIED_ENDMATCH";
+      return retType;
+   }
+   
+   public static String frameworkEvent(int eventType)
+   {
+      String retType = "[" + eventType + "]";
+      if (FrameworkEvent.ERROR == eventType)
+         retType = "ERROR";
+      else if (FrameworkEvent.INFO == eventType)
+         retType = "INFO";
+      else if (FrameworkEvent.PACKAGES_REFRESHED == eventType)
+         retType = "PACKAGES_REFRESHED";
+      else if (FrameworkEvent.STARTED == eventType)
+         retType = "STARTED";
+      else if (FrameworkEvent.STARTLEVEL_CHANGED == eventType)
+         retType = "STARTLEVEL_CHANGED";
+      else if (FrameworkEvent.STOPPED == eventType)
+         retType = "STOPPED";
+      else if (FrameworkEvent.STOPPED_BOOTCLASSPATH_MODIFIED == eventType)
+         retType = "STOPPED_BOOTCLASSPATH_MODIFIED";
+      else if (FrameworkEvent.STOPPED_UPDATE == eventType)
+         retType = "STOPPED_UPDATE";
+      else if (FrameworkEvent.WAIT_TIMEDOUT == eventType)
+         retType = "WAIT_TIMEDOUT";
+      else if (FrameworkEvent.WARNING == eventType)
+         retType = "WARNING";
+      return retType;
+   }
+   
+   /**
+    * Return the string representation of a LogService level
+    */
+   public static String logLevel(int level)
+   {
+      String logLevel = "[" + level + "]";
+      switch (level)
+      {
+         // LogService.LOG_DEBUG:
+         case 0x4:
+            logLevel = "DEBUG";
+            break;
+         // LogService.LOG_INFO:
+         case 0x3:
+            logLevel = "INFO";
+            break;
+         // LogService.LOG_WARNING:
+         case 0x2:
+            logLevel = "WARN";
+            break;
+         // LogService.LOG_ERROR
+         case 0x1:
+            logLevel = "ERROR";
+            break;
+      }
+      return logLevel;
+   }
+}

Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -1,114 +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.osgi.spi.util;
-
-//$Id$
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-
-/**
- * String representation for common OSGi Constants
- * 
- * @author thomas.diesler at jboss.com
- * @since 04-Mar-2009
- */
-public abstract class OSGiConstantsHelper 
-{
-   /**
-    * Return the string representation of a {@link Bundle} state
-    */
-   public static String bundleState(int bundleState)
-   {
-      String retState = "[" + bundleState + "]";
-      if (Bundle.UNINSTALLED == bundleState)
-         retState = "UNINSTALLED";
-      else if (Bundle.INSTALLED == bundleState)
-         retState = "INSTALLED";
-      else if (Bundle.RESOLVED == bundleState)
-         retState = "RESOLVED";
-      else if (Bundle.STARTING == bundleState)
-         retState = "STARTING";
-      else if (Bundle.STOPPING == bundleState)
-         retState = "STOPPING";
-      else if (Bundle.ACTIVE == bundleState)
-         retState = "ACTIVE";
-      return retState;
-   }
-   
-   /**
-    * Return the string representation of a {@link BundleEvent} type
-    */
-   public static String bundleEvent(int eventType)
-   {
-      String retType = "[" + eventType + "]";
-      if (BundleEvent.INSTALLED == eventType)
-         retType = "INSTALLED";
-      else if (BundleEvent.LAZY_ACTIVATION == eventType)
-         retType = "LAZY_ACTIVATION";
-      else if (BundleEvent.RESOLVED == eventType)
-         retType = "RESOLVED";
-      else if (BundleEvent.STARTING == eventType)
-         retType = "STARTING";
-      else if (BundleEvent.STARTED == eventType)
-         retType = "STARTED";
-      else if (BundleEvent.STOPPING == eventType)
-         retType = "STOPPING";
-      else if (BundleEvent.STOPPED == eventType)
-         retType = "STOPPED";
-      else if (BundleEvent.UNINSTALLED == eventType)
-         retType = "UNINSTALLED";
-      else if (BundleEvent.UNRESOLVED == eventType)
-         retType = "UNRESOLVED";
-      else if (BundleEvent.UPDATED == eventType)
-         retType = "UPDATED";
-      return retType;
-   }
-   
-   /**
-    * Return the string representation of a LogService level
-    */
-   public static String logLevel(int level)
-   {
-      String logLevel = "[" + level + "]";
-      switch (level)
-      {
-         // LogService.LOG_DEBUG:
-         case 0x4:
-            logLevel = "DEBUG";
-            break;
-         // LogService.LOG_INFO:
-         case 0x3:
-            logLevel = "INFO";
-            break;
-         // LogService.LOG_WARNING:
-         case 0x2:
-            logLevel = "WARN";
-            break;
-         // LogService.LOG_ERROR
-         case 0x1:
-            logLevel = "ERROR";
-            break;
-      }
-      return logLevel;
-   }
-}

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -25,7 +25,7 @@
 import java.net.URL;
 import java.util.Enumeration;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+// $Id: $
 
 /**
  * An abstraction of a bundle class loader.

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -24,7 +24,7 @@
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 /**
  * An abstraction of a bundle event manager.
@@ -39,4 +39,6 @@
    void addBundleListener(BundleListener listener);
 
    void removeBundleListener(BundleListener listener);
+
+   void setEnabled(boolean enabled);
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,11 @@
  */
 package org.jboss.osgi.jbossmc.api;
 
+// $Id: $
+
+import org.jboss.virtual.VirtualFile;
 import org.osgi.framework.Bundle;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
-
-
 /**
  * An abstraction of a bundle factory.
  * 
@@ -34,5 +34,9 @@
  */
 public interface BundleFactory 
 {
+   String getVirtualLocation(String location);
+   
+   VirtualFile getVirtualFile(String location);
+   
    Bundle createBundle(String location);
 }
\ No newline at end of file

Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,39 @@
+/*
+ * 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.osgi.jbossmc.api;
+
+// $Id: $
+
+import java.io.File;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstraction of a bundle persistent storage system.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundlePersistentStorage 
+{
+   File getDataFile(Bundle bundle, String filename);
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
  */
 package org.jboss.osgi.jbossmc.api;
 
-// $Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.List;
 
@@ -35,11 +35,13 @@
  */
 public interface BundleRegistry 
 {
-   long installBundle(Bundle bundle);
+   long registerBundle(Bundle bundle);
    
-   void uninstallBundle(Bundle bundle);
+   void unregisterBundle(Bundle bundle);
 
    Bundle getBundleById(long id);
 
+   Bundle getBundleByLocation(String location);
+   
    List<Bundle> getBundles();
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,12 +21,11 @@
  */
 package org.jboss.osgi.jbossmc.api;
 
+// $Id: $
+
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
-
-
 /**
  * An abstraction of a bundle resolver.
  * 

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
  */
 package org.jboss.osgi.jbossmc.api;
 
-// $Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
@@ -39,4 +39,6 @@
    void addFrameworkListener(FrameworkListener listener);
 
    void removeFrameworkListener(FrameworkListener listener);
+
+   void setEnabled(boolean enabled);
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,11 @@
  */
 package org.jboss.osgi.jbossmc.api;
 
+// $Id: $
+
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceListener;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
-
 /**
  * An abstraction of a service event manager.
  * 
@@ -41,4 +41,6 @@
    void addServiceListener(ServiceListener listener, String filter);
 
    void removeServiceListener(ServiceListener listener);
+   
+   void setEnabled(boolean enabled);
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,12 @@
  */
 package org.jboss.osgi.jbossmc.api;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.Dictionary;
 
 import org.osgi.framework.Bundle;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
@@ -37,13 +38,17 @@
  */
 public interface ServiceRegistry 
 {
-   ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties);
+   ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties);
    
-   ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties);
+   ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties);
 
+   void unregisterService(ServiceRegistration registration);
+
    ServiceReference getServiceReference(String clazz);
 
-   ServiceReference[] getServiceReferences(String clazz, String filter);
+   ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
 
    Object getService(Bundle bundle, ServiceReference sref);
+
+   boolean ungetService(Bundle bundle, ServiceReference reference);
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.io.IOException;
 import java.net.URL;

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -25,12 +25,16 @@
 
 import java.io.File;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Dictionary;
+import java.util.EventListener;
 import java.util.List;
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.jbossmc.api.BundleEventManager;
 import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
 import org.jboss.osgi.jbossmc.api.BundleRegistry;
 import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
 import org.jboss.osgi.jbossmc.api.ServiceEventManager;
@@ -38,6 +42,7 @@
 import org.jboss.osgi.spi.NotImplementedException;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.BundleListener;
 import org.osgi.framework.Filter;
@@ -62,6 +67,10 @@
    private FrameworkImpl framework;
    private Bundle bundle;
    
+   private List<EventListener> registeredListeners = new ArrayList<EventListener>();
+   private List<ServiceRegistration> registeredServices = new ArrayList<ServiceRegistration>();
+   private List<ServiceReference> usedServices = new ArrayList<ServiceReference>();
+   
    public BundleContextImpl(FrameworkImpl framework, Bundle bundle)
    {
       this.framework = framework;
@@ -77,42 +86,49 @@
    {
       BundleEventManager eventManager = getFramework().getBundleEventManager();
       eventManager.addBundleListener(listener);
+      registeredListeners.add(listener);
    }
 
    public void removeBundleListener(BundleListener listener)
    {
       BundleEventManager eventManager = getFramework().getBundleEventManager();
       eventManager.removeBundleListener(listener);
+      registeredListeners.remove(listener);
    }
 
    public void addFrameworkListener(FrameworkListener listener)
    {
       FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
       eventManager.addFrameworkListener(listener);
+      registeredListeners.add(listener);
    }
 
    public void removeFrameworkListener(FrameworkListener listener)
    {
       FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
       eventManager.removeFrameworkListener(listener);
+      registeredListeners.remove(listener);
    }
 
    public void addServiceListener(ServiceListener listener)
    {
       ServiceEventManager eventManager = getFramework().getServiceEventManager();
       eventManager.addServiceListener(listener);
+      registeredListeners.add(listener);
    }
 
    public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
    {
       ServiceEventManager eventManager = getFramework().getServiceEventManager();
       eventManager.addServiceListener(listener, filter);
+      registeredListeners.add(listener);
    }
 
    public void removeServiceListener(ServiceListener listener)
    {
       ServiceEventManager eventManager = getFramework().getServiceEventManager();
       eventManager.removeServiceListener(listener);
+      registeredListeners.remove(listener);
    }
 
    public Filter createFilter(String filter) throws InvalidSyntaxException
@@ -141,13 +157,13 @@
 
    public File getDataFile(String filename)
    {
-      // [TODO] BundleContext.getDataFile(String filename)
-      throw new NotImplementedException();
+      BundlePersistentStorage bundleStorage = getFramework().getBundlePersistentStorage();
+      return bundleStorage.getDataFile(bundle, filename);
    }
 
    public String getProperty(String key)
    {
-      String property = getFramework().getProperty(key);
+      String property = (String)getFramework().getProperty(key);
       if (property == null)
          property = System.getProperty(key);
       
@@ -157,9 +173,20 @@
    public Object getService(ServiceReference reference)
    {
       ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
-      return serviceRegistry.getService(getBundle(), reference);
+      Object service = serviceRegistry.getService(bundle, reference);
+      if (service != null)
+      {
+         usedServices.add(reference);
+      }
+      return service;
    }
 
+   public boolean ungetService(ServiceReference reference)
+   {
+      ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+      return serviceRegistry.ungetService(bundle, reference);
+   }
+   
    public ServiceReference getServiceReference(String clazz)
    {
       ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
@@ -180,14 +207,30 @@
 
    public Bundle installBundle(String location) throws BundleException
    {
-      // Create the bundle from the location
+      // Convert location to a virtual file URL
       BundleFactory bundleFactory = getFramework().getBundleFactory();
-      Bundle bundle = bundleFactory.createBundle(location);
+      location = bundleFactory.getVirtualLocation(location); 
       
-      // Register the bundle 
+      // 1.  If a bundle containing the same location identifier is already installed, the Bundle object for that bundle is returned.
       BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
-      bundleRegistry.installBundle(bundle);
+      Bundle bundle = bundleRegistry.getBundleByLocation(location);
+      if (bundle != null)
+         return bundle;
       
+      // 2. The bundle's content is read from the input stream. If this fails, a BundleException is thrown.
+      // 3. The bundle's associated resources are allocated. The associated resources minimally consist of a unique identifier and a persistent storage area if the platform has file system support. 
+      bundle = bundleFactory.createBundle(location);
+      bundleRegistry.registerBundle(bundle);
+      
+      // 4. The bundle's state is set to INSTALLED.
+      BundleImpl bundleImpl = (BundleImpl)bundle;
+      bundleImpl.setState(Bundle.INSTALLED);
+      
+      // 5. A bundle event of type BundleEvent.INSTALLED is fired.
+      BundleEventManager eventManager = getFramework().getBundleEventManager();
+      eventManager.fireBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle));
+      
+      // 6. The Bundle object for the newly or previously installed bundle is returned. 
       return bundle;
    }
 
@@ -197,21 +240,83 @@
       throw new NotImplementedException();
    }
 
+   @SuppressWarnings("unchecked")
    public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
    {
       ServiceRegistry registry = getFramework().getServiceRegistry();
-      return registry.registerService(getBundle(), clazzes, service, properties);
+      ServiceRegistration sreg = registry.registerService(bundle, clazzes, service, properties);
+      registeredServices.add(sreg);
+      return sreg;
    }
 
+   @SuppressWarnings("unchecked")
    public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
    {
       ServiceRegistry registry = getFramework().getServiceRegistry();
-      return registry.registerService(getBundle(), clazz, service, properties);
+      ServiceRegistration sreg = registry.registerService(bundle, clazz, service, properties);
+      registeredServices.add(sreg);
+      return sreg;
    }
 
-   public boolean ungetService(ServiceReference reference)
+   public void releaseRegisteredListeners()
    {
-      // [TODO] BundleContext.ungetService
-      throw new NotImplementedException();
+      ArrayList<EventListener> reverseList = new ArrayList<EventListener>(registeredListeners);
+      Collections.reverse(reverseList);
+      
+      for (EventListener listener : reverseList)
+      {
+         try
+         {
+            if (listener instanceof FrameworkListener)
+               removeFrameworkListener((FrameworkListener)listener);
+            else if (listener instanceof ServiceListener)
+               removeServiceListener((ServiceListener)listener);
+            else if (listener instanceof BundleListener)
+               removeBundleListener((BundleListener)listener);
+         }
+         catch (Exception ex)
+         {
+            log.error("Cannot release registered listener", ex);
+         }
+      }
+      registeredListeners.clear();
    }
+
+   public void releaseRegisteredServices()
+   {
+      ArrayList<ServiceRegistration> reverseList = new ArrayList<ServiceRegistration>(registeredServices);
+      Collections.reverse(reverseList);
+      
+      for (ServiceRegistration sreg : reverseList)
+      {
+         try
+         {
+            sreg.unregister();
+         }
+         catch (Exception ex)
+         {
+            log.error("Cannot release registered service", ex);
+         }
+      }
+      registeredServices.clear();
+   }
+
+   public void releaseUsedServices()
+   {
+      ArrayList<ServiceReference> reverseList = new ArrayList<ServiceReference>(usedServices);
+      Collections.reverse(reverseList);
+      
+      for (ServiceReference sref : reverseList)
+      {
+         try
+         {
+            ungetService(sref);
+         }
+         catch (Exception ex)
+         {
+            log.error("Cannot release used service", ex);
+         }
+      }
+      usedServices.clear();
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,13 +21,14 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.ArrayList;
 import java.util.List;
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.spi.util.ConstantsHelper;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
 
@@ -42,16 +43,32 @@
    // Provide logging
    final Logger log = Logger.getLogger(BundleEventManagerImpl.class);
    
-   private FrameworkImpl framework;
    private List<BundleListener> listeners = new ArrayList<BundleListener>();
+   private boolean enabled = true;
 
    public BundleEventManagerImpl(FrameworkImpl framework)
    {
-      this.framework = framework;
+      
    }
 
+   public boolean isEnabled()
+   {
+      return enabled;
+   }
+
+   public void setEnabled(boolean enabled)
+   {
+      this.enabled = enabled;
+   }
+
    public void fireBundleEvent(BundleEvent event)
    {
+      if (enabled == false)
+         return;
+      
+      String typeStr = ConstantsHelper.bundleEvent(event.getType());
+      log.debug("BundleEvent " + typeStr + " " + event.getSource());
+      
       // [TODO] When a BundleEvent is fired, it is asynchronously delivered to a BundleListener
       
       for (BundleListener listener : new ArrayList<BundleListener>(listeners))

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.io.IOException;
 import java.net.URL;
@@ -52,6 +52,28 @@
 
    public Bundle createBundle(String location)
    {
+      VirtualFile vfsRoot = getVirtualFile(location);
+      BundleImpl bundle = new BundleImpl(vfsRoot);
+      bundle.setBundleContext(new BundleContextImpl(framework, bundle));
+      return bundle;
+   }
+
+   public String getVirtualLocation(String location)
+   {
+      try
+      {
+         VirtualFile vFile = getVirtualFile(location);
+         URL locationURL = vFile.toURL();
+         return locationURL.toExternalForm();
+      }
+      catch (Exception ex)
+      {
+         throw new IllegalStateException("Cannot obtain virtual bundle location", ex);
+      }
+   }
+   
+   public VirtualFile getVirtualFile(String location)
+   {
       VirtualFile vfsRoot;
       try
       {
@@ -62,9 +84,6 @@
       {
          throw new IllegalArgumentException("Invalid bundle location URL: " + location);
       }
-      
-      BundleImpl bundle = new BundleImpl(vfsRoot);
-      bundle.setBundleContext(new BundleContextImpl(framework, bundle));
-      return bundle;
+      return vfsRoot;
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -26,10 +26,13 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.security.cert.X509Certificate;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
+import java.util.Vector;
 import java.util.jar.Attributes;
 import java.util.jar.Manifest;
 
@@ -40,11 +43,15 @@
 import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
 import org.jboss.osgi.spi.NotImplementedException;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
 
@@ -66,13 +73,13 @@
    private Dictionary<String, String> headers;
    private BundleLifecycle bundleLifecycle;
    private BundleClassLoader classLoader;
-   private String toStringValue;
-
+   private String toStringCache;
+   
    public BundleImpl()
    {
       // ctor used by the framework
       // [TODO] remove when we have a VFS root for the framework
-      
+
       this.bundleLifecycle = new BundleLifecycleImpl(this);
    }
 
@@ -183,23 +190,100 @@
 
    public URL getEntry(String path)
    {
-      // [TODO] Bundle.getEntry(String path)
-      throw new NotImplementedException();
+      assertNotUninstalled();
+
+      URL entryURL = null;
+      try
+      {
+         VirtualFile child = vFile.getChild(path);
+         if (child != null)
+            entryURL = child.toURL();
+      }
+      catch (Exception ex)
+      {
+         // ignore
+      }
+      return entryURL;
    }
 
-   public Enumeration<URL> getEntryPaths(String path)
+   public Enumeration<String> getEntryPaths(String path)
    {
-      // [TODO] Bundle.getEntryPaths(String path)
-      throw new NotImplementedException();
+      assertNotUninstalled();
+
+      Vector<String> paths = new Vector<String>();
+      try
+      {
+         VirtualFile child = vFile.getChild(path);
+         if (child != null)
+         {
+            for (VirtualFile vf : child.getChildrenRecursively())
+            {
+               String entry = vf.getPathName();
+               if (vf.isLeaf() == false)
+                  entry = entry + "/";
+               
+               paths.add(entry);
+            }
+         }
+      }
+      catch (Exception ex)
+      {
+         // ignore
+      }
+      return paths.size() > 0 ? paths.elements() : null;
    }
 
-   public Enumeration findEntries(String path, String filePattern, boolean recurse)
+   public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
    {
-      // [TODO] Bundle.findEntries(String path, String filePattern, boolean recurse)
-      throw new NotImplementedException();
+      assertNotUninstalled();
+
+      // If null is specified, this is equivalent to "*" and matches all files.
+      if (filePattern == null)
+         filePattern = "*";
+
+      final Filter filter;
+      try
+      {
+         filter = FrameworkUtil.createFilter("(name=" + filePattern + ")");
+      }
+      catch (InvalidSyntaxException e)
+      {
+         throw new IllegalArgumentException("Cannot create filter from: " + filePattern);
+      }
+      
+      final Hashtable<String, String> dictionary = new Hashtable<String, String>();
+      VirtualFileFilter vfFilter = new VirtualFileFilter()
+      {
+         public boolean accepts(VirtualFile file)
+         {
+            String name = file.getName();
+            dictionary.put("name", name);
+            boolean match = filter.match(dictionary);
+            return match;
+         }
+      };
+
+      Vector<URL> paths = new Vector<URL>();
+      try
+      {
+         VirtualFile child = vFile.getChild(path);
+         if (child != null)
+         {
+            List<VirtualFile> matchedFiles = (recurse ? child.getChildrenRecursively(vfFilter) : child.getChildren(vfFilter));
+            for (VirtualFile vf : matchedFiles)
+            {
+               paths.add(vf.toURL());
+            }
+         }
+      }
+      catch (Exception ex)
+      {
+         // ignore
+      }
+      return paths.size() > 0 ? paths.elements() : null;
    }
 
-   public Dictionary getHeaders()
+   public Dictionary<String, String> getHeaders()
    {
       if (headers == null)
       {
@@ -223,7 +307,7 @@
       return headers;
    }
 
-   public Dictionary getHeaders(String locale)
+   public Dictionary<String, String> getHeaders(String locale)
    {
       // [TODO] Bundle.getHeaders(String locale)
       throw new NotImplementedException();
@@ -257,7 +341,7 @@
       return getClassLoader().getResources(name);
    }
 
-   public Map getSignerCertificates(int signersType)
+   public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType)
    {
       // [TODO] Bundle.getSignerCertificates(int signersType)
       throw new NotImplementedException();
@@ -312,16 +396,34 @@
       return contextImpl.getFramework();
    }
 
+   private void assertNotUninstalled()
+   {
+      if (state == Bundle.UNINSTALLED)
+         throw new IllegalStateException("Bundle already uninstalled: " + this);
+   }
+
    @Override
+   public boolean equals(Object obj)
+   {
+      if (!(obj instanceof BundleImpl))
+         return false;
+
+      BundleImpl other = (BundleImpl)obj;
+      return other.getBundleId() == getBundleId();
+   }
+
+   @Override
+   public int hashCode()
+   {
+      return new Long(getBundleId()).hashCode();
+   }
+
+   @Override
    public String toString()
    {
-      if (toStringValue == null)
-      {
-         long id = getBundleId();
-         String name = getSymbolicName();
-         Version version = getVersion();
-         toStringValue = "[id=" + id + ",name=" + name + ",version=" + version + "]";
-      }
-      return toStringValue;
+      if (toStringCache == null || getBundleId() == 0)
+         toStringCache = "[" + getBundleId() + "] " + getSymbolicName() + "-" + getVersion();
+
+      return toStringCache;
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -59,20 +59,23 @@
    {
       // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
       if (getState() == Bundle.UNINSTALLED)
-         throw new IllegalStateException("Bundle already uninstalled: " + this);
+         throw new IllegalStateException("Bundle already uninstalled: " + bundle);
 
       // [TODO] Implement the optional Start Level service 
 
       // [TODO] If this bundle is in the process of being activated or deactivated then this method must wait 
       // for activation or deactivation to complete before continuing.
       if (getState() == Bundle.STARTING || getState() == Bundle.STARTING)
-         throw new IllegalStateException("Bundle already staring/stopping: " + this);
+         throw new IllegalStateException("Bundle already staring/stopping: " + bundle);
 
       // If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
       if (getState() != Bundle.RESOLVED)
       {
          BundleResolver resolver = getFramework().getBundleResolver();
          resolver.resolveBundle(bundle);
+         
+         BundleEventManager eventManager = getFramework().getBundleEventManager();
+         eventManager.fireBundleEvent(new BundleEvent(BundleEvent.RESOLVED, bundle));
       }
 
       // [TODO] Lazy bundle activation
@@ -101,11 +104,15 @@
             // A bundle event of type BundleEvent.STOPPING is fired
             eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
 
-            // [TODO] Any services registered by this bundle must be unregistered.
+            // Any services registered by this bundle must be unregistered.
+            BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
+            contextImpl.releaseRegisteredServices();
 
-            // [TODO] Any services used by this bundle must be released.
+            // Any services used by this bundle must be released.
+            contextImpl.releaseUsedServices();
 
-            // [TODO] Any listeners registered by this bundle must be removed.
+            // Any listeners registered by this bundle must be removed.
+            contextImpl.releaseRegisteredListeners();
 
             // This bundle's state is set to RESOLVED.
             setState(Bundle.RESOLVED);
@@ -121,22 +128,20 @@
       // If this bundle's state is UNINSTALLED, because this bundle was uninstalled while 
       // the BundleActivator.start was running 
       if (getState() == Bundle.UNINSTALLED)
-         throw new IllegalStateException("Bundle already uninstalled: " + this);
+         throw new IllegalStateException("Bundle already uninstalled: " + bundle);
 
       // This bundle's state is set to ACTIVE
       setState(Bundle.ACTIVE);
 
       // A bundle event of type BundleEvent.STARTED is fired
       eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTED, bundle));
-      
-      log.debug("Bundle STARTED " + bundle);
    }
 
    public void stop(int options) throws BundleException
    {
       // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
       if (getState() == Bundle.UNINSTALLED)
-         throw new IllegalStateException("Bundle already unistalled: " + this);
+         throw new IllegalStateException("Bundle already unistalled: " + bundle);
       
       // [TODO] 2. If this bundle is in the process of being activated or deactivated then this method must wait for activation or deactivation to complete
       
@@ -169,15 +174,19 @@
          }
       }
       
-      // [TODO] 8. Any services registered by this bundle must be unregistered.
+      // 8. Any services registered by this bundle must be unregistered.
+      BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
+      contextImpl.releaseRegisteredServices();
       
-      // [TODO] 9. Any services used by this bundle must be released.
+      // 9. Any services used by this bundle must be released.
+      contextImpl.releaseUsedServices();
       
-      // [TODO] 10. Any listeners registered by this bundle must be removed.
+      // 10. Any listeners registered by this bundle must be removed.
+      contextImpl.releaseRegisteredListeners();
       
       // 11. If this bundle's state is UNINSTALLED, because this bundle was uninstalled while the BundleActivator.stop method was running, a BundleException must be thrown.
       if (getState() == Bundle.UNINSTALLED)
-         throw new IllegalStateException("Bundle already unistalled: " + this);
+         throw new IllegalStateException("Bundle already unistalled: " + bundle);
       
       // 12. This bundle's state is set to RESOLVED.
       setState(Bundle.RESOLVED);
@@ -185,14 +194,21 @@
       // 13. A bundle event of type BundleEvent.STOPPED is fired.    
       eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
       
-      log.debug("Bundle STOPPED " + bundle);
+      // A BundleException must be thrown after completion of the remaining steps
+      if (activatorStopException != null)
+      {
+         if (activatorStopException instanceof BundleException)
+            throw (BundleException)activatorStopException;
+         
+         throw new BundleException("Exception in BundleActivator.stop()", activatorStopException);
+      }
    }
 
    public void uninstall() throws BundleException
    {
       // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
       if (getState() == Bundle.UNINSTALLED)
-         throw new IllegalStateException("Bundle already unistalled: " + this);
+         throw new IllegalStateException("Bundle already unistalled: " + bundle);
 
       // 2. If this bundle's state is ACTIVE, STARTING or STOPPING, this bundle is stopped as described in the Bundle.stop method. 
       if (getState() == Bundle.ACTIVE || getState() == Bundle.STARTING || getState() == Bundle.STOPPING)
@@ -218,11 +234,9 @@
 
       // 5. This bundle and any persistent storage area provided for this bundle by the Framework are removed.
       BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
-      bundleRegistry.uninstallBundle(bundle);
+      bundleRegistry.unregisterBundle(bundle);
 
       // [TODO] Any persistent storage area provided for this bundle are removed.
-      
-      log.debug("Bundle UNINSTALLED " + bundle);
    }
 
    private int getState()

Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,81 @@
+/*
+ * 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.osgi.jbossmc.framework;
+
+//$Id: $
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * A simple implementation of a BundleStorage
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundlePersistentStorageImpl implements BundlePersistentStorage
+{
+   // Provide logging
+   final Logger log = Logger.getLogger(BundlePersistentStorageImpl.class);
+   
+   private FrameworkImpl framework;
+
+   public BundlePersistentStorageImpl(FrameworkImpl framework)
+   {
+      this.framework = framework;
+   }
+
+   public File getDataFile(Bundle bundle, String filename)
+   {
+      File bundleDir = getBundleStorageDir(bundle);
+      File dataFile = new File(bundleDir.getAbsolutePath() + "/" + filename);
+      return dataFile;
+   }
+
+   private File getBundleStorageDir(Bundle bundle)
+   {
+      String dirName = (String)framework.getProperty(Constants.FRAMEWORK_STORAGE);
+      if (dirName == null)
+      {
+         try
+         {
+            File tmpFile = File.createTempFile("Constants.FRAMEWORK_STORAGE", null);
+            dirName = tmpFile.getParent();
+            tmpFile.delete();
+         }
+         catch (IOException ex)
+         {
+            throw new IllegalStateException("Cannot create temp storage file", ex);
+         }
+      }
+      
+      File bundleDir = new File(dirName + "/bundle-" + bundle.getBundleId());
+      if (bundleDir.exists() == false)
+         bundleDir.mkdirs();
+      return bundleDir;
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,10 +21,9 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -46,13 +45,13 @@
    final Logger log = Logger.getLogger(BundleRegistryImpl.class);
    
    private long globalId;
-   private Map<Long, Bundle> registry = new LinkedHashMap<Long, Bundle>();
+   private Map<String, Bundle> registry = new LinkedHashMap<String, Bundle>();
 
    public BundleRegistryImpl(FrameworkImpl framework)
    {
    }
 
-   public long installBundle(Bundle bundle)
+   public long registerBundle(Bundle bundle)
    {
       if (bundle == null)
          throw new IllegalArgumentException("Cannot install null bundle");
@@ -60,27 +59,39 @@
       BundleImpl bundleImpl = (BundleImpl)bundle;
       bundleImpl.setBundleId(globalId++);
       
-      Long bundleId = new Long(bundle.getBundleId());
-      registry.put(bundleId, bundle);
+      registry.put(bundle.getLocation(), bundle);
       
-      return bundleId;
+      return bundle.getBundleId();
    }
 
-   public void uninstallBundle(Bundle bundle)
+   public void unregisterBundle(Bundle bundle)
    {
       if (bundle == null)
          throw new IllegalArgumentException("Cannot uninstall null bundle");
       
-      Long bundleId = new Long(bundle.getBundleId());
-      if (registry.remove(bundleId) == null)
+      if (registry.remove(bundle.getLocation()) == null)
          throw new IllegalStateException("Cannot unregister bundle: " + bundle);
    }
 
    public Bundle getBundleById(long id)
    {
-      return registry.get(new Long(id));
+      Bundle bundle = null;
+      for (Bundle aux : new ArrayList<Bundle>(registry.values()))
+      {
+         if (id == aux.getBundleId())
+         {
+            bundle = aux;
+            break;
+         }
+      }
+      return bundle;
    }
 
+   public Bundle getBundleByLocation(String location)
+   {
+      return registry.get(location);
+   }
+
    public List<Bundle> getBundles()
    {
       ArrayList<Bundle> bundles = new ArrayList<Bundle>(registry.values());

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.jbossmc.api.BundleClassLoader;
@@ -40,11 +40,8 @@
    // Provide logging
    final Logger log = Logger.getLogger(BundleResolverImpl.class);
    
-   private FrameworkImpl framework;
-
    public BundleResolverImpl(FrameworkImpl framework)
    {
-      this.framework = framework;
    }
 
    public void resolveBundle(Bundle bundle) throws BundleException

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,13 +21,14 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.ArrayList;
 import java.util.List;
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.jboss.osgi.spi.util.ConstantsHelper;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 
@@ -42,16 +43,40 @@
    // Provide logging
    final Logger log = Logger.getLogger(FrameworkEventManagerImpl.class);
    
-   private FrameworkImpl framework;
    private List<FrameworkListener> listeners = new ArrayList<FrameworkListener>();
+   private boolean enabled = true;
 
    public FrameworkEventManagerImpl(FrameworkImpl framework)
    {
-      this.framework = framework;
    }
 
+   public boolean isEnabled()
+   {
+      return enabled;
+   }
+
+   public void setEnabled(boolean enabled)
+   {
+      this.enabled = enabled;
+   }
+
    public void fireFrameworkEvent(FrameworkEvent event)
    {
+      if (enabled == false)
+         return;
+      
+      String typeStr = ConstantsHelper.frameworkEvent(event.getType());
+      String message = "FrameworkEvent " + typeStr + " " + event.getSource();
+      
+      if (event.getType() == FrameworkEvent.ERROR)
+         log.error(message);
+      else if (event.getType() == FrameworkEvent.WARNING)
+         log.warn(message);
+      else if (event.getType() == FrameworkEvent.INFO)
+         log.info(message);
+      else
+         log.debug(message);
+      
       // [TODO] When a FrameworkEvent is fired, it is asynchronously delivered to a FrameworkListener.
       
       for (FrameworkListener listener : new ArrayList<FrameworkListener>(listeners))

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -40,6 +40,7 @@
    // Provide logging
    final Logger log = Logger.getLogger(FrameworkFactoryImpl.class);
 
+   @SuppressWarnings("unchecked")
    public Framework newFramework(Map configuration)
    {
       return new FrameworkImpl(configuration);

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -25,19 +25,25 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.jbossmc.api.BundleEventManager;
 import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
 import org.jboss.osgi.jbossmc.api.BundleRegistry;
 import org.jboss.osgi.jbossmc.api.BundleResolver;
 import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
 import org.jboss.osgi.jbossmc.api.ServiceEventManager;
 import org.jboss.osgi.jbossmc.api.ServiceRegistry;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.framework.launch.Framework;
 
 /**
@@ -51,18 +57,19 @@
    // Provide logging
    final Logger log = Logger.getLogger(FrameworkImpl.class);
 
-   private Map<String, String> properties = new HashMap<String, String>();
+   private Map<String, Object> properties = new HashMap<String, Object>();
    private int startLevel;
-   
+
    private BundleRegistry bundleRegistry;
    private BundleFactory bundleFactory;
    private BundleResolver bundleResolver;
    private BundleEventManager bundleEventManager;
+   private BundlePersistentStorage bundlePersistentStorage;
    private FrameworkEventManager frameworkEventManager;
    private ServiceEventManager serviceEventManager;
    private ServiceRegistry serviceRegistry;
 
-   public FrameworkImpl(Map props)
+   public FrameworkImpl(Map<String, Object> props)
    {
       if (props != null)
          properties.putAll(props);
@@ -102,11 +109,11 @@
       this.startLevel = startLevel;
    }
 
-   public String getProperty(String key)
+   public Object getProperty(String key)
    {
       return properties.get(key);
    }
-   
+
    public void init() throws BundleException
    {
       initInternal();
@@ -192,19 +199,20 @@
 
       // Have a valid Bundle Context
       setBundleContext(new SystemBundleContext(this));
-      
+
       bundleFactory = new BundleFactoryImpl(this);
       bundleResolver = new BundleResolverImpl(this);
       bundleRegistry = new BundleRegistryImpl(this);
+      bundlePersistentStorage = new BundlePersistentStorageImpl(this);
       serviceRegistry = new ServiceRegistryImpl(this);
-      bundleEventManager = new BundleEventManagerImpl(this);
-      frameworkEventManager = new FrameworkEventManagerImpl(this);
-      serviceEventManager = new ServiceEventManagerImpl(this);
 
       // Be at start level 0
       setStartLevel(0);
 
-      // [TODO] Have event handling enabled
+      // Have event handling enabled
+      bundleEventManager = new BundleEventManagerImpl(this);
+      frameworkEventManager = new FrameworkEventManagerImpl(this);
+      serviceEventManager = new ServiceEventManagerImpl(this);
 
       // [TODO] Have reified Bundle objects for all installed bundles
 
@@ -219,23 +227,66 @@
 
       // [TODO] All installed bundles must be started
 
-      // [TODO] This Framework's state is set to ACTIVE
+      // This Framework's state is set to ACTIVE
       setState(ACTIVE);
 
-      // [TODO] A framework event of type STARTED is fired
+      // A framework event of type STARTED is fired
+      frameworkEventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, this, null));
    }
 
    private void stopInternal()
    {
-      // [TODO] This Framework's state is set to STOPPING
+      // This Framework's state is set to STOPPING
+      setState(STOPPING);
 
-      // [TODO] All installed bundles must be stopped
+      // All installed bundles must be stopped
+      List<Bundle> reverseList = bundleRegistry.getBundles();
+      Collections.reverse(reverseList);
+      for (Bundle bundle : reverseList)
+      {
+         try
+         {
+            bundle.stop();
+         }
+         catch (BundleException ex)
+         {
+            log.error("Cannot stop bundle: " + bundle, ex);
+         }
+      }
 
-      // [TODO] Unregister all services registered by this Framework
+      // Unregister all services registered by this Framework
+      ServiceReference[] srefs = null;
+      try
+      {
+         srefs = serviceRegistry.getServiceReferences(null, null);
+      }
+      catch (InvalidSyntaxException ex)
+      {
+         // ignore
+      }
+      if (srefs != null)
+      {
+         for (ServiceReference sref : srefs)
+         {
+            ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
+            try
+            {
+               srefImpl.getServiceRegistration().unregister();
+            }
+            catch (Exception ex)
+            {
+               log.error("Cannot unregister service: " + sref, ex);
+            }
+         }
+      }
 
-      // [TODO] Event handling is disabled
+      // Event handling is disabled
+      bundleEventManager.setEnabled(false);
+      serviceEventManager.setEnabled(false);
+      frameworkEventManager.setEnabled(false);
 
-      // [TODO] This Framework's state is set to RESOLVED
+      // This Framework's state is set to RESOLVED
+      setState(RESOLVED);
 
       // [TODO] All resources held by this Framework are released.
 
@@ -272,6 +323,11 @@
       return bundleResolver;
    }
 
+   public BundlePersistentStorage getBundlePersistentStorage()
+   {
+      return bundlePersistentStorage;
+   }
+
    public ServiceRegistry getServiceRegistry()
    {
       return serviceRegistry;
@@ -291,4 +347,10 @@
    {
       return frameworkEventManager;
    }
+
+   @Override
+   public String toString()
+   {
+      return "[" + getBundleId() + "] " + getSymbolicName();
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
@@ -29,6 +29,7 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.jboss.osgi.spi.util.ConstantsHelper;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Filter;
 import org.osgi.framework.FrameworkUtil;
@@ -48,16 +49,31 @@
    // Provide logging
    final Logger log = Logger.getLogger(ServiceEventManagerImpl.class);
    
-   private FrameworkImpl framework;
    private Map<ServiceListener, ListenerRegistration> listeners = new LinkedHashMap<ServiceListener, ListenerRegistration>();
-
+   private boolean enabled = true;
+   
    public ServiceEventManagerImpl(FrameworkImpl framework)
    {
-      this.framework = framework;
    }
    
+   public boolean isEnabled()
+   {
+      return enabled;
+   }
+
+   public void setEnabled(boolean enabled)
+   {
+      this.enabled = enabled;
+   }
+
    public void fireServiceEvent(ServiceEvent event)
    {
+      if (enabled == false)
+         return;
+      
+      String typeStr = ConstantsHelper.serviceEvent(event.getType());
+      log.debug("ServiceEvent " + typeStr + " " + event.getSource());
+      
       ServiceReference sref = event.getServiceReference();
       String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
       if (clazzes == null)

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,16 +21,20 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Dictionary;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.spi.NotImplementedException;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
@@ -49,7 +53,10 @@
    private Object service;
    private Dictionary<String, Object> properties;
    private ServiceRegistration registration;
+   private Map<Bundle, Long> bundleUseCount = new HashMap<Bundle, Long>();
+   private Map<Bundle, Object> cachedService = new HashMap<Bundle, Object>();
    private boolean unregistered;
+   private String toStringCache;
    
    public ServiceReferenceImpl(Bundle bundle, Object service, Dictionary<String, Object> props)
    {
@@ -58,6 +65,39 @@
       this.properties = props;
    }
 
+   public Long getUseCount(Bundle bundle)
+   {
+      Long useCount = bundleUseCount.get(bundle);
+      return useCount != null ? useCount : new Long(0);
+   }
+   
+   public Long incrementUseCount(Bundle bundle)
+   {
+      Long useCount = new Long(getUseCount(bundle) + 1);
+      bundleUseCount.put(bundle, useCount);
+      return useCount;
+   }
+   
+   public Long decrementUseCount(Bundle bundle)
+   {
+      Long useCount = new Long(getUseCount(bundle) - 1);
+      bundleUseCount.put(bundle, useCount);
+      return useCount;
+   }
+   
+   public Object getCachedService(Bundle bundle)
+   {
+      return cachedService.get(bundle);
+   }
+
+   public void setCachedService(Bundle bundle, Object service)
+   {
+      if (service != null)
+         cachedService.put(bundle, service);
+      else
+         cachedService.remove(bundle);
+   }
+
    public boolean isUnregistered()
    {
       return unregistered;
@@ -123,4 +163,25 @@
       // [TODO] ServiceReference.isAssignableTo(Bundle bundle, String className)
       throw new NotImplementedException();
    }
+
+   @Override
+   public String toString()
+   {
+      if (toStringCache == null)
+      {
+         Long id = (Long)properties.get(Constants.SERVICE_ID);
+         StringBuffer buffer = new StringBuffer("[" + id + "] ");
+         buffer.append(Arrays.asList((String[])properties.get(Constants.OBJECTCLASS)));
+         
+         for (String key : getPropertyKeys())
+         {
+            if (!key.equals(Constants.SERVICE_ID) && !key.equals(Constants.OBJECTCLASS))
+            {
+               buffer.append("\n " + key + "=" + properties.get(key));
+            }
+         }
+         toStringCache = buffer.toString();
+      }
+      return toStringCache;
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,12 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.Dictionary;
 
 import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.ServiceRegistry;
 import org.jboss.osgi.spi.NotImplementedException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
@@ -41,10 +42,12 @@
    // Provide logging
    final Logger log = Logger.getLogger(ServiceRegistrationImpl.class);
 
+   private ServiceRegistry serviceRegistry;
    private ServiceReferenceImpl serviceRef;
 
-   public ServiceRegistrationImpl(ServiceReferenceImpl serviceRef)
+   public ServiceRegistrationImpl(ServiceRegistry serviceRegistry, ServiceReferenceImpl serviceRef)
    {
+      this.serviceRegistry = serviceRegistry;
       this.serviceRef = serviceRef;
       serviceRef.setServiceRegistration(this);
    }
@@ -54,6 +57,7 @@
       return serviceRef;
    }
 
+   @SuppressWarnings("unchecked")
    public void setProperties(Dictionary properties)
    {
       // [TODO] ServiceRegistration.setProperties(Dictionary properties)
@@ -62,7 +66,6 @@
 
    public void unregister()
    {
-      // [TODO] ServiceRegistration.unregister()
-      throw new NotImplementedException();
+      serviceRegistry.unregisterService(this);
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,21 +21,27 @@
  */
 package org.jboss.osgi.jbossmc.framework;
 
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler at jboss.com $
+//$Id: $
 
 import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.jbossmc.api.ServiceEventManager;
 import org.jboss.osgi.jbossmc.api.ServiceRegistry;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceReference;
@@ -61,16 +67,36 @@
       this.framework = framework;
    }
 
-   public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties)
+   public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties)
    {
       return registerServiceInternal(bundle, new String[] {clazz}, service, properties);
    }
 
-   public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties)
+   public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties)
    {
       return registerServiceInternal(bundle, clazzes, service, properties);
    }
 
+   public void unregisterService(ServiceRegistration registration)
+   {
+      ServiceReference sref = registration.getReference();
+      String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
+      for (String clazz : clazzes)
+      {
+         List<ServiceReference> srefs = registry.get(clazz);
+         if (srefs != null)
+         {
+            Iterator<ServiceReference> itRefs = srefs.iterator();
+            while (itRefs.hasNext())
+            {
+               ServiceReference next = itRefs.next();
+               if (sref == next)
+                  itRefs.remove();
+            }
+         }
+      }
+   }
+
    public ServiceReference getServiceReference(String clazz)
    {
       ServiceReference srefBest = null;
@@ -89,8 +115,11 @@
                
                Integer thisRanking = (Integer)sref.getProperty(Constants.SERVICE_RANKING);
                Long thisId = (Long)sref.getProperty(Constants.SERVICE_ID);
-               if (bestRanking != null && thisRanking != null)
+               if (thisRanking != null)
                {
+                  if (bestRanking == null)
+                     bestRanking = new Integer(0);
+                  
                   if (bestRanking < thisRanking)
                      srefBest = sref;
                   
@@ -107,23 +136,52 @@
       return srefBest;
    }
    
-   public ServiceReference[] getServiceReferences(String clazz, String filter)
+   public ServiceReference[] getServiceReferences(String clazz, String filterStr) throws InvalidSyntaxException
    {
-      ServiceReference[] srefArr = null;
+      Set<ServiceReference> resultRefs = new LinkedHashSet<ServiceReference>();
       
-      // [TODO] The result is an array of ServiceReference objects for all services that meet all of the following conditions:
-      //   * If the specified class name, clazz, is not null, the service must have been registered with the specified class name. The complete list of class names with which a service was registered is available from the service's objectClass property.
-      //   * If the specified filter is not null, the filter expression must match the service.
-      //   * If the Java Runtime Environment supports permissions, the caller must have ServicePermission with the GET action for at least one of the class names under which the service was registered.
-      //   * For each class name with which the service was registered, calling ServiceReference.isAssignableTo(Bundle, String) with the context bundle and the class name on the service's ServiceReference object must return true
+      // If the specified class name, clazz, is not null, the service must have been registered with the specified class name.
+      if (clazz != null)
+      {
+         List<ServiceReference> srefs = registry.get(clazz);
+         if (srefs != null)
+            resultRefs.addAll(srefs);
+      }
       
-      List<ServiceReference> srefs = registry.get(clazz);
-      if (srefs != null)
+      // null for all services
+      if (clazz == null)
       {
-         srefArr = new ServiceReference[srefs.size()];
-         srefs.toArray(srefArr);
+         for (String auxclazz : registry.keySet())
+         {
+            List<ServiceReference> srefs = registry.get(auxclazz);
+            if (srefs != null)
+               resultRefs.addAll(srefs);
+         }
       }
-      return srefArr;   
+      
+      // If the specified filter is not null, the filter expression must match the service.
+      if (filterStr != null)
+      {
+         Filter filter = FrameworkUtil.createFilter(filterStr);
+         Iterator<ServiceReference> itref = resultRefs.iterator();
+         while (itref.hasNext())
+         {
+            ServiceReference sref = itref.next();
+            if (filter.match(sref) == false)
+               itref.remove();
+         }
+      }
+      
+      // [TODO] If the Java Runtime Environment supports permissions, the caller must have ServicePermission with the GET action for at least one of the class names under which the service was registered.
+      
+      // [TODO] For each class name with which the service was registered, calling ServiceReference.isAssignableTo(Bundle, String) with the context bundle and the class name on the service's ServiceReference object must return true
+      
+      // Return null if no services are registered which satisfy the search
+      if (resultRefs.size() == 0)
+         return null;
+      
+      ServiceReference[] srefArr = new ServiceReference[resultRefs.size()];
+      return resultRefs.toArray(srefArr);
    }
 
    public Object getService(Bundle bundle, ServiceReference sref)
@@ -134,22 +192,57 @@
       if (srefImpl.isUnregistered())
          return null;
       
-      // [TODO] The context bundle's use count for this service is incremented by one.
+      // The context bundle's use count for this service is incremented by one.
+      srefImpl.incrementUseCount(bundle);
       
-      // [TODO] The service was registered with an object implementing the ServiceFactory interface
+      // The service was registered with an object implementing the ServiceFactory interface
       Object service = srefImpl.getService();
       if (service instanceof ServiceFactory)
       {
-         ServiceFactory factory = (ServiceFactory)service;
-         service = factory.getService(bundle, srefImpl.getServiceRegistration());
+         if (srefImpl.getUseCount(bundle) == 1)
+         {
+            ServiceFactory factory = (ServiceFactory)service;
+            service = factory.getService(bundle, srefImpl.getServiceRegistration());
+            srefImpl.setCachedService(bundle, service);
+         }
+         else
+         {
+            service = srefImpl.getCachedService(bundle);
+         }
       }
       
       // The service object for the service is returned.
       return service;
    }
    
-   private ServiceRegistration registerServiceInternal(Bundle bundle, String[] clazzes, Object service, Dictionary<String, String> props)
+   public boolean ungetService(Bundle bundle, ServiceReference sref)
    {
+      ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
+      
+      // 1. If the context bundle's use count for the service is zero or the service has been unregistered, false is returned.
+      if (srefImpl.getUseCount(bundle) == 0 || srefImpl.isUnregistered())
+         return false;
+      
+      // 2. The context bundle's use count for this service is decremented by one.
+      srefImpl.decrementUseCount(bundle);
+      
+      // 3. If the context bundle's use count for the service is currently zero and the service was registered with a ServiceFactory object, 
+      // the ServiceFactory.ungetService(Bundle, ServiceRegistration, Object) method is called to release the service object for the context bundle.
+      Object service = srefImpl.getService();
+      if (srefImpl.getUseCount(bundle) == 0 && service instanceof ServiceFactory)
+      {
+         ServiceFactory factory = (ServiceFactory)service;
+         service = srefImpl.getCachedService(bundle);
+         factory.ungetService(bundle, srefImpl.getServiceRegistration(), service);
+         srefImpl.setCachedService(bundle, null);
+      }
+      
+      // 4. true is returned. 
+      return true;
+   }
+
+   private ServiceRegistration registerServiceInternal(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> props)
+   {
       // If service is not a ServiceFactory, an IllegalArgumentException is thrown if service 
       // is not an instanceof all the specified class names.
       if ((service instanceof ServiceFactory) == false)
@@ -191,7 +284,6 @@
       ServiceReferenceImpl sref = new ServiceReferenceImpl(bundle, service, properties);
       for (String clazz : clazzes)
       {
-         log.debug("Register Service: " + clazz);
          List<ServiceReference> list = registry.get(clazz);
          if (list == null)
          {
@@ -206,6 +298,6 @@
       eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, sref));
       
       // 5. A ServiceRegistration object for this registration is returned.
-      return new ServiceRegistrationImpl(sref);
+      return new ServiceRegistrationImpl(this, sref);
    }
 }
\ No newline at end of file

Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,134 @@
+/*
+ * 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.jbossmc.simple;
+
+//$Id: SimpleTestCase.java 91196 2009-07-14 09:41:15Z thomas.diesler at jboss.com $
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Install a bundle and verifies its entries
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleEntriesTestCase extends OSGiTest
+{
+   private static Framework framework;
+   
+   /*
+    * /META-INF/
+    * /META-INF/MANIFEST.MF
+    * /org/
+    * /org/jboss/
+    * /org/jboss/test/
+    * /org/jboss/test/osgi/
+    * /org/jboss/test/osgi/jbossmc/
+    * /org/jboss/test/osgi/jbossmc/simple/
+    * /org/jboss/test/osgi/jbossmc/simple/bundle/
+    * /org/jboss/test/osgi/jbossmc/simple/bundle/SimpleActivator.class
+    * /org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.class
+    */
+   
+   @BeforeClass
+   public static void beforeClass() throws BundleException
+   {
+      FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+      framework = factory.newFramework(null);
+      framework.start();
+   }
+   
+   @AfterClass
+   public static void afterClass() throws BundleException
+   {
+      framework.stop();
+   }
+   
+   @Test
+   public void testGetEntryPaths() throws Exception
+   {
+      BundleContext sysContext = framework.getBundleContext();
+      String location = getTestArchiveURL("simple-bundle.jar").toString();
+      Bundle bundle = sysContext.installBundle(location);
+
+      String path = "/";
+      assertEquals(11, countEntryPaths(bundle.getEntryPaths(path)));
+
+      path = "META-INF";
+      assertEquals(1, countEntryPaths(bundle.getEntryPaths(path)));
+
+      path = "org/jboss/test/osgi/jbossmc/simple/bundle";
+      assertEquals(2, countEntryPaths(bundle.getEntryPaths(path)));
+      
+      bundle.uninstall();
+   }
+
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testFindEntries() throws Exception
+   {
+      BundleContext sysContext = framework.getBundleContext();
+      String location = getTestArchiveURL("simple-bundle.jar").toString();
+      Bundle bundle = sysContext.installBundle(location);
+
+      Enumeration entries = bundle.findEntries("META-INF", "M*.*", false);
+      assertTrue("One entry", entries.hasMoreElements());
+      URL entryURL = (URL)entries.nextElement();
+      assertTrue("Ends with MANIFEST.MF", entryURL.toExternalForm().endsWith("simple-bundle.jar/META-INF/MANIFEST.MF"));
+      
+      bundle.uninstall();
+   }
+
+   @SuppressWarnings("unchecked")
+   private int countEntryPaths(Enumeration entries)
+   {
+      int count = 0;
+      while (entries.hasMoreElements())
+      {
+         entries.nextElement();
+         count++;
+      }
+      return count;
+   }
+   
+   @SuppressWarnings({ "unused", "unchecked" })
+   private void printEntryPaths(Enumeration entries)
+   {
+      while (entries.hasMoreElements())
+         System.out.println(entries.nextElement());
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -69,15 +69,18 @@
    }
    
    @Test
-   public void testSimpleBundle() throws Exception
+   public void testBundleInstall() throws Exception
    {
-      BundleContext context = framework.getBundleContext();
+      BundleContext sysContext = framework.getBundleContext();
       String location = getTestArchiveURL("simple-bundle.jar").toString();
-      Bundle bundle = context.installBundle(location);
+      Bundle bundle = sysContext.installBundle(location);
 
       assertEquals("simple-bundle", bundle.getSymbolicName());
       
       bundle.start();
-      assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+      assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+      
+      bundle.uninstall();
+      assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
    }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -24,7 +24,6 @@
 //$Id: SimpleService.java 91196 2009-07-14 09:41:15Z thomas.diesler at jboss.com $
 
 import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
 
 /**
  * A SimpleService
@@ -34,8 +33,6 @@
  */
 public class SimpleService 
 {
-   private LogService log;
-   
    public SimpleService(BundleContext context)
    {
    }

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java	2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java	2009-08-19 14:33:04 UTC (rev 92578)
@@ -71,7 +71,7 @@
       tracker.open();
       
       StartLevel service = (StartLevel)tracker.getService();
-      out.println("startLevel=" + service.getStartLevel());
+      out.println("startLevel=" + (service != null ? service.getStartLevel() : 1));
     }
     else
     {




More information about the jboss-cvs-commits mailing list