felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1734365 - in /felix/trunk/fileinstall: ./ src/main/java/org/apache/felix/fileinstall/internal/ src/test/java/org/apache/felix/fileinstall/internal/
Date Thu, 10 Mar 2016 07:47:03 GMT
Author: djencks
Date: Thu Mar 10 07:46:57 2016
New Revision: 1734365

URL: http://svn.apache.org/viewvc?rev=1734365&view=rev
Log:
FELIX-5209 get the system bundle by location not id

Modified:
    felix/trunk/fileinstall/pom.xml
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
    felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
    felix/trunk/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/DirectoryWatcherTest.java

Modified: felix/trunk/fileinstall/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/pom.xml?rev=1734365&r1=1734364&r2=1734365&view=diff
==============================================================================
--- felix/trunk/fileinstall/pom.xml (original)
+++ felix/trunk/fileinstall/pom.xml Thu Mar 10 07:46:57 2016
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.felix</groupId>
     <artifactId>felix-parent</artifactId>
-    <version>2.1</version>
+    <version>3</version>
     <relativePath>../pom/pom.xml</relativePath>
   </parent>
 	

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java?rev=1734365&r1=1734364&r2=1734365&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/DirectoryWatcher.java
Thu Mar 10 07:46:57 2016
@@ -127,6 +127,7 @@ public class DirectoryWatcher extends Th
     boolean useStartActivationPolicy;
     String filter;
     BundleContext context;
+    private Bundle systemBundle;
     String originatingFileName;
     boolean noInitialDelay;
     int startLevel;
@@ -161,6 +162,7 @@ public class DirectoryWatcher extends Th
         this.fileInstall = fileInstall;
         this.properties = properties;
         this.context = context;
+        systemBundle = context.getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
         poll = getLong(properties, POLL, 2000);
         logLevel = getInt(properties, LOG_LEVEL, Util.getGlobalLogLevel(context));
         originatingFileName = properties.get(FILENAME);
@@ -295,10 +297,10 @@ public class DirectoryWatcher extends Th
 
         while (!interrupted()) {
             try {
-                FrameworkStartLevel startLevelSvc = context.getBundle(0).adapt(FrameworkStartLevel.class);
+                FrameworkStartLevel startLevelSvc = systemBundle.adapt(FrameworkStartLevel.class);
                 // Don't access the disk when the framework is still in a startup phase.
                 if (startLevelSvc.getStartLevel() >= activeLevel
-                        && context.getBundle(0).getState() == Bundle.ACTIVE) {
+                        && systemBundle.getState() == Bundle.ACTIVE) {
                     Set<File> files = scanner.scan(false);
                     // Check that there is a result.  If not, this means that the directory
can not be listed,
                     // so it's presumably not a valid directory (it may have been deleted
by someone).
@@ -311,6 +313,7 @@ public class DirectoryWatcher extends Th
                     wait(poll);
                 }
             } catch (InterruptedException e) {
+                interrupt();
                 return;
             } catch (Throwable e) {
                 try {
@@ -669,7 +672,7 @@ public class DirectoryWatcher extends Th
      */
     void refresh(Collection<Bundle> bundles) throws InterruptedException
     {
-        FileInstall.refresh(context, bundles);
+        FileInstall.refresh(systemBundle, bundles);
     }
 
     /**
@@ -1188,7 +1191,7 @@ public class DirectoryWatcher extends Th
      */
     private void startAllBundles()
     {
-        FrameworkStartLevel startLevelSvc = context.getBundle(0).adapt(FrameworkStartLevel.class);
+        FrameworkStartLevel startLevelSvc = systemBundle.adapt(FrameworkStartLevel.class);
         List<Bundle> bundles = new ArrayList<Bundle>();
         for (Artifact artifact : getArtifacts()) {
             if (artifact.getBundleId() > 0) {
@@ -1226,7 +1229,7 @@ public class DirectoryWatcher extends Th
       */
     private boolean startBundle(Bundle bundle)
     {
-        FrameworkStartLevel startLevelSvc = context.getBundle(0).adapt(FrameworkStartLevel.class);
+        FrameworkStartLevel startLevelSvc = systemBundle.adapt(FrameworkStartLevel.class);
         // Fragments can never be started.
         // Bundles can only be started transient when the start level of the framework is
high
         // enough. Persistent (i.e. non-transient) starts will simply make the framework
start the

Modified: felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java?rev=1734365&r1=1734364&r2=1734365&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
(original)
+++ felix/trunk/fileinstall/src/main/java/org/apache/felix/fileinstall/internal/FileInstall.java
Thu Mar 10 07:46:57 2016
@@ -317,10 +317,10 @@ public class FileInstall implements Bund
     /**
      * Convenience to refresh the packages
      */
-    static void refresh(BundleContext context, Collection<Bundle> bundles) throws InterruptedException
+    static void refresh(Bundle systemBundle, Collection<Bundle> bundles) throws InterruptedException
     {
         final CountDownLatch latch = new CountDownLatch(1);
-        FrameworkWiring wiring = context.getBundle(0).adapt(FrameworkWiring.class);
+        FrameworkWiring wiring = systemBundle.adapt(FrameworkWiring.class);
         wiring.refreshBundles(bundles, new FrameworkListener() {
             public void frameworkEvent(FrameworkEvent event) {
                 latch.countDown();

Modified: felix/trunk/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/DirectoryWatcherTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/DirectoryWatcherTest.java?rev=1734365&r1=1734364&r2=1734365&view=diff
==============================================================================
--- felix/trunk/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/DirectoryWatcherTest.java
(original)
+++ felix/trunk/fileinstall/src/test/java/org/apache/felix/fileinstall/internal/DirectoryWatcherTest.java
Thu Mar 10 07:46:57 2016
@@ -34,6 +34,7 @@ import org.junit.Assert;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.startlevel.FrameworkStartLevel;
 import org.osgi.framework.wiring.BundleRevision;
@@ -74,7 +75,7 @@ public class DirectoryWatcherTest extend
         EasyMock.expect(mockBundleContext.getServiceReference(LogService.class.getName()))
                         .andStubReturn(null);
         EasyMock.expect(mockBundleContext.getBundle()).andReturn(mockBundle).anyTimes();
-        EasyMock.expect(mockBundleContext.getBundle(0)).andReturn(mockSysBundle).anyTimes();
+        EasyMock.expect(mockBundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION)).andReturn(mockSysBundle).anyTimes();
         EasyMock.expect(mockSysBundle.getState()).andReturn(Bundle.ACTIVE).anyTimes();
         EasyMock.expect(mockSysBundle.adapt(FrameworkStartLevel.class)).andReturn(mockStartLevel).anyTimes();
         EasyMock.expect(mockStartLevel.getStartLevel()).andReturn(50).anyTimes();



Mime
View raw message