aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1498639 - /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
Date Mon, 01 Jul 2013 19:36:14 GMT
Author: jwross
Date: Mon Jul  1 19:36:14 2013
New Revision: 1498639

URL: http://svn.apache.org/r1498639
Log:
[aries-1062] org.apache.aries.subsystem.core.internal.Activator needs to be improved

Refactor the Activator.addingService method. Start with patch
https://issues.apache.org/jira/secure/attachment/12581693/Activator.java.patch. Remove early
returns
and simply always call activate(). Remove nested ifs.

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

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java?rev=1498639&r1=1498638&r2=1498639&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
Mon Jul  1 19:36:14 2013
@@ -240,34 +240,24 @@ public class Activator implements Bundle
 	@Override
 	public synchronized Object addingService(ServiceReference<Object> reference) {
 		Object service = bundleContext.getService(reference);
-		if (service instanceof Coordinator) {
-			if (coordinator == null) {
-				coordinator = (Coordinator)service;
-				activate();
-			}
-		}
-		else if (service instanceof RegionDigraph) {
-			if (regionDigraph == null) {
-				regionDigraph = (RegionDigraph)service;
-				activate();
-			}
-		}
-		else if (service instanceof Resolver) {
-			if (resolver == null) {
-				resolver = (Resolver)service;
-				activate();
-			}
-		}
-		else if (service instanceof ModelledResourceManager) {
-			if (modelledResourceManager == null) {
-				modelledResourceManager = (ModelledResourceManager)service;
-				activate();
-			}
-		}
-		else if (service instanceof IDirectoryFinder)
-			finders.add((IDirectoryFinder)service);
-		else
-			repositories.add((Repository)service);
+		// Use all of each type of the following services.
+		if (service instanceof IDirectoryFinder)
+			finders.add((IDirectoryFinder) service);
+		else if (service instanceof Repository)
+			repositories.add((Repository) service);
+		// Use only one of each type of the following services.
+		else if (service instanceof Coordinator && coordinator == null)
+			coordinator = (Coordinator) service;
+		else if (service instanceof RegionDigraph && regionDigraph == null)
+			regionDigraph = (RegionDigraph) service;
+		else if (service instanceof Resolver && resolver == null)
+			resolver = (Resolver) service;
+		else if (service instanceof ModelledResourceManager && modelledResourceManager
== null)
+			modelledResourceManager = (ModelledResourceManager) service;
+		// Activation is harmless if already active or all required services
+		// have not yet been found.
+		activate();
+		// Filter guarantees we want to track all services received.
 		return service;
 	}
 



Mime
View raw message