Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 31de15c216ea8df9bb86f8344a4586f00337d02d (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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/**
 * 
 */
package org.eclipse.papyrus.infra.core.services;

import java.util.Collections;
import java.util.List;

/**
 * Descriptor of a service. This descriptor describe a service.
 * 
 * @author cedirc dumoulin
 * 
 */
public class ServiceDescriptor {

	/**
	 * Possible kind for service types.
	 * 
	 */
	public enum ServiceTypeKind {
		service, serviceFactory, pojo
	};

	/** Classname of the service. USed to start the service */
	private String serviceClassname;

	/** Kind of start for this service */
	private ServiceStartKind serviceStartKind;

	/** Kind of service */
	private ServiceTypeKind serviceTypeKind = ServiceTypeKind.service;

	/**
	 * Service priority. If two service are registered under the same key, only
	 * the one with the higher priority is started.
	 */
	private int priority;

	/**
	 * Key used to register the service.
	 */
	private String key;

	/**
	 * Id of the bundle owning the .class that is referenced by
	 * serviceClassname. Requested when instanciating the class.
	 */
	private String classBundleID;

	/**
	 * If set to true, the service is anonymous : it is not registered and can't
	 * be retrieved with getService().
	 */
	private boolean isAnonymous = false;

	/**
	 * List of keys of Services required by this service.
	 */
	private List<String> requiredServices = Collections.emptyList();

	/**
	 * Empty list.
	 */
	private static List<String> EMPTY_LIST_STRING = Collections.emptyList();

	/**
	 * Constructor.
	 * 
	 * @param key
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 * @param requiredServices
	 */
	public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, List<String> requiredServices) {
		this.key = key;
		this.serviceClassname = serviceClassname;
		this.serviceStartKind = serviceStartKind;
		this.priority = priority;
		this.requiredServices = requiredServices;
	}

	/**
	 * Constructor.
	 * 
	 * @param key
	 *        A class used as key. The classname is used as key.
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 * @param requiredServices
	 */
	public ServiceDescriptor(Class<?> key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, List<String> requiredServices) {
		this(key.getName(), serviceClassname, serviceStartKind, priority, requiredServices);
	}

	/**
	 * Constructor.
	 * 
	 * @param key
	 *        A class used as key. The classname is used as key.
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 * @param isAnonymous
	 * @param requiredServices
	 */
	public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous, List<String> requiredServices) {
		this.key = key;
		this.serviceClassname = serviceClassname;
		this.serviceStartKind = serviceStartKind;
		this.priority = priority;
		this.isAnonymous = isAnonymous;
		this.requiredServices = requiredServices;
	}

	/**
	 * Constructor.
	 * 
	 * @param key
	 *        A class used as key. The classname is used as key.
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 * @param isAnonymous
	 * @param requiredServices
	 */
	public ServiceDescriptor(Class<?> key, String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous, List<String> requiredServices) {
		this(key.getName(), serviceClassname, serviceStartKind, priority, isAnonymous, requiredServices);
	}

	/**
	 * Constructor.
	 * 
	 * @param key
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 */
	public ServiceDescriptor(String key, String serviceClassname, ServiceStartKind serviceStartKind, int priority) {
		this(key, serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING);
	}

	/**
	 * Constructor.
	 * 
	 * @param key
	 *        A class used as key. The classname is used as key.
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 */
	public ServiceDescriptor(Class<?> key, String serviceClassname, ServiceStartKind serviceStartKind, int priority) {
		this(key.getName(), serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING);
	}

	/**
	 * Constructor.
	 * 
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 * @param requiredServices
	 */
	public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority, List<String> requiredServices) {
		this(serviceClassname, serviceClassname, serviceStartKind, priority, requiredServices);
	}

	/**
	 * Constructor.
	 * 
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 */
	public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority, boolean isAnonymous) {
		this(serviceClassname, serviceClassname, serviceStartKind, priority, isAnonymous, EMPTY_LIST_STRING);
	}

	/**
	 * Constructor.
	 * 
	 * @param serviceClassname
	 * @param serviceStartKind
	 * @param priority
	 */
	public ServiceDescriptor(String serviceClassname, ServiceStartKind serviceStartKind, int priority) {
		this(serviceClassname, serviceClassname, serviceStartKind, priority, EMPTY_LIST_STRING);
	}

	/**
	 * @return the serviceStartKind
	 */
	public ServiceStartKind getServiceStartKind() {
		return serviceStartKind;
	}

	/**
	 * Return true if StartKind is 'always'.
	 * 
	 * @return
	 */
	public boolean isStartAtStartup() {
		return serviceStartKind == ServiceStartKind.STARTUP;
	}

	/**
	 * @return the priority
	 */
	public int getPriority() {
		return priority;
	}

	/**
	 * @return the key
	 */
	public String getKey() {
		return key;
	}

	/**
	 * @return the serviceClassname
	 */
	public String getServiceClassname() {
		return serviceClassname;
	}

	/**
	 * @return the classBundleID
	 */
	public String getClassBundleID() {
		return classBundleID;
	}

	/**
	 * @param classBundleId
	 *        the classBundleID to set
	 */
	public void setClassBundleID(String classBundleId) {
		classBundleID = classBundleId;
	}

	/**
	 * Get the keys of all the required services
	 * 
	 * @return the requiredServices
	 */
	public List<String> getRequiredServiceKeys() {
		return requiredServices;
	}

	/**
	 * @param requiredServices
	 *        the requiredServices to set
	 */
	public void setRequiredServiceKeys(List<String> requiredServices) {
		this.requiredServices = requiredServices;
	}

	/**
	 * @see java.lang.Object#toString()
	 * @return
	 * 
	 */
	@Override
	public String toString() {
		return "ServiceDescriptor [key=" + key + ", serviceClassname=" + serviceClassname + ", serviceStartKind=" + serviceStartKind + ", priority=" + priority + "]";
	}

	/**
	 * @return the isAnonymous
	 */
	public boolean isAnonymous() {
		return isAnonymous;
	}

	/**
	 * @param isAnonymous
	 *        the isAnonymous to set
	 */
	public void setAnonymous(boolean isAnonymous) {
		this.isAnonymous = isAnonymous;
	}

	/**
	 * @return the serviceTypeKind
	 */
	public ServiceTypeKind getServiceTypeKind() {
		return serviceTypeKind;
	}

	/**
	 * @param serviceTypeKind
	 *        the serviceTypeKind to set
	 */
	public void setServiceTypeKind(ServiceTypeKind serviceTypeKind) {
		this.serviceTypeKind = serviceTypeKind;
	}

}

Back to the top