Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 22198fda8102e088e57bd4b7e7e205f9e41fdf95 (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
/**
 * 
 */
package org.eclipse.papyrus.infra.core.services;

import java.util.ArrayList;
import java.util.List;

/**
 * Base class to create a Service composed of other services called Parts.
 * ServiceParts register themselves to the ComposedService. The ComposedService
 * maintain a list of its part.
 * 
 * @author cedric dumoulin
 * 
 * @param T
 *        The type of sub-services that can register to this
 *        ComposedService.
 */
public abstract class ComposedService<T> implements IService {

	/**
	 * The list of serviceParts composing this Service.
	 */
	protected List<T> serviceParts = new ArrayList<T>();

	/**
	 * Constructor. Constructor.
	 * 
	 */
	public ComposedService() {

	}

	/**
	 * Add the provided servicePart.
	 * 
	 * @param servicePart
	 */
	public void addServicePart(T servicePart) {
		serviceParts.add(servicePart);
	}

	/**
	 * Remove the provided servicePart.
	 * 
	 * @param servicePart
	 */
	public void removeServicePart(T servicePart) {
		serviceParts.remove(servicePart);
	}

	/**
	 * Do nothing here.
	 * 
	 * @see org.eclipse.papyrus.infra.core.services.IService#init(org.eclipse.papyrus.infra.core.services.ServicesRegistry)
	 * 
	 * @param servicesRegistry
	 * @throws ServiceException
	 */
	public void init(ServicesRegistry servicesRegistry) throws ServiceException {
	}

	/**
	 * Do nothing here.
	 * 
	 * @see org.eclipse.papyrus.infra.core.services.IService#startService()
	 * 
	 * @throws ServiceException
	 */
	public void startService() throws ServiceException {
	}

	/**
	 * Do nothing here.
	 * 
	 * @see org.eclipse.papyrus.infra.core.services.IService#disposeService()
	 * 
	 * @throws ServiceException
	 */
	public void disposeService() throws ServiceException {
	}

	/**
	 * Get a list of registered sub service parts.
	 * 
	 * @return List of registered services.
	 */
	public List<T> getRegisteredServices() {
		return serviceParts;
	}

}

Back to the top