aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r1598280 - in /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal: InstallAction.java SubsystemResourceInstaller.java
Date Thu, 29 May 2014 12:44:16 GMT
Author: mnuttall
Date: Thu May 29 12:44:15 2014
New Revision: 1598280

URL: http://svn.apache.org/r1598280
Log:
Aries-1187: Installing a subsystem does not cleanup files left in tmp area. From a patch by
Samuel Bratton. 

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResourceInstaller.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java?rev=1598280&r1=1598279&r2=1598280&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
Thu May 29 12:44:15 2014
@@ -19,6 +19,7 @@ import java.security.AccessControlContex
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.apache.aries.util.filesystem.ICloseableDirectory;
 import org.apache.aries.util.filesystem.IDirectory;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
@@ -26,12 +27,15 @@ import org.osgi.service.coordinator.Coor
 import org.osgi.service.coordinator.CoordinationException;
 import org.osgi.service.resolver.ResolutionException;
 import org.osgi.service.subsystem.SubsystemException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class InstallAction implements PrivilegedAction<BasicSubsystem> {
 	private final IDirectory content;
 	private final AccessControlContext context;
 	private final String location;
 	private final BasicSubsystem parent;
+	private static final Logger logger = LoggerFactory.getLogger(InstallAction.class);
 	
 	public InstallAction(String location, IDirectory content, BasicSubsystem parent, AccessControlContext
context) {
 		this.location = location;
@@ -88,10 +92,27 @@ public class InstallAction implements Pr
 					throw (SecurityException)t;
 				throw new SubsystemException(t);
 			}
+			finally {
+				closeContentIfIClosable();
+			}
 		}
+		closeContentIfIClosable();
 		return result;
 	}
 
+	private void closeContentIfIClosable() {
+		//clean up temp file
+		if (content instanceof ICloseableDirectory) {
+			try{
+				((ICloseableDirectory) content).close();
+			}
+			catch (IOException ioex) {
+				logger.info("Exception calling close for content {}. Exception {}", 
+						content, ioex);					
+			}
+		} 
+	}
+	
 	private void checkLifecyclePermission(final BasicSubsystem subsystem) {
 		AccessController.doPrivileged(new PrivilegedAction<Object>() {
 			@Override

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResourceInstaller.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResourceInstaller.java?rev=1598280&r1=1598279&r2=1598280&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResourceInstaller.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResourceInstaller.java
Thu May 29 12:44:15 2014
@@ -106,10 +106,12 @@ public class SubsystemResourceInstaller 
 				ResourceInstaller.newInstance(coordination, dependency, subsystem).install();
 		}
 		// ...followed by content.
-		List<Resource> installableContent = new ArrayList<Resource>(subsystem.getResource().getInstallableContent());
-		Collections.sort(installableContent, comparator);
-		for (Resource content : installableContent)
-			ResourceInstaller.newInstance(coordination, content, subsystem).install();
+		if (State.INSTALLING.equals(subsystem.getState())) {
+			List<Resource> installableContent = new ArrayList<Resource>(subsystem.getResource().getInstallableContent());
+			Collections.sort(installableContent, comparator);
+			for (Resource content : installableContent)
+				ResourceInstaller.newInstance(coordination, content, subsystem).install();
+		}
 		// Simulate installation of shared content so that necessary relationships are established.
 		for (Resource content : subsystem.getResource().getSharedContent())
 			ResourceInstaller.newInstance(coordination, content, subsystem).install();



Mime
View raw message