From 8e6a88f76a60bb864d67ea61beb461e5a29a846c Mon Sep 17 00:00:00 2001 From: Carsten Hammer Date: Fri, 5 Jul 2019 20:38:23 +0200 Subject: Use jdk 5 for-each-loop (comp.tests, console, ds.tests, event, http) Replace most simple uses of Iterator with a corresponding for-each-loop. Also add missing braces on loops as necessary. Change-Id: I0dcaa50a43e0ff3b450f386dfa856d75bdcb6cbc Signed-off-by: Carsten Hammer --- .../equinox/compendium/tests/Activator.java | 6 +- .../equinox/metatype/tests/AbstractTest.java | 9 +- .../metatype/tests/AttributeTypePasswordTest.java | 6 +- .../equinox/metatype/tests/ExtendableTest.java | 10 +- .../metatype/tests/GetDefaultValueTest.java | 104 +++++------ .../console/commands/EquinoxCommandProvider.java | 198 ++++++++++----------- .../META-INF/MANIFEST.MF | 2 +- bundles/org.eclipse.equinox.ds.tests/pom.xml | 2 +- .../eclipse/equinox/ds/tests/DSTestsActivator.java | 11 +- .../org/eclipse/equinox/ds/tests/tbc/DSTest.java | 32 ++-- .../eclipse/equinox/internal/event/Activator.java | 6 +- .../META-INF/MANIFEST.MF | 2 +- bundles/org.eclipse.equinox.http.jetty/pom.xml | 2 +- .../http/jetty/internal/HttpServerManager.java | 8 +- .../META-INF/MANIFEST.MF | 2 +- .../org.eclipse.equinox.http.servlet.tests/pom.xml | 2 +- .../http/servlet/tests/bundle/BundleAdvisor.java | 3 +- .../META-INF/MANIFEST.MF | 2 +- bundles/org.eclipse.equinox.http.servlet/pom.xml | 2 +- .../servlet/internal/context/ProxyContext.java | 8 +- .../internal/servlet/ServletContextAdaptor.java | 3 +- 21 files changed, 210 insertions(+), 210 deletions(-) diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java index f51298829..415bcdfc2 100644 --- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java +++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/compendium/tests/Activator.java @@ -70,9 +70,9 @@ public class Activator implements BundleActivator { Bundle[] bundles = packageAdmin.getBundles(symbolicName, null); if (bundles == null) return null; - for (int i = 0; i < bundles.length; i++) { - if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { - return bundles[i]; + for (Bundle bundle : bundles) { + if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { + return bundle; } } return null; diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java index 8c0358430..a173cf4f7 100644 --- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java +++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AbstractTest.java @@ -125,11 +125,12 @@ public abstract class AbstractTest { protected AttributeDefinition findAttributeDefinitionById(String id, AttributeDefinition[] ads) { if (id == null || ads == null) return null; - for (int i = 0; i < ads.length; i++) { - if (ads[i] == null) + for (AttributeDefinition ad : ads) { + if (ad == null) { continue; - if (id.equals(ads[i].getID())) { - return ads[i]; + } + if (id.equals(ad.getID())) { + return ad; } } return null; diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java index 07f4eb183..c51c9d70a 100644 --- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java +++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/AttributeTypePasswordTest.java @@ -42,9 +42,9 @@ public class AttributeTypePasswordTest extends AbstractTest { MetaTypeInformation mti = metatype.getMetaTypeInformation(bundle); ObjectClassDefinition ocd = mti.getObjectClassDefinition("org.eclipse.equinox.metatype.tests.tb1", null); //$NON-NLS-1$ AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); - for (int i = 0; i < ads.length; i++) { - if (ads[i].getID().equals("password1")) { //$NON-NLS-1$ - Assert.assertEquals("Attribute type is not PASSWORD", AttributeDefinition.PASSWORD, ads[i].getType()); //$NON-NLS-1$ + for (AttributeDefinition ad : ads) { + if (ad.getID().equals("password1")) { //$NON-NLS-1$ + Assert.assertEquals("Attribute type is not PASSWORD", AttributeDefinition.PASSWORD, ad.getType()); //$NON-NLS-1$ } } } diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java index 28c7f4507..9eb9a3d26 100644 --- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java +++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/ExtendableTest.java @@ -57,18 +57,18 @@ public class ExtendableTest extends AbstractTest { Assert.assertEquals("Wrong attributes size", 1, attributes.size()); //$NON-NLS-1$ Assert.assertEquals("Wrong value", "true", attributes.get("enabled")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ EquinoxAttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); - for (int i = 0; i < ads.length; i++) { - if (ads[i].getID().equals("ad1")) { //$NON-NLS-1$ - schemas = ads[i].getExtensionUris(); + for (EquinoxAttributeDefinition ad : ads) { + if (ad.getID().equals("ad1")) { //$NON-NLS-1$ + schemas = ad.getExtensionUris(); Assert.assertNotNull("Null extension schemas", schemas); //$NON-NLS-1$ Assert.assertEquals("Wrong schemas size", 2, schemas.size()); //$NON-NLS-1$ assertTrue("Missing schema", schemas.contains("urn:xmlns:foo")); //$NON-NLS-1$ //$NON-NLS-2$ assertTrue("Missing schema", schemas.contains("urn:xmlns:validation")); //$NON-NLS-1$ //$NON-NLS-2$ - attributes = ads[i].getExtensionAttributes("urn:xmlns:foo"); //$NON-NLS-1$ + attributes = ad.getExtensionAttributes("urn:xmlns:foo"); //$NON-NLS-1$ Assert.assertNotNull("Null attributes", attributes); //$NON-NLS-1$ Assert.assertEquals("Wrong attributes size", 1, attributes.size()); //$NON-NLS-1$ Assert.assertEquals("Wrong value", "foo", attributes.get("bar")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - attributes = ads[i].getExtensionAttributes("urn:xmlns:validation"); //$NON-NLS-1$ + attributes = ad.getExtensionAttributes("urn:xmlns:validation"); //$NON-NLS-1$ Assert.assertNotNull("Null attributes", attributes); //$NON-NLS-1$ Assert.assertEquals("Wrong attributes size", 2, attributes.size()); //$NON-NLS-1$ Assert.assertEquals("Wrong value", "[a-zA-Z0-9]", attributes.get("regexp")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ diff --git a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java index b33fade25..509d29c84 100644 --- a/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java +++ b/bundles/org.eclipse.equinox.compendium.tests/src/org/eclipse/equinox/metatype/tests/GetDefaultValueTest.java @@ -45,82 +45,82 @@ public class GetDefaultValueTest extends AbstractTest { Assert.assertEquals("Wrong object class definition name", "getDefaultValues", ocd.getName()); //$NON-NLS-1$ //$NON-NLS-2$ AttributeDefinition[] ads = ocd.getAttributeDefinitions(ObjectClassDefinition.ALL); Assert.assertEquals("Wrong number of attribute definitions", 24, ads.length); //$NON-NLS-1$ - for (int i = 0; i < ads.length; i++) { - switch (Integer.parseInt(ads[i].getID())) { - case 1 : - assertAttributeDefinition(ads[i], 0, null, null, "1", null, null, null, AttributeDefinition.INTEGER); //$NON-NLS-1$ + for (AttributeDefinition ad : ads) { + switch (Integer.parseInt(ad.getID())) { + case 1: + assertAttributeDefinition(ad, 0, null, null, "1", null, null, null, AttributeDefinition.INTEGER); //$NON-NLS-1$ break; - case 2 : - assertAttributeDefinition(ads[i], 1, null, null, "2", null, null, null, AttributeDefinition.DOUBLE); //$NON-NLS-1$ + case 2: + assertAttributeDefinition(ad, 1, null, null, "2", null, null, null, AttributeDefinition.DOUBLE); //$NON-NLS-1$ break; - case 3 : - assertAttributeDefinition(ads[i], -1, null, null, "3", null, null, null, AttributeDefinition.SHORT); //$NON-NLS-1$ + case 3: + assertAttributeDefinition(ad, -1, null, null, "3", null, null, null, AttributeDefinition.SHORT); //$NON-NLS-1$ break; - case 4 : - assertAttributeDefinition(ads[i], 5, null, null, "4", null, null, null, AttributeDefinition.BYTE); //$NON-NLS-1$ + case 4: + assertAttributeDefinition(ad, 5, null, null, "4", null, null, null, AttributeDefinition.BYTE); //$NON-NLS-1$ break; - case 5 : - assertAttributeDefinition(ads[i], -10, null, null, "5", null, null, null, AttributeDefinition.INTEGER); //$NON-NLS-1$ + case 5: + assertAttributeDefinition(ad, -10, null, null, "5", null, null, null, AttributeDefinition.INTEGER); //$NON-NLS-1$ break; - case 6 : - assertAttributeDefinition(ads[i], 0, null, null, "6", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ + case 6: + assertAttributeDefinition(ad, 0, null, null, "6", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ break; - case 7 : - assertAttributeDefinition(ads[i], 1, null, null, "7", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ + case 7: + assertAttributeDefinition(ad, 1, null, null, "7", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ break; - case 8 : - assertAttributeDefinition(ads[i], -1, null, null, "8", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ + case 8: + assertAttributeDefinition(ad, -1, null, null, "8", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ break; - case 9 : - assertAttributeDefinition(ads[i], 20, null, null, "9", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ + case 9: + assertAttributeDefinition(ad, 20, null, null, "9", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ break; - case 10 : - assertAttributeDefinition(ads[i], -9, null, null, "10", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ + case 10: + assertAttributeDefinition(ad, -9, null, null, "10", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ break; - case 11 : - assertAttributeDefinition(ads[i], 0, null, null, "11", null, null, null, AttributeDefinition.BYTE); //$NON-NLS-1$ + case 11: + assertAttributeDefinition(ad, 0, null, null, "11", null, null, null, AttributeDefinition.BYTE); //$NON-NLS-1$ break; - case 12 : - assertAttributeDefinition(ads[i], 1, null, null, "12", null, null, null, AttributeDefinition.SHORT); //$NON-NLS-1$ + case 12: + assertAttributeDefinition(ad, 1, null, null, "12", null, null, null, AttributeDefinition.SHORT); //$NON-NLS-1$ break; - case 13 : - assertAttributeDefinition(ads[i], -1, null, null, "13", null, null, null, AttributeDefinition.INTEGER); //$NON-NLS-1$ + case 13: + assertAttributeDefinition(ad, -1, null, null, "13", null, null, null, AttributeDefinition.INTEGER); //$NON-NLS-1$ break; - case 14 : - assertAttributeDefinition(ads[i], 7, null, null, "14", null, null, null, AttributeDefinition.DOUBLE); //$NON-NLS-1$ + case 14: + assertAttributeDefinition(ad, 7, null, null, "14", null, null, null, AttributeDefinition.DOUBLE); //$NON-NLS-1$ break; - case 15 : - assertAttributeDefinition(ads[i], -3, null, null, "15", null, null, null, AttributeDefinition.DOUBLE); //$NON-NLS-1$ + case 15: + assertAttributeDefinition(ad, -3, null, null, "15", null, null, null, AttributeDefinition.DOUBLE); //$NON-NLS-1$ break; - case 16 : - assertAttributeDefinition(ads[i], 0, new String[] {""}, null, "16", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ //$NON-NLS-2$ + case 16: + assertAttributeDefinition(ad, 0, new String[] {""}, null, "16", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ //$NON-NLS-2$ break; - case 17 : - assertAttributeDefinition(ads[i], 1, new String[0], null, "17", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ + case 17: + assertAttributeDefinition(ad, 1, new String[0], null, "17", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ break; - case 18 : - assertAttributeDefinition(ads[i], -1, new String[0], null, "18", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ + case 18: + assertAttributeDefinition(ad, -1, new String[0], null, "18", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ break; - case 19 : - assertAttributeDefinition(ads[i], 42, new String[0], null, "19", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ + case 19: + assertAttributeDefinition(ad, 42, new String[0], null, "19", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ break; - case 20 : - assertAttributeDefinition(ads[i], -210, new String[0], null, "20", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ + case 20: + assertAttributeDefinition(ad, -210, new String[0], null, "20", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ break; - case 21 : - assertAttributeDefinition(ads[i], 2, new String[] {"", ""}, null, "21", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + case 21: + assertAttributeDefinition(ad, 2, new String[] {"", ""}, null, "21", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ break; - case 22 : - assertAttributeDefinition(ads[i], -2, new String[] {"", ""}, null, "22", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + case 22: + assertAttributeDefinition(ad, -2, new String[] {"", ""}, null, "22", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ break; - case 23 : - assertAttributeDefinition(ads[i], 4, new String[] {"", "", ""}, null, "23", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + case 23: + assertAttributeDefinition(ad, 4, new String[] {"", "", ""}, null, "23", null, null, null, AttributeDefinition.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ break; - case 24 : - assertAttributeDefinition(ads[i], -8, new String[] {"", "", "", "", ""}, null, "24", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ + case 24: + assertAttributeDefinition(ad, -8, new String[] {"", "", "", "", ""}, null, "24", null, null, null, AttributeDefinition.PASSWORD); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ break; - default : - fail("Unexpected attribute definition ID: " + ads[i].getID()); //$NON-NLS-1$ + default: + fail("Unexpected attribute definition ID: " + ad.getID()); //$NON-NLS-1$ } } } diff --git a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java index b07c67a65..1833407fb 100755 --- a/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java +++ b/bundles/org.eclipse.equinox.console/src/org/eclipse/equinox/console/commands/EquinoxCommandProvider.java @@ -7,7 +7,7 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 - * + * * Contributors: * IBM Corporation - initial API and implementation * Lazar Kirchev, SAP AG - derivative implementation to migrate the commands from FrameworkCommandProvider to Gogo shell commands @@ -79,7 +79,7 @@ import org.osgi.service.startlevel.StartLevel; /** * This class provides methods to execute commands from the command line. It registers - * itself as a service so it can be invoked by a CommandProcessor. + * itself as a service so it can be invoked by a CommandProcessor. * * The commands provided by this class are: ---Controlling the OSGi framework--- @@ -138,18 +138,18 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { /** this list contains the bundles known to be lazily awaiting activation */ private final List lazyActivation = new ArrayList<>(); - + private Activator activator; - - /** commands provided by this command provider */ - private static final String[] functions = new String[] {"exit", "shutdown", "sta", "start", "sto", "stop", "i", + + /** commands provided by this command provider */ + private static final String[] functions = new String[] {"exit", "shutdown", "sta", "start", "sto", "stop", "i", "install", "up", "up", "up", "update", "update", "update", "un", "uninstall", "s", "status", "se", "services", "p", "p", "packages", "packages", "bundles", "b", "bundle", "gc", "init", "close", "r", "refresh", "exec", "fork", "h", "headers", "pr", "props", "setp", "setprop", "ss", "t", "threads", "sl", "setfwsl", "setbsl", - "setibsl", "requiredBundles", "classSpaces", "profilelog", "getPackages", "getprop", "diag", "enableBundle", + "setibsl", "requiredBundles", "classSpaces", "profilelog", "getPackages", "getprop", "diag", "enableBundle", "disableBundle", "disabledBundles"}; - - + + /** * Constructor. * @@ -171,7 +171,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void startService() { EquinoxCommandsConverter converter = new EquinoxCommandsConverter(context); converterReg = context.registerService(Converter.class.getName(), converter, null); - + Dictionary props = new Hashtable<>(); props.put(Constants.SERVICE_RANKING, Integer.valueOf(Integer.MAX_VALUE)); props.put(CommandProcessor.COMMAND_SCOPE, "equinox"); @@ -184,9 +184,9 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { if (converterReg != null) { converterReg.unregister(); } - + context.removeBundleListener(this); - + if (providerReg != null) { providerReg.unregister(); } @@ -233,12 +233,12 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + if (bundles.length == 0) { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + for(Bundle bundle : bundles) { bundle.start(); } @@ -265,12 +265,12 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + if (bundles.length == 0) { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + for(Bundle bundle : bundles) { bundle.stop(); } @@ -326,7 +326,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void up(@Descriptor(ConsoleMsg.CONSOLE_HELP_UPDATE_COMMAND_ARGUMENT_DESCRIPTION) Bundle[] bundles) throws Exception { update(bundles); } - + /** * Handle the update command's abbreviation. Invoke update() * @@ -336,12 +336,12 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { @Descriptor(ConsoleMsg.CONSOLE_HELP_UPDATE_SOURCE_COMMAND_DESCRIPTION) public void up( @Descriptor(ConsoleMsg.CONSOLE_HELP_UPDATE_SOURCE_COMMAND_BUNDLE_ARGUMENT_DESCRIPTION) - Bundle bundle, + Bundle bundle, @Descriptor(ConsoleMsg.CONSOLE_HELP_UPDATE_SOURCE_COMMAND_URL_ARGUMENT_DESCRIPTION) URL source) throws Exception { update(bundle, source); } - + /** * Handle the update command. Update the specified bundle(s). * @@ -353,12 +353,12 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + if(bundles.length == 0) { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + for(Bundle bundle : bundles) { bundle.update(); } @@ -373,7 +373,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { @Descriptor(ConsoleMsg.CONSOLE_HELP_UPDATE_SOURCE_COMMAND_DESCRIPTION) public void update( @Descriptor(ConsoleMsg.CONSOLE_HELP_UPDATE_SOURCE_COMMAND_BUNDLE_ARGUMENT_DESCRIPTION) - Bundle bundle, + Bundle bundle, @Descriptor(ConsoleMsg.CONSOLE_HELP_UPDATE_SOURCE_COMMAND_URL_ARGUMENT_DESCRIPTION) URL source) throws Exception { bundle.update(source.openStream()); @@ -400,12 +400,12 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + if(bundles.length == 0) { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + for (Bundle bundle : bundles) { bundle.uninstall(); } @@ -431,11 +431,11 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } return stateFilter; } - + /** * Handle the status command's abbreviation. Invoke status() * - * @param arguments + * @param arguments */ @Descriptor(ConsoleMsg.CONSOLE_HELP_STATUS_COMMAND_DESCRIPTION) public void s(@Descriptor(ConsoleMsg.CONSOLE_HELP_STATUS_ARGUMENT_DESCRIPTION) String... arguments) throws Exception { @@ -455,10 +455,10 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE); } System.out.println(); - + String states = ""; String[] bsnSegments = null; - + if(arguments != null && arguments.length > 0) { if(arguments[0].equals("-s")) { if (arguments.length > 1) { @@ -474,13 +474,13 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } int stateFilter; - + try { stateFilter = getStatesFromConstants(states); } catch (IllegalArgumentException e) { return; } - + Bundle[] bundles = context.getBundles(); int size = bundles.length; @@ -488,7 +488,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_INSTALLED_BUNDLES_ERROR); return; } - + System.out.print(ConsoleMsg.CONSOLE_ID); System.out.print(tab); System.out.println(ConsoleMsg.CONSOLE_BUNDLE_LOCATION_MESSAGE); @@ -580,9 +580,9 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { if (users != null) { System.out.print(" "); //$NON-NLS-1$ System.out.println(ConsoleMsg.CONSOLE_BUNDLES_USING_SERVICE_MESSAGE); - for (int k = 0; k < users.length; k++) { + for (Bundle user : users) { System.out.print(" "); //$NON-NLS-1$ - System.out.println(users[k]); + System.out.println(user); } } else { System.out.print(" "); //$NON-NLS-1$ @@ -604,7 +604,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void p(@Descriptor(ConsoleMsg.CONSOLE_HELP_PACKAGES_BUNDLE_ARGUMENT_DESCRIPTION)Bundle... bundle) throws Exception { packages(bundle); } - + /** * Handle the packages command's abbreviation. Invoke packages() * @@ -614,7 +614,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void p(@Descriptor(ConsoleMsg.CONSOLE_HELP_PACKAGES_PACKAGE_ARGUMENT_DESCRIPTION)String packageName) throws Exception { packages(packageName); } - + /** * Handle the packages command. Display imported/exported packages details. * @@ -635,7 +635,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE); } } - + /** * Handle the packages command. Display imported/exported packages details. * @@ -651,34 +651,30 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_NO_PACKAGE_ADMIN_MESSAGE); } } - + @SuppressWarnings("deprecation") private void getPackages(ExportedPackage[] packages) throws Exception { if (packages == null) { System.out.println(ConsoleMsg.CONSOLE_NO_EXPORTED_PACKAGES_MESSAGE); return; } - for (int i = 0; i < packages.length; i++) { - org.osgi.service.packageadmin.ExportedPackage pkg = packages[i]; + for (ExportedPackage pkg : packages) { System.out.print(pkg); - boolean removalPending = pkg.isRemovalPending(); if (removalPending) { System.out.print("("); //$NON-NLS-1$ System.out.print(ConsoleMsg.CONSOLE_REMOVAL_PENDING_MESSAGE); System.out.println(")"); //$NON-NLS-1$ } - org.osgi.framework.Bundle exporter = pkg.getExportingBundle(); if (exporter != null) { System.out.print("<"); //$NON-NLS-1$ System.out.print(exporter); System.out.println(">"); //$NON-NLS-1$ - org.osgi.framework.Bundle[] importers = pkg.getImportingBundles(); - for (int j = 0; j < importers.length; j++) { + for (Bundle importer : importers) { System.out.print(" "); //$NON-NLS-1$ - System.out.print(importers[j]); + System.out.print(importer); System.out.print(" "); //$NON-NLS-1$ System.out.println(ConsoleMsg.CONSOLE_IMPORTS_MESSAGE); } @@ -699,7 +695,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void bundles(@Descriptor(ConsoleMsg.CONSOLE_HELP_STATUS_ARGUMENT_DESCRIPTION) String... arguments) throws Exception { String states = ""; String[] bsnSegments = null; - + if(arguments != null && arguments.length > 0) { if(arguments[0].equals("-s")) { if (arguments.length > 1) { @@ -750,9 +746,9 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { if (services != null) { System.out.print(" "); //$NON-NLS-1$ System.out.println(ConsoleMsg.CONSOLE_REGISTERED_SERVICES_MESSAGE); - for (int j = 0; j < services.length; j++) { + for (ServiceReference service : services) { System.out.print(" "); //$NON-NLS-1$ - System.out.println(services[j]); + System.out.println(service); } } else { System.out.print(" "); //$NON-NLS-1$ @@ -763,9 +759,9 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { if (services != null) { System.out.print(" "); //$NON-NLS-1$ System.out.println(ConsoleMsg.CONSOLE_SERVICES_IN_USE_MESSAGE); - for (int j = 0; j < services.length; j++) { + for (ServiceReference service : services) { System.out.print(" "); //$NON-NLS-1$ - System.out.println(services[j]); + System.out.println(service); } } else { System.out.print(" "); //$NON-NLS-1$ @@ -795,7 +791,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return; } - + for (Bundle bundle : bundles) { long id = bundle.getBundleId(); System.out.println(bundle); @@ -816,9 +812,9 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { if (services != null) { System.out.print(" "); //$NON-NLS-1$ System.out.println(ConsoleMsg.CONSOLE_REGISTERED_SERVICES_MESSAGE); - for (int j = 0; j < services.length; j++) { + for (ServiceReference service : services) { System.out.print(" "); //$NON-NLS-1$ - System.out.println(services[j]); + System.out.println(service); } } else { System.out.print(" "); //$NON-NLS-1$ @@ -829,9 +825,9 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { if (services != null) { System.out.print(" "); //$NON-NLS-1$ System.out.println(ConsoleMsg.CONSOLE_SERVICES_IN_USE_MESSAGE); - for (int j = 0; j < services.length; j++) { + for (ServiceReference service : services) { System.out.print(" "); //$NON-NLS-1$ - System.out.println(services[j]); + System.out.println(service); } } else { System.out.print(" "); //$NON-NLS-1$ @@ -934,10 +930,10 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } } - + System.out.println(); System.out.println(); - } + } } private List getUnresolvedImports( @@ -1069,8 +1065,9 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { securityAdmin.setDefaultPermissions(null); String[] permLocations = securityAdmin.getLocations(); if (permLocations != null) - for (int i = 0; i < permLocations.length; i++) - securityAdmin.setPermissions(permLocations[i], null); + for (String permLocation : permLocations) { + securityAdmin.setPermissions(permLocation, null); + } ConditionalPermissionUpdate update = condPermAdmin.newConditionalPermissionUpdate(); update.getConditionalPermissionInfos().clear(); update.commit(); @@ -1083,7 +1080,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { /** * Handle the close command. Shutdown and exit. - + */ @Descriptor(ConsoleMsg.CONSOLE_HELP_CLOSE_COMMAND_DESCRIPTION) public void close() throws Exception { @@ -1187,19 +1184,19 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { @Descriptor(ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_DESCRIPTION) public List> headers(@Descriptor(ConsoleMsg.CONSOLE_HELP_HEADERS_COMMAND_ARGUMENT_DESCRIPTION) Bundle... bundles) throws Exception { ArrayList> headers = new ArrayList<>(); - + if (bundles == null || bundles.length == 0) { System.out.println(ConsoleMsg.CONSOLE_NO_BUNDLE_SPECIFIED_ERROR); return headers; } - - + + for (Bundle bundle : bundles) { headers.add(bundle.getHeaders()); } return headers; } - + /** * Handles the props command's abbreviation. Invokes props() * @@ -1278,10 +1275,10 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.CONSOLE_FRAMEWORK_IS_SHUTDOWN_MESSAGE); } System.out.println(); - + String states = ""; String[] bsnSegments = null; - + if(arguments != null && arguments.length > 0) { if(arguments[0].equals("-s")) { if (arguments.length > 1) { @@ -1297,13 +1294,13 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } int stateFilter; - + try { stateFilter = getStatesFromConstants(states); } catch (IllegalArgumentException e) { return; } - + Bundle[] bundles = context.getBundles(); int size = bundles.length; @@ -1316,7 +1313,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.print(tab); System.out.println(ConsoleMsg.CONSOLE_STATE_BUNDLE_TITLE); for (Bundle b : bundles) { - + if (!match(b, bsnSegments, stateFilter)) continue; String label = b.getSymbolicName(); @@ -1324,13 +1321,14 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { label = b.toString(); else label = label + "_" + b.getVersion(); //$NON-NLS-1$ - System.out.println(b.getBundleId() + "\t" + getStateName(b) + label); //$NON-NLS-1$ + System.out.println(b.getBundleId() + "\t" + getStateName(b) + label); //$NON-NLS-1$ PackageAdmin packageAdmin = activator.getPackageAdmin(); if ((packageAdmin.getBundleType(b) & PackageAdmin.BUNDLE_TYPE_FRAGMENT) != 0) { Bundle[] hosts = packageAdmin.getHosts(b); if (hosts != null) - for (int j = 0; j < hosts.length; j++) - System.out.println("\t Master=" + hosts[j].getBundleId()); //$NON-NLS-1$ + for (Bundle host : hosts) { + System.out.println("\t Master=" + host.getBundleId()); //$NON-NLS-1$ + } } else { Bundle[] fragments = packageAdmin.getFragments(b); if (fragments != null) { @@ -1364,12 +1362,12 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void t() throws Exception { t(null, null); } - + @Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ACTION_DESCRIPTION) public void t(@Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ARG_ACTION_DESCRIPTION) String action, @Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ARG_THREAD_DESCRIPTION) String thread) throws Exception { t(action, thread, null); } - + @Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ACTION_THROWABLE_DESCRIPTION) public void t(@Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ARG_ACTION_DESCRIPTION) String action, @Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ARG_THREAD_DESCRIPTION) String thread, @Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ARG_THROWABLE_DESCRIPTION) Class throwable) throws Exception { threads(action, thread, throwable); @@ -1379,7 +1377,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void threads() throws Exception { threads(null, null); } - + @Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ACTION_DESCRIPTION) public void threads(@Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ARG_ACTION_DESCRIPTION) String action, @Descriptor(ConsoleMsg.CONSOLE_THREADS_COMMAND_ARG_THREAD_DESCRIPTION) String thread) throws Exception { threads(action, thread, null); @@ -1399,7 +1397,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { ThreadGroup tg = getTopThreadGroup(); Thread[] threads = new Thread[tg.activeCount()]; int count = tg.enumerate(threads, true); - + // Was an action specified? if (action != null) { // An action was specified. Process it here and return without @@ -1408,10 +1406,10 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { // A thread needs to be stopped. // Locate the thread with the specified name. Thread t = null; - for (int i = 0; i < threads.length; i++) { - if (threads[i].getName().equals(thread)) { + for (Thread namedthread : threads) { + if (namedthread.getName().equals(thread)) { // Found the thread. Stop the loop. - t = threads[i]; + t = namedthread; break; } } @@ -1452,15 +1450,15 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.THREADS_UNRECOGNIZED_ACTION); return; } - + // No need to sort if an action was specified. Util.sortByString(threads); StringBuilder sb = new StringBuilder(120); System.out.println(); System.out.println(ConsoleMsg.CONSOLE_THREADGROUP_TITLE); - for (int i = 0; i < threadGroups.length; i++) { - tg = threadGroups[i]; + for (ThreadGroup threadGroup : threadGroups) { + tg = threadGroup; int all = tg.activeCount(); //tg.allThreadsCount(); int local = tg.enumerate(new Thread[all], false); //tg.threadsCount(); ThreadGroup p = tg.getParent(); @@ -1484,7 +1482,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } /** - * Handles the sl (startlevel) command. + * Handles the sl (startlevel) command. * * @param bundle bundle to display startlevel for; if no bundle is specified, the framework startlevel is displayed */ @@ -1505,7 +1503,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } /** - * Handles the setfwsl (set framework startlevel) command. + * Handles the setfwsl (set framework startlevel) command. * * @param newSL new value for the framewrok start level */ @@ -1524,7 +1522,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } /** - * Handles the setbsl (set bundle startlevel) command. + * Handles the setbsl (set bundle startlevel) command. * * @param newSL new value for bundle start level * @param bundles bundles whose start value will be changed @@ -1532,7 +1530,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { @SuppressWarnings("deprecation") @Descriptor(ConsoleMsg.CONSOLE_HELP_SETBSL_COMMAND_DESCRIPTION) public void setbsl( - @Descriptor(ConsoleMsg.CONSOLE_HELP_SETFWSL_COMMAND_ARGUMENT_DESCRIPTION)int newSL, + @Descriptor(ConsoleMsg.CONSOLE_HELP_SETFWSL_COMMAND_ARGUMENT_DESCRIPTION)int newSL, @Descriptor(ConsoleMsg.CONSOLE_HELP_SETBSL_COMMAND_ARGUMENT_DESCRIPTION) Bundle... bundles) throws Exception { StartLevel startLevel = activator.getStartLevel(); if (startLevel != null) { @@ -1540,7 +1538,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println(ConsoleMsg.STARTLEVEL_NO_STARTLEVEL_OR_BUNDLE_GIVEN); return; } - for (Bundle bundle : bundles) { + for (Bundle bundle : bundles) { try { startLevel.setBundleStartLevel(bundle, newSL); System.out.println(NLS.bind(ConsoleMsg.STARTLEVEL_BUNDLE_STARTLEVEL, Long.valueOf(bundle.getBundleId()), Integer.valueOf(newSL))); @@ -1552,7 +1550,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } /** - * Handles the setibsl (set initial bundle startlevel) command. + * Handles the setibsl (set initial bundle startlevel) command. * * @param newInitialSL new value for initial start level */ @@ -1572,7 +1570,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { /** * Lists required bundles having the specified symbolic name or all if no bsn is specified - * + * * @param symbolicName */ @Descriptor(ConsoleMsg.CONSOLE_HELP_REQUIRED_BUNDLES_COMMAND_DESCRIPTION) @@ -1582,7 +1580,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { /** * Lists required bundles having the specified symbolic name or all if no bsn is specified - * + * * @param symbolicName */ @SuppressWarnings("deprecation") @@ -1644,7 +1642,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } /** - * Handles the profilelog command. + * Handles the profilelog command. */ @Descriptor(ConsoleMsg.CONSOLE_HELP_PROFILELOG_COMMAND_DESCRIPTION) public void profilelog() throws Exception { @@ -1676,7 +1674,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { System.out.println("Bundle is not resolved."); return; } - + Map> packages = getPackagesInternal(wiring); for (List packageSources : packages.values()) { for (PackageSource packageSource : packageSources) { @@ -1781,7 +1779,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { /** * Given a string containing a startlevel value, validate it and convert it to an int - * + * * @param intp A CommandInterpreter object used for printing out error messages * @param value A string containing a potential startlevel * @return The start level or an int <0 if it was invalid @@ -1898,7 +1896,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } } } - + @Descriptor(ConsoleMsg.CONSOLE_HELP_DIAG_COMMAND_DESCRIPTION) public void diag(@Descriptor(ConsoleMsg.CONSOLE_HELP_DIAG_COMMAND_ARGUMENT_DESCRIPTION) Bundle[] bundles) throws Exception { if (bundles.length == 0) { @@ -1924,7 +1922,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } } } - + private ResolutionReport getResolutionReport(Bundle[] bundles) { DiagReportListener reportListener = new DiagReportListener(bundles); ServiceRegistration hookReg = context.registerService(ResolverHookFactory.class, reportListener, null); @@ -1947,7 +1945,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { targetTriggers.add(revision); } } - + } volatile ResolutionReport report = null; class DiagResolverHook implements ResolverHook, ResolutionReport.Listener { @@ -1978,7 +1976,7 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { public void end() { // nothing } - + } @Override public ResolverHook begin(Collection triggers) { @@ -2014,11 +2012,11 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } } - + private boolean confirmStop() { System.out.print(ConsoleMsg.CONSOLE_STOP_MESSAGE); System.out.flush(); - + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String reply = null; try { @@ -2026,13 +2024,13 @@ public class EquinoxCommandProvider implements SynchronousBundleListener { } catch (IOException e) { System.out.println(ConsoleMsg.CONSOLE_STOP_ERROR_READ_CONFIRMATION); } - + if (reply != null) { if (reply.toLowerCase().startsWith(ConsoleMsg.CONSOLE_STOP_CONFIRMATION_YES) || reply.length() == 0) { return true; } } - + return false; } } diff --git a/bundles/org.eclipse.equinox.ds.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.ds.tests/META-INF/MANIFEST.MF index b6c5fd572..b8dd8976c 100644 --- a/bundles/org.eclipse.equinox.ds.tests/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.ds.tests/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Declarative Services Tests Bundle-Category: test Bundle-SymbolicName: org.eclipse.equinox.ds.tests -Bundle-Version: 1.5.400.qualifier +Bundle-Version: 1.5.500.qualifier Bundle-Activator: org.eclipse.equinox.ds.tests.DSTestsActivator Bundle-ActivationPolicy: lazy Require-Bundle: org.junit diff --git a/bundles/org.eclipse.equinox.ds.tests/pom.xml b/bundles/org.eclipse.equinox.ds.tests/pom.xml index f9d4fcb8f..74df0c6f3 100644 --- a/bundles/org.eclipse.equinox.ds.tests/pom.xml +++ b/bundles/org.eclipse.equinox.ds.tests/pom.xml @@ -19,6 +19,6 @@ org.eclipse.equinox org.eclipse.equinox.ds.tests - 1.5.400-SNAPSHOT + 1.5.500-SNAPSHOT eclipse-test-plugin diff --git a/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/DSTestsActivator.java b/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/DSTestsActivator.java index 11c582039..54e937674 100644 --- a/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/DSTestsActivator.java +++ b/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/DSTestsActivator.java @@ -49,14 +49,15 @@ public class DSTestsActivator implements BundleActivator { private static void activateBundle(String symbolicName) { if (instance != null) { Bundle[] bundles = instance.context.getBundles(); - for (int i = 0; i < bundles.length; i++) { - if (symbolicName.equals(bundles[i].getSymbolicName())) { - if (bundles[i].getState() != Bundle.ACTIVE) + for (Bundle bundle : bundles) { + if (symbolicName.equals(bundle.getSymbolicName())) { + if (bundle.getState() != Bundle.ACTIVE) { try { - bundles[i].start(Bundle.START_TRANSIENT); - } catch (BundleException e) { + bundle.start(Bundle.START_TRANSIENT); + }catch (BundleException e) { e.printStackTrace(); } + } } } } diff --git a/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/tbc/DSTest.java b/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/tbc/DSTest.java index 557dcfd4e..c02cb9954 100644 --- a/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/tbc/DSTest.java +++ b/bundles/org.eclipse.equinox.ds.tests/src/org/eclipse/equinox/ds/tests/tbc/DSTest.java @@ -1476,13 +1476,13 @@ public class DSTest { if (services == null) { return false; } - for (int i = 0; i < services.length; i++) { - if (services[i] instanceof NamespaceProvider) { - NamespaceProvider s = (NamespaceProvider) services[i]; - if (s.getComponentNSID() == nsid) { - return true; + for (Object service : services) { + if (service instanceof NamespaceProvider) { + NamespaceProvider s = (NamespaceProvider) service; + if (s.getComponentNSID() == nsid) { + return true; + } } - } } return false; @@ -2507,8 +2507,8 @@ public class DSTest { ServiceReference ref = trackerBaseService.getServiceReference(); assertNotNull("Provided service of " + COMP + " should be available", ref); String[] keys = ref.getPropertyKeys(); - for (int i = 0; i < keys.length; i++) { - assertTrue("Private properties should not be propagated", !keys[i].startsWith(".")); + for (String key : keys) { + assertTrue("Private properties should not be propagated", !key.startsWith(".")); } uninstallBundle(tb22); @@ -2983,15 +2983,15 @@ public class DSTest { if (services == null) { return null; } - for (int i = 0; i < services.length; i++) { - if (services[i] instanceof PropertiesProvider) { - PropertiesProvider s = (PropertiesProvider) services[i]; - Dictionary props = s.getProperties(); - if (props != null && ((String) props.get(ComponentConstants.COMPONENT_NAME)).equals(componentName)) { - return s; + for (Object service : services) { + if (service instanceof PropertiesProvider) { + PropertiesProvider s = (PropertiesProvider) service; + Dictionary props = s.getProperties(); + if (props != null && ((String) props.get(ComponentConstants.COMPONENT_NAME)).equals(componentName)) { + return s; + } + } } - } - } return null; } diff --git a/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/internal/event/Activator.java b/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/internal/event/Activator.java index 5b28e4ec4..042fae27e 100644 --- a/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/internal/event/Activator.java +++ b/bundles/org.eclipse.equinox.event/src/org/eclipse/equinox/internal/event/Activator.java @@ -31,9 +31,11 @@ public class Activator implements BundleActivator { //don't register the service if this bundle has already registered it declaratively ServiceReference[] refs = bundleContext.getBundle().getRegisteredServices(); if (refs != null) { - for (int i = 0; i < refs.length; i++) - if (serviceFilter.match(refs[i])) + for (ServiceReference ref : refs) { + if (serviceFilter.match(ref)) { return; // We found a service registered by this bundle already + } + } } eventAdmin = new EventComponent(); diff --git a/bundles/org.eclipse.equinox.http.jetty/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.jetty/META-INF/MANIFEST.MF index e41da993a..746224355 100644 --- a/bundles/org.eclipse.equinox.http.jetty/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.http.jetty/META-INF/MANIFEST.MF @@ -4,7 +4,7 @@ Bundle-Name: %bundleName Bundle-Vendor: %providerName Bundle-Localization: plugin Bundle-SymbolicName: org.eclipse.equinox.http.jetty -Bundle-Version: 3.7.100.qualifier +Bundle-Version: 3.7.200.qualifier Bundle-Activator: org.eclipse.equinox.http.jetty.internal.Activator Import-Package: javax.servlet;version="[3.1.0,5.0.0)", javax.servlet.http;version="[3.1.0,5.0.0)", diff --git a/bundles/org.eclipse.equinox.http.jetty/pom.xml b/bundles/org.eclipse.equinox.http.jetty/pom.xml index 32fc5e31f..b1a2dbb90 100644 --- a/bundles/org.eclipse.equinox.http.jetty/pom.xml +++ b/bundles/org.eclipse.equinox.http.jetty/pom.xml @@ -21,6 +21,6 @@ org.eclipse.equinox org.eclipse.equinox.http.jetty - 3.7.100-SNAPSHOT + 3.7.200-SNAPSHOT eclipse-plugin diff --git a/bundles/org.eclipse.equinox.http.jetty/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java b/bundles/org.eclipse.equinox.http.jetty/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java index 42123b2ea..65c370859 100644 --- a/bundles/org.eclipse.equinox.http.jetty/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java +++ b/bundles/org.eclipse.equinox.http.jetty/src/org/eclipse/equinox/http/jetty/internal/HttpServerManager.java @@ -367,11 +367,11 @@ public class HttpServerManager implements ManagedServiceFactory { private static boolean deleteDirectory(File directory) { if (directory.exists() && directory.isDirectory()) { File[] files = directory.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory()) { - deleteDirectory(files[i]); + for (File file : files) { + if (file.isDirectory()) { + deleteDirectory(file); } else { - files[i].delete(); + file.delete(); } } } diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF index 0db378b83..87aeffafd 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.http.servlet.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: org.eclipse.equinox.http.servlet.tests Bundle-SymbolicName: org.eclipse.equinox.http.servlet.tests -Bundle-Version: 1.6.100.qualifier +Bundle-Version: 1.6.200.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Eclipse-BundleShape: dir Require-Bundle: org.junit;bundle-version="4.0" diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml b/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml index 979c5ae9c..807257c81 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml +++ b/bundles/org.eclipse.equinox.http.servlet.tests/pom.xml @@ -19,7 +19,7 @@ org.eclipse.equinox org.eclipse.equinox.http.servlet.tests - 1.6.100-SNAPSHOT + 1.6.200-SNAPSHOT eclipse-test-plugin diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java index 5c410b571..533cdd8b1 100644 --- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java +++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/bundle/BundleAdvisor.java @@ -36,8 +36,7 @@ public class BundleAdvisor extends Object { throw new IllegalArgumentException("symbolicName must not be null"); //$NON-NLS-1$ BundleContext context = getBundleContext(); Bundle[] bundles = context.getBundles(); - for (int i = 0; i < bundles.length; i++) { - Bundle bundle = bundles [ i ]; + for (Bundle bundle : bundles) { String bsn = bundle.getSymbolicName(); boolean match = symbolicName.equals(bsn); if (match) { diff --git a/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF index de34d92b8..3f1e1e616 100644 --- a/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.http.servlet/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-Vendor: %providerName Bundle-SymbolicName: org.eclipse.equinox.http.servlet -Bundle-Version: 1.6.100.qualifier +Bundle-Version: 1.6.200.qualifier Bundle-Activator: org.eclipse.equinox.http.servlet.internal.Activator Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/bundles/org.eclipse.equinox.http.servlet/pom.xml b/bundles/org.eclipse.equinox.http.servlet/pom.xml index a3a555e27..ad9b8e551 100644 --- a/bundles/org.eclipse.equinox.http.servlet/pom.xml +++ b/bundles/org.eclipse.equinox.http.servlet/pom.xml @@ -20,6 +20,6 @@ org.eclipse.equinox org.eclipse.equinox.http.servlet - 1.6.100-SNAPSHOT + 1.6.200-SNAPSHOT eclipse-plugin diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java index 60ffe5458..c668225a6 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/context/ProxyContext.java @@ -111,11 +111,11 @@ public class ProxyContext { protected static boolean deleteDirectory(File directory) { if (directory.exists() && directory.isDirectory()) { File[] files = directory.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory()) { - deleteDirectory(files[i]); + for (File file : files) { + if (file.isDirectory()) { + deleteDirectory(file); } else { - files[i].delete(); + file.delete(); } } } diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java index 6410c0b95..69873a07d 100644 --- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java +++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ServletContextAdaptor.java @@ -43,8 +43,7 @@ public class ServletContextAdaptor { Method[] handlerMethods = ServletContextAdaptor.class.getDeclaredMethods(); - for (int i = 0; i < handlerMethods.length; i++) { - Method handlerMethod = handlerMethods[i]; + for (Method handlerMethod : handlerMethods) { String name = handlerMethod.getName(); Class[] parameterTypes = handlerMethod.getParameterTypes(); -- cgit v1.2.3