diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherImpl.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherImpl.java index 0c4a599250..2b01b5380b 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherImpl.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherImpl.java @@ -20,7 +20,6 @@ import org.eclipse.equinox.internal.frameworkadmin.utils.SimpleBundlesState; import org.eclipse.equinox.internal.frameworkadmin.utils.Utils; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.osgi.service.log.LogService; public class EclipseLauncherImpl { static String getStringOfCmd(String[] cmdarray) { @@ -41,7 +40,7 @@ static String getStringOfCmd(String[] cmdarray) { public Process launch(Manipulator manipulator, File cwd) throws IllegalArgumentException, IOException, FrameworkAdminRuntimeException { SimpleBundlesState.checkAvailability(fwAdmin); - Log.log(LogService.LOG_DEBUG, this, "launch(Manipulator , File )", ""); //$NON-NLS-1$ //$NON-NLS-2$ + Log.debug(this, "launch(Manipulator , File )", ""); //$NON-NLS-1$ //$NON-NLS-2$ LauncherData launcherData = manipulator.getLauncherData(); if (launcherData.getLauncher() == null) return launchInMemory(manipulator, cwd); @@ -57,7 +56,7 @@ private Process launchByLauncher(Manipulator manipulator, File cwd) throws IOExc if (cwd == null) cwd = launcherData.getLauncher().getParentFile(); Process process = Runtime.getRuntime().exec(cmdarray, null, cwd); - Log.log(LogService.LOG_DEBUG, "\t" + getStringOfCmd(cmdarray)); //$NON-NLS-1$ + Log.debug("\t" + getStringOfCmd(cmdarray)); //$NON-NLS-1$ return process; } @@ -88,7 +87,7 @@ private Process launchInMemory(Manipulator manipulator, File cwd) throws IOExcep String[] cmdarray = new String[cmdList.size()]; cmdList.toArray(cmdarray); - Log.log(LogService.LOG_DEBUG, "In CWD = " + cwd + "\n\t" + getStringOfCmd(cmdarray)); //$NON-NLS-1$ //$NON-NLS-2$ + Log.debug("In CWD = " + cwd + "\n\t" + getStringOfCmd(cmdarray)); //$NON-NLS-1$ //$NON-NLS-2$ Process process = Runtime.getRuntime().exec(cmdarray, null, cwd); return process; } diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java index 4ed2e2ac86..385d348620 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EclipseLauncherParser.java @@ -26,17 +26,17 @@ import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; import org.eclipse.osgi.service.environment.Constants; import org.eclipse.osgi.util.NLS; -import org.osgi.service.log.LogService; public class EclipseLauncherParser { private static final String CONFIGURATION_FOLDER = "configuration"; //$NON-NLS-1$ - //this figures out the location of the data area on partial data read from the .ini + // this figures out the location of the data area on partial data read from the + // .ini private URI getOSGiInstallArea(List lines, URI base, LauncherData launcherData) { - //does the eclipse.ini say anything for osgi.install.area? + // does the eclipse.ini say anything for osgi.install.area? File osgiInstallArea = ParserUtils.getOSGiInstallArea(lines, null, launcherData.getLauncher(), base); if (osgiInstallArea == null) { - //otherwise use the launcherData to figure it out + // otherwise use the launcherData to figure it out osgiInstallArea = ParserUtils.getOSGiInstallArea(lines, null, launcherData); } if (osgiInstallArea != null) @@ -70,7 +70,9 @@ void read(File launcherConfigFile, LauncherData launcherData) throws IOException getFrameworkJar(lines, launcherFolder, launcherData); URI osgiInstallArea = getOSGiInstallArea(lines, launcherFolder, launcherData); if (osgiInstallArea == null) { - osgiInstallArea = launcherData.getFwJar() != null ? ParserUtils.fromOSGiJarToOSGiInstallArea(launcherData.getFwJar().getAbsolutePath()).toURI() : launcherFolder; + osgiInstallArea = launcherData.getFwJar() != null + ? ParserUtils.fromOSGiJarToOSGiInstallArea(launcherData.getFwJar().getAbsolutePath()).toURI() + : launcherFolder; } URI configArea = getConfigurationLocation(lines, osgiInstallArea, launcherData); if (configArea == null) @@ -81,7 +83,7 @@ void read(File launcherConfigFile, LauncherData launcherData) throws IOException getProgramArgs(lines, launcherData); getVM(lines, launcherFolder, launcherData); - Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_configFile, launcherConfigFile.getAbsolutePath())); + Log.info(NLS.bind(Messages.log_configFile, launcherConfigFile.getAbsolutePath())); } private void getFrameworkJar(List lines, URI launcherFolder, LauncherData launcherData) { @@ -93,10 +95,13 @@ private void getFrameworkJar(List lines, URI launcherFolder, LauncherDat launcherData.setFwJar(URIUtil.toFile(location)); } - private void getPersistentDataLocation(List lines, URI osgiInstallArea, URI configArea, LauncherData launcherData) { - //TODO The setting of the -clean could only do properly once config.ini has been read + private void getPersistentDataLocation(List lines, URI osgiInstallArea, URI configArea, + LauncherData launcherData) { + // TODO The setting of the -clean could only do properly once config.ini has + // been read if (launcherData.getFwPersistentDataLocation() == null) { - launcherData.setFwPersistentDataLocation(URIUtil.toFile(configArea), ParserUtils.isArgumentSet(EquinoxConstants.OPTION_CLEAN, lines)); + launcherData.setFwPersistentDataLocation(URIUtil.toFile(configArea), + ParserUtils.isArgumentSet(EquinoxConstants.OPTION_CLEAN, lines)); } } @@ -111,7 +116,7 @@ private void getVM(List lines, URI launcherFolder, LauncherData launcher launcherData.setJvm(URIUtil.toFile(VMFullPath)); ParserUtils.setValueForArgument(EquinoxConstants.OPTION_VM, VMFullPath.toString(), lines); } catch (URISyntaxException e) { - Log.log(LogService.LOG_ERROR, NLS.bind(Messages.log_failed_make_absolute, vm)); + Log.error(NLS.bind(Messages.log_failed_make_absolute, vm)); return; } } @@ -128,21 +133,23 @@ private void setVM(List lines, File vm, URI launcherFolder, File install URI vmRelativePath = null; if (vm.isAbsolute()) { // Bug 437680: Correctly relativize on MacOS - // Example: (traditional layout) (bundled layout) - // Install home: install/ Eclipse.app/ - // Launcher: Eclipse.app/Contents/MacOS/ Contents/MacOS/ - // VM: jre/ jre/ - // Result: ../../../jre ../../jre + // Example: (traditional layout) (bundled layout) + // Install home: install/ Eclipse.app/ + // Launcher: Eclipse.app/Contents/MacOS/ Contents/MacOS/ + // VM: jre/ jre/ + // Result: ../../../jre ../../jre URI vmRelativePathToHome = installHome.toURI().relativize(vm.toURI()); if (vmRelativePathToHome.isAbsolute()) { // VM is not below the install root -> use absolute path vmRelativePath = vmRelativePathToHome; } else { - // make VM path relative to launcher folder (which is different to the install root in MacOS installs) + // make VM path relative to launcher folder (which is different to the install + // root in MacOS installs) vmRelativePath = URIUtil.makeRelative(vm.toURI(), launcherFolder); } } else { - //For relative files, File#toURI will create an absolute URI by resolving against the current working directory, we don't want that + // For relative files, File#toURI will create an absolute URI by resolving + // against the current working directory, we don't want that String path = vm.getPath().replace('\\', '/'); try { vmRelativePath = URIUtil.fromString(path); @@ -151,7 +158,8 @@ private void setVM(List lines, File vm, URI launcherFolder, File install } } - ParserUtils.setValueForArgument(EquinoxConstants.OPTION_VM, FileUtils.toPath(vmRelativePath).replace('\\', '/'), lines); + ParserUtils.setValueForArgument(EquinoxConstants.OPTION_VM, FileUtils.toPath(vmRelativePath).replace('\\', '/'), + lines); } private void getJVMArgs(List lines, LauncherData launcherData) { @@ -201,7 +209,7 @@ private URI getLauncherLibrary(List lines, URI launcherFolder) { result = URIUtil.makeAbsolute(FileUtils.fromPath(launcherLibrary), launcherFolder); ParserUtils.setValueForArgument(EquinoxConstants.OPTION_LAUNCHER_LIBRARY, result.toString(), lines); } catch (URISyntaxException e) { - Log.log(LogService.LOG_ERROR, NLS.bind(Messages.log_failed_make_absolute, launcherLibrary)); + Log.error(NLS.bind(Messages.log_failed_make_absolute, launcherLibrary)); return null; } return result; @@ -214,9 +222,10 @@ private void setLauncherLibrary(List lines, URI launcherFolder) { try { URI result = URIUtil.makeRelative(FileUtils.fromPath(launcherLibrary), launcherFolder); - ParserUtils.setValueForArgument(EquinoxConstants.OPTION_LAUNCHER_LIBRARY, FileUtils.toPath(result).replace('\\', '/'), lines); + ParserUtils.setValueForArgument(EquinoxConstants.OPTION_LAUNCHER_LIBRARY, + FileUtils.toPath(result).replace('\\', '/'), lines); } catch (URISyntaxException e) { - Log.log(LogService.LOG_ERROR, NLS.bind(Messages.log_failed_make_absolute, launcherLibrary)); + Log.error(NLS.bind(Messages.log_failed_make_absolute, launcherLibrary)); return; } } @@ -227,7 +236,7 @@ private URI getConfigurationLocation(List lines, URI osgiInstallArea, La try { return URIUtil.makeAbsolute(new URI(CONFIGURATION_FOLDER), osgiInstallArea); } catch (URISyntaxException e1) { - //ignore + // ignore } URI result = null; @@ -236,7 +245,7 @@ private URI getConfigurationLocation(List lines, URI osgiInstallArea, La ParserUtils.setValueForArgument(EquinoxConstants.OPTION_CONFIGURATION, result.toString(), lines); data.setFwConfigLocation(URIUtil.toFile(result)); } catch (URISyntaxException e) { - Log.log(LogService.LOG_ERROR, NLS.bind(Messages.log_failed_make_absolute, configuration)); + Log.error(NLS.bind(Messages.log_failed_make_absolute, configuration)); return null; } return result; @@ -244,7 +253,7 @@ private URI getConfigurationLocation(List lines, URI osgiInstallArea, La private void setConfigurationLocation(List lines, URI osgiInstallArea, LauncherData data) { String result = FileUtils.toPath(URIUtil.makeRelative(data.getFwConfigLocation().toURI(), osgiInstallArea)); - //We don't write the default + // We don't write the default if (CONFIGURATION_FOLDER.equals(result)) { if (ParserUtils.getValueForArgument(EquinoxConstants.OPTION_CONFIGURATION, lines) != null) ParserUtils.removeArgument(EquinoxConstants.OPTION_CONFIGURATION, lines); @@ -267,7 +276,7 @@ private URI getStartup(List lines, URI launcherFolder) { result = URIUtil.makeAbsolute(FileUtils.fromPath(startup), launcherFolder); ParserUtils.setValueForArgument(EquinoxConstants.OPTION_STARTUP, result.toString(), lines); } catch (URISyntaxException e) { - Log.log(LogService.LOG_ERROR, NLS.bind(Messages.log_failed_make_absolute, startup)); + Log.error(NLS.bind(Messages.log_failed_make_absolute, startup)); return null; } return result; @@ -280,9 +289,10 @@ private void setStartup(List lines, URI launcherFolder) { try { URI result = URIUtil.makeRelative(FileUtils.fromPath(startup), launcherFolder); - ParserUtils.setValueForArgument(EquinoxConstants.OPTION_STARTUP, FileUtils.toPath(result).replace('\\', '/'), lines); + ParserUtils.setValueForArgument(EquinoxConstants.OPTION_STARTUP, + FileUtils.toPath(result).replace('\\', '/'), lines); } catch (URISyntaxException e) { - Log.log(LogService.LOG_ERROR, NLS.bind(Messages.log_failed_make_relative, startup)); + Log.error(NLS.bind(Messages.log_failed_make_relative, startup)); return; } } @@ -295,26 +305,26 @@ void save(EquinoxLauncherData launcherData, boolean backup) throws IOException { if (!Utils.createParentDir(launcherConfigFile)) { throw new IllegalStateException(Messages.exception_failedToCreateDir); } - //Tweak all the values to make them relative + // Tweak all the values to make them relative File launcherFolder = launcherData.getLauncher().getParentFile(); List newlines = new ArrayList<>(); newlines.addAll(Arrays.asList(launcherData.getProgramArgs())); setStartup(newlines, launcherFolder.toURI()); setInstall(newlines, launcherData, launcherFolder); - //Get the osgi install area + // Get the osgi install area File osgiInstallArea = ParserUtils.getOSGiInstallArea(newlines, null, launcherData); - //setInstall(lines, osgiInstallArea, launcherFolder); + // setInstall(lines, osgiInstallArea, launcherFolder); setConfigurationLocation(newlines, osgiInstallArea.toURI(), launcherData); setLauncherLibrary(newlines, launcherFolder.toURI()); - // setFrameworkJar(newlines, launcherData.getFwJar()); + // setFrameworkJar(newlines, launcherData.getFwJar()); setVM(newlines, launcherData.getJvm(), launcherFolder.toURI(), launcherData.getHome()); - //We are done, let's update the program args in the launcher data + // We are done, let's update the program args in the launcher data launcherData.setProgramArgs(null); launcherData.setProgramArgs(newlines.toArray(new String[newlines.size()])); - //append jvm args + // append jvm args setJVMArgs(newlines, launcherData); // backup file if exists. @@ -323,10 +333,10 @@ void save(EquinoxLauncherData launcherData, boolean backup) throws IOException { File dest = Utils.getSimpleDataFormattedFile(launcherConfigFile); if (!launcherConfigFile.renameTo(dest)) throw new IOException(NLS.bind(Messages.exception_failedToRename, launcherConfigFile, dest)); - Log.log(LogService.LOG_INFO, this, "save()", NLS.bind(Messages.log_renameSuccessful, launcherConfigFile, dest)); //$NON-NLS-1$ + Log.info(this, "save()", NLS.bind(Messages.log_renameSuccessful, launcherConfigFile, dest)); //$NON-NLS-1$ } - //only write the file if we actually have content + // only write the file if we actually have content if (newlines.size() > 0) { try (BufferedWriter bw = new BufferedWriter(new FileWriter(launcherConfigFile));) { for (String arg : newlines) { @@ -336,7 +346,7 @@ void save(EquinoxLauncherData launcherData, boolean backup) throws IOException { bw.newLine(); } bw.flush(); - Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_launcherConfigSave, launcherConfigFile)); + Log.info(NLS.bind(Messages.log_launcherConfigSave, launcherConfigFile)); } } File previousLauncherIni = launcherData.getPreviousLauncherIni(); diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java index 71d0e1e6f5..8e3318d153 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java @@ -27,7 +27,6 @@ import org.eclipse.osgi.service.resolver.*; import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; -import org.osgi.service.log.LogService; public class EquinoxBundlesState implements BundlesState { static final long DEFAULT_TIMESTAMP = 0L; @@ -332,7 +331,7 @@ private boolean composeState(BundleInfo[] bInfos, Dictionary pro } if (DEBUG) { System.out.println(""); //$NON-NLS-1$ - Log.log(LogService.LOG_DEBUG, this, "composeExpectedState()", "installBundle():"); //$NON-NLS-1$ //$NON-NLS-2$ + Log.debug(this, "composeExpectedState()", "installBundle():"); //$NON-NLS-1$ //$NON-NLS-2$ } if (flagNewState) { int indexSystemBundle = -1; @@ -354,13 +353,13 @@ private boolean composeState(BundleInfo[] bInfos, Dictionary pro } for (int j = 0; j < bInfos.length; j++) { if (DEBUG) - Log.log(LogService.LOG_DEBUG, this, "composeExpectedState()", "bInfos[" + j + "]=" + bInfos[j]); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + Log.debug(this, "composeExpectedState()", "bInfos[" + j + "]=" + bInfos[j]); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ try { this.installBundle(bInfos[j]); // System.out.println("install bInfos[" + j + "]=" + bInfos[j]); } catch (RuntimeException e) { // catch the exception and continue - Log.log(LogService.LOG_ERROR, this, "composeExpectedState()", "BundleInfo:" + bInfos[j], e); //$NON-NLS-1$ //$NON-NLS-2$ + Log.error("BundleInfo:" + bInfos[j], e); //$NON-NLS-1$ } } return true; @@ -387,7 +386,7 @@ private BundleInfo convertSystemBundle(BundleDescription toConvert) { } } } catch (FrameworkAdminRuntimeException e1) { - Log.log(LogService.LOG_ERROR, "", e1); //$NON-NLS-1$ + Log.error("", e1); //$NON-NLS-1$ } return createBundleInfo(toConvert, markedAsStarted, sl, location, null); } @@ -541,7 +540,7 @@ private void initialize(boolean useFwPersistentData) { File installArea = ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configData.getProperties(), launcherData); if (DEBUG) - Log.log(LogService.LOG_DEBUG, this, "initialize(useFwPersistentDat)", "installArea=" + installArea); //$NON-NLS-1$ //$NON-NLS-2$ + Log.debug(this, "initialize(useFwPersistentDat)", "installArea=" + installArea); //$NON-NLS-1$ //$NON-NLS-2$ if (installArea == null) throw new IllegalStateException(Messages.exception_noInstallArea); File fwPersistentDataLocation = new File(installArea, "configuration"); //$NON-NLS-1$ @@ -581,7 +580,7 @@ public void installBundle(BundleInfo bInfo) throws FrameworkAdminRuntimeExceptio addBundleToState(newBundleDescription); manipulator.getConfigData().addBundle(bInfo); } catch (BundleException e) { - Log.log(LogService.LOG_WARNING, this, "installBundle(BundleInfo)", e); //$NON-NLS-1$ + Log.warn(this, "installBundle(BundleInfo)", e); //$NON-NLS-1$ } } @@ -703,7 +702,7 @@ public void uninstallBundle(BundleInfo bInfo) throws FrameworkAdminRuntimeExcept try { Dictionary manifest = Utils.getOSGiManifest(bInfo.getLocation()); if (manifest == null) { - Log.log(LogService.LOG_WARNING, this, "uninstallBundle(BundleInfo)", //$NON-NLS-1$ + Log.warn(this, "uninstallBundle(BundleInfo)", //$NON-NLS-1$ NLS.bind(Messages.exception_bundleManifest, bInfo.getLocation())); return; } @@ -712,7 +711,7 @@ public void uninstallBundle(BundleInfo bInfo) throws FrameworkAdminRuntimeExcept removeBundleFromState(bundleDescription); manipulator.getConfigData().removeBundle(bInfo); } catch (BundleException e) { - Log.log(LogService.LOG_WARNING, this, "uninstallBundle(BundleInfo)", e); //$NON-NLS-1$ + Log.warn(this, "uninstallBundle(BundleInfo)", e); //$NON-NLS-1$ } } } diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java index a12579366f..3889d01e6c 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxFwConfigFileParser.java @@ -26,10 +26,11 @@ import org.eclipse.osgi.util.NLS; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; -import org.osgi.service.log.LogService; public class EquinoxFwConfigFileParser { - private static final Set KNOWN_PROPERTIES = new HashSet<>(Arrays.asList(new String[] {EquinoxConstants.PROP_BUNDLES, EquinoxConstants.PROP_FW_EXTENSIONS, EquinoxConstants.PROP_INITIAL_STARTLEVEL, EquinoxConstants.PROP_BUNDLES_STARTLEVEL})); + private static final Set KNOWN_PROPERTIES = new HashSet<>( + Arrays.asList(new String[] { EquinoxConstants.PROP_BUNDLES, EquinoxConstants.PROP_FW_EXTENSIONS, + EquinoxConstants.PROP_INITIAL_STARTLEVEL, EquinoxConstants.PROP_BUNDLES_STARTLEVEL })); private static final String CONFIG_DIR = "@config.dir/"; //$NON-NLS-1$ private static final String KEY_ECLIPSE_PROV_DATA_AREA = "eclipse.p2.data.area"; //$NON-NLS-1$ private static final String KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL = "org.eclipse.equinox.simpleconfigurator.configUrl"; //$NON-NLS-1$ @@ -41,7 +42,7 @@ public class EquinoxFwConfigFileParser { private static boolean DEBUG = false; public EquinoxFwConfigFileParser(BundleContext context) { - //Empty + // Empty } private static StringBuffer toOSGiBundleListForm(BundleInfo bundleInfo, URI location) { @@ -94,10 +95,12 @@ private static int getStartLevel(String startInfo) { return BundleInfo.NO_LEVEL; } - private void readBundlesList(Manipulator manipulator, URI osgiInstallArea, Properties props) throws NumberFormatException { + private void readBundlesList(Manipulator manipulator, URI osgiInstallArea, Properties props) + throws NumberFormatException { ConfigData configData = manipulator.getConfigData(); - BundleInfo[] fwExtensions = parseBundleList(manipulator, props.getProperty(EquinoxConstants.PROP_FW_EXTENSIONS)); + BundleInfo[] fwExtensions = parseBundleList(manipulator, + props.getProperty(EquinoxConstants.PROP_FW_EXTENSIONS)); if (fwExtensions != null) { for (BundleInfo fwExtension : fwExtensions) { fwExtension.setFragmentHost(Constants.SYSTEM_BUNDLE_SYMBOLICNAME); @@ -146,9 +149,9 @@ private BundleInfo[] parseBundleList(Manipulator manipulator, String value) { bundles.add(new BundleInfo(FileUtils.fromFileURL(location), startLevel, markedAsStarted)); continue; } catch (URISyntaxException e) { - //Ignore + // Ignore } - //Fallback case, we use the location as a string + // Fallback case, we use the location as a string bundles.add(new BundleInfo(location, null, null, startLevel, markedAsStarted)); } return bundles.toArray(new BundleInfo[bundles.size()]); @@ -158,17 +161,20 @@ private void writeBundlesList(File fwJar, Properties props, BundleInfo[] bundles StringBuilder osgiBundlesList = new StringBuilder(); StringBuilder osgiFrameworkExtensionsList = new StringBuilder(); for (BundleInfo bundle : bundles) { - //framework jar does not get stored on the bundle list, figure out who that is. + // framework jar does not get stored on the bundle list, figure out who that is. if (fwJar != null) { if (URIUtil.sameURI(fwJar.toURI(), bundle.getLocation())) continue; } else if (EquinoxConstants.FW_SYMBOLIC_NAME.equals(bundle.getSymbolicName())) continue; - URI location = fwJar != null ? URIUtil.makeRelative(bundle.getLocation(), fwJar.getParentFile().toURI()) : bundle.getLocation(); + URI location = fwJar != null ? URIUtil.makeRelative(bundle.getLocation(), fwJar.getParentFile().toURI()) + : bundle.getLocation(); String fragmentHost = bundle.getFragmentHost(); - boolean isFrameworkExtension = fragmentHost != null && (fragmentHost.startsWith(EquinoxConstants.FW_SYMBOLIC_NAME) || fragmentHost.startsWith(Constants.SYSTEM_BUNDLE_SYMBOLICNAME)); + boolean isFrameworkExtension = fragmentHost != null + && (fragmentHost.startsWith(EquinoxConstants.FW_SYMBOLIC_NAME) + || fragmentHost.startsWith(Constants.SYSTEM_BUNDLE_SYMBOLICNAME)); if (isFrameworkExtension) { bundle.setStartLevel(BundleInfo.NO_LEVEL); @@ -197,7 +203,7 @@ public void readFwConfig(Manipulator manipulator, File inputFile) throws IOExcep throw new IllegalArgumentException(NLS.bind(Messages.exception_inputFileIsDirectory, inputFile)); boolean baseHasChanged = false; - //Initialize data structures + // Initialize data structures ConfigData configData = manipulator.getConfigData(); LauncherData launcherData = manipulator.getLauncherData(); configData.initialize(); @@ -207,29 +213,36 @@ public void readFwConfig(Manipulator manipulator, File inputFile) throws IOExcep Properties props = loadProperties(inputFile); // load shared configuration properties - Properties sharedConfigProperties = getSharedConfiguration(ParserUtils.getOSGiInstallArea(Arrays.asList(manipulator.getLauncherData().getProgramArgs()), props, manipulator.getLauncherData()), props.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); + Properties sharedConfigProperties = getSharedConfiguration( + ParserUtils.getOSGiInstallArea(Arrays.asList(manipulator.getLauncherData().getProgramArgs()), props, + manipulator.getLauncherData()), + props.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); if (sharedConfigProperties != null) { baseHasChanged = hasBaseChanged(inputFile, manipulator, props); if (!baseHasChanged) sharedConfigProperties.putAll(props); else { - sharedConfigProperties.put(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA, props.get(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); + sharedConfigProperties.put(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA, + props.get(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); } props = sharedConfigProperties; } - //Start figuring out stuffs - //URI rootURI = launcherData.getLauncher() != null ? launcherData.getLauncher().getParentFile().toURI() : null; + // Start figuring out stuffs + // URI rootURI = launcherData.getLauncher() != null ? + // launcherData.getLauncher().getParentFile().toURI() : null; readFwJarLocation(configData, launcherData, props); URI configArea = inputFile.getParentFile().toURI(); - //readLauncherPath(props, rootURI); + // readLauncherPath(props, rootURI); readp2DataArea(props, configArea); readSimpleConfiguratorURL(props, configArea); if (!baseHasChanged) - readBundlesList(manipulator, ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), props, launcherData).toURI(), props); + readBundlesList(manipulator, ParserUtils + .getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), props, launcherData).toURI(), + props); readInitialStartLeve(configData, props); readDefaultStartLevel(configData, props); @@ -240,12 +253,14 @@ public void readFwConfig(Manipulator manipulator, File inputFile) throws IOExcep String value = props.getProperty(key); configData.setProperty(key, value); } - Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_configFile, inputFile.getAbsolutePath())); + Log.info(NLS.bind(Messages.log_configFile, inputFile.getAbsolutePath())); } private boolean hasBaseChanged(File configIni, Manipulator manipulator, Properties configProps) { LauncherData launcherData = manipulator.getLauncherData(); - File sharedConfigIni = findSharedConfigIniFile(ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); + File sharedConfigIni = findSharedConfigIniFile( + ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), + configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); File timestampFile = new File(configIni.getParentFile(), BASE_TIMESTAMP_FILE_CONFIGINI); Properties timestamps; try { @@ -260,29 +275,37 @@ private boolean hasBaseChanged(File configIni, Manipulator manipulator, Properti private void readDefaultStartLevel(ConfigData configData, Properties props) { if (props.getProperty(EquinoxConstants.PROP_BUNDLES_STARTLEVEL) != null) - configData.setInitialBundleStartLevel(Integer.parseInt(props.getProperty(EquinoxConstants.PROP_BUNDLES_STARTLEVEL))); + configData.setInitialBundleStartLevel( + Integer.parseInt(props.getProperty(EquinoxConstants.PROP_BUNDLES_STARTLEVEL))); } private void writeDefaultStartLevel(ConfigData configData, Properties props) { if (configData.getInitialBundleStartLevel() != BundleInfo.NO_LEVEL) - props.setProperty(EquinoxConstants.PROP_BUNDLES_STARTLEVEL, Integer.toString(configData.getInitialBundleStartLevel())); + props.setProperty(EquinoxConstants.PROP_BUNDLES_STARTLEVEL, + Integer.toString(configData.getInitialBundleStartLevel())); } private void readInitialStartLeve(ConfigData configData, Properties props) { if (props.getProperty(EquinoxConstants.PROP_INITIAL_STARTLEVEL) != null) - configData.setBeginningFwStartLevel(Integer.parseInt(props.getProperty(EquinoxConstants.PROP_INITIAL_STARTLEVEL))); + configData.setBeginningFwStartLevel( + Integer.parseInt(props.getProperty(EquinoxConstants.PROP_INITIAL_STARTLEVEL))); } private void writeInitialStartLevel(ConfigData configData, Properties props) { if (configData.getBeginingFwStartLevel() != BundleInfo.NO_LEVEL) - props.setProperty(EquinoxConstants.PROP_INITIAL_STARTLEVEL, Integer.toString(configData.getBeginingFwStartLevel())); + props.setProperty(EquinoxConstants.PROP_INITIAL_STARTLEVEL, + Integer.toString(configData.getBeginingFwStartLevel())); } - private File readFwJarLocation(ConfigData configData, LauncherData launcherData, Properties props) throws URISyntaxException { + private File readFwJarLocation(ConfigData configData, LauncherData launcherData, Properties props) + throws URISyntaxException { File fwJar = null; if (props.getProperty(EquinoxConstants.PROP_OSGI_FW) != null) { URI absoluteFwJar = null; - absoluteFwJar = URIUtil.makeAbsolute(FileUtils.fromFileURL(props.getProperty(EquinoxConstants.PROP_OSGI_FW)), ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), props, launcherData).toURI()); + absoluteFwJar = URIUtil.makeAbsolute( + FileUtils.fromFileURL(props.getProperty(EquinoxConstants.PROP_OSGI_FW)), + ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), props, launcherData) + .toURI()); props.setProperty(EquinoxConstants.PROP_OSGI_FW, absoluteFwJar.toString()); String fwJarString = props.getProperty(EquinoxConstants.PROP_OSGI_FW); @@ -290,7 +313,8 @@ private File readFwJarLocation(ConfigData configData, LauncherData launcherData, fwJar = URIUtil.toFile(absoluteFwJar); if (fwJar == null) throw new IllegalStateException(Messages.exception_noFrameworkLocation); - //Here we overwrite the value read from eclipse.ini, because the value of osgi.framework always takes precedence. + // Here we overwrite the value read from eclipse.ini, because the value of + // osgi.framework always takes precedence. launcherData.setFwJar(fwJar); } else { throw new IllegalStateException(Messages.exception_noFrameworkLocation); @@ -304,7 +328,10 @@ private File readFwJarLocation(ConfigData configData, LauncherData launcherData, private void writeFwJarLocation(ConfigData configData, LauncherData launcherData, Properties props) { if (launcherData.getFwJar() == null) return; - props.setProperty(EquinoxConstants.PROP_OSGI_FW, FileUtils.toFileURL(URIUtil.makeRelative(launcherData.getFwJar().toURI(), ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configData.getProperties(), launcherData).toURI()))); + props.setProperty(EquinoxConstants.PROP_OSGI_FW, + FileUtils.toFileURL(URIUtil.makeRelative(launcherData.getFwJar().toURI(), + ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), + configData.getProperties(), launcherData).toURI()))); } private static Properties loadProperties(File inputFile) throws FileNotFoundException, IOException { @@ -318,7 +345,7 @@ private static Properties loadProperties(File inputFile) throws FileNotFoundExce if (is != null) is.close(); } catch (IOException e) { - Log.log(LogService.LOG_WARNING, NLS.bind(Messages.log_failed_reading_properties, inputFile)); + Log.warn(NLS.bind(Messages.log_failed_reading_properties, inputFile)); } is = null; } @@ -344,33 +371,35 @@ private File findSharedConfigIniFile(File base, String sharedConfigurationArea) sharedConfigurationURL = new URL(sharedConfigurationArea); } catch (MalformedURLException e) { // unexpected since this was written by the framework - Log.log(LogService.LOG_WARNING, NLS.bind(Messages.log_shared_config_url, sharedConfigurationArea)); + Log.warn(NLS.bind(Messages.log_shared_config_url, sharedConfigurationArea)); return null; } // check for a relative URL if (!sharedConfigurationURL.getPath().startsWith("/")) { //$NON-NLS-1$ if (!rootURL.getProtocol().equals(sharedConfigurationURL.getProtocol())) { - Log.log(LogService.LOG_WARNING, NLS.bind(Messages.log_shared_config_relative_url, rootURL.toExternalForm(), sharedConfigurationArea)); + Log.warn(NLS.bind(Messages.log_shared_config_relative_url, rootURL.toExternalForm(), + sharedConfigurationArea)); return null; } try { sharedConfigurationURL = new URL(rootURL, sharedConfigurationArea); } catch (MalformedURLException e) { // unexpected since this was written by the framework - Log.log(LogService.LOG_WARNING, NLS.bind(Messages.log_shared_config_relative_url, rootURL.toExternalForm(), sharedConfigurationArea)); + Log.warn(NLS.bind(Messages.log_shared_config_relative_url, rootURL.toExternalForm(), + sharedConfigurationArea)); return null; } } File sharedConfigurationFolder = EquinoxManipulatorImpl.toFile(sharedConfigurationURL); if (!sharedConfigurationFolder.isDirectory()) { - Log.log(LogService.LOG_WARNING, NLS.bind(Messages.log_shared_config_file_missing, sharedConfigurationFolder)); + Log.warn(NLS.bind(Messages.log_shared_config_file_missing, sharedConfigurationFolder)); return null; } File sharedConfigIni = new File(sharedConfigurationFolder, EquinoxConstants.CONFIG_INI); if (!sharedConfigIni.exists()) { - Log.log(LogService.LOG_WARNING, NLS.bind(Messages.log_shared_config_file_missing, sharedConfigIni)); + Log.warn(NLS.bind(Messages.log_shared_config_file_missing, sharedConfigIni)); return null; } @@ -383,7 +412,8 @@ private void readp2DataArea(Properties props, URI configArea) throws URISyntaxEx if (url != null) { if (url.startsWith(CONFIG_DIR)) url = "file:" + url.substring(CONFIG_DIR.length()); //$NON-NLS-1$ - props.setProperty(KEY_ECLIPSE_PROV_DATA_AREA, URIUtil.makeAbsolute(FileUtils.fromFileURL(url), configArea).toString()); + props.setProperty(KEY_ECLIPSE_PROV_DATA_AREA, + URIUtil.makeAbsolute(FileUtils.fromFileURL(url), configArea).toString()); } } } @@ -402,7 +432,8 @@ private void writep2DataArea(ConfigData configData, Properties props, URI config return; } String result = URIUtil.toUnencodedString(relative); - //We only relativize up to the level where the p2 and config folder are siblings (e.g. foo/p2 and foo/config) + // We only relativize up to the level where the p2 and config folder are + // siblings (e.g. foo/p2 and foo/config) if (result.startsWith("../..")) //$NON-NLS-1$ result = dataArea; else if (!result.equals(dataArea)) { @@ -415,24 +446,31 @@ else if (!result.equals(dataArea)) { private void readSimpleConfiguratorURL(Properties props, URI configArea) throws URISyntaxException { if (props.getProperty(KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL) != null) - props.setProperty(KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL, URIUtil.makeAbsolute(FileUtils.fromFileURL(props.getProperty(KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL)), configArea).toString()); + props.setProperty(KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL, + URIUtil.makeAbsolute( + FileUtils.fromFileURL( + props.getProperty(KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL)), + configArea).toString()); } - private void writeSimpleConfiguratorURL(ConfigData configData, Properties props, URI configArea) throws URISyntaxException { - //FIXME How would someone set such a value..... + private void writeSimpleConfiguratorURL(ConfigData configData, Properties props, URI configArea) + throws URISyntaxException { + // FIXME How would someone set such a value..... String value = getFwProperty(configData, KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL); if (value != null) - props.setProperty(KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL, FileUtils.toFileURL(URIUtil.makeRelative(URIUtil.fromString(value), configArea))); + props.setProperty(KEY_ORG_ECLIPSE_EQUINOX_SIMPLECONFIGURATOR_CONFIGURL, + FileUtils.toFileURL(URIUtil.makeRelative(URIUtil.fromString(value), configArea))); } private String getFwProperty(ConfigData data, String key) { return data.getProperty(key); } - public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean backup, boolean relative) throws IOException {//{ + public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean backup, boolean relative) + throws IOException {// { ConfigData configData = manipulator.getConfigData(); LauncherData launcherData = manipulator.getLauncherData(); - //Get the OSGi jar from the bundle.info + // Get the OSGi jar from the bundle.info File fwJar = EquinoxBundlesState.getSystemBundleFromBundleInfos(configData); launcherData.setFwJar(fwJar); @@ -440,7 +478,8 @@ public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean b if (outputFile.exists()) { if (outputFile.isFile()) { if (!outputFile.getName().equals(EquinoxConstants.CONFIG_INI)) - throw new IllegalStateException(NLS.bind(Messages.exception_fwConfigLocationName, outputFile.getAbsolutePath(), EquinoxConstants.CONFIG_INI)); + throw new IllegalStateException(NLS.bind(Messages.exception_fwConfigLocationName, + outputFile.getAbsolutePath(), EquinoxConstants.CONFIG_INI)); } else { // Directory outputFile = new File(outputFile, EquinoxConstants.CONFIG_INI); } @@ -453,11 +492,12 @@ public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean b } Properties configProps = new Properties(); - //URI rootURI = launcherData.getLauncher() != null ? launcherData.getLauncher().getParentFile().toURI() : null; + // URI rootURI = launcherData.getLauncher() != null ? + // launcherData.getLauncher().getParentFile().toURI() : null; writeFwJarLocation(configData, launcherData, configProps); try { - //writeLauncherPath(configData, configProps, rootURI); + // writeLauncherPath(configData, configProps, rootURI); URI configArea = manipulator.getLauncherData().getFwConfigLocation().toURI(); writep2DataArea(configData, configProps, configArea); writeSimpleConfiguratorURL(configData, configProps, configArea); @@ -472,11 +512,12 @@ public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean b original.putAll(configProps); configProps = original; - //Deal with the fw jar and ensure it is not set. - //TODO This can't be done before because of the previous calls to appendProperties + // Deal with the fw jar and ensure it is not set. + // TODO This can't be done before because of the previous calls to + // appendProperties if (configProps == null || configProps.size() == 0) { - Log.log(LogService.LOG_WARNING, this, "saveFwConfig() ", Messages.log_configProps); //$NON-NLS-1$ + Log.warn(this, "saveFwConfig() ", Messages.log_configProps); //$NON-NLS-1$ return; } if (!Utils.createParentDir(outputFile)) { @@ -491,7 +532,8 @@ public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean b File dest = Utils.getSimpleDataFormattedFile(outputFile); if (!outputFile.renameTo(dest)) throw new IOException(NLS.bind(Messages.exception_failedToRename, outputFile, dest)); - Log.log(LogService.LOG_INFO, this, "saveFwConfig()", NLS.bind(Messages.log_renameSuccessful, outputFile, dest)); //$NON-NLS-1$ + Log.info(this, "saveFwConfig()", //$NON-NLS-1$ + NLS.bind(Messages.log_renameSuccessful, outputFile, dest)); } filterPropertiesFromSharedArea(configProps, manipulator); @@ -501,16 +543,19 @@ public void saveFwConfig(BundleInfo[] bInfos, Manipulator manipulator, boolean b private void saveProperties(File outputFile, Properties configProps) throws IOException { String header = "This configuration file was written by: " + this.getClass().getName(); //$NON-NLS-1$ - try (FileOutputStream out = new FileOutputStream(outputFile)){ + try (FileOutputStream out = new FileOutputStream(outputFile)) { configProps.store(out, header); - Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_propertiesSaved, outputFile)); + Log.info(NLS.bind(Messages.log_propertiesSaved, outputFile)); } } private void filterPropertiesFromSharedArea(Properties configProps, Manipulator manipulator) { LauncherData launcherData = manipulator.getLauncherData(); - //Remove from the config file that we are about to write the properties that are unchanged compared to what is in the base - Properties sharedConfigProperties = getSharedConfiguration(ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); + // Remove from the config file that we are about to write the properties that + // are unchanged compared to what is in the base + Properties sharedConfigProperties = getSharedConfiguration( + ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), + configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); if (sharedConfigProperties == null) return; Enumeration keys = configProps.propertyNames(); @@ -568,7 +613,7 @@ private boolean equalsIgnoringSeparators(String s1, String s2) { } private void canonicalizePathsForComparison(StringBuffer s) { - final String[] tokens = new String[] {"\\\\", "\\", "//", "/"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ + final String[] tokens = new String[] { "\\\\", "\\", "//", "/" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ for (String token : tokens) { int idx = s.length(); for (int i = s.length(); i != 0 && idx != -1; i--) { @@ -580,10 +625,14 @@ private void canonicalizePathsForComparison(StringBuffer s) { } } - private void rememberSharedConfigurationTimestamp(Properties configProps, Manipulator manipulator, File folder) throws IOException { + private void rememberSharedConfigurationTimestamp(Properties configProps, Manipulator manipulator, File folder) + throws IOException { LauncherData launcherData = manipulator.getLauncherData(); - //Remove from the config file that we are about to write the properties that are unchanged compared to what is in the base - File sharedConfigIni = findSharedConfigIniFile(ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); + // Remove from the config file that we are about to write the properties that + // are unchanged compared to what is in the base + File sharedConfigIni = findSharedConfigIniFile( + ParserUtils.getOSGiInstallArea(Arrays.asList(launcherData.getProgramArgs()), configProps, launcherData), + configProps.getProperty(EquinoxConstants.PROP_SHARED_CONFIGURATION_AREA)); if (sharedConfigIni == null) return; File timestampFile = new File(folder, BASE_TIMESTAMP_FILE_CONFIGINI); diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java index c3693112c1..eee4b6bfda 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java @@ -29,10 +29,10 @@ import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; import org.osgi.framework.startlevel.BundleStartLevel; -import org.osgi.service.log.LogService; import org.osgi.service.startlevel.StartLevel; import org.osgi.util.tracker.ServiceTracker; +@SuppressWarnings({ "rawtypes", "unchecked", "deprecation" }) public class EquinoxManipulatorImpl implements Manipulator { private static final long DEFAULT_LASTMODIFIED = 0L; private static final boolean LOG_ILLEGALSTATEEXCEPTION = false; @@ -115,7 +115,6 @@ else if (launcherData.getFwPersistentDataLocation() != null) BundleContext context = null; private Properties platformProperties = new Properties(); - @SuppressWarnings("rawtypes") ServiceTracker cmTracker; int trackingCount = -1; private final PlatformAdmin platformAdmin; @@ -127,7 +126,6 @@ else if (launcherData.getFwPersistentDataLocation() != null) EquinoxFwAdminImpl fwAdmin = null; - @SuppressWarnings({ "rawtypes", "unchecked" }) EquinoxManipulatorImpl(BundleContext context, EquinoxFwAdminImpl fwAdmin, PlatformAdmin admin, StartLevel slService, boolean runtime) { this.context = context; @@ -195,7 +193,6 @@ public LauncherData getLauncherData() throws FrameworkAdminRuntimeException { * * @see Location */ - @SuppressWarnings({ "rawtypes", "unchecked" }) private File getRunningConfigurationLocation() { ServiceTracker tracker = null; Filter filter = null; @@ -223,7 +220,7 @@ static File toFile(URL url) { } return file; } catch (URISyntaxException e) { - Log.log(LogService.LOG_WARNING, "URL is not a valid URI, using only path for file", e); //$NON-NLS-1$ + Log.warn("URL is not a valid URI, using only path for file", "toFile(URL url)", e); //$NON-NLS-1$ //$NON-NLS-2$ return new File(url.getFile()); } } @@ -292,7 +289,7 @@ private long getTimeStampWithoutFwPersistentData() { @Override public void initialize() { - Log.log(LogService.LOG_DEBUG, this, "initialize()", "BEGIN"); //$NON-NLS-1$ //$NON-NLS-2$ + Log.debug(this, "initialize()", "BEGIN"); //$NON-NLS-1$ //$NON-NLS-2$ configData.initialize(); launcherData.initialize(); } @@ -362,7 +359,7 @@ private void initializeRuntime() { @Override public void load() throws IllegalStateException, IOException, FrameworkAdminRuntimeException { - Log.log(LogService.LOG_DEBUG, this, "load()", "BEGIN"); //$NON-NLS-1$//$NON-NLS-2$ + Log.debug(this, "load()", "BEGIN"); //$NON-NLS-1$//$NON-NLS-2$ loadWithoutFwPersistentData(); BundlesState bundlesState = null; @@ -408,7 +405,7 @@ private void loadWithoutFwPersistentData() throws IOException { // Save all parameter in memory into proper config files. @Override public void save(boolean backup) throws IOException, FrameworkAdminRuntimeException { - Log.log(LogService.LOG_DEBUG, this, "save()", "BEGIN"); //$NON-NLS-1$//$NON-NLS-2$ + Log.debug(this, "save()", "BEGIN"); //$NON-NLS-1$//$NON-NLS-2$ SimpleBundlesState.checkAvailability(fwAdmin); try { @@ -443,7 +440,7 @@ public void save(boolean backup) throws IOException, FrameworkAdminRuntimeExcept newBInfos = configuratorManipulator.save(this, backup); } catch (IllegalStateException e) { if (LOG_ILLEGALSTATEEXCEPTION) - Log.log(LogService.LOG_WARNING, this, "save()", e); //$NON-NLS-1$ + Log.warn(this, "save()", e); //$NON-NLS-1$ newBInfos = configData.getBundles(); } } else { @@ -492,7 +489,6 @@ public void setConfigData(ConfigData configData) { * started among them. 4. set the object that corresponds to the chosen * ConfiguratorBundle. */ - @SuppressWarnings("unchecked") private ConfiguratorManipulator setConfiguratorManipulator() { if (context == null) { this.configuratorManipulator = this.fwAdmin.getConfiguratorManipulator(); diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Log.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Log.java index 86da5dffc0..455adeb997 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Log.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/Log.java @@ -21,7 +21,7 @@ /** * Utility class with static methods for logging to LogService, if available */ -@SuppressWarnings({"rawtypes", "unchecked"}) +@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" }) public class Log { static private ServiceTracker logTracker; static private boolean useLog = false; @@ -38,11 +38,19 @@ public static void init(BundleContext bc) { logTracker.open(); } - public static void log(int level, Object obj, String method, String message) { - log(level, obj, method, message, null); + static void debug(Object obj, String method, String message) { + log(LogService.LOG_DEBUG, obj, method, message, null); } - public static void log(int level, Object obj, String method, String message, Throwable e) { + static void warn(Object obj, String method, String message) { + log(LogService.LOG_WARNING, obj, method, message, null); + } + + static void info(Object obj, String method, String message) { + log(LogService.LOG_INFO, obj, method, message, null); + } + + private static void log(int level, Object obj, String method, String message, Throwable e) { LogService logService = null; String msg = ""; //$NON-NLS-1$ if (method == null) { @@ -78,16 +86,28 @@ else if (level == LogService.LOG_ERROR) { } } - public static void log(int level, Object obj, String method, Throwable e) { - log(level, obj, method, null, e); + static void warn(Object obj, String method, Throwable e) { + log(LogService.LOG_WARNING, obj, method, null, e); + } + + static void debug(String message) { + log(LogService.LOG_DEBUG, null, null, message, null); + } + + static void warn(String message) { + log(LogService.LOG_WARNING, null, null, message, null); + } + + static void info(String message) { + log(LogService.LOG_INFO, null, null, message, null); } - public static void log(int level, String message) { - log(level, null, null, message, null); + static void error(String message) { + log(LogService.LOG_ERROR, null, null, message, null); } - public static void log(int level, String message, Throwable e) { - log(level, null, null, message, e); + static void error(String message, Throwable e) { + log(LogService.LOG_ERROR, null, null, message, e); } private Log() { diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java index f4ceeea50b..cbcc4e34d2 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/ParserUtils.java @@ -19,12 +19,12 @@ import java.net.URISyntaxException; import java.util.List; import java.util.Properties; -import org.eclipse.core.runtime.*; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.internal.frameworkadmin.equinox.utils.FileUtils; import org.eclipse.equinox.internal.provisional.frameworkadmin.LauncherData; import org.eclipse.osgi.service.environment.Constants; import org.eclipse.osgi.util.NLS; -import org.osgi.service.log.LogService; public class ParserUtils { private static final String FILE_PROTOCOL = "file:"; //$NON-NLS-1$ @@ -53,11 +53,12 @@ else if (launcherData.getHome() != null) File launcherFile = launcherData.getLauncher(); if (launcherFile != null) { if (Constants.OS_MACOSX.equals(launcherData.getOS())) { // - //TODO We are going to change this - the equinox launcher will look 3 levels up on the mac when going from executable to launcher.jar - //see org.eclipse.equinox.executable/library/eclipse.c : findStartupJar(); + // TODO We are going to change this - the equinox launcher will look 3 levels up + // on the mac when going from executable to launcher.jar + // see org.eclipse.equinox.executable/library/eclipse.c : findStartupJar(); IPath launcherPath = IPath.fromOSString(launcherFile.getAbsolutePath()); if (launcherPath.segmentCount() > 2) { - //removing "MacOS/eclipse" from the end of the path + // removing "MacOS/eclipse" from the end of the path launcherPath = launcherPath.removeLastSegments(2).append("Eclipse"); //$NON-NLS-1$ return launcherPath.toFile(); } @@ -70,8 +71,9 @@ else if (launcherData.getHome() != null) public static URI getFrameworkJar(List lines, URI launcherFolder) { String fwk = ParserUtils.getValueForArgument(EquinoxConstants.OPTION_FW, lines); if (fwk == null) { - //Search the file system using the default location - URI location = FileUtils.getEclipsePluginFullLocation(EquinoxConstants.FW_SYMBOLIC_NAME, new File(URIUtil.toFile(launcherFolder), EquinoxConstants.PLUGINS_DIR)); + // Search the file system using the default location + URI location = FileUtils.getEclipsePluginFullLocation(EquinoxConstants.FW_SYMBOLIC_NAME, + new File(URIUtil.toFile(launcherFolder), EquinoxConstants.PLUGINS_DIR)); if (location != null) return location; return null; @@ -79,12 +81,13 @@ public static URI getFrameworkJar(List lines, URI launcherFolder) { try { return URIUtil.makeAbsolute(URIUtil.fromString(fwk), launcherFolder); } catch (URISyntaxException e) { - Log.log(LogService.LOG_ERROR, NLS.bind(Messages.exception_createAbsoluteURI, fwk, launcherFolder)); + Log.error(NLS.bind(Messages.exception_createAbsoluteURI, fwk, launcherFolder)); return null; } } - //This method should only be used to determine the osgi install area when reading the eclipse.ini + // This method should only be used to determine the osgi install area when + // reading the eclipse.ini public static File getOSGiInstallArea(List args, Properties properties, File launcherFile, URI base) { if (args == null) return null; diff --git a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java index 011f8e82b2..ce38d3c5ed 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.test/src/org/eclipse/equinox/frameworkadmin/tests/SharedConfigurationTest.java @@ -22,15 +22,11 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.URIUtil; import org.eclipse.equinox.frameworkadmin.BundleInfo; -import org.eclipse.equinox.internal.frameworkadmin.equinox.Log; -import org.eclipse.equinox.internal.frameworkadmin.equinox.Messages; import org.eclipse.equinox.internal.provisional.frameworkadmin.*; -import org.eclipse.osgi.util.NLS; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; import org.osgi.framework.BundleException; -import org.osgi.service.log.LogService; public class SharedConfigurationTest extends AbstractFwkAdminTest { @@ -235,7 +231,6 @@ private void saveProperties(File outputFile, Properties configProps) throws IOEx try { out = new FileOutputStream(outputFile); configProps.store(out, header); - Log.log(LogService.LOG_INFO, NLS.bind(Messages.log_propertiesSaved, outputFile)); } finally { try { out.flush();