From d14501ca0b6a212c8f33ef8d31f5147e0476730f Mon Sep 17 00:00:00 2001 From: Jochen Hiller Date: Sat, 7 Nov 2015 17:01:48 +0100 Subject: [PATCH] #481650 Fixed bug with wrong bundle initial start level * added test cases to check start level * set current init level also before start of bundle * minor refactorings of XargsFileLauncher Change-Id: I671533016aba0487914ddc79852bb12a48c2deae Signed-off-by: Jochen Hiller --- .../main/dist/samples/equinox-console.xargs | 2 +- .../src/main/dist/samples/felix.xargs | 21 +- .../compat/service/XargsFileLauncher.java | 125 ++++++------ ...a => XargsFileLauncherPropertiesTest.java} | 2 +- .../service/XargsFileLauncherXargsTest.java | 190 ++++++++++++++++++ .../test/util/AbstractConciergeTestCase.java | 49 +++-- 6 files changed, 306 insertions(+), 83 deletions(-) rename org.eclipse.concierge/test/org/eclipse/concierge/compat/service/{XargsFileLauncherTest.java => XargsFileLauncherPropertiesTest.java} (99%) create mode 100644 org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherXargsTest.java diff --git a/distribution/src/main/dist/samples/equinox-console.xargs b/distribution/src/main/dist/samples/equinox-console.xargs index 3cfd892..6bec6d6 100644 --- a/distribution/src/main/dist/samples/equinox-console.xargs +++ b/distribution/src/main/dist/samples/equinox-console.xargs @@ -1,7 +1,7 @@ # xargs sample file to load Equinox Console # uncomment to clean storage first --Dorg.osgi.framework.storage.clean=onFirstInit +# -Dorg.osgi.framework.storage.clean=onFirstInit # use our own profile -Dorg.eclipse.concierge.profile=equinox-console diff --git a/distribution/src/main/dist/samples/felix.xargs b/distribution/src/main/dist/samples/felix.xargs index 70957dd..2b6da9a 100644 --- a/distribution/src/main/dist/samples/felix.xargs +++ b/distribution/src/main/dist/samples/felix.xargs @@ -1,4 +1,5 @@ # xargs sample file to load some Felix bundles +# We will start the bundles in different start levels to show that capability # uncomment to clean storage first # -Dorg.osgi.framework.storage.clean=onFirstInit @@ -7,17 +8,25 @@ -Dorg.eclipse.concierge.profile=felix # repos to load bundles from --Drepo=https://archive.apache.org/dist/felix/ +-Drepo=https://archive.apache.org/dist/felix -# load bundles +# load shell with start level 1 +-initlevel 1 -istart bundles/org.eclipse.concierge.shell-5.0.0.*.jar + +# start DS with start level 2 +-initlevel 2 -istart ${repo}/org.apache.felix.scr-1.8.0.jar --istart ${repo}/org.apache.felix.eventadmin-1.4.2.jar + +# start other services with level 3 +# First install (will use current start level 2), then start with level 3 +-install ${repo}/org.apache.felix.eventadmin-1.4.2.jar -install ${repo}/org.apache.felix.metatype-1.0.12.jar -install ${repo}/org.apache.felix.configadmin-1.8.4.jar --level 1 +-initlevel 3 +-start ${repo}/org.apache.felix.eventadmin-1.4.2.jar -start ${repo}/org.apache.felix.metatype-1.0.12.jar - --level 2 -start ${repo}/org.apache.felix.configadmin-1.8.4.jar + +# check in shell with command "startlevel " diff --git a/org.eclipse.concierge/src/org/eclipse/concierge/compat/service/XargsFileLauncher.java b/org.eclipse.concierge/src/org/eclipse/concierge/compat/service/XargsFileLauncher.java index 35bcf2f..88e8d6f 100644 --- a/org.eclipse.concierge/src/org/eclipse/concierge/compat/service/XargsFileLauncher.java +++ b/org.eclipse.concierge/src/org/eclipse/concierge/compat/service/XargsFileLauncher.java @@ -32,7 +32,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.eclipse.concierge.BundleImpl; import org.eclipse.concierge.BundleImpl.Revision; import org.eclipse.concierge.Concierge; import org.eclipse.concierge.Factory; @@ -40,12 +39,14 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; +import org.osgi.framework.startlevel.BundleStartLevel; import org.osgi.framework.wiring.BundleRevision; public class XargsFileLauncher { - protected static final boolean WIN = System.getProperty("os.name").toLowerCase().startsWith("win"); - + protected static final boolean WIN = System.getProperty("os.name") + .toLowerCase().startsWith("win"); + /** * process an init.xargs-style file. * @@ -58,12 +59,13 @@ public class XargsFileLauncher { * if something goes wrong. For example, if strict startup is * set and the installation of a bundle fails. */ - public Concierge processXargsFile(final File file) throws BundleException, - FileNotFoundException { + public Concierge processXargsFile(final File file) + throws BundleException, FileNotFoundException { InputStream inputStream = new FileInputStream(file); // we have to preserve the properties for later variable and wildcard // replacement - final Map passedProperties = getPropertiesFromXargsInputStream(inputStream); + final Map passedProperties = getPropertiesFromXargsInputStream( + inputStream); // now process again for install/start options with given properties inputStream = new FileInputStream(file); @@ -72,8 +74,8 @@ public Concierge processXargsFile(final File file) throws BundleException, public Concierge processXargsInputStream( final Map passedProperties, - final InputStream inputStream) throws BundleException, - FileNotFoundException { + final InputStream inputStream) + throws BundleException, FileNotFoundException { // create framework with given properties final Concierge concierge = (Concierge) new Factory() @@ -88,13 +90,11 @@ public Concierge processXargsInputStream( if (concierge.restart) { return concierge; } - - final BundleContext context = concierge.getBundleContext(); - int maxLevel = 1; + final BundleContext context = concierge.getBundleContext(); - final BufferedReader reader = new BufferedReader(new InputStreamReader( - inputStream)); + final BufferedReader reader = new BufferedReader( + new InputStreamReader(inputStream)); try { final HashMap memory = new HashMap( @@ -112,9 +112,6 @@ public Concierge processXargsInputStream( } else if (token.startsWith("-initlevel")) { token = getArg(token, 10); initLevel = Integer.parseInt(token); - if (initLevel > maxLevel) { - maxLevel = initLevel; - } continue; } else if (token.startsWith("-all")) { token = getArg(token, 4); @@ -127,64 +124,79 @@ public Concierge processXargsInputStream( } final File files[]; files = jardir.listFiles(new FilenameFilter() { - public boolean accept(File arg0, String arg1) { - return arg1.toLowerCase().endsWith(".jar") - || arg1.toLowerCase().endsWith(".zip"); + public boolean accept(File dir, String name) { + return name.toLowerCase().endsWith(".jar") + || name.toLowerCase().endsWith(".zip"); } }); if (files == null) { - logError("NO FILES FOUND IN " - + concierge.BUNDLE_LOCATION); + logError("NO FILES FOUND IN " + jardir.getPath()); break; } + // first install all bundles final List bundlesToStart = new ArrayList(); for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { continue; } - final BundleImpl b = (BundleImpl) context + final Bundle b = (Bundle) context .installBundle(files[i].getPath()); - b.setStartLevel(initLevel); + // adapt to BundleStartLevel + final BundleStartLevel bundleStartLevel = b + .adapt(BundleStartLevel.class); + bundleStartLevel.setStartLevel(initLevel); bundlesToStart.add(b); } - // TODO start bundles in start level order? + // then start all bundles (if not a fragment) for (Iterator iter = bundlesToStart.iterator(); iter .hasNext();) { Bundle b = iter.next(); + // is it a fragment? final Revision rev = (Revision) b .adapt(BundleRevision.class); if (!rev.isFragment()) { b.start(); } } - continue; } else if (token.startsWith("-istart")) { - token = getArg(token, 7); - token = replaceVariable(token, passedProperties); - token = resolveWildcardName(token); - final BundleImpl bundle = (BundleImpl) context - .installBundle(token); - bundle.setStartLevel(initLevel); + String bundleLocation = getArg(token, 7); + bundleLocation = replaceVariable(bundleLocation, + passedProperties); + bundleLocation = resolveWildcardName(bundleLocation); + final Bundle bundle = context.installBundle(bundleLocation); + // adapt to BundleStartLevel + final BundleStartLevel bundleStartLevel = bundle + .adapt(BundleStartLevel.class); + bundleStartLevel.setStartLevel(initLevel); bundle.start(); } else if (token.startsWith("-install")) { - token = getArg(token, 8); - token = replaceVariable(token, passedProperties); - token = resolveWildcardName(token); - final BundleImpl bundle = (BundleImpl) context - .installBundle(token); - bundle.setStartLevel(initLevel); - memory.put(token, bundle); + String bundleLocation = getArg(token, 8); + bundleLocation = replaceVariable(bundleLocation, + passedProperties); + bundleLocation = resolveWildcardName(bundleLocation); + final Bundle bundle = context.installBundle(bundleLocation); + // adapt to BundleStartLevel + final BundleStartLevel bundleStartLevel = bundle + .adapt(BundleStartLevel.class); + bundleStartLevel.setStartLevel(initLevel); + memory.put(bundleLocation, bundle); } else if (token.startsWith("-start")) { - token = getArg(token, 6); - token = replaceVariable(token, passedProperties); - token = resolveWildcardName(token); - final Bundle bundle = (Bundle) memory.remove(token); + String bundleLocation = getArg(token, 6); + bundleLocation = replaceVariable(bundleLocation, + passedProperties); + bundleLocation = resolveWildcardName(bundleLocation); + final Bundle bundle = memory.remove(bundleLocation); if (bundle == null) { - logError("Bundle " + token + logError("Bundle " + bundleLocation + " is marked to be started but has not been " + "installed before. Ignoring the command !"); } else { + // set start level again in case it has been changed + // meanwhile + final BundleStartLevel bundleStartLevel = bundle + .adapt(BundleStartLevel.class); + bundleStartLevel.setStartLevel(initLevel); bundle.start(); } } else if (token.startsWith("-skip")) { @@ -211,8 +223,8 @@ public boolean accept(File arg0, String arg1) { public Map getPropertiesFromXargsInputStream( final InputStream inputStream) { final Map properties = new HashMap(); - final BufferedReader reader = new BufferedReader(new InputStreamReader( - inputStream)); + final BufferedReader reader = new BufferedReader( + new InputStreamReader(inputStream)); try { String line; @@ -259,8 +271,8 @@ public Map getPropertiesFromXargsInputStream( value = replaceVariable(value, properties); if (doAdd) { String oldValue = properties.get(key); - properties.put(key, (oldValue == null ? "" - : oldValue) + value); + properties.put(key, + (oldValue == null ? "" : oldValue) + value); } else { properties.put(key, value); } @@ -344,20 +356,20 @@ String resolveWildcardName(final String bundleName) { return bundleName; } // TODO how to check http protocol? - final File dir = new File(bundleName.substring(0, - bundleName.lastIndexOf("/"))); + final File dir = new File( + bundleName.substring(0, bundleName.lastIndexOf("/"))); // try to use a file filter final FileFilter filter = new FileFilter() { public boolean accept(final File pathname) { final String preStar = bundleName.substring(0, bundleName.lastIndexOf("*")); - final String postStar = bundleName.substring(bundleName - .lastIndexOf("*") + 1); - - final String path = WIN ? pathname.getPath().replace('\\', '/') : pathname.getPath(); - - return path.startsWith(preStar) - && path.endsWith(postStar); + final String postStar = bundleName + .substring(bundleName.lastIndexOf("*") + 1); + + final String path = WIN ? pathname.getPath().replace('\\', '/') + : pathname.getPath(); + + return path.startsWith(preStar) && path.endsWith(postStar); } }; final File foundFiles[] = dir.listFiles(filter); @@ -366,6 +378,7 @@ public boolean accept(final File pathname) { } else if (foundFiles.length == 1) { return foundFiles[0].getPath(); // exact match } else if (foundFiles.length > 1) { + // sort the list of found files, takes the "newest" one final ArrayList sortedFiles = new ArrayList(); for (int i = 0; i < foundFiles.length; i++) { sortedFiles.add(foundFiles[i].getPath()); diff --git a/org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherTest.java b/org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherPropertiesTest.java similarity index 99% rename from org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherTest.java rename to org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherPropertiesTest.java index e902871..e86cd7a 100644 --- a/org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherTest.java +++ b/org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherPropertiesTest.java @@ -25,7 +25,7 @@ /** * Tests the XargsLauncher with its pattern replacement and wildcard support. */ -public class XargsFileLauncherTest { +public class XargsFileLauncherPropertiesTest { @Test public void testConstructor() { diff --git a/org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherXargsTest.java b/org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherXargsTest.java new file mode 100644 index 0000000..7d66299 --- /dev/null +++ b/org.eclipse.concierge/test/org/eclipse/concierge/compat/service/XargsFileLauncherXargsTest.java @@ -0,0 +1,190 @@ +/******************************************************************************* + * Copyright (c) 2014 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * and Eclipse Distribution License v1.0 which accompany this distribution. + * The Eclipse Public License is available at + * http://www.eclipse.org/legal/epl-v10.html + * and the Eclipse Distribution License is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * Contributors: + * Jochen Hiller + *******************************************************************************/ +package org.eclipse.concierge.compat.service; + +import static org.hamcrest.CoreMatchers.is; + +import java.io.File; + +import org.eclipse.concierge.Concierge; +import org.eclipse.concierge.test.util.AbstractConciergeTestCase; +import org.eclipse.concierge.test.util.SyntheticBundleBuilder; +import org.eclipse.concierge.test.util.TestUtils; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.osgi.framework.Bundle; +import org.osgi.framework.startlevel.BundleStartLevel; + +/** + * Tests the XargsFileLauncher with xargs files. + */ +public class XargsFileLauncherXargsTest extends AbstractConciergeTestCase { + + private String dir; + private File fileA; + private File fileB; + private File fileC; + + @Before + public void setUp() throws Exception { + dir = "build/tests/testBundles"; + new File(dir).mkdirs(); + SyntheticBundleBuilder builder; + + builder = new SyntheticBundleBuilder(); + builder.bundleSymbolicName("bundleA"); + fileA = builder.asFile(dir + "/bundleA.jar"); + + builder = new SyntheticBundleBuilder(); + builder.bundleSymbolicName("bundleB") + .addManifestHeader("Require-Bundle", "bundleA"); + fileB = builder.asFile(dir + "/bundleB.jar"); + + builder = new SyntheticBundleBuilder(); + builder.bundleSymbolicName("bundleC") + .addManifestHeader("Require-Bundle", "bundleB"); + fileC = builder.asFile(dir + "/bundleC.jar"); + } + + @After + public void tearDown() throws Exception { + stopFramework(); + fileC.delete(); + fileB.delete(); + fileA.delete(); + fileA = fileB = fileC = null; + new File(dir).delete(); + dir = null; + } + + /** Test is these bundles can be started with default start level 1. */ + @Test + public void testDefaultStartLevel() throws Exception { + File f = TestUtils.createFileFromString( + "-Dorg.osgi.framework.storage.clean=onFirstInit \n" + + "-istart " + fileA.getPath() + "#Comment to align\n" + + "-istart " + fileB.getPath() + "#Comment to align\n" + + "-istart " + fileC.getPath() + "#Comment to align\n", + "xargs"); + framework = Concierge.doMain(new String[] { f.toString() }); + Bundle[] bundles = framework.getBundleContext().getBundles(); + Assert.assertThat(bundles.length, is(4)); + assertBundlesActive(bundles); + Assert.assertThat(asBSL(bundles[1]).getStartLevel(), is(1)); + Assert.assertThat(asBSL(bundles[2]).getStartLevel(), is(1)); + Assert.assertThat(asBSL(bundles[3]).getStartLevel(), is(1)); + } + + /** Test if start level will be applied correct. */ + @Test + public void testStartLevelIStart123() throws Exception { + File f = TestUtils.createFileFromString( + "-Dorg.osgi.framework.storage.clean=onFirstInit \n" + + "-initlevel 1 #Comment to align\n" + + "-istart " + fileA.getPath() + "#Comment to align\n" + + "-initlevel 2 #Comment to align\n" + + "-istart " + fileB.getPath() + "#Comment to align\n" + + "-initlevel 3 #Comment to align\n" + + "-istart " + fileC.getPath() + "#Comment to align\n", + "xargs"); + framework = Concierge.doMain(new String[] { f.toString() }); + Bundle[] bundles = framework.getBundleContext().getBundles(); + Assert.assertThat(bundles.length, is(4)); + assertBundlesActive(bundles); + Assert.assertThat(asBSL(bundles[1]).getStartLevel(), is(1)); + Assert.assertThat(asBSL(bundles[2]).getStartLevel(), is(2)); + Assert.assertThat(asBSL(bundles[3]).getStartLevel(), is(3)); + } + + /** Test if start level will be applied correct. */ + @Test + public void testStartLevelIStart321() throws Exception { + File f = TestUtils.createFileFromString( + "-Dorg.osgi.framework.storage.clean=onFirstInit \n" + + "-initlevel 3 #Comment to align\n" + + "-istart " + fileA.getPath() + "#Comment to align\n" + + "-initlevel 2 #Comment to align\n" + + "-istart " + fileB.getPath() + "#Comment to align\n" + + "-initlevel 1 #Comment to align\n" + + "-istart " + fileC.getPath() + "#Comment to align\n", + "xargs"); + framework = Concierge.doMain(new String[] { f.toString() }); + Bundle[] bundles = framework.getBundleContext().getBundles(); + Assert.assertThat(bundles.length, is(4)); + assertBundlesActive(bundles); + Assert.assertThat(asBSL(bundles[1]).getStartLevel(), is(3)); + Assert.assertThat(asBSL(bundles[2]).getStartLevel(), is(2)); + Assert.assertThat(asBSL(bundles[3]).getStartLevel(), is(1)); + } + + /** Test if start level will be applied correct. */ + @Test + @Ignore("TODO does not work: bundles with startlevel > 3 will NOT be started") + public void testStartLevelIStart102030() throws Exception { + File f = TestUtils.createFileFromString( + "-Dorg.osgi.framework.storage.clean=onFirstInit \n" + + "-initlevel 10 #Comment to align\n" + + "-istart " + fileA.getPath() + "#Comment to align\n" + + "-initlevel 20 #Comment to align\n" + + "-istart " + fileB.getPath() + "#Comment to align\n" + + "-initlevel 30 #Comment to align\n" + + "-istart " + fileC.getPath() + "#Comment to align\n", + "xargs"); + framework = Concierge.doMain(new String[] { f.toString() }); + Bundle[] bundles = framework.getBundleContext().getBundles(); + Assert.assertThat(bundles.length, is(4)); + assertBundlesActive(bundles); + Assert.assertThat(asBSL(bundles[1]).getStartLevel(), is(10)); + Assert.assertThat(asBSL(bundles[2]).getStartLevel(), is(20)); + Assert.assertThat(asBSL(bundles[3]).getStartLevel(), is(30)); + } + + /** + * Test if start level will be applied correct when using install and start + * seperately. + */ + @Test + public void testStartLevelInstallStart123() throws Exception { + File f = TestUtils.createFileFromString( + "-Dorg.osgi.framework.storage.clean=onFirstInit \n" + + "-initlevel 1 #Comment to align\n" + + "-install " + fileA.getPath() + "#Comment to align\n" + + "-initlevel 2 #Comment to align\n" + + "-install " + fileB.getPath() + "#Comment to align\n" + + "-initlevel 3 #Comment to align\n" + + "-install " + fileC.getPath() + "#Comment to align\n" + + "-initlevel 1 #Comment to align\n" + + "-start " + fileA.getPath() + "#Comment to align\n" + + "-initlevel 2 #Comment to align\n" + + "-start " + fileB.getPath() + "#Comment to align\n" + + "-initlevel 3 #Comment to align\n" + + "-start " + fileC.getPath() + "#Comment to align\n", + "xargs"); + framework = Concierge.doMain(new String[] { f.toString() }); + Bundle[] bundles = framework.getBundleContext().getBundles(); + Assert.assertThat(bundles.length, is(4)); + assertBundlesActive(bundles); + Assert.assertThat(asBSL(bundles[1]).getStartLevel(), is(1)); + Assert.assertThat(asBSL(bundles[2]).getStartLevel(), is(2)); + Assert.assertThat(asBSL(bundles[3]).getStartLevel(), is(3)); + } + + private BundleStartLevel asBSL(Bundle b) { + return b.adapt(BundleStartLevel.class); + } + +} diff --git a/org.eclipse.concierge/test/org/eclipse/concierge/test/util/AbstractConciergeTestCase.java b/org.eclipse.concierge/test/org/eclipse/concierge/test/util/AbstractConciergeTestCase.java index 5a46ed2..d262ffe 100644 --- a/org.eclipse.concierge/test/org/eclipse/concierge/test/util/AbstractConciergeTestCase.java +++ b/org.eclipse.concierge/test/org/eclipse/concierge/test/util/AbstractConciergeTestCase.java @@ -41,7 +41,9 @@ */ public abstract class AbstractConciergeTestCase { - /** This property allows to wait some time when framework has been shutdown. */ + /** + * This property allows to wait some time when framework has been shutdown. + */ private final static String PROPERTY_WAIT_AFTER_FRAMEWORK_SHUTDOWN = "org.eclipse.concierge.tests.waitAfterFrameworkShutdown"; protected Framework framework = null; @@ -56,6 +58,12 @@ public void startFramework() throws Exception { startFrameworkClean(launchArgs); } + /** Start framework in clean mode. */ + public void startFrameworkClean() throws Exception { + Map launchArgs = new HashMap(); + startFrameworkClean(launchArgs); + } + /** Start framework with given settings but in clean mode. */ public void startFrameworkClean(Map launchArgs) throws Exception { @@ -74,7 +82,8 @@ public void startFramework(final Map launchArgs) } /** Start framework for a given framework. */ - public void useFramework(final Framework frameworkToStart) throws Exception { + public void useFramework(final Framework frameworkToStart) + throws Exception { // start OSGi framework this.framework = frameworkToStart; this.bundleContext = this.framework.getBundleContext(); @@ -82,8 +91,8 @@ public void useFramework(final Framework frameworkToStart) throws Exception { if (stayInShell()) { String shellJarName = "./test/resources/org.eclipse.concierge.shell-5.0.0.20151029184259.jar"; if (!new File(shellJarName).exists()) { - System.err.println("Oops, could not find shell bundle at " - + shellJarName); + System.err.println( + "Oops, could not find shell bundle at " + shellJarName); } else { // assume to get shell jar file in target folder installAndStartBundle(shellJarName); @@ -235,13 +244,14 @@ protected Bundle installAndStartBundle(final String bundleName) */ protected void enforceResolveBundle(final Bundle bundle) { // initiate resolver - framework.adapt(FrameworkWiring.class).resolveBundles( - Collections.singleton(bundle)); + framework.adapt(FrameworkWiring.class) + .resolveBundles(Collections.singleton(bundle)); } /** Returns true when the specified bundle is a fragment. */ protected boolean isFragmentBundle(final Bundle bundle) { - return (bundle.adapt(BundleRevision.class).getTypes() & BundleRevision.TYPE_FRAGMENT) != 0; + return (bundle.adapt(BundleRevision.class).getTypes() + & BundleRevision.TYPE_FRAGMENT) != 0; } /** Checks about Bundle RESOLVED state for all bundles. */ @@ -272,7 +282,8 @@ protected void assertBundleResolved(final Bundle bundle) { /** Checks about Bundle RESOLVED or ACTIVE state. */ protected boolean isBundleResolved(final Bundle bundle) { - return ((bundle.getState() == Bundle.RESOLVED) || (bundle.getState() == Bundle.ACTIVE)); + return ((bundle.getState() == Bundle.RESOLVED) + || (bundle.getState() == Bundle.ACTIVE)); } /** Checks about Bundle ACTIVE state. */ @@ -400,8 +411,8 @@ public Object getClassField(final String className, final Class clazz = this.bundle.loadClass(className); final Field field = clazz.getField(classFieldName); if (!Modifier.isStatic(field.getModifiers())) { - throw new RuntimeException("Oops, field " + field.toString() - + " is not static"); + throw new RuntimeException( + "Oops, field " + field.toString() + " is not static"); } // get the value of field, as class field object == null final Object result = field.get(null); @@ -414,7 +425,7 @@ public Object getClassField(final String className, */ public Object callClassMethod(final String className, final String classMethodName, final Object[] args) - throws Exception { + throws Exception { final Class clazz = this.bundle.loadClass(className); // get parameter types from args final Class[] parameterTypes = new Class[args.length]; @@ -424,8 +435,8 @@ public Object callClassMethod(final String className, final Method method = clazz.getDeclaredMethod(classMethodName, parameterTypes); if (!Modifier.isStatic(method.getModifiers())) { - throw new RuntimeException("Oops, method " + method.toString() - + " is not static"); + throw new RuntimeException( + "Oops, method " + method.toString() + " is not static"); } // TODO jhi Maybe set accessible if private? final Object result = method.invoke(null, args); @@ -454,7 +465,7 @@ public Object createInstance(String className, final Object[] args) public Object createInstance(String className, final String[] parameterTypeNames, final Object[] args) - throws Exception { + throws Exception { final Class clazz = this.bundle.loadClass(className); dumpDeclaredConstructors(clazz); // get parameter types from args @@ -489,8 +500,8 @@ public Object callMethod(final Object obj, final String methodName, dumpDeclaredMethods(clazz); final Method method = clazz.getMethod(methodName, parameterTypes); if (Modifier.isStatic(method.getModifiers())) { - throw new RuntimeException("Oops, method " + method.toString() - + " is static"); + throw new RuntimeException( + "Oops, method " + method.toString() + " is static"); } final Object result = method.invoke(obj, args); return result; @@ -504,14 +515,14 @@ public Object callMethod(final Object obj, final String methodName, */ public Object callMethod(final Object obj, final String methodName, final Class[] parameterTypes, final Object[] args) - throws Exception { + throws Exception { final Class clazz = obj.getClass(); dumpMethods(clazz); dumpDeclaredMethods(clazz); final Method method = clazz.getMethod(methodName, parameterTypes); if (Modifier.isStatic(method.getModifiers())) { - throw new RuntimeException("Oops, method " + method.toString() - + " is static"); + throw new RuntimeException( + "Oops, method " + method.toString() + " is static"); } final Object result = method.invoke(obj, args); return result;