You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2012/05/02 15:01:38 UTC

svn commit: r1333021 - in /felix/trunk/resolver/src/main/java/org/apache/felix/resolver: Activator.java ResolverImpl.java WireImpl.java

Author: rickhall
Date: Wed May  2 13:01:37 2012
New Revision: 1333021

URL: http://svn.apache.org/viewvc?rev=1333021&view=rev
Log:
Created equals()/hashCode() methods for Wire (FELIX-3495), removed exception from
stop() activator method, and make copies of mandatory/optional resource parameters
from ResolveContext.

Modified:
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Activator.java
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
    felix/trunk/resolver/src/main/java/org/apache/felix/resolver/WireImpl.java

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Activator.java?rev=1333021&r1=1333020&r2=1333021&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Activator.java (original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/Activator.java Wed May  2 13:01:37 2012
@@ -48,6 +48,5 @@ public class Activator implements Bundle
 
     public void stop(BundleContext bc) throws Exception
     {
-        throw new UnsupportedOperationException("Not supported yet.");
     }
 }
\ No newline at end of file

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java?rev=1333021&r1=1333020&r2=1333021&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java (original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java Wed May  2 13:01:37 2012
@@ -67,8 +67,9 @@ public class ResolverImpl implements Res
         Map<Resource, Packages> resourcePkgMap =
             new HashMap<Resource, Packages>();
 
-        Collection<Resource> mandatoryResources = rc.getMandatoryResources();
-        Collection<Resource> optionalResources = rc.getOptionalResources();
+        // Make copies of arguments in case we want to modify them.
+        Collection<Resource> mandatoryResources = new ArrayList(rc.getMandatoryResources());
+        Collection<Resource> optionalResources = new ArrayList(rc.getOptionalResources());
 // TODO: RFC-112 - Need impl-specific type.
 //        Collection<Resource> ondemandFragments = (rc instanceof ResolveContextImpl)
 //            ? ((ResolveContextImpl) rc).getOndemandResources() : Collections.EMPTY_LIST;

Modified: felix/trunk/resolver/src/main/java/org/apache/felix/resolver/WireImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/resolver/src/main/java/org/apache/felix/resolver/WireImpl.java?rev=1333021&r1=1333020&r2=1333021&view=diff
==============================================================================
--- felix/trunk/resolver/src/main/java/org/apache/felix/resolver/WireImpl.java (original)
+++ felix/trunk/resolver/src/main/java/org/apache/felix/resolver/WireImpl.java Wed May  2 13:01:37 2012
@@ -67,4 +67,50 @@ class WireImpl implements Wire
             + " -> "
             + "[" + m_provider + "]";
     }
+
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (obj == null)
+        {
+            return false;
+        }
+        if (!(obj instanceof Wire))
+        {
+            return false;
+        }
+        final Wire other = (Wire) obj;
+        if (this.m_requirer != other.getRequirer()
+            && (this.m_requirer == null || !this.m_requirer.equals(other.getRequirer())))
+        {
+            return false;
+        }
+        if (this.m_req != other.getRequirement()
+            && (this.m_req == null || !this.m_req.equals(other.getRequirement())))
+        {
+            return false;
+        }
+        if (this.m_provider != other.getProvider()
+            && (this.m_provider == null || !this.m_provider.equals(other.getProvider())))
+        {
+            return false;
+        }
+        if (this.m_cap != other.getCapability()
+            && (this.m_cap == null || !this.m_cap.equals(other.getCapability())))
+        {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public int hashCode()
+    {
+        int hash = 5;
+        hash = 29 * hash + (this.m_requirer != null ? this.m_requirer.hashCode() : 0);
+        hash = 29 * hash + (this.m_req != null ? this.m_req.hashCode() : 0);
+        hash = 29 * hash + (this.m_provider != null ? this.m_provider.hashCode() : 0);
+        hash = 29 * hash + (this.m_cap != null ? this.m_cap.hashCode() : 0);
+        return hash;
+    }
 }
\ No newline at end of file