Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce usage of deprecated LogService constants #467

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <eclipse>.ini
// this figures out the location of the data area on partial data read from the
// <eclipse>.ini
private URI getOSGiInstallArea(List<String> 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)
Expand Down Expand Up @@ -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)
Expand All @@ -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<String> lines, URI launcherFolder, LauncherData launcherData) {
Expand All @@ -93,10 +95,13 @@ private void getFrameworkJar(List<String> lines, URI launcherFolder, LauncherDat
launcherData.setFwJar(URIUtil.toFile(location));
}

private void getPersistentDataLocation(List<String> 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<String> 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));
}
}

Expand All @@ -111,7 +116,7 @@ private void getVM(List<String> 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;
}
}
Expand All @@ -128,21 +133,23 @@ private void setVM(List<String> 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);
Expand All @@ -151,7 +158,8 @@ private void setVM(List<String> 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<String> lines, LauncherData launcherData) {
Expand Down Expand Up @@ -201,7 +209,7 @@ private URI getLauncherLibrary(List<String> 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;
Expand All @@ -214,9 +222,10 @@ private void setLauncherLibrary(List<String> 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;
}
}
Expand All @@ -227,7 +236,7 @@ private URI getConfigurationLocation(List<String> lines, URI osgiInstallArea, La
try {
return URIUtil.makeAbsolute(new URI(CONFIGURATION_FOLDER), osgiInstallArea);
} catch (URISyntaxException e1) {
//ignore
// ignore
}

URI result = null;
Expand All @@ -236,15 +245,15 @@ private URI getConfigurationLocation(List<String> 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;
}

private void setConfigurationLocation(List<String> 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);
Expand All @@ -267,7 +276,7 @@ private URI getStartup(List<String> 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;
Expand All @@ -280,9 +289,10 @@ private void setStartup(List<String> 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;
}
}
Expand All @@ -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<String> 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.
Expand All @@ -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) {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -332,7 +331,7 @@ private boolean composeState(BundleInfo[] bInfos, Dictionary<Object, Object> 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;
Expand All @@ -354,13 +353,13 @@ private boolean composeState(BundleInfo[] bInfos, Dictionary<Object, Object> 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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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$
Expand Down Expand Up @@ -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$
}
}

Expand Down Expand Up @@ -703,7 +702,7 @@ public void uninstallBundle(BundleInfo bInfo) throws FrameworkAdminRuntimeExcept
try {
Dictionary<String, String> 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;
}
Expand All @@ -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$
}
}
}
Expand Down
Loading
Loading