incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n..@apache.org
Subject svn commit: r917778 - /incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/BundleInfoImpl.java
Date Mon, 01 Mar 2010 22:56:27 GMT
Author: not
Date: Mon Mar  1 22:56:26 2010
New Revision: 917778

URL: http://svn.apache.org/viewvc?rev=917778&view=rev
Log:
ARIES-183 Add toString, equals and hashCode for better debug and set handling.

Modified:
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/BundleInfoImpl.java

Modified: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/BundleInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/BundleInfoImpl.java?rev=917778&r1=917777&r2=917778&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/BundleInfoImpl.java
(original)
+++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/BundleInfoImpl.java
Mon Mar  1 22:56:26 2010
@@ -35,7 +35,7 @@
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 
-public class BundleInfoImpl implements BundleInfo {
+public final class BundleInfoImpl implements BundleInfo {
   private Content _symbolicName;
   private Version _version;
   private Attributes _attributes;
@@ -135,4 +135,30 @@
     
     return _requireBundle;
   }
-}
+  
+  /**
+   * Equality is just based on the location. If you install a bundle from the same location
string
+   * you get the same Bundle, even if the underlying bundle had a different symbolic name/version.
+   * This seems reasonable and quick.
+   */
+  public boolean equals(Object other)
+  {
+    if (other == null) return false;
+    if (other == this) return true;
+    if (other instanceof BundleInfoImpl) {
+      return _location.equals(((BundleInfoImpl)other)._location);
+    }
+    
+    return false;
+  }
+  
+  public int hashCode()
+  {
+    return _location.hashCode();
+  }
+  
+  public String toString()
+  {
+    return _symbolicName.getContentName() + "_" + getVersion();
+  }
+}
\ No newline at end of file



Mime
View raw message