Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java
new file mode 100644
index 00000000000..22198fda810
--- /dev/null
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/ComposedService.java
@@ -0,0 +1,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