felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1658274 - in /felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm: context/ impl/
Date Sun, 08 Feb 2015 23:16:27 GMT
Author: pderop
Date: Sun Feb  8 23:16:26 2015
New Revision: 1658274

URL: http://svn.apache.org/r1658274
Log:
Log an Error if one given dependency is added to more than one component.

Modified:
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
    felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/AbstractDependency.java
Sun Feb  8 23:16:26 2015
@@ -136,7 +136,6 @@ public abstract class AbstractDependency
      * @param prototype all the fields of the prototype will be copied to this dependency.
      */
     public AbstractDependency(AbstractDependency<T> prototype) {
-        m_component = prototype.m_component;
         m_instanceBound = prototype.m_instanceBound;
         m_required = prototype.m_required;
         m_add = prototype.m_add;
@@ -150,6 +149,11 @@ public abstract class AbstractDependency
         m_propagateCallbackInstance = prototype.m_propagateCallbackInstance;
         m_propagateCallbackMethod = prototype.m_propagateCallbackMethod;
     }
+    
+    @Override
+    public String toString() {
+        return new StringBuilder(getType()).append(" dependency [").append(getName()).append("]").toString();
+    }
 
     // ----------------------- Dependency interface -----------------------------
 
@@ -530,7 +534,7 @@ public abstract class AbstractDependency
      * Returns the component implementation context
      * @return the component implementation context
      */
-    protected ComponentContext getComponentContext() {
+    public ComponentContext getComponentContext() {
         return m_component;
     }
 

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/context/DependencyContext.java
Sun Feb  8 23:16:26 2015
@@ -38,6 +38,11 @@ public interface DependencyContext exten
     public void setComponentContext(ComponentContext component);
     
     /**
+     * Returns the Component implementation context associated to this Dependency context.
+     */
+    public ComponentContext getComponentContext();
+    
+    /**
      * The Component implementation asks this dependency to invoke a component dependency
callback.
      * 
      * @param type the type of the callback to invoke (add/change/remove/swap ...)

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/BundleDependencyImpl.java
Sun Feb  8 23:16:26 2015
@@ -83,7 +83,7 @@ public class BundleDependencyImpl extend
         m_tracker = null;
         super.stop();
     }
-
+    
     @Override
     public String getName() {
         StringBuilder sb = new StringBuilder();

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ComponentImpl.java
Sun Feb  8 23:16:26 2015
@@ -172,6 +172,11 @@ public class ComponentImpl implements Co
 				List<DependencyContext> instanceBoundDeps = new ArrayList<>();
 				for (Dependency d : dependencies) {
 					DependencyContext dc = (DependencyContext) d;
+					if (dc.getComponentContext() != null) {
+                        m_logger.err("%s can't be added to %s (dependency already added to
another component).", dc,
+                            ComponentImpl.this);
+                        continue;
+					}
 					m_dependencyEvents.put(dc,  new ConcurrentSkipListSet<Event>());
 					m_dependencies.add(dc);
 					dc.setComponentContext(ComponentImpl.this);

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
Sun Feb  8 23:16:26 2015
@@ -127,10 +127,6 @@ public class ConfigurationDependencyImpl
 		return this;
 	}
 		
-    public String toString() {
-    	return "ConfigurationDependency[" + m_pid + "]";
-    }
-    
     @Override
     public String getSimpleName() {
         return m_pid;

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FilterComponent.java
Sun Feb  8 23:16:26 2015
@@ -65,6 +65,11 @@ public class FilterComponent implements
     public FilterComponent(Component service) {
         m_component = (ComponentImpl) service;
     }
+    
+    @Override
+    public String toString() {
+        return m_component.toString();
+    }
 
     public Component add(Dependency ... dependencies) {
         m_component.add(dependencies);

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ResourceDependencyImpl.java
Sun Feb  8 23:16:26 2015
@@ -234,7 +234,7 @@ public class ResourceDependencyImpl exte
             throw new IllegalStateException("cannot find resource");
         }
     }
-
+    
     @Override
     public String getName() {
         StringBuilder sb = new StringBuilder();

Modified: felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java?rev=1658274&r1=1658273&r2=1658274&view=diff
==============================================================================
--- felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
(original)
+++ felix/sandbox/pderop/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ServiceDependencyImpl.java
Sun Feb  8 23:16:26 2015
@@ -32,7 +32,6 @@ import org.apache.felix.dm.Component;
 import org.apache.felix.dm.ComponentDeclaration;
 import org.apache.felix.dm.ServiceDependency;
 import org.apache.felix.dm.context.AbstractDependency;
-import org.apache.felix.dm.context.ComponentContext;
 import org.apache.felix.dm.context.DependencyContext;
 import org.apache.felix.dm.context.Event;
 import org.apache.felix.dm.context.EventType;
@@ -307,11 +306,6 @@ public class ServiceDependencyImpl exten
     }
     
     @Override
-    public String toString() {
-        return "ServiceDependency[" + m_trackedServiceName + " " + m_trackedServiceFilterUnmodified
+ "]";
-    }
-
-    @Override
     public String getName() {
         StringBuilder sb = new StringBuilder();
         if (m_trackedServiceName != null) {
@@ -554,8 +548,4 @@ public class ServiceDependencyImpl exten
 			removedService(reference, service);
 		}
 	}	
-	
-    public ComponentContext getComponentContext() {
-        return m_component;
-    }
 }



Mime
View raw message