Skip to content

Commit

Permalink
Format java files in o.e.equinox.app
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/org/osgi

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
  • Loading branch information
Torbjorn-Svensson committed Oct 5, 2023
1 parent 0864eb8 commit 4855a47
Show file tree
Hide file tree
Showing 15 changed files with 438 additions and 292 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
package org.eclipse.equinox.app;

/**
* Bootstrap type for an application. An IApplication represent executable
* entry points into an application. An IApplication can be configured into
* the Platform's <code>org.eclipse.core.runtime.applications</code> extension-point.
* Bootstrap type for an application. An IApplication represent executable entry
* points into an application. An IApplication can be configured into the
* Platform's <code>org.eclipse.core.runtime.applications</code>
* extension-point.
*
* <p>
* Clients may implement this interface.
Expand All @@ -38,28 +39,32 @@ public interface IApplication {
public static final Integer EXIT_RESTART = Integer.valueOf(23);

/**
* Exit object requesting that the command passed back be executed. Typically
* this is used to relaunch Eclipse with different command line arguments. When the executable is
* relaunched the command line will be retrieved from the
* {@link IApplicationContext#EXIT_DATA_PROPERTY eclipse.exitdata} system property.
* Exit object requesting that the command passed back be executed. Typically
* this is used to relaunch Eclipse with different command line arguments. When
* the executable is relaunched the command line will be retrieved from the
* {@link IApplicationContext#EXIT_DATA_PROPERTY eclipse.exitdata} system
* property.
*/
public static final Integer EXIT_RELAUNCH = Integer.valueOf(24);

/**
* Starts this application with the given context and returns a result. The content of
* the context is unchecked and should conform to the expectations of the application being
* invoked. This method can return the value {@link IApplicationContext#EXIT_ASYNC_RESULT} if
* the application will deliver its results asynchronously with the
* {@link IApplicationContext#setResult(Object, IApplication)} method; otherwise this method must not exit
* until the application is finished and is ready to exit.
* Starts this application with the given context and returns a result. The
* content of the context is unchecked and should conform to the expectations of
* the application being invoked. This method can return the value
* {@link IApplicationContext#EXIT_ASYNC_RESULT} if the application will deliver
* its results asynchronously with the
* {@link IApplicationContext#setResult(Object, IApplication)} method; otherwise
* this method must not exit until the application is finished and is ready to
* exit.
* <p>
* Applications can return any object they like. If an <code>Integer</code> is returned
* it is treated as the program exit code if Eclipse is exiting.
* Applications can return any object they like. If an <code>Integer</code> is
* returned it is treated as the program exit code if Eclipse is exiting.
* </p>
* <p>
* Note: This method is called by the platform; it is not intended
* to be called directly by clients.
* Note: This method is called by the platform; it is not intended to be called
* directly by clients.
* </p>
*
* @return the return value of the application
* @see #EXIT_OK
* @see #EXIT_RESTART
Expand All @@ -71,16 +76,17 @@ public interface IApplication {
public Object start(IApplicationContext context) throws Exception;

/**
* Forces this running application to exit. This method should wait until the
* running application is ready to exit. The {@link #start(IApplicationContext)}
* should already have exited or should exit very soon after this method exits<p>
* Forces this running application to exit. This method should wait until the
* running application is ready to exit. The {@link #start(IApplicationContext)}
* should already have exited or should exit very soon after this method exits
* <p>
*
* This method is only called to force an application to exit.
* This method will not be called if an application exits normally from
* the {@link #start(IApplicationContext)} method.
* This method is only called to force an application to exit. This method will
* not be called if an application exits normally from the
* {@link #start(IApplicationContext)} method.
* <p>
* Note: This method is called by the platform; it is not intended
* to be called directly by clients.
* Note: This method is called by the platform; it is not intended to be called
* directly by clients.
* </p>
*/
public void stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,140 +23,157 @@
* <p>
* This interface is not intended to be implemented by clients.
* </p>
*
* @since 1.0
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IApplicationContext {

/**
* A system property that may be set by an application to specify exit data
* for the application. The value of the property must be a <code>String</code>.
* A system property that may be set by an application to specify exit data for
* the application. The value of the property must be a <code>String</code>.
* <p>
* Typically applications do not need to set this property. If an error is detected
* while launching or running an application then the launcher will set this property
* automatically in order to display a message to the end user. An application may
* set this property for the following reasons:
* Typically applications do not need to set this property. If an error is
* detected while launching or running an application then the launcher will set
* this property automatically in order to display a message to the end user. An
* application may set this property for the following reasons:
* </p>
* <ul>
* <li>To provide the command line arguments to relaunch the eclipse platform. See
* {@link IApplication#EXIT_RELAUNCH}</li>
* <li>To provide an error message that will be displayed to the end user. This will
* cause an error dialog to be displayed to the user, this option should not be used
* by headless applications.</li>
* <li>To suppress all error dialogs displayed by the launcher this property can be
* set to the empty <code>String</code>. This is useful for
* headless applications where error dialogs must never be displayed.</li>
* <li>To provide the command line arguments to relaunch the eclipse platform.
* See {@link IApplication#EXIT_RELAUNCH}</li>
* <li>To provide an error message that will be displayed to the end user. This
* will cause an error dialog to be displayed to the user, this option should
* not be used by headless applications.</li>
* <li>To suppress all error dialogs displayed by the launcher this property can
* be set to the empty <code>String</code>. This is useful for headless
* applications where error dialogs must never be displayed.</li>
* </ul>
*
* @since 1.3
*/
public static final String EXIT_DATA_PROPERTY = "eclipse.exitdata"; //$NON-NLS-1$

/**
* A key used to store arguments for the application. The content of this argument
* is unchecked and should conform to the expectations of the application being invoked.
* Typically this is a <code>String</code> array.
* A key used to store arguments for the application. The content of this
* argument is unchecked and should conform to the expectations of the
* application being invoked. Typically this is a <code>String</code> array.
* <p>
*
* If the map used to launch an application {@link ApplicationDescriptor#launch(Map)} does
* not contain a value for this key then command line arguments used to launch
* the platform are set in the arguments of the application context.
* If the map used to launch an application
* {@link ApplicationDescriptor#launch(Map)} does not contain a value for this
* key then command line arguments used to launch the platform are set in the
* arguments of the application context.
*/
public static final String APPLICATION_ARGS = "application.args"; //$NON-NLS-1$

/**
* Exit object that indicates the application result will be delivered asynchronously.
* This object must be returned by the method {@link IApplication#start(IApplicationContext)}
* for applications which deliver a result asynchronously with the method
* Exit object that indicates the application result will be delivered
* asynchronously. This object must be returned by the method
* {@link IApplication#start(IApplicationContext)} for applications which
* deliver a result asynchronously with the method
* {@link IApplicationContext#setResult(Object, IApplication)}.
*
* @since 1.3
*/
public static final Object EXIT_ASYNC_RESULT = new Object();

/**
* The arguments used for the application. The arguments from
* {@link ApplicationDescriptor#launch(Map)} are used as the arguments
* for this context when an application is launched.
* The arguments used for the application. The arguments from
* {@link ApplicationDescriptor#launch(Map)} are used as the arguments for this
* context when an application is launched.
*
* @return a map of application arguments.
*/
public Map getArguments();

/**
* This method should be called once the application is completely initialized and running.
* This method will perform certain operations that are needed once an application is running.
* One example is bringing down a splash screen if it exists.
* This method should be called once the application is completely initialized
* and running. This method will perform certain operations that are needed once
* an application is running. One example is bringing down a splash screen if it
* exists.
*/
public void applicationRunning();

/**
* Returns the application associated with this application context. This information
* is used to guide the runtime as to what application extension to create and execute.
* Returns the application associated with this application context. This
* information is used to guide the runtime as to what application extension to
* create and execute.
*
* @return this product's application or <code>null</code> if none
*/
public String getBrandingApplication();

/**
* Returns the name of the product associated with this application context.
* The name is typically used in the title bar of UI windows.
* Returns the name of the product associated with this application context. The
* name is typically used in the title bar of UI windows.
*
* @return the name of the product or <code>null</code> if none
*/
public String getBrandingName();

/**
* Returns the text description of the product associated with this application context.
* Returns the text description of the product associated with this application
* context.
*
* @return the description of the product or <code>null</code> if none
*/
public String getBrandingDescription();

/** Returns the unique product id of the product associated with this application context.
/**
* Returns the unique product id of the product associated with this application
* context.
*
* @return the id of the product
*/
public String getBrandingId();

/**
* Returns the property with the given key of the product associated with this application context.
* <code>null</code> is returned if there is no such key/value pair.
* Returns the property with the given key of the product associated with this
* application context. <code>null</code> is returned if there is no such
* key/value pair.
*
* @param key the name of the property to return
* @return the value associated with the given key or <code>null</code> if none
*/
public String getBrandingProperty(String key);

/**
* Returns the bundle which is responsible for the definition of the product associated with
* this application context.
* Typically this is used as a base for searching for images and other files
* that are needed in presenting the product.
* Returns the bundle which is responsible for the definition of the product
* associated with this application context. Typically this is used as a base
* for searching for images and other files that are needed in presenting the
* product.
*
* @return the bundle which defines the product or <code>null</code> if none
*/
public Bundle getBrandingBundle();

/**
* Sets the result of the application asynchronously. This method can only be used
* after the application's {@link IApplication#start(IApplicationContext) start}
* method has returned the value of {@link IApplicationContext#EXIT_ASYNC_RESULT}.
* Sets the result of the application asynchronously. This method can only be
* used after the application's {@link IApplication#start(IApplicationContext)
* start} method has returned the value of
* {@link IApplicationContext#EXIT_ASYNC_RESULT}.
* <p>
* The specified application must be the same application instance which is
* associated with this application context. In other word the application instance
* for which {@link IApplication#start(IApplicationContext)} was called with this
* application context; otherwise an <code>IllegalArgumentException</code> is
* thrown.
* The specified application must be the same application instance which is
* associated with this application context. In other word the application
* instance for which {@link IApplication#start(IApplicationContext)} was called
* with this application context; otherwise an
* <code>IllegalArgumentException</code> is thrown.
* </p>
*
* @param result the result value for the application. May be null.
* @param application the application instance associated with this application context
* @throws IllegalStateException if {@link IApplicationContext#EXIT_ASYNC_RESULT} was
* not returned by the application's {@link IApplication#start(IApplicationContext) start}
* method or if the result has already been set for this application context.
* @throws IllegalArgumentException if the specified application is not the same
* application instance associated with this application context.
*
* @param result the result value for the application. May be null.
* @param application the application instance associated with this application
* context
* @throws IllegalStateException if
* {@link IApplicationContext#EXIT_ASYNC_RESULT}
* was not returned by the application's
* {@link IApplication#start(IApplicationContext)
* start} method or if the result has already
* been set for this application context.
* @throws IllegalArgumentException if the specified application is not the same
* application instance associated with this
* application context.
*
*
* @since 1.3
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
public static final String PI_APP = "org.eclipse.equinox.app"; //$NON-NLS-1$
public static boolean DEBUG = false;
private volatile static BundleContext _context;
// PackageAdmin is a system service that never goes away as long
// as the framework is active. No need to track it!!
// PackageAdmin is a system service that never goes away as long
// as the framework is active. No need to track it!!
private volatile static PackageAdmin _packageAdmin;
private volatile static EclipseAppContainer container;
// tracks the FrameworkLog service
Expand All @@ -45,7 +45,8 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
@Override
public void start(BundleContext bc) {
_context = bc;
// doing simple get service here because we expect the PackageAdmin service to always be available
// doing simple get service here because we expect the PackageAdmin service to
// always be available
ServiceReference ref = bc.getServiceReference(PackageAdmin.class.getName());
if (ref != null)
_packageAdmin = (PackageAdmin) bc.getService(ref);
Expand Down Expand Up @@ -120,7 +121,8 @@ private void processCommandLineArgs(BundleContext bc) {
public Object addingService(ServiceReference reference) {
BundleContext context = _context;
if (context == null)
return null; // really should never happen since we close the tracker before nulling out context
return null; // really should never happen since we close the tracker before nulling out
// context
Object service = null;
EclipseAppContainer startContainer = null;
synchronized (this) {
Expand All @@ -135,7 +137,8 @@ public Object addingService(ServiceReference reference) {
startContainer = container;
}
}
// must not start the container while holding a lock because this will register additional services
// must not start the container while holding a lock because this will register
// additional services
if (startContainer != null) {
startContainer.start();
return service;
Expand Down Expand Up @@ -168,7 +171,8 @@ public void removedService(ServiceReference reference, Object service) {
currentContainer.stop();
}

// helper used to protect callers from permission checks when opening service trackers
// helper used to protect callers from permission checks when opening service
// trackers
static void openTracker(final ServiceTracker tracker, final boolean allServices) {
if (System.getSecurityManager() == null)
tracker.open(allServices);
Expand Down Expand Up @@ -224,7 +228,7 @@ static Bundle getBundle(IContributor contributor) {
Bundle[] bundles = packageAdmin.getBundles(contributor.getName(), null);
if (bundles == null)
return null;
//Return the first bundle that is not installed or uninstalled
// Return the first bundle that is not installed or uninstalled
for (Bundle bundle : bundles) {
if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
return bundle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public void run() {
// pasing null will cause EclipseAppHandle to get the correct arguments
appHandle.run(null);
} catch (Throwable e) {
Activator.log(new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.ERROR, 0, e.getMessage(), 0, e, null));
Activator.log(
new FrameworkLogEntry(Activator.PI_APP, FrameworkLogEntry.ERROR, 0, e.getMessage(), 0, e, null));
}
}

Expand Down
Loading

0 comments on commit 4855a47

Please sign in to comment.