Skip to content

Commit

Permalink
Format java files in o.e.osgi
Browse files Browse the repository at this point in the history
This was achieved by running:
eclipse -consolelog -nosplash -application org.eclipse.jdt.core.JavaCodeFormatter \
  -config .settings/org.eclipse.jdt.core.prefs . -data `mktemp -d` && \
  git checkout osgi/src/org/osgi felix

Signed-off-by: Torbjörn SVENSSON <[email protected]>
  • Loading branch information
Torbjorn-Svensson committed Dec 17, 2023
1 parent 9e23b5e commit ba6e0a9
Show file tree
Hide file tree
Showing 210 changed files with 8,476 additions and 5,906 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,26 @@ public void checkForConsoleBundle() throws BundleException {
if ("none".equals(consolePort)) //$NON-NLS-1$
return;
// otherwise we need to check for the equinox console bundle and start it
ServiceReference<org.osgi.service.packageadmin.PackageAdmin> paRef = context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class);
ServiceReference<org.osgi.service.packageadmin.PackageAdmin> paRef = context
.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class);
org.osgi.service.packageadmin.PackageAdmin pa = paRef == null ? null : context.getService(paRef);
Bundle[] consoles = pa.getBundles(consoleBundle, null);
if (consoles == null || consoles.length == 0) {
if (consolePort != null)
throw new BundleException("Could not find bundle: " + consoleBundle, BundleException.UNSUPPORTED_OPERATION); //$NON-NLS-1$
throw new BundleException("Could not find bundle: " + consoleBundle, //$NON-NLS-1$
BundleException.UNSUPPORTED_OPERATION);
return;
}
try {
consoles[0].start(Bundle.START_TRANSIENT);
} catch (BundleException e) {
throw new BundleException("Could not start bundle: " + consoleBundle, BundleException.UNSUPPORTED_OPERATION, e); //$NON-NLS-1$
throw new BundleException("Could not start bundle: " + consoleBundle, BundleException.UNSUPPORTED_OPERATION, //$NON-NLS-1$
e);
}
}

/**
* Stops the OSGi Command console
* Stops the OSGi Command console
*/
public void stopConsole() {
// nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,27 @@ public class DefaultStartupMonitor implements StartupMonitor {
private final EquinoxConfiguration equinoxConfig;

/**
* Create a new startup monitor using the given splash handler. The splash handle must
* have an updateSplash method.
* Create a new startup monitor using the given splash handler. The splash
* handle must have an updateSplash method.
*/
public DefaultStartupMonitor(Runnable splashHandler, EquinoxConfiguration equinoxConfig) throws IllegalStateException {
public DefaultStartupMonitor(Runnable splashHandler, EquinoxConfiguration equinoxConfig)
throws IllegalStateException {
this.splashHandler = splashHandler;
this.equinoxConfig = equinoxConfig;

try {
updateMethod = splashHandler.getClass().getMethod("updateSplash", (Class[]) null); //$NON-NLS-1$
} catch (SecurityException | NoSuchMethodException e) {
//TODO maybe we could do something else in the update method in this case, like print something to the console?
// TODO maybe we could do something else in the update method in this case, like
// print something to the console?
throw new IllegalStateException(e.getMessage(), e);
}

}

/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.core.runtime.adaptor.StartupMonitor#update()
*/
@Override
Expand All @@ -54,7 +58,7 @@ public void update() {
// ignore, this is best effort
}
} else {
//TODO maybe we could print something interesting to the console?
// TODO maybe we could print something interesting to the console?
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public class EclipseAppLauncher implements ApplicationLauncher {
private final FrameworkLog log;
private final EquinoxConfiguration equinoxConfig;

public EclipseAppLauncher(BundleContext context, boolean relaunch, boolean failOnNoDefault, FrameworkLog log, EquinoxConfiguration equinoxConfig) {
public EclipseAppLauncher(BundleContext context, boolean relaunch, boolean failOnNoDefault, FrameworkLog log,
EquinoxConfiguration equinoxConfig) {
this.context = context;
this.relaunch = relaunch;
this.failOnNoDefault = failOnNoDefault;
Expand All @@ -52,13 +53,15 @@ public EclipseAppLauncher(BundleContext context, boolean relaunch, boolean failO
* Used for backwards compatibility with < 3.2 runtime
*/
private void findRunnableService() {
// look for a ParameterizedRunnable registered as a service by runtimes (3.0, 3.1)
// look for a ParameterizedRunnable registered as a service by runtimes (3.0,
// 3.1)
String appClass = ParameterizedRunnable.class.getName();
ServiceReference<?>[] runRefs = null;
try {
runRefs = context.getServiceReferences(ParameterizedRunnable.class.getName(), "(&(objectClass=" + appClass + ")(eclipse.application=*))"); //$NON-NLS-1$//$NON-NLS-2$
runRefs = context.getServiceReferences(ParameterizedRunnable.class.getName(),
"(&(objectClass=" + appClass + ")(eclipse.application=*))"); //$NON-NLS-1$//$NON-NLS-2$
} catch (InvalidSyntaxException e) {
// ignore this. It should never happen as we have tested the above format.
// ignore this. It should never happen as we have tested the above format.
}
if (runRefs != null && runRefs.length > 0) {
// found the service use it as the application.
Expand All @@ -70,13 +73,15 @@ private void findRunnableService() {
}

/*
* Starts this application launcher on the current thread. This method
* should be called by the main thread to ensure that applications are
* launched in the main thread.
* Starts this application launcher on the current thread. This method should be
* called by the main thread to ensure that applications are launched in the
* main thread.
*/
public Object start(Object defaultContext) throws Exception {
// here we assume that launch has been called by runtime before we started
// TODO this may be a bad assumption but it works for now because we register the app launcher as a service and runtime synchronously calls launch on the service
// TODO this may be a bad assumption but it works for now because we register
// the app launcher as a service and runtime synchronously calls launch on the
// service
if (failOnNoDefault && runnable == null)
throw new IllegalStateException(Msg.ECLIPSE_STARTUP_ERROR_NO_APPLICATION);
Object result = null;
Expand Down Expand Up @@ -108,7 +113,8 @@ public Object start(Object defaultContext) throws Exception {
if (!relaunch || (b.getState() & Bundle.ACTIVE) == 0)
throw e;
if (log != null)
log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0, Msg.ECLIPSE_STARTUP_APP_ERROR, 1, e, null));
log.log(new FrameworkLogEntry(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, 0,
Msg.ECLIPSE_STARTUP_APP_ERROR, 1, e, null));
}
doRelaunch = (relaunch && (b.getState() & Bundle.ACTIVE) != 0);
} while (doRelaunch);
Expand All @@ -124,7 +130,8 @@ private Object runApplication(Object defaultContext) throws Exception {
// wait for an application to be launched.
waitForAppLock.acquire();
// an application is ready; acquire the running lock.
// this must happen after we have acquired an application (by acquiring waitForAppLock above).
// this must happen after we have acquired an application (by acquiring
// waitForAppLock above).
runningLock.acquire();
if (EclipseStarter.debug) {
String timeString = equinoxConfig.getConfiguration("eclipse.startTime"); //$NON-NLS-1$
Expand All @@ -135,7 +142,8 @@ private Object runApplication(Object defaultContext) throws Exception {
// run the actual application on the current thread (main).
return runnable.run(appContext != null ? appContext : defaultContext);
} finally {
// free the runnable application and release the lock to allow another app to be launched.
// free the runnable application and release the lock to allow another app to be
// launched.
runnable = null;
appContext = null;
runningLock.release();
Expand Down Expand Up @@ -177,17 +185,19 @@ public void shutdown() {
}

/*
* Similar to the start method this method will restart the default method on current thread.
* This method assumes that the default application was launched at least once and that an ApplicationDescriptor
* exists that can be used to relaunch the default application.
* Similar to the start method this method will restart the default method on
* current thread. This method assumes that the default application was launched
* at least once and that an ApplicationDescriptor exists that can be used to
* relaunch the default application.
*/
public Object reStart(Object argument) throws Exception {
ServiceReference<?> ref[] = null;
ref = context.getServiceReferences("org.osgi.service.application.ApplicationDescriptor", "(eclipse.application.default=true)"); //$NON-NLS-1$//$NON-NLS-2$
ref = context.getServiceReferences("org.osgi.service.application.ApplicationDescriptor", //$NON-NLS-1$
"(eclipse.application.default=true)"); //$NON-NLS-1$
if (ref != null && ref.length > 0) {
Object defaultApp = context.getService(ref[0]);
Method launch = defaultApp.getClass().getMethod("launch", new Class[] {Map.class}); //$NON-NLS-1$
launch.invoke(defaultApp, new Object[] {null});
Method launch = defaultApp.getClass().getMethod("launch", new Class[] { Map.class }); //$NON-NLS-1$
launch.invoke(defaultApp, new Object[] { null });
return start(argument);
}
throw new IllegalStateException(Msg.ECLIPSE_STARTUP_ERROR_NO_APPLICATION);
Expand Down
Loading

0 comments on commit ba6e0a9

Please sign in to comment.