incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1202555 - in /sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks: BundleTaskCreator.java SynchronousRefreshPackagesTask.java
Date Wed, 16 Nov 2011 07:05:33 GMT
Author: cziegeler
Date: Wed Nov 16 07:05:33 2011
New Revision: 1202555

URL: http://svn.apache.org/viewvc?rev=1202555&view=rev
Log:
SLING-2288 : Bundle jar is silently ignored by the installer if MANIFEST.MF is not the first
file in the archive

Modified:
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java
    sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SynchronousRefreshPackagesTask.java

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java?rev=1202555&r1=1202554&r2=1202555&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/BundleTaskCreator.java
Wed Nov 16 07:05:33 2011
@@ -156,7 +156,7 @@ public class BundleTaskCreator implement
 
 	    // check if symbolic name and version is provided in the attributes
         if ( toActivate.getAttribute(Constants.BUNDLE_SYMBOLICNAME) == null ) {
-            final Util.BundleHeaders headers = Util.readBundleHeaders(toActivate);
+            final Util.BundleHeaders headers = Util.readBundleHeaders(toActivate, logger);
             if ( headers == null ) {
                 logger.info("Resource of type bundle {} is not really a bundle - manifest
entries are missing.", toActivate);
                 return new ChangeStateTask(resourceList, ResourceState.IGNORED);

Modified: sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SynchronousRefreshPackagesTask.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SynchronousRefreshPackagesTask.java?rev=1202555&r1=1202554&r2=1202555&view=diff
==============================================================================
--- sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SynchronousRefreshPackagesTask.java
(original)
+++ sling/trunk/installer/core/src/main/java/org/apache/sling/installer/core/impl/tasks/SynchronousRefreshPackagesTask.java
Wed Nov 16 07:05:33 2011
@@ -24,9 +24,11 @@ import org.apache.sling.installer.core.i
 import org.osgi.framework.Bundle;
 import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
-import org.osgi.service.packageadmin.PackageAdmin;
 
-/** Execute an OSGi "refresh packages" operation, synchronously */
+/**
+ * Execute an OSGi "refresh packages" operation, synchronously
+ * by waiting until a package refresh event occurs.
+ */
 public class SynchronousRefreshPackagesTask extends AbstractInstallTask implements FrameworkListener
{
 
     /** Tracker for the package admin. */
@@ -34,10 +36,14 @@ public class SynchronousRefreshPackagesT
 
     private static final String REFRESH_PACKAGES_ORDER = "60-";
 
-    /** Max time allowed to refresh packages (TODO configurable??) */
-    public static final int MAX_REFRESH_PACKAGES_WAIT_SECONDS = 30;
+    /** Max time allowed to refresh packages */
+    private static final int MAX_REFRESH_PACKAGES_WAIT_SECONDS = 30;
 
-	private volatile int packageRefreshEventsCount;
+    /** Max time between the checks if the event has occured */
+    private static final long MAX_SLEEP = 250L;
+
+    /** Counter for package refresh events. */
+    private volatile int packageRefreshEventsCount;
 
 	public SynchronousRefreshPackagesTask(final BundleTaskCreator btc) {
 	    super(null);
@@ -68,10 +74,6 @@ public class SynchronousRefreshPackagesT
 		return getClass().getSimpleName();
 	}
 
-    private PackageAdmin getPackageAdmin() {
-        return this.bundleTaskCreator.getPackageAdmin();
-    }
-
     /**
      * @see org.apache.sling.installer.api.tasks.InstallTask#execute(org.apache.sling.installer.api.tasks.InstallationContext)
      */
@@ -96,22 +98,23 @@ public class SynchronousRefreshPackagesT
         // if one happened very recently and there's nothing to refresh
         this.bundleTaskCreator.getBundleContext().addFrameworkListener(this);
         try {
-            this.getPackageAdmin().refreshPackages(null);
-            while(true) {
-                if(System.currentTimeMillis() > timeout) {
+            this.bundleTaskCreator.getPackageAdmin().refreshPackages(null);
+            while (true) {
+                if (System.currentTimeMillis() > timeout) {
                     this.getLogger().warn("No FrameworkEvent.PACKAGES_REFRESHED event received
within {}"
         	    				+ " seconds after refresh", MAX_REFRESH_PACKAGES_WAIT_SECONDS);
                     break;
                 }
-                if(packageRefreshEventsCount >= targetEventCount) {
+                if (packageRefreshEventsCount >= targetEventCount) {
                     final long delta = System.currentTimeMillis() - start;
                     this.getLogger().debug("FrameworkEvent.PACKAGES_REFRESHED received {}"
         	    				+ " msec after refreshPackages call", delta);
                     break;
                 }
                 try {
-                    Thread.sleep(250L);
-                } catch(InterruptedException ignore) {
+                    Thread.sleep(MAX_SLEEP);
+                } catch (final InterruptedException ignore) {
+                    // ignore
                 }
             }
         } finally {



Mime
View raw message