Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f9164e664db31bf16b2946d064b02963bf154781 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*******************************************************************************
 * Copyright (c) 2005, 2010 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.equinox.app;

import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.service.application.ApplicationDescriptor;

/**
 * The context used to start an application.
 * <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>.
	 * <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:
	 * <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>
	 * </ul>
	 * </p>
	 * @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.
	 * <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.
	 */
	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
	 * {@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.
	 * 
	 * @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.
	 */
	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.
	 * 
	 * @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.
	 * 
	 * @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.
	 * 
	 * @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.
	 * 
	 * @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.
	 * 
	 * @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.
	 * 
	 * @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}.
	 * <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.
	 * </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.
	 *   
	 * 
	 * @since 1.3
	 */
	public void setResult(Object result, IApplication application);

}

Back to the top