Skip to content

Commit

Permalink
Support Platform.getOS/WS/Arch() in non-OSGi environments
Browse files Browse the repository at this point in the history
Unless the bundle's context has its own local configuration,
BundleContext.getProperty() delegates to System.getProperty() anyways.
  • Loading branch information
HannesWell committed Apr 22, 2024
1 parent a59ae09 commit 16fb526
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,6 @@ public ILog getLog(Bundle bundle) {
return new Log(bundle, null);
}

public String getNL() {
return getBundleContext().getProperty(PROP_NL);
}

/**
* Unicode locale extensions are defined using command line parameter -nlExtensions,
* or the system property "osgi.nl.extensions".
Expand All @@ -459,18 +455,30 @@ public String getOption(String option) {
}

public String getOS() {
return getBundleContext().getProperty(PROP_OS);
return getContextProperty(PROP_OS);
}

public String getWS() {
return getContextProperty(PROP_WS);
}

public String getOSArch() {
return getBundleContext().getProperty(PROP_ARCH);
return getContextProperty(PROP_ARCH);
}

public String getNL() {
return getContextProperty(PROP_NL);
}

private String getContextProperty(String key) {
BundleContext ctx = context;
return ctx != null ? ctx.getProperty(key) : System.getProperty(key);
}

public PlatformAdmin getPlatformAdmin() {
return platformTracker == null ? null : platformTracker.getService();
}


public IPreferencesService getPreferencesService() {
return preferencesTracker == null ? null : preferencesTracker.getService();
}
Expand Down Expand Up @@ -549,10 +557,6 @@ public Location getUserLocation() {
return userLocation.getService();
}

public String getWS() {
return getBundleContext().getProperty(PROP_WS);
}

private void initializeAuthorizationHandler() {
try {
AuthorizationHandler.setKeyringFile(keyringFile);
Expand Down

0 comments on commit 16fb526

Please sign in to comment.