Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-04-22 16:33:40 +0000
committerChristian W. Damus2014-04-22 16:33:40 +0000
commitebde630de0593d0278d5ab36bfc024b3d9dc0737 (patch)
treef2db080acfd99c5ea71331b80726672a4da0702f /plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services
parent1021d79f1ef9e27245464e445d795b8d336b57d4 (diff)
parentcd03d0c5e3808d3831f70679ff3c17a67c4b2873 (diff)
downloadorg.eclipse.papyrus-ebde630de0593d0278d5ab36bfc024b3d9dc0737.tar.gz
org.eclipse.papyrus-ebde630de0593d0278d5ab36bfc024b3d9dc0737.tar.xz
org.eclipse.papyrus-ebde630de0593d0278d5ab36bfc024b3d9dc0737.zip
Merge branch 'refs/heads/master' into bugs/431953-stereo-repair2
Conflicts: plugins/uml/org.eclipse.papyrus.uml.modelrepair/src/org/eclipse/papyrus/uml/modelrepair/internal/participants/StereotypeApplicationRepairParticipant.java
Diffstat (limited to 'plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services')
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java206
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java200
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java246
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java330
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java360
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java264
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java412
-rw-r--r--plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java176
8 files changed, 1137 insertions, 1057 deletions
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java
index 6f94954eda0..672ce0d9d23 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ErrorServiceTypeEntry.java
@@ -1,98 +1,108 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import org.eclipse.papyrus.infra.core.services.BadStateException;
-import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceState;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * A service entry used for faulty services. In this implementation, methods do
- * nothings or throw an error.
- *
- *
- * @author cedric dumoulin
- *
- */
-public class ErrorServiceTypeEntry extends ServiceTypeEntry {
-
- /**
- * The original service descriptor.
- */
- private ServiceDescriptor descriptor;
-
- /**
- *
- * Constructor.
- *
- * @param descriptor
- */
- public ErrorServiceTypeEntry(ServiceDescriptor descriptor) {
- super(descriptor);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#getServiceInstance()
- *
- * @return
- * @throws ServiceException
- */
- @Override
- public Object getServiceInstance() throws ServiceException {
- throw new BadStateException("Service has not started.", ServiceState.error, descriptor);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#createService()
- *
- * @throws ServiceException
- */
- @Override
- public void createService() throws ServiceException {
- // do nothing
-
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#initService(ServicesRegistry)
- *
- * @param servicesRegistry
- * @throws ServiceException
- */
- @Override
- public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
- // do nothing
-
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#startService()
- *
- * @throws ServiceException
- */
- @Override
- public void startService() throws ServiceException {
- // do nothing
-
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#disposeService()
- *
- * @throws ServiceException
- */
- @Override
- public void disposeService() throws ServiceException {
- // do nothing
-
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceState;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * A service entry used for faulty services. In this implementation, methods do
+ * nothings or throw an error.
+ *
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class ErrorServiceTypeEntry extends ServiceTypeEntry {
+
+ /**
+ * The original service descriptor.
+ */
+ private ServiceDescriptor descriptor;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param descriptor
+ */
+ public ErrorServiceTypeEntry(ServiceDescriptor descriptor) {
+ super(descriptor);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#getServiceInstance()
+ *
+ * @return
+ * @throws ServiceException
+ */
+ @Override
+ public Object getServiceInstance() throws ServiceException {
+ throw new BadStateException("Service has not started.", ServiceState.error, descriptor); //$NON-NLS-1$
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#createService()
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void createService() throws ServiceException {
+ // do nothing
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#initService(ServicesRegistry)
+ *
+ * @param servicesRegistry
+ * @throws ServiceException
+ */
+ @Override
+ public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
+ // do nothing
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#startService()
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void startService() throws ServiceException {
+ // do nothing
+
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.services.internal.ServiceTypeEntry#disposeService()
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void disposeService() throws ServiceException {
+ // do nothing
+
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java
index e9ed32687e2..1263fa397c1 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/LazyStartupEntry.java
@@ -1,95 +1,105 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceState;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * An ServiceEntry managing {@link IService} registered as lazy start.
- *
- * @author cedric dumoulin
- *
- */
-public class LazyStartupEntry extends ServiceStartupEntry {
-
- protected ServicesRegistry registry;
-
- /**
- * Constructor.
- *
- * @param serviceDescriptor
- * @param registry
- */
- public LazyStartupEntry(ServiceTypeEntry serviceEntry, ServicesRegistry registry) {
-
- super(serviceEntry);
- this.registry = registry;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.services.internal.ServiceStartupEntry#getServiceInstance()
- *
- * @return
- * @throws ServiceException
- */
- @Override
- public Object getServiceInstance() throws ServiceException {
- if(serviceEntry.getState() == ServiceState.registered) {
- // Start the service
- try {
- serviceEntry.createService();
- serviceEntry.initService(registry);
- serviceEntry.startService();
- } catch (Exception e) {
- // There was an error. The service is in error
- serviceEntry = new ErrorServiceTypeEntry(serviceEntry.getDescriptor());
- }
- }
-
- // Return the instance
- return serviceEntry.getServiceInstance();
- }
-
- /**
- * Do nothing
- *
- * @throws ServiceException
- */
- @Override
- public void createService() throws ServiceException {
- }
-
- /**
- * Do nothing
- *
- * @param servicesRegistry
- * @throws ServiceException
- */
- @Override
- public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
- }
-
- /**
- * Do nothing.
- *
- * @throws ServiceException
- */
- @Override
- public void startService() throws ServiceException {
- }
-
- /**
- * @see org.eclipse.papyrus.infra.core.services.AbstractServiceEntry#disposeService()
- *
- * @throws ServiceException
- */
- @Override
- public void disposeService() throws ServiceException {
- serviceEntry.disposeService();
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceState;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * An ServiceEntry managing {@link IService} registered as lazy start.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class LazyStartupEntry extends ServiceStartupEntry {
+
+ protected ServicesRegistry registry;
+
+ /**
+ * Constructor.
+ *
+ * @param serviceDescriptor
+ * @param registry
+ */
+ public LazyStartupEntry(ServiceTypeEntry serviceEntry, ServicesRegistry registry) {
+
+ super(serviceEntry);
+ this.registry = registry;
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.services.internal.ServiceStartupEntry#getServiceInstance()
+ *
+ * @return
+ * @throws ServiceException
+ */
+ @Override
+ public Object getServiceInstance() throws ServiceException {
+ if(serviceEntry.getState() == ServiceState.registered) {
+ // Start the service
+ try {
+ serviceEntry.createService();
+ serviceEntry.initService(registry);
+ serviceEntry.startService();
+ } catch (Exception e) {
+ // There was an error. The service is in error
+ serviceEntry = new ErrorServiceTypeEntry(serviceEntry.getDescriptor());
+ }
+ }
+
+ // Return the instance
+ return serviceEntry.getServiceInstance();
+ }
+
+ /**
+ * Do nothing
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void createService() throws ServiceException {
+ }
+
+ /**
+ * Do nothing
+ *
+ * @param servicesRegistry
+ * @throws ServiceException
+ */
+ @Override
+ public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
+ }
+
+ /**
+ * Do nothing.
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void startService() throws ServiceException {
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.services.AbstractServiceEntry#disposeService()
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void disposeService() throws ServiceException {
+ serviceEntry.disposeService();
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java
index d0723ca4977..05fd4b1c752 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/PojoServiceEntry.java
@@ -1,118 +1,128 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import org.eclipse.papyrus.infra.core.services.BadStateException;
-import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceState;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * Entry for a service provided as POJO.
- *
- *
- * @author cedric dumoulin
- */
-public class PojoServiceEntry extends ServiceTypeEntry {
-
- /** Instance of the service, if started. */
- private Object serviceInstance;
-
- /**
- * Constructor.
- *
- * @param serviceDescriptor
- */
- public PojoServiceEntry(ServiceDescriptor serviceDescriptor) {
- super(serviceDescriptor);
- setState(ServiceState.registered);
- }
-
- /**
- * Create an entry for an already created service. Constructor.
- *
- * @param descriptor
- * Descriptor of the service. Key and priority should be set.
- * @param serviceInstance
- * The service Instance
- */
- public PojoServiceEntry(ServiceDescriptor descriptor, Object serviceInstance) {
- super(descriptor);
- this.serviceInstance = serviceInstance;
- setState(ServiceState.registered);
- }
-
- /**
- * Get the service instance.
- *
- * @return
- * @throws ServiceException
- * If service can't be started.
- */
- public Object getServiceInstance() throws ServiceException {
-
- if(serviceInstance == null)
- throw new BadStateException("Service is not created.", state, serviceDescriptor);
-
- return serviceInstance;
- }
-
- /**
- * Already created : do nothing.
- *
- * @throws ServiceException
- */
- public void createService() throws ServiceException {
- checkState(ServiceState.registered);
- // Exit if already created.
- if(serviceInstance != null) {
- setState(ServiceState.created);
- return;
- }
-
- // Create it
- try {
- // Create the instance
- serviceInstance = instanciateService();
- } catch (Exception e) {
- setState(ServiceState.error);
- throw new ServiceException(e);
- }
- setState(ServiceState.created);
- }
-
- /**
- * Pojo : can't initialize the service. Do nothing.
- *
- * @param servicesRegistry
- * The servicesRegistry containing this service.
- *
- * @throws ServiceException
- */
- public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
- setState(ServiceState.initialized);
- }
-
- /**
- * Already started : do nothing.
- *
- * @throws ServiceException
- */
- public void startService() throws ServiceException {
- setState(ServiceState.started);
- }
-
- /**
- * Do nothing.
- */
- public void disposeService() throws ServiceException {
- if(serviceInstance == null)
- return;
-
- serviceInstance = null;
- setState(ServiceState.disposed);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceState;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * Entry for a service provided as POJO.
+ *
+ *
+ * @author cedric dumoulin
+ */
+public class PojoServiceEntry extends ServiceTypeEntry {
+
+ /** Instance of the service, if started. */
+ private Object serviceInstance;
+
+ /**
+ * Constructor.
+ *
+ * @param serviceDescriptor
+ */
+ public PojoServiceEntry(ServiceDescriptor serviceDescriptor) {
+ super(serviceDescriptor);
+ setState(ServiceState.registered);
+ }
+
+ /**
+ * Create an entry for an already created service. Constructor.
+ *
+ * @param descriptor
+ * Descriptor of the service. Key and priority should be set.
+ * @param serviceInstance
+ * The service Instance
+ */
+ public PojoServiceEntry(ServiceDescriptor descriptor, Object serviceInstance) {
+ super(descriptor);
+ this.serviceInstance = serviceInstance;
+ setState(ServiceState.registered);
+ }
+
+ /**
+ * Get the service instance.
+ *
+ * @return
+ * @throws ServiceException
+ * If service can't be started.
+ */
+ public Object getServiceInstance() throws ServiceException {
+
+ if(serviceInstance == null)
+ throw new BadStateException("Service is not created.", state, serviceDescriptor); //$NON-NLS-1$
+
+ return serviceInstance;
+ }
+
+ /**
+ * Already created : do nothing.
+ *
+ * @throws ServiceException
+ */
+ public void createService() throws ServiceException {
+ checkState(ServiceState.registered);
+ // Exit if already created.
+ if(serviceInstance != null) {
+ setState(ServiceState.created);
+ return;
+ }
+
+ // Create it
+ try {
+ // Create the instance
+ serviceInstance = instanciateService();
+ } catch (Exception e) {
+ setState(ServiceState.error);
+ throw new ServiceException(e);
+ }
+ setState(ServiceState.created);
+ }
+
+ /**
+ * Pojo : can't initialize the service. Do nothing.
+ *
+ * @param servicesRegistry
+ * The servicesRegistry containing this service.
+ *
+ * @throws ServiceException
+ */
+ public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
+ setState(ServiceState.initialized);
+ }
+
+ /**
+ * Already started : do nothing.
+ *
+ * @throws ServiceException
+ */
+ public void startService() throws ServiceException {
+ setState(ServiceState.started);
+ }
+
+ /**
+ * Do nothing.
+ */
+ public void disposeService() throws ServiceException {
+ if(serviceInstance == null)
+ return;
+
+ serviceInstance = null;
+ setState(ServiceState.disposed);
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java
index 763915adf3b..a1ca9ddd0ba 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceEntry.java
@@ -1,160 +1,170 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import org.eclipse.papyrus.infra.core.services.BadStateException;
-import org.eclipse.papyrus.infra.core.services.IService;
-import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceState;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * Entry of a Service implementing {@link IService}. This class provide methods
- * to manage the Service life cycle.
- *
- * @author cedric dumoulin
- *
- */
-public class ServiceEntry extends ServiceTypeEntry {
-
- /** Instance of the service, if started. */
- private IService serviceInstance;
-
- /**
- * Constructor.
- *
- * @param serviceDescriptor
- * @param registry
- */
- public ServiceEntry(ServiceDescriptor serviceDescriptor) {
- super(serviceDescriptor);
- setState(ServiceState.registered);
-
- }
-
- /**
- * Create an entry for an already created service. Constructor.
- *
- * @param descriptor
- * Descriptor of the service. Key and priority should be set.
- * @param serviceInstance
- * The service Instance
- */
- public ServiceEntry(ServiceDescriptor descriptor, IService serviceInstance) {
- super(descriptor);
- this.serviceInstance = serviceInstance;
- setState(ServiceState.registered);
- }
-
- /**
- * Get the service instance, even if it is not started. The service should
- * be created.
- *
- * @return
- * @throws ServiceException
- * If service can't be started.
- */
- public Object getServiceInstance() throws ServiceException {
-
- if(serviceInstance == null)
- throw new BadStateException("Service is not created.", state, serviceDescriptor);
-
- return serviceInstance;
-
- }
-
- /**
- * @see java.lang.Object#toString()
- * @return
- *
- */
- @Override
- public String toString() {
- return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]";
- }
-
- /**
- * Create the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- public void createService() throws ServiceException {
- checkState(ServiceState.registered);
- // Exit if already created.
- if(serviceInstance != null) {
- setState(ServiceState.created);
- return;
- }
-
- // Create it
- try {
- // Create the instance
- serviceInstance = (IService)instanciateService();
- } catch (Exception e) {
- setState(ServiceState.error);
- throw new ServiceException(e);
- }
- setState(ServiceState.created);
- }
-
- /**
- * Start the associated service if not a Lazy Service.
- *
- * @param servicesRegistry
- * The servicesRegistry containing this service.
- *
- * @throws ServiceException
- */
- public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
- checkState(ServiceState.created);
- try {
- serviceInstance.init(servicesRegistry);
- } catch (ServiceException e) {
- setState(ServiceState.error);
- throw e;
- } catch (Exception e) {
- setState(ServiceState.error);
- throw new ServiceException(e);
- }
-
- setState(ServiceState.initialized);
- }
-
- /**
- * Start the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- public void startService() throws ServiceException {
-
- checkState(ServiceState.initialized);
- setState(ServiceState.starting);
-
- try {
- serviceInstance.startService();
- } catch (ServiceException e) {
- setState(ServiceState.error);
- throw e;
- } catch (Exception e) {
- setState(ServiceState.error);
- throw new ServiceException(e);
- }
-
- setState(ServiceState.started);
- }
-
- /**
- * Dispose the service.
- */
- public void disposeService() throws ServiceException {
- if(serviceInstance == null)
- return;
-
- serviceInstance.disposeService();
- serviceInstance = null;
- setState(ServiceState.disposed);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.IService;
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceState;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * Entry of a Service implementing {@link IService}. This class provide methods
+ * to manage the Service life cycle.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class ServiceEntry extends ServiceTypeEntry {
+
+ /** Instance of the service, if started. */
+ private IService serviceInstance;
+
+ /**
+ * Constructor.
+ *
+ * @param serviceDescriptor
+ * @param registry
+ */
+ public ServiceEntry(ServiceDescriptor serviceDescriptor) {
+ super(serviceDescriptor);
+ setState(ServiceState.registered);
+
+ }
+
+ /**
+ * Create an entry for an already created service. Constructor.
+ *
+ * @param descriptor
+ * Descriptor of the service. Key and priority should be set.
+ * @param serviceInstance
+ * The service Instance
+ */
+ public ServiceEntry(ServiceDescriptor descriptor, IService serviceInstance) {
+ super(descriptor);
+ this.serviceInstance = serviceInstance;
+ setState(ServiceState.registered);
+ }
+
+ /**
+ * Get the service instance, even if it is not started. The service should
+ * be created.
+ *
+ * @return
+ * @throws ServiceException
+ * If service can't be started.
+ */
+ public Object getServiceInstance() throws ServiceException {
+
+ if(serviceInstance == null)
+ throw new BadStateException("Service is not created.", state, serviceDescriptor); //$NON-NLS-1$
+
+ return serviceInstance;
+
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ * @return
+ *
+ */
+ @Override
+ public String toString() {
+ return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ * Create the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ public void createService() throws ServiceException {
+ checkState(ServiceState.registered);
+ // Exit if already created.
+ if(serviceInstance != null) {
+ setState(ServiceState.created);
+ return;
+ }
+
+ // Create it
+ try {
+ // Create the instance
+ serviceInstance = (IService)instanciateService();
+ } catch (Exception e) {
+ setState(ServiceState.error);
+ throw new ServiceException(e);
+ }
+ setState(ServiceState.created);
+ }
+
+ /**
+ * Start the associated service if not a Lazy Service.
+ *
+ * @param servicesRegistry
+ * The servicesRegistry containing this service.
+ *
+ * @throws ServiceException
+ */
+ public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
+ checkState(ServiceState.created);
+ try {
+ serviceInstance.init(servicesRegistry);
+ } catch (ServiceException e) {
+ setState(ServiceState.error);
+ throw e;
+ } catch (Exception e) {
+ setState(ServiceState.error);
+ throw new ServiceException(e);
+ }
+
+ setState(ServiceState.initialized);
+ }
+
+ /**
+ * Start the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ public void startService() throws ServiceException {
+
+ checkState(ServiceState.initialized);
+ setState(ServiceState.starting);
+
+ try {
+ serviceInstance.startService();
+ } catch (ServiceException e) {
+ setState(ServiceState.error);
+ throw e;
+ } catch (Exception e) {
+ setState(ServiceState.error);
+ throw new ServiceException(e);
+ }
+
+ setState(ServiceState.started);
+ }
+
+ /**
+ * Dispose the service.
+ */
+ public void disposeService() throws ServiceException {
+ if(serviceInstance == null)
+ return;
+
+ serviceInstance.disposeService();
+ serviceInstance = null;
+ setState(ServiceState.disposed);
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java
index c053b0f3668..f2f455e44ea 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceFactoryEntry.java
@@ -1,175 +1,185 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import org.eclipse.papyrus.infra.core.services.BadStateException;
-import org.eclipse.papyrus.infra.core.services.IServiceFactory;
-import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceState;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * Entry of a Service implementing {@link IServiceFactory}. This class provide
- * methods to manage the Service life cycle.
- *
- * @author cedric dumoulin
- *
- */
-public class ServiceFactoryEntry extends ServiceTypeEntry {
-
- /** Instance of the service, if started. */
- private Object serviceInstance;
-
- /** Instance of the factory, if created. */
- private IServiceFactory factoryInstance;
-
- /**
- * Constructor.
- *
- * @param serviceDescriptor
- * @param registry
- */
- public ServiceFactoryEntry(ServiceDescriptor serviceDescriptor) {
- super(serviceDescriptor);
- setState(ServiceState.registered);
-
- }
-
- /**
- * Create an entry for an already created service. Constructor.
- *
- * @param descriptor
- * Descriptor of the service. Key and priority should be set.
- * @param serviceInstance
- * The service Instance
- */
- public ServiceFactoryEntry(ServiceDescriptor descriptor, IServiceFactory factoryInstance) {
- super(descriptor);
- this.factoryInstance = factoryInstance;
- setState(ServiceState.registered);
- }
-
- /**
- * Get the service instance, even if it is not started. The service should
- * be created.
- *
- * @return
- * @throws ServiceException
- * If service can't be started.
- */
- public Object getServiceInstance() throws ServiceException {
-
- if(factoryInstance == null) {
- throw new BadStateException("Service is not available (state="
- + state.toString()
- + "). ", state, serviceDescriptor);
-
- }
- // Get the service instance if needed.
- if(serviceInstance == null) {
- serviceInstance = factoryInstance.createServiceInstance();
- if(serviceInstance == null) {
- throw new ServiceException("Service Factory '" + getDescriptor().getKey() + " return a null service. It should return a valid service.");
- }
- }
-
- return serviceInstance;
-
- }
-
- /**
- * @see java.lang.Object#toString()
- * @return
- *
- */
- @Override
- public String toString() {
- return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]";
- }
-
- /**
- * Create the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- public void createService() throws ServiceException {
- checkState(ServiceState.registered);
- // Exit if already created.
- if(factoryInstance != null) {
- setState(ServiceState.created);
- return;
- }
-
- // Create it
- try {
- // Create the instance
- factoryInstance = (IServiceFactory)instanciateService();
- } catch (Exception e) {
- setState(ServiceState.error);
- throw new ServiceException(e);
- }
- setState(ServiceState.created);
- }
-
- /**
- * Start the associated service if not a Lazy Service.
- *
- * @param servicesRegistry
- * The servicesRegistry containing this service.
- *
- * @throws ServiceException
- */
- public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
- checkState(ServiceState.created);
- try {
- factoryInstance.init(servicesRegistry);
- } catch (ServiceException e) {
- setState(ServiceState.error);
- throw e;
- } catch (Exception e) {
- setState(ServiceState.error);
- throw new ServiceException(e);
- }
-
- setState(ServiceState.initialized);
- }
-
- /**
- * Start the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- public void startService() throws ServiceException {
-
- checkState(ServiceState.initialized);
- setState(ServiceState.starting);
-
- try {
- factoryInstance.startService();
- } catch (ServiceException e) {
- setState(ServiceState.error);
- throw e;
- } catch (Exception e) {
- setState(ServiceState.error);
- throw new ServiceException(e);
- }
-
- setState(ServiceState.started);
- }
-
- /**
- * Dispose the service.
- */
- public void disposeService() throws ServiceException {
- if(factoryInstance == null)
- return;
-
- factoryInstance.disposeService();
- factoryInstance = null;
- serviceInstance = null;
- setState(ServiceState.disposed);
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.IServiceFactory;
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceState;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * Entry of a Service implementing {@link IServiceFactory}. This class provide
+ * methods to manage the Service life cycle.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class ServiceFactoryEntry extends ServiceTypeEntry {
+
+ /** Instance of the service, if started. */
+ private Object serviceInstance;
+
+ /** Instance of the factory, if created. */
+ private IServiceFactory factoryInstance;
+
+ /**
+ * Constructor.
+ *
+ * @param serviceDescriptor
+ * @param registry
+ */
+ public ServiceFactoryEntry(ServiceDescriptor serviceDescriptor) {
+ super(serviceDescriptor);
+ setState(ServiceState.registered);
+
+ }
+
+ /**
+ * Create an entry for an already created service. Constructor.
+ *
+ * @param descriptor
+ * Descriptor of the service. Key and priority should be set.
+ * @param serviceInstance
+ * The service Instance
+ */
+ public ServiceFactoryEntry(ServiceDescriptor descriptor, IServiceFactory factoryInstance) {
+ super(descriptor);
+ this.factoryInstance = factoryInstance;
+ setState(ServiceState.registered);
+ }
+
+ /**
+ * Get the service instance, even if it is not started. The service should
+ * be created.
+ *
+ * @return
+ * @throws ServiceException
+ * If service can't be started.
+ */
+ public Object getServiceInstance() throws ServiceException {
+
+ if(factoryInstance == null) {
+ throw new BadStateException("Service is not available (state=" //$NON-NLS-1$
+ + state.toString()
+ + "). ", state, serviceDescriptor); //$NON-NLS-1$
+
+ }
+ // Get the service instance if needed.
+ if(serviceInstance == null) {
+ serviceInstance = factoryInstance.createServiceInstance();
+ if(serviceInstance == null) {
+ throw new ServiceException("Service Factory '" + getDescriptor().getKey() + " return a null service. It should return a valid service."); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ return serviceInstance;
+
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ * @return
+ *
+ */
+ @Override
+ public String toString() {
+ return "ServiceEntry [serviceDescriptor=" + serviceDescriptor.toString() + ", serviceInstance=" + serviceInstance + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /**
+ * Create the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ public void createService() throws ServiceException {
+ checkState(ServiceState.registered);
+ // Exit if already created.
+ if(factoryInstance != null) {
+ setState(ServiceState.created);
+ return;
+ }
+
+ // Create it
+ try {
+ // Create the instance
+ factoryInstance = (IServiceFactory)instanciateService();
+ } catch (Exception e) {
+ setState(ServiceState.error);
+ throw new ServiceException(e);
+ }
+ setState(ServiceState.created);
+ }
+
+ /**
+ * Start the associated service if not a Lazy Service.
+ *
+ * @param servicesRegistry
+ * The servicesRegistry containing this service.
+ *
+ * @throws ServiceException
+ */
+ public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
+ checkState(ServiceState.created);
+ try {
+ factoryInstance.init(servicesRegistry);
+ } catch (ServiceException e) {
+ setState(ServiceState.error);
+ throw e;
+ } catch (Exception e) {
+ setState(ServiceState.error);
+ throw new ServiceException(e);
+ }
+
+ setState(ServiceState.initialized);
+ }
+
+ /**
+ * Start the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ public void startService() throws ServiceException {
+
+ checkState(ServiceState.initialized);
+ setState(ServiceState.starting);
+
+ try {
+ factoryInstance.startService();
+ } catch (ServiceException e) {
+ setState(ServiceState.error);
+ throw e;
+ } catch (Exception e) {
+ setState(ServiceState.error);
+ throw new ServiceException(e);
+ }
+
+ setState(ServiceState.started);
+ }
+
+ /**
+ * Dispose the service.
+ */
+ public void disposeService() throws ServiceException {
+ if(factoryInstance == null)
+ return;
+
+ factoryInstance.disposeService();
+ factoryInstance = null;
+ serviceInstance = null;
+ setState(ServiceState.disposed);
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java
index 285a5d5ea4c..4b5033c115f 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceStartupEntry.java
@@ -1,127 +1,137 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceState;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * Base class for the different types of service startups (lazy, synchronized).
- *
- * @author cedric dumoulin
- *
- */
-public abstract class ServiceStartupEntry {
-
- /**
- * The ServiceEntry, according to its type.
- */
- protected ServiceTypeEntry serviceEntry;
-
- /**
- * Entries of Services required by this service.
- */
- protected List<ServiceStartupEntry> requiredServices;
-
- /**
- *
- * Constructor.
- *
- * @param serviceDescriptor
- */
- public ServiceStartupEntry(ServiceTypeEntry serviceEntry) {
- this.serviceEntry = serviceEntry;
- }
-
- /**
- * Create the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- abstract public void createService() throws ServiceException;
-
- /**
- * Init the associated service if not a Lazy Service.
- *
- * @param servicesRegistry
- * The servicesRegistry containing this service.
- *
- * @throws ServiceException
- */
- abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException;
-
- /**
- * Start the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- abstract public void startService() throws ServiceException;
-
- /**
- * Get the service instance.
- *
- * @return
- * @throws ServiceException
- */
- abstract public Object getServiceInstance() throws ServiceException;
-
- /**
- * Dispose associated service.
- */
- abstract public void disposeService() throws ServiceException;
-
- /**
- * Return the list of the {@link ServiceStartupEntry} required by this
- * service.
- *
- * @return
- */
- public Collection<ServiceStartupEntry> getRequiredServices() {
-
- throw new UnsupportedOperationException("Not yet implemented");
- // return requiredServices;
- }
-
- /**
- * Get {@link ServiceDescriptor} associated to this entry.
- *
- * @return
- */
- public ServiceDescriptor getDescriptor() {
- return serviceEntry.getDescriptor();
- }
-
- /**
- * @return the state of the service
- */
- public ServiceState getState() {
- return serviceEntry.getState();
- }
-
- /**
- * Return true if the service is started. Return false otherwise.
- *
- * @return
- */
- public boolean isStarted() {
- return serviceEntry.isStarted();
- }
-
- /**
- *
- * @see java.lang.Object#toString()
- *
- * @return
- */
- @Override
- public String toString() {
- return super.toString() + ": key=" + getDescriptor().getKey();
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceState;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * Base class for the different types of service startups (lazy, synchronized).
+ *
+ * @author cedric dumoulin
+ *
+ */
+public abstract class ServiceStartupEntry {
+
+ /**
+ * The ServiceEntry, according to its type.
+ */
+ protected ServiceTypeEntry serviceEntry;
+
+ /**
+ * Entries of Services required by this service.
+ */
+ protected List<ServiceStartupEntry> requiredServices;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param serviceDescriptor
+ */
+ public ServiceStartupEntry(ServiceTypeEntry serviceEntry) {
+ this.serviceEntry = serviceEntry;
+ }
+
+ /**
+ * Create the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ abstract public void createService() throws ServiceException;
+
+ /**
+ * Init the associated service if not a Lazy Service.
+ *
+ * @param servicesRegistry
+ * The servicesRegistry containing this service.
+ *
+ * @throws ServiceException
+ */
+ abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException;
+
+ /**
+ * Start the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ abstract public void startService() throws ServiceException;
+
+ /**
+ * Get the service instance.
+ *
+ * @return
+ * @throws ServiceException
+ */
+ abstract public Object getServiceInstance() throws ServiceException;
+
+ /**
+ * Dispose associated service.
+ */
+ abstract public void disposeService() throws ServiceException;
+
+ /**
+ * Return the list of the {@link ServiceStartupEntry} required by this
+ * service.
+ *
+ * @return
+ */
+ public Collection<ServiceStartupEntry> getRequiredServices() {
+
+ throw new UnsupportedOperationException("Not yet implemented"); //$NON-NLS-1$
+ // return requiredServices;
+ }
+
+ /**
+ * Get {@link ServiceDescriptor} associated to this entry.
+ *
+ * @return
+ */
+ public ServiceDescriptor getDescriptor() {
+ return serviceEntry.getDescriptor();
+ }
+
+ /**
+ * @return the state of the service
+ */
+ public ServiceState getState() {
+ return serviceEntry.getState();
+ }
+
+ /**
+ * Return true if the service is started. Return false otherwise.
+ *
+ * @return
+ */
+ public boolean isStarted() {
+ return serviceEntry.isStarted();
+ }
+
+ /**
+ *
+ * @see java.lang.Object#toString()
+ *
+ * @return
+ */
+ @Override
+ public String toString() {
+ return super.toString() + ": key=" + getDescriptor().getKey(); //$NON-NLS-1$
+ }
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java
index a5dbc205147..761dc98698e 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/ServiceTypeEntry.java
@@ -1,201 +1,211 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.papyrus.infra.core.services.BadStateException;
-import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServiceState;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-import org.osgi.framework.Bundle;
-
-/**
- * Base class for the different types of service entries (PoJo, Service,
- * ServiceFactory, ...).
- *
- * @author cedric dumoulin
- */
-public abstract class ServiceTypeEntry {
-
- /**
- * Current state of the service.
- */
- protected ServiceState state = ServiceState.registered;
-
- /**
- * Descriptor of the service associated to this entry.
- */
- protected ServiceDescriptor serviceDescriptor;
-
- /**
- *
- * Constructor.
- *
- */
- public ServiceTypeEntry(ServiceDescriptor serviceDescriptor) {
- this.serviceDescriptor = serviceDescriptor;
- }
-
- /**
- * Change the state of the service.
- *
- * @param newState
- */
- protected void setState(ServiceState newState) {
- state = newState;
- }
-
- /**
- * @return the state
- */
- public ServiceState getState() {
- return state;
- }
-
- /**
- * Check if the current state is the proposed state. Throws an exception if
- * the state is different.
- *
- * @param expectedState
- * @throws BadStateException
- */
- protected void checkState(ServiceState expectedState) throws BadStateException {
- if(expectedState != state) {
- throw new BadStateException(expectedState, state, serviceDescriptor);
- }
- }
-
- /**
- * Get the descriptor of the service associated to this entry.
- *
- * @return
- */
- public ServiceDescriptor getDescriptor() {
- return serviceDescriptor;
- }
-
- /**
- * Instanciate the service as specified in serviceClassname.
- *
- * @return the created service.
- * @throws ServiceException
- */
- protected Object instanciateService() throws ServiceException {
-
- // Load the Class of the service
- String serviceClassname = serviceDescriptor.getServiceClassname();
- Class<?> classname = loadClass();
-
- // Try to get the one arg constructor.
- // This require the ServiceRegistry. Old stuff, not more used.
- // try {
- // Constructor<?> constructor =
- // classname.getConstructor(ServicesRegistry.class);
- // return constructor.newInstance(registry);
- // } catch (SecurityException e) {
- // // Do nothing, try next constructor
- // } catch (NoSuchMethodException e) {
- // // Do nothing, try next constructor
- // } catch (IllegalArgumentException e) {
- // throw new ServiceException("Can't instanciate '" + serviceClassname +
- // "' with args ServicesRegistry.", e);
- // } catch (InstantiationException e) {
- // throw new ServiceException("Can't instanciate '" + serviceClassname +
- // "' with args ServicesRegistry.", e);
- // } catch (IllegalAccessException e) {
- // throw new ServiceException("Can't instanciate '" + serviceClassname +
- // "' with args ServicesRegistry.", e);
- // } catch (InvocationTargetException e) {
- // throw new ServiceException("Can't instanciate '" + serviceClassname +
- // "' with args ServicesRegistry.", e);
- // }
-
- // Try with zero arg constructor.
- try {
- return classname.newInstance();
- } catch (SecurityException e) {
- throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e);
- } catch (IllegalArgumentException e) {
- throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e);
- } catch (InstantiationException e) {
- throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e);
- } catch (IllegalAccessException e) {
- throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e);
- }
- }
-
- /**
- * Load the Class object. Try from current ClassLoader, then try using the
- * plugin referenced in the serviceDescriptor.PluginId
- *
- * @return
- * @throws ServiceException
- */
- private Class<?> loadClass() throws ServiceException {
- String serviceClassname = serviceDescriptor.getServiceClassname();
- Class<?> serviceClass;
- try {
- serviceClass = Class.forName(serviceClassname);
- } catch (ClassNotFoundException e1) {
- // Try using bundle
- try {
- String bundleID = serviceDescriptor.getClassBundleID();
- Bundle bundle = Platform.getBundle(bundleID);
- serviceClass = bundle.loadClass(serviceClassname);
- } catch (ClassNotFoundException e2) {
- throw new ServiceException("Can't find class for the name '" + serviceClassname + "'.", e2);
- }
- }
-
- return serviceClass;
- }
-
- /**
- * Return true if the service is started. Return false otherwise.
- *
- * @return
- */
- public boolean isStarted() {
- return state == ServiceState.started;
- }
-
- /**
- * Get the service instance.
- *
- * @return
- * @throws ServiceException
- */
- abstract public Object getServiceInstance() throws ServiceException;
-
- /**
- * Create the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- abstract public void createService() throws ServiceException;
-
- /**
- * Start the associated service if not a Lazy Service.
- *
- * @param servicesRegistry
- * The servicesRegistry containing this service.
- *
- * @throws ServiceException
- */
- abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException;
-
- /**
- * Start the associated service if not a Lazy Service.
- *
- * @throws ServiceException
- */
- abstract public void startService() throws ServiceException;
-
- /**
- * Dispose associated service.
- */
- abstract public void disposeService() throws ServiceException;
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.infra.core.services.BadStateException;
+import org.eclipse.papyrus.infra.core.services.ServiceDescriptor;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServiceState;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.osgi.framework.Bundle;
+
+/**
+ * Base class for the different types of service entries (PoJo, Service,
+ * ServiceFactory, ...).
+ *
+ * @author cedric dumoulin
+ */
+public abstract class ServiceTypeEntry {
+
+ /**
+ * Current state of the service.
+ */
+ protected ServiceState state = ServiceState.registered;
+
+ /**
+ * Descriptor of the service associated to this entry.
+ */
+ protected ServiceDescriptor serviceDescriptor;
+
+ /**
+ *
+ * Constructor.
+ *
+ */
+ public ServiceTypeEntry(ServiceDescriptor serviceDescriptor) {
+ this.serviceDescriptor = serviceDescriptor;
+ }
+
+ /**
+ * Change the state of the service.
+ *
+ * @param newState
+ */
+ protected void setState(ServiceState newState) {
+ state = newState;
+ }
+
+ /**
+ * @return the state
+ */
+ public ServiceState getState() {
+ return state;
+ }
+
+ /**
+ * Check if the current state is the proposed state. Throws an exception if
+ * the state is different.
+ *
+ * @param expectedState
+ * @throws BadStateException
+ */
+ protected void checkState(ServiceState expectedState) throws BadStateException {
+ if(expectedState != state) {
+ throw new BadStateException(expectedState, state, serviceDescriptor);
+ }
+ }
+
+ /**
+ * Get the descriptor of the service associated to this entry.
+ *
+ * @return
+ */
+ public ServiceDescriptor getDescriptor() {
+ return serviceDescriptor;
+ }
+
+ /**
+ * Instanciate the service as specified in serviceClassname.
+ *
+ * @return the created service.
+ * @throws ServiceException
+ */
+ protected Object instanciateService() throws ServiceException {
+
+ // Load the Class of the service
+ String serviceClassname = serviceDescriptor.getServiceClassname();
+ Class<?> classname = loadClass();
+
+ // Try to get the one arg constructor.
+ // This require the ServiceRegistry. Old stuff, not more used.
+ // try {
+ // Constructor<?> constructor =
+ // classname.getConstructor(ServicesRegistry.class);
+ // return constructor.newInstance(registry);
+ // } catch (SecurityException e) {
+ // // Do nothing, try next constructor
+ // } catch (NoSuchMethodException e) {
+ // // Do nothing, try next constructor
+ // } catch (IllegalArgumentException e) {
+ // throw new ServiceException("Can't instanciate '" + serviceClassname +
+ // "' with args ServicesRegistry.", e);
+ // } catch (InstantiationException e) {
+ // throw new ServiceException("Can't instanciate '" + serviceClassname +
+ // "' with args ServicesRegistry.", e);
+ // } catch (IllegalAccessException e) {
+ // throw new ServiceException("Can't instanciate '" + serviceClassname +
+ // "' with args ServicesRegistry.", e);
+ // } catch (InvocationTargetException e) {
+ // throw new ServiceException("Can't instanciate '" + serviceClassname +
+ // "' with args ServicesRegistry.", e);
+ // }
+
+ // Try with zero arg constructor.
+ try {
+ return classname.newInstance();
+ } catch (SecurityException e) {
+ throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (IllegalArgumentException e) {
+ throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (InstantiationException e) {
+ throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); //$NON-NLS-1$ //$NON-NLS-2$
+ } catch (IllegalAccessException e) {
+ throw new ServiceException("Can't instanciate '" + serviceClassname + "' with zero args.", e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ /**
+ * Load the Class object. Try from current ClassLoader, then try using the
+ * plugin referenced in the serviceDescriptor.PluginId
+ *
+ * @return
+ * @throws ServiceException
+ */
+ private Class<?> loadClass() throws ServiceException {
+ String serviceClassname = serviceDescriptor.getServiceClassname();
+ Class<?> serviceClass;
+ try {
+ serviceClass = Class.forName(serviceClassname);
+ } catch (ClassNotFoundException e1) {
+ // Try using bundle
+ try {
+ String bundleID = serviceDescriptor.getClassBundleID();
+ Bundle bundle = Platform.getBundle(bundleID);
+ serviceClass = bundle.loadClass(serviceClassname);
+ } catch (ClassNotFoundException e2) {
+ throw new ServiceException("Can't find class for the name '" + serviceClassname + "'.", e2); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ return serviceClass;
+ }
+
+ /**
+ * Return true if the service is started. Return false otherwise.
+ *
+ * @return
+ */
+ public boolean isStarted() {
+ return state == ServiceState.started;
+ }
+
+ /**
+ * Get the service instance.
+ *
+ * @return
+ * @throws ServiceException
+ */
+ abstract public Object getServiceInstance() throws ServiceException;
+
+ /**
+ * Create the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ abstract public void createService() throws ServiceException;
+
+ /**
+ * Start the associated service if not a Lazy Service.
+ *
+ * @param servicesRegistry
+ * The servicesRegistry containing this service.
+ *
+ * @throws ServiceException
+ */
+ abstract public void initService(ServicesRegistry servicesRegistry) throws ServiceException;
+
+ /**
+ * Start the associated service if not a Lazy Service.
+ *
+ * @throws ServiceException
+ */
+ abstract public void startService() throws ServiceException;
+
+ /**
+ * Dispose associated service.
+ */
+ abstract public void disposeService() throws ServiceException;
+
+}
diff --git a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java
index 9707b036379..3e85c89b483 100644
--- a/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java
+++ b/plugins/infra/core/org.eclipse.papyrus.infra.core/src/org/eclipse/papyrus/infra/core/services/internal/StartStartupEntry.java
@@ -1,83 +1,93 @@
-/**
- *
- */
-package org.eclipse.papyrus.infra.core.services.internal;
-
-import org.eclipse.papyrus.infra.core.services.ServiceException;
-import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
-
-/**
- * An ServiceEntry managing {@link IService} that should be started when the
- * registry is started.
- *
- * @author cedric dumoulin
- *
- */
-public class StartStartupEntry extends ServiceStartupEntry {
-
- /**
- * Constructor.
- *
- * @param serviceDescriptor
- * @param registry
- */
- public StartStartupEntry(ServiceTypeEntry serviceEntry) {
-
- super(serviceEntry);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.core.services.internal.ServiceStartupEntry#getServiceInstance()
- *
- * @return
- * @throws ServiceException
- */
- @Override
- public Object getServiceInstance() throws ServiceException {
- // Return the instance
- return serviceEntry.getServiceInstance();
- }
-
- /**
- * Do nothing
- *
- * @throws ServiceException
- */
- @Override
- public void createService() throws ServiceException {
- serviceEntry.createService();
- }
-
- /**
- * Do nothing
- *
- * @param servicesRegistry
- * @throws ServiceException
- */
- @Override
- public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
- serviceEntry.initService(servicesRegistry);
- }
-
- /**
- * Do nothing.
- *
- * @throws ServiceException
- */
- @Override
- public void startService() throws ServiceException {
- serviceEntry.startService();
- }
-
- /**
- * @see org.eclipse.papyrus.infra.core.services.AbstractServiceEntry#disposeService()
- *
- * @throws ServiceException
- */
- @Override
- public void disposeService() throws ServiceException {
- serviceEntry.disposeService();
- }
-
-}
+/*****************************************************************************
+ * Copyright (c) CEA LIST.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cedric Dumoulin Cedric.dumoulin@lifl.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.core.services.internal;
+
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+
+/**
+ * An ServiceEntry managing {@link IService} that should be started when the
+ * registry is started.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class StartStartupEntry extends ServiceStartupEntry {
+
+ /**
+ * Constructor.
+ *
+ * @param serviceDescriptor
+ * @param registry
+ */
+ public StartStartupEntry(ServiceTypeEntry serviceEntry) {
+
+ super(serviceEntry);
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.core.services.internal.ServiceStartupEntry#getServiceInstance()
+ *
+ * @return
+ * @throws ServiceException
+ */
+ @Override
+ public Object getServiceInstance() throws ServiceException {
+ // Return the instance
+ return serviceEntry.getServiceInstance();
+ }
+
+ /**
+ * Do nothing
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void createService() throws ServiceException {
+ serviceEntry.createService();
+ }
+
+ /**
+ * Do nothing
+ *
+ * @param servicesRegistry
+ * @throws ServiceException
+ */
+ @Override
+ public void initService(ServicesRegistry servicesRegistry) throws ServiceException {
+ serviceEntry.initService(servicesRegistry);
+ }
+
+ /**
+ * Do nothing.
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void startService() throws ServiceException {
+ serviceEntry.startService();
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.services.AbstractServiceEntry#disposeService()
+ *
+ * @throws ServiceException
+ */
+ @Override
+ public void disposeService() throws ServiceException {
+ serviceEntry.disposeService();
+ }
+
+}

Back to the top