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`

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
  • Loading branch information
Torbjorn-Svensson committed Oct 1, 2023
1 parent 7373ef3 commit b8f4bb3
Show file tree
Hide file tree
Showing 20 changed files with 944 additions and 808 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@
* This exception is used to indicate problems related to application lifecycle
* management.
*
* {@code ApplicationException} object is created by the Application Admin
* to denote an exception condition in the lifecycle of an application.
* {@code ApplicationException} object is created by the Application Admin to
* denote an exception condition in the lifecycle of an application.
* {@code ApplicationException}s should not be created by developers. <br/>
* {@code ApplicationException}s are associated with an error code. This
* code describes the type of problem reported in this exception. The possible
* codes are:
* {@code ApplicationException}s are associated with an error code. This code
* describes the type of problem reported in this exception. The possible codes
* are:
* <ul>
* <li> {@link #APPLICATION_LOCKED} - The application couldn't be launched
* <li>{@link #APPLICATION_LOCKED} - The application couldn't be launched
* because it is locked.</li>
* <li> {@link #APPLICATION_NOT_LAUNCHABLE} - The application is not in
* <li>{@link #APPLICATION_NOT_LAUNCHABLE} - The application is not in
* launchable state.</li>
* <li> {@link #APPLICATION_INTERNAL_ERROR} - An exception was thrown by the
* <li>{@link #APPLICATION_INTERNAL_ERROR} - An exception was thrown by the
* application or its container during launch.</li>
* <li> {@link #APPLICATION_SCHEDULING_FAILED} - The scheduling of an application
* <li>{@link #APPLICATION_SCHEDULING_FAILED} - The scheduling of an application
* failed.
* <li> {@link #APPLICATION_DUPLICATE_SCHEDULE_ID} - The application scheduling
* <li>{@link #APPLICATION_DUPLICATE_SCHEDULE_ID} - The application scheduling
* failed because the specified identifier is already in use.
* <li> {@link #APPLICATION_EXITVALUE_NOT_AVAILABLE} - The exit value is not
* <li>{@link #APPLICATION_EXITVALUE_NOT_AVAILABLE} - The exit value is not
* available for an application instance because the instance has not
* terminated.
* <li> {@link #APPLICATION_INVALID_STARTUP_ARGUMENT} - One of the specified
* <li>{@link #APPLICATION_INVALID_STARTUP_ARGUMENT} - One of the specified
* startup arguments is invalid, for example its type is not permitted.
* </ul>
*
Expand All @@ -49,16 +49,15 @@
public class ApplicationException extends Exception {
private static final long serialVersionUID = -7173190453622508207L;
private final int errorCode;

/**
* The application couldn't be launched because it is locked.
*/
public static final int APPLICATION_LOCKED = 0x01;
public static final int APPLICATION_LOCKED = 0x01;

/**
* The application is not in launchable state, it's
* {@link ApplicationDescriptor#APPLICATION_LAUNCHABLE}
* attribute is false.
* The application is not in launchable state, it's
* {@link ApplicationDescriptor#APPLICATION_LAUNCHABLE} attribute is false.
*/
public static final int APPLICATION_NOT_LAUNCHABLE = 0x02;

Expand All @@ -67,17 +66,17 @@ public class ApplicationException extends Exception {
* during launch. The exception is available from {@code getCause()}.
*/
public static final int APPLICATION_INTERNAL_ERROR = 0x03;

/**
* The application schedule could not be created due to some internal error
* (for example, the schedule information couldn't be saved due to some
* storage error).
* The application schedule could not be created due to some internal error (for
* example, the schedule information couldn't be saved due to some storage
* error).
*/
public static final int APPLICATION_SCHEDULING_FAILED = 0x04;

/**
* The application scheduling failed because the specified identifier
* is already in use.
* The application scheduling failed because the specified identifier is already
* in use.
*/
public static final int APPLICATION_DUPLICATE_SCHEDULE_ID = 0x05;

Expand All @@ -90,27 +89,28 @@ public class ApplicationException extends Exception {
public static final int APPLICATION_EXITVALUE_NOT_AVAILABLE = 0x06;

/**
* One of the specified startup arguments is invalid, for example its
* type is not permitted.
* One of the specified startup arguments is invalid, for example its type is
* not permitted.
*
* @since 1.1
*/
public static final int APPLICATION_INVALID_STARTUP_ARGUMENT = 0x07;

/**
* Creates an {@code ApplicationException} with the specified error code.
* @param errorCode The code of the error
*
* @param errorCode The code of the error
*/
public ApplicationException(int errorCode) {
super();
this.errorCode = errorCode;
}

/**
* Creates a {@code ApplicationException} that wraps another exception.
*
* @param errorCode The code of the error
* @param cause The cause of this exception.
* @param errorCode The code of the error
* @param cause The cause of this exception.
*/
public ApplicationException(int errorCode, Throwable cause) {
super(cause);
Expand All @@ -119,8 +119,9 @@ public ApplicationException(int errorCode, Throwable cause) {

/**
* Creates an {@code ApplicationException} with the specified error code.
* @param errorCode The code of the error
* @param message The associated message
*
* @param errorCode The code of the error
* @param message The associated message
*/
public ApplicationException(int errorCode, String message) {
super(message);
Expand All @@ -130,21 +131,19 @@ public ApplicationException(int errorCode, String message) {
/**
* Creates a {@code ApplicationException} that wraps another exception.
*
* @param errorCode The code of the error
* @param message The associated message.
* @param cause The cause of this exception.
* @param errorCode The code of the error
* @param message The associated message.
* @param cause The cause of this exception.
*/
public ApplicationException(int errorCode, String message, Throwable cause) {
super(message, cause);
this.errorCode = errorCode;
}

/**
* Returns the cause of this exception or {@code null} if no cause was
* set.
* Returns the cause of this exception or {@code null} if no cause was set.
*
* @return The cause of this exception or {@code null} if no cause was
* set.
* @return The cause of this exception or {@code null} if no cause was set.
*/
@Override
public Throwable getCause() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
*/
public abstract class ApplicationHandle {
/*
* NOTE: An implementor may also choose to replace this class in
* their distribution with a class that directly interfaces with the
* org.osgi.service.application implementation. This replacement class MUST NOT alter the
* public/protected signature of this class.
* NOTE: An implementor may also choose to replace this class in their
* distribution with a class that directly interfaces with the
* org.osgi.service.application implementation. This replacement class MUST NOT
* alter the public/protected signature of this class.
*/

/**
* The property key for the unique identifier (PID) of the application
* instance.
* The property key for the unique identifier (PID) of the application instance.
*/
public static final String APPLICATION_PID = Constants.SERVICE_PID;

Expand Down Expand Up @@ -66,8 +65,7 @@ public abstract class ApplicationHandle {

/**
* The application instance is being stopped. This is the state of the
* application instance during the execution of the {@code destroy()}
* method.
* application instance during the execution of the {@code destroy()} method.
*/
public final static String STOPPING = "STOPPING";

Expand All @@ -77,25 +75,24 @@ public abstract class ApplicationHandle {

/**
* Application instance identifier is specified by the container when the
* instance is created. The instance identifier must remain static for the
* instance is created. The instance identifier must remain static for the
* lifetime of the instance, it must remain the same even across framework
* restarts for the same application instance. This value must be the same
* as the {@code service.pid} service property of this application
* handle.
* restarts for the same application instance. This value must be the same as
* the {@code service.pid} service property of this application handle.
* <p>
* The instance identifier should follow the following scheme:
* &lt;<i>application descriptor PID</i>&gt;.&lt;<i>index</i>&gt;
* where &lt;<i>application descriptor PID</i>&gt; is the PID of the
* corresponding {@code ApplicationDescriptor} and &lt;<i>index</i>&gt;
* is a unique integer index assigned by the application container.
* Even after destroying the application index the same index value should not
* be reused in a reasonably long timeframe.
* The instance identifier should follow the following scheme:
* &lt;<i>application descriptor PID</i>&gt;.&lt;<i>index</i>&gt; where
* &lt;<i>application descriptor PID</i>&gt; is the PID of the corresponding
* {@code ApplicationDescriptor} and &lt;<i>index</i>&gt; is a unique integer
* index assigned by the application container. Even after destroying the
* application index the same index value should not be reused in a reasonably
* long timeframe.
*
* @param instanceId the instance identifier of the represented application
* instance. It must not be null.
* instance. It must not be null.
*
* @param descriptor the {@code ApplicationDescriptor} of the represented
* application instance. It must not be null.
* application instance. It must not be null.
*
* @throws NullPointerException if any of the arguments is null.
*/
Expand All @@ -109,8 +106,8 @@ protected ApplicationHandle(String instanceId, ApplicationDescriptor descriptor)
}

/**
* Retrieves the {@code ApplicationDescriptor} to which this
* {@code ApplicationHandle} belongs.
* Retrieves the {@code ApplicationDescriptor} to which this
* {@code ApplicationHandle} belongs.
*
* @return The corresponding {@code ApplicationDescriptor}
*/
Expand All @@ -123,43 +120,41 @@ public final ApplicationDescriptor getApplicationDescriptor() {
*
* @return the state of the application.
*
* @throws IllegalStateException
* if the application handle is unregistered
* @throws IllegalStateException if the application handle is unregistered
*/
public abstract String getState();

/**
* Returns the exit value for the application instance. The timeout
* specifies how the method behaves when the application has not yet
* terminated. A negative, zero or positive value may be used.
* Returns the exit value for the application instance. The timeout specifies
* how the method behaves when the application has not yet terminated. A
* negative, zero or positive value may be used.
* <ul>
* <li> negative - The method does not wait for termination. If the
* application has not terminated then an {@code ApplicationException}
* is thrown.</li>
* <li>negative - The method does not wait for termination. If the application
* has not terminated then an {@code ApplicationException} is thrown.</li>
*
* <li> zero - The method waits until the application terminates.</li>
* <li>zero - The method waits until the application terminates.</li>
*
* <li> positive - The method waits until the application terminates or the
* <li>positive - The method waits until the application terminates or the
* timeout expires. If the timeout expires and the application has not
* terminated then an {@code ApplicationException} is thrown.</li>
* </ul>
* <p>
* The default implementation throws an
* {@code UnsupportedOperationException}. The application model should
* override this method if exit values are supported.
* The default implementation throws an {@code UnsupportedOperationException}.
* The application model should override this method if exit values are
* supported.
* </p>
*
* @param timeout The maximum time in milliseconds to wait for the
* application to timeout.
* @return The exit value for the application instance. The value is
* application specific.
* @param timeout The maximum time in milliseconds to wait for the application
* to timeout.
* @return The exit value for the application instance. The value is application
* specific.
* @throws UnsupportedOperationException If the application model does not
* support exit values.
* @throws InterruptedException If the thread is interrupted while waiting
* for the timeout.
* @throws ApplicationException If the application has not terminated. The
* error code will be
* {@link ApplicationException#APPLICATION_EXITVALUE_NOT_AVAILABLE}.
* support exit values.
* @throws InterruptedException If the thread is interrupted while
* waiting for the timeout.
* @throws ApplicationException If the application has not terminated.
* The error code will be
* {@link ApplicationException#APPLICATION_EXITVALUE_NOT_AVAILABLE}.
*
* @since 1.1
*/
Expand All @@ -168,8 +163,8 @@ public Object getExitValue(long timeout) throws ApplicationException, Interrupte
}

/**
* Returns the unique identifier of this instance. This value is also
* available as a service property of this application handle's service.pid.
* Returns the unique identifier of this instance. This value is also available
* as a service property of this application handle's service.pid.
*
* @return the unique identifier of the instance
*/
Expand All @@ -178,49 +173,46 @@ public final String getInstanceId() {
}

/**
* The application instance's lifecycle state can be influenced by this
* method. It lets the application instance perform operations to stop
* the application safely, e.g. saving its state to a permanent storage.
* The application instance's lifecycle state can be influenced by this method.
* It lets the application instance perform operations to stop the application
* safely, e.g. saving its state to a permanent storage.
* <p>
* The method must check if the lifecycle transition is valid; a STOPPING
* application cannot be stopped. If it is invalid then the method must
* exit. Otherwise the lifecycle state of the application instance must be
* set to STOPPING. Then the destroySpecific() method must be called to
* perform any application model specific steps for safe stopping of the
* represented application instance.
* application cannot be stopped. If it is invalid then the method must exit.
* Otherwise the lifecycle state of the application instance must be set to
* STOPPING. Then the destroySpecific() method must be called to perform any
* application model specific steps for safe stopping of the represented
* application instance.
* <p>
* At the end the {@code ApplicationHandle} must be unregistered.
* This method should free all the resources related to this
* {@code ApplicationHandle}.
* At the end the {@code ApplicationHandle} must be unregistered. This method
* should free all the resources related to this {@code ApplicationHandle}.
* <p>
* When this method is completed the application instance has already made
* its operations for safe stopping, the ApplicationHandle has been
* unregistered and its related resources has been freed. Further calls on
* this application should not be made because they may have unexpected
* results.
* When this method is completed the application instance has already made its
* operations for safe stopping, the ApplicationHandle has been unregistered and
* its related resources has been freed. Further calls on this application
* should not be made because they may have unexpected results.
*
* @throws SecurityException
* if the caller doesn't have "lifecycle"
* {@code ApplicationAdminPermission} for the corresponding application.
* @throws SecurityException if the caller doesn't have "lifecycle"
* {@code ApplicationAdminPermission} for the
* corresponding application.
*
* @throws IllegalStateException
* if the application handle is unregistered
* @throws IllegalStateException if the application handle is unregistered
*/
public final void destroy() {
if (STOPPING.equals(getState()))
return;
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkPermission(new ApplicationAdminPermission(getApplicationDescriptor(), ApplicationAdminPermission.LIFECYCLE_ACTION));
sm.checkPermission(new ApplicationAdminPermission(getApplicationDescriptor(),
ApplicationAdminPermission.LIFECYCLE_ACTION));
destroySpecific();
}

/**
* Called by the destroy() method to perform application model specific
* steps to stop and destroy an application instance safely.
* Called by the destroy() method to perform application model specific steps to
* stop and destroy an application instance safely.
*
* @throws IllegalStateException
* if the application handle is unregistered
* @throws IllegalStateException if the application handle is unregistered
*/
protected abstract void destroySpecific();

Expand Down
Loading

0 comments on commit b8f4bb3

Please sign in to comment.