Author: cziegeler
Date: Fri Sep 18 09:22:37 2015
New Revision: 1703787

URL: http://svn.apache.org/viewvc?rev=1703787&view=rev
Log:
SLING-5044 : Get system bundle by location, not number 0

Modified:
    sling/trunk/installer/core/pom.xml
    
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleInfo.java
    
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SystemBundleUpdateTask.java
    
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/TaskSupport.java
    
sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleContext.java

Modified: sling/trunk/installer/core/pom.xml
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/core/pom.xml?rev=1703787&r1=1703786&r2=1703787&view=diff
==============================================================================
--- sling/trunk/installer/core/pom.xml (original)
+++ sling/trunk/installer/core/pom.xml Fri Sep 18 09:22:37 2015
@@ -133,7 +133,7 @@
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
-            <version>4.1.0</version>
+            <version>4.3.0</version>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>

Modified: 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleInfo.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleInfo.java?rev=1703787&r1=1703786&r2=1703787&view=diff
==============================================================================
--- 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleInfo.java
 (original)
+++ 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleInfo.java
 Fri Sep 18 09:22:37 2015
@@ -71,7 +71,7 @@ public class BundleInfo {
         if (bundleSymbolicName != null) {
             // check if this is the system bundle
             if ( 
Constants.SYSTEM_BUNDLE_SYMBOLICNAME.equals(bundleSymbolicName) ) {
-                return bundleContext.getBundle(0);
+                return 
bundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
             }
             final List<Bundle> matchingBundles = new ArrayList<Bundle>();
             final Bundle[] bundles = bundleContext.getBundles();

Modified: 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SystemBundleUpdateTask.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SystemBundleUpdateTask.java?rev=1703787&r1=1703786&r2=1703787&view=diff
==============================================================================
--- 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SystemBundleUpdateTask.java
 (original)
+++ 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SystemBundleUpdateTask.java
 Fri Sep 18 09:22:37 2015
@@ -28,6 +28,7 @@ import org.apache.sling.installer.api.ta
 import org.apache.sling.installer.core.impl.AbstractInstallTask;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
 
 /**
  * Update the system bundle from a RegisteredResource.
@@ -45,7 +46,7 @@ public class SystemBundleUpdateTask exte
 
     @Override
     public void execute(final InstallationContext ctx) {
-        final Bundle systemBundle = this.getBundleContext().getBundle(0);
+        final Bundle systemBundle = 
this.getBundleContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION);
         // sanity check
         if ( systemBundle == null ) {
             this.setFinishedState(ResourceState.IGNORED);

Modified: 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/TaskSupport.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/TaskSupport.java?rev=1703787&r1=1703786&r2=1703787&view=diff
==============================================================================
--- 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/TaskSupport.java
 (original)
+++ 
sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/TaskSupport.java
 Fri Sep 18 09:22:37 2015
@@ -22,6 +22,7 @@ import org.apache.sling.installer.core.i
 import org.apache.sling.installer.core.impl.util.PABundleRefresher;
 import org.apache.sling.installer.core.impl.util.WABundleRefresher;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.wiring.FrameworkWiring;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.startlevel.StartLevel;
@@ -83,14 +84,14 @@ public class TaskSupport {
     public BundleRefresher getBundleRefresher() {
         if ( checkedWireAdmin == null ) {
             try {
-                this.bundleContext.getBundle(0).adapt(FrameworkWiring.class);
+                
this.bundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(FrameworkWiring.class);
                 checkedWireAdmin = true;
             } catch (final Throwable t) {
                 checkedWireAdmin = false;
             }
         }
         if ( checkedWireAdmin.booleanValue() ) {
-            return new 
WABundleRefresher(this.bundleContext.getBundle(0).adapt(FrameworkWiring.class),
+            return new 
WABundleRefresher(this.bundleContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(FrameworkWiring.class),
                     this.bundleContext);
         } else {
             return new PABundleRefresher((PackageAdmin) 
this.packageAdminTracker.getService(),

Modified: 
sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleContext.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleContext.java?rev=1703787&r1=1703786&r2=1703787&view=diff
==============================================================================
--- 
sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleContext.java
 (original)
+++ 
sling/trunk/installer/core/src/test/java/org/apache/sling/installer/core/impl/MockBundleContext.java
 Fri Sep 18 09:22:37 2015
@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Map;
@@ -40,26 +41,31 @@ import org.osgi.framework.Version;
 
 public class MockBundleContext implements BundleContext {
 
+    @Override
     public boolean ungetService(ServiceReference reference) {
         // TODO Auto-generated method stub
         return false;
     }
 
+    @Override
     public void removeServiceListener(ServiceListener listener) {
         // TODO Auto-generated method stub
 
     }
 
+    @Override
     public void removeFrameworkListener(FrameworkListener listener) {
         // TODO Auto-generated method stub
 
     }
 
+    @Override
     public void removeBundleListener(BundleListener listener) {
         // TODO Auto-generated method stub
 
     }
 
+    @Override
     @SuppressWarnings("rawtypes")
     public ServiceRegistration registerService(String clazz, Object service,
             Dictionary properties) {
@@ -67,6 +73,7 @@ public class MockBundleContext implement
         return null;
     }
 
+    @Override
     @SuppressWarnings("rawtypes")
     public ServiceRegistration registerService(String[] clazzes,
             Object service, Dictionary properties) {
@@ -74,37 +81,44 @@ public class MockBundleContext implement
         return null;
     }
 
+    @Override
     public Bundle installBundle(String location) throws BundleException {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public Bundle installBundle(String location, InputStream input)
             throws BundleException {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public ServiceReference[] getServiceReferences(String clazz, String filter)
             throws InvalidSyntaxException {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public ServiceReference getServiceReference(String clazz) {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public Object getService(ServiceReference reference) {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public String getProperty(String key) {
         return null;
     }
 
+    @Override
     public File getDataFile(String filename) {
         try {
             if ( "installer".equals(filename) ) {
@@ -120,133 +134,159 @@ public class MockBundleContext implement
         }
     }
 
+    @Override
     public Bundle[] getBundles() {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public Bundle getBundle(long id) {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public Bundle getBundle() {
         return new Bundle() {
 
+            @Override
             public int getState() {
                 // TODO Auto-generated method stub
                 return 0;
             }
 
+            @Override
             public void start(int options) throws BundleException {
                 // TODO Auto-generated method stub
 
             }
 
+            @Override
             public void start() throws BundleException {
                 // TODO Auto-generated method stub
 
             }
 
+            @Override
             public void stop(int options) throws BundleException {
                 // TODO Auto-generated method stub
 
             }
 
+            @Override
             public void stop() throws BundleException {
                 // TODO Auto-generated method stub
 
             }
 
+            @Override
             public void update(InputStream input) throws BundleException {
                 // TODO Auto-generated method stub
 
             }
 
+            @Override
             public void update() throws BundleException {
                 // TODO Auto-generated method stub
 
             }
 
+            @Override
             public void uninstall() throws BundleException {
                 // TODO Auto-generated method stub
 
             }
 
+            @Override
             @SuppressWarnings("rawtypes")
             public Dictionary getHeaders() {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public long getBundleId() {
                 // TODO Auto-generated method stub
                 return 0;
             }
 
+            @Override
             public String getLocation() {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public ServiceReference[] getRegisteredServices() {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public ServiceReference[] getServicesInUse() {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public boolean hasPermission(Object permission) {
                 // TODO Auto-generated method stub
                 return false;
             }
 
+            @Override
             public URL getResource(String name) {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             @SuppressWarnings("rawtypes")
             public Dictionary getHeaders(String locale) {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public String getSymbolicName() {
                 return "test-bundle";
             }
 
+            @Override
             @SuppressWarnings("rawtypes")
             public Class loadClass(String name) throws ClassNotFoundException {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             @SuppressWarnings("rawtypes")
             public Enumeration getResources(String name) throws IOException {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             @SuppressWarnings("rawtypes")
             public Enumeration getEntryPaths(String path) {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public URL getEntry(String path) {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public long getLastModified() {
                 // TODO Auto-generated method stub
                 return 0;
             }
 
+            @Override
             @SuppressWarnings("rawtypes")
             public Enumeration findEntries(String path, String filePattern,
                     boolean recurse) {
@@ -254,22 +294,26 @@ public class MockBundleContext implement
                 return null;
             }
 
+            @Override
             public BundleContext getBundleContext() {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             @SuppressWarnings("rawtypes")
             public Map getSignerCertificates(int signersType) {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public Version getVersion() {
                 // TODO Auto-generated method stub
                 return null;
             }
 
+            @Override
             public <A> A adapt(Class<A> type) {
                 // TODO Auto-generated method stub
                 return null;
@@ -277,33 +321,64 @@ public class MockBundleContext implement
         };
     }
 
+    @Override
+    public ServiceRegistration registerService(Class clazz, Object service, 
Dictionary properties) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public ServiceReference getServiceReference(Class clazz) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Collection getServiceReferences(Class clazz, String filter)
+            throws InvalidSyntaxException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Bundle getBundle(String location) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
     public ServiceReference[] getAllServiceReferences(String clazz,
             String filter) throws InvalidSyntaxException {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public Filter createFilter(String filter) throws InvalidSyntaxException {
         // TODO Auto-generated method stub
         return null;
     }
 
+    @Override
     public void addServiceListener(ServiceListener listener) {
         // TODO Auto-generated method stub
 
     }
 
+    @Override
     public void addServiceListener(ServiceListener listener, String filter)
             throws InvalidSyntaxException {
         // TODO Auto-generated method stub
 
     }
 
+    @Override
     public void addFrameworkListener(FrameworkListener listener) {
         // TODO Auto-generated method stub
 
     }
 
+    @Override
     public void addBundleListener(BundleListener listener) {
         // TODO Auto-generated method stub
 


Reply via email to