incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r955918 - in /sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl: OsgiInstallerContext.java PersistentBundleInfo.java
Date Fri, 18 Jun 2010 10:05:05 GMT
Author: cziegeler
Date: Fri Jun 18 10:05:05 2010
New Revision: 955918

URL: http://svn.apache.org/viewvc?rev=955918&view=rev
Log:
SLING-1560 : Improve and clean up code
Silently close streams

Modified:
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
    sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java?rev=955918&r1=955917&r2=955918&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/OsgiInstallerContext.java
Fri Jun 18 10:05:05 2010
@@ -26,13 +26,27 @@ import org.osgi.framework.Version;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.packageadmin.PackageAdmin;
 
-/** Installer context, gives access to selected methods of the {@link OsgiInstallerImpl}
*/
+/**
+ * Installer context, gives access to selected methods of the {@link OsgiInstallerImpl}
+ */
 public interface OsgiInstallerContext {
 
+    /**
+     * Return the bundle context.
+     */
     BundleContext getBundleContext();
-	PackageAdmin getPackageAdmin();
-	ConfigurationAdmin getConfigurationAdmin();
-	void incrementCounter(int index);
+
+    /**
+     * Return the package admin.
+     */
+    PackageAdmin getPackageAdmin();
+
+    /**
+     * Return the config admin.
+     */
+    ConfigurationAdmin getConfigurationAdmin();
+
+    void incrementCounter(int index);
     void setCounter(int index, long value);
     Bundle getMatchingBundle(String bundleSymbolicName);
     boolean isSnapshot(Version v);
@@ -58,16 +72,33 @@ public interface OsgiInstallerContext {
      * */
     String getInstalledBundleVersion(String symbolicName) throws IOException;
 
-
+    /**
+     * Log a debug message.
+     */
     void logDebug(final String message);
 
+    /**
+     * Log a debug message with exception.
+     */
     void logDebug(final String message, final Throwable t);
 
+    /**
+     * Log a info message.
+     */
     void logInfo(final String message);
 
+    /**
+     * Log a info message with exception.
+     */
     void logInfo(final String message, final Throwable t);
 
+    /**
+     * Log a warning message.
+     */
     void logWarn(final String message);
 
+    /**
+     * Log a warning message with exception.
+     */
     void logWarn(final String message, final Throwable t);
 }

Modified: sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java?rev=955918&r1=955917&r2=955918&view=diff
==============================================================================
--- sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java
(original)
+++ sling/trunk/installer/osgi/installer/src/main/java/org/apache/sling/osgi/installer/impl/PersistentBundleInfo.java
Fri Jun 18 10:05:05 2010
@@ -29,19 +29,22 @@ import java.util.List;
 import java.util.Properties;
 import java.util.TreeSet;
 
-/** Store the digests and version numbers of installed bundles
- *  in a file, to keep track of what we installed.
+/**
+ * Store the digests and version numbers of installed bundles
+ * in a file, to keep track of what we installed.
  */
 class PersistentBundleInfo {
+
     private Properties digests = new Properties();
     private final File dataFile;
     private final OsgiInstallerContext ctx;
     private static final String VERSION_PREFIX = "V:";
 
-    /** Load the list from supplied file, which is also
-     *  used by purgeAndSave to save our data
+    /**
+     * Load the list from supplied file, which is also
+     * used by purgeAndSave to save our data.
      */
-    PersistentBundleInfo(OsgiInstallerContext ctx, File dataFile) throws IOException {
+    PersistentBundleInfo(OsgiInstallerContext ctx, File dataFile) {
         this.ctx = ctx;
         this.dataFile = dataFile;
         InputStream is = null;
@@ -52,14 +55,15 @@ class PersistentBundleInfo {
         } catch(IOException ioe) {
             ctx.logInfo("No digests retrieved, cannot read properties file " + dataFile.getName());
         } finally {
-            if(is != null) {
-                is.close();
+            if (is != null) {
+                try {is.close(); } catch (final IOException ignore) {}
             }
         }
     }
 
-    /** Remove data which do not belongs to installed bundles,
-     *  and save our data
+    /**
+     * Remove data which do not belongs to installed bundles,
+     * and save our data
      */
     void purgeAndSave(TreeSet<String> installedBundlesSymbolicNames) throws IOException
{
         final List<String> toRemove = new ArrayList<String>();
@@ -79,26 +83,32 @@ class PersistentBundleInfo {
             os = new FileOutputStream(dataFile);
             digests.store(os, "Stored by " + getClass().getName());
         } finally {
-            if(os != null) {
-                os.flush();
-                os.close();
+            if (os != null) {
+                try {os.flush(); } catch (final IOException ignore) {}
+                try {os.close(); } catch (final IOException ignore) {}
             }
         }
         ctx.logInfo("Stored digests of " + digests.size() + " bundles in data file " + dataFile.getName());
     }
 
-    /** Store a bundle digest - not persisted until purgeAndSave is called */
+    /**
+     * Store a bundle digest - not persisted until purgeAndSave is called.
+     */
     void putInfo(String bundleSymbolicName, String digest, String installedVersion) {
         digests.setProperty(bundleSymbolicName, digest);
         digests.setProperty(VERSION_PREFIX + bundleSymbolicName, installedVersion);
     }
 
-    /** Retrieve digest, null if not found */
+    /**
+     * Retrieve digest, null if not found.
+     */
     String getDigest(String bundleSymbolicName) {
         return digests.getProperty(bundleSymbolicName);
     }
 
-    /** Retrieve installed version, null if not found */
+    /**
+     * Retrieve installed version, null if not found.
+     */
     String getInstalledVersion(String bundleSymbolicName) {
         return digests.getProperty(VERSION_PREFIX + bundleSymbolicName);
     }



Mime
View raw message