Return-Path: X-Original-To: apmail-aries-commits-archive@www.apache.org Delivered-To: apmail-aries-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B2CBE10969 for ; Mon, 1 Jul 2013 19:36:36 +0000 (UTC) Received: (qmail 60492 invoked by uid 500); 1 Jul 2013 19:36:36 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 60426 invoked by uid 500); 1 Jul 2013 19:36:36 -0000 Mailing-List: contact commits-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list commits@aries.apache.org Received: (qmail 60418 invoked by uid 99); 1 Jul 2013 19:36:35 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jul 2013 19:36:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jul 2013 19:36:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 9853E23889D5; Mon, 1 Jul 2013 19:36:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@aries.apache.org From: jwross@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130701193614.9853E23889D5@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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; }