Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-04-24 14:33:45 +0000
committerEike Stepper2018-04-24 14:33:45 +0000
commitcdd0658a95a41d9adb12fe218451f57eec100b75 (patch)
treecbe078bd562bbe4140d722f514d73460eab5db00
parentdae004cdde935190ffcf04cda8ad3db88fd04d1b (diff)
downloadcdo-cdd0658a95a41d9adb12fe218451f57eec100b75.tar.gz
cdo-cdd0658a95a41d9adb12fe218451f57eec100b75.tar.xz
cdo-cdd0658a95a41d9adb12fe218451f57eec100b75.zip
[533989] Give IManagedContainers a name
https://bugs.eclipse.org/bugs/show_bug.cgi?id=533989
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java2
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java6
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java14
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ManagedContainer.java32
5 files changed, 55 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
index e3330a8d85..ed7f7b2daa 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
@@ -338,6 +338,8 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
protected IManagedContainer createServerContainer()
{
IManagedContainer container = ContainerUtil.createContainer();
+ container.setName("server");
+
Net4jUtil.prepareContainer(container);
CDONet4jServerUtil.prepareContainer(container);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
index be01b4d04f..2da48ab8c4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
@@ -128,6 +128,8 @@ public abstract class SessionConfig extends Config implements ISessionConfig
protected IManagedContainer createClientContainer()
{
IManagedContainer container = ContainerUtil.createContainer();
+ container.setName("client");
+
Net4jUtil.prepareContainer(container);
container.registerFactory(new ExecutorServiceFactory()
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java
index c0bb001f43..3441dc1893 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/internal/util/container/PluginContainer.java
@@ -35,8 +35,11 @@ public class PluginContainer extends ManagedContainer implements IPluginContaine
{
}
+ /**
+ * @since 3.8
+ */
@Override
- public String toString()
+ protected String getTypeName()
{
return "PluginContainer"; //$NON-NLS-1$
}
@@ -67,6 +70,7 @@ public class PluginContainer extends ManagedContainer implements IPluginContaine
if (instance == null)
{
PluginContainer container = new PluginContainer();
+ container.setName("INSTANCE");
container.activate();
instance = container; // Leave instance==null in case of a Throwable in activate()
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
index 826ad25dba..be7e77a150 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/IManagedContainer.java
@@ -35,6 +35,20 @@ import java.util.Set;
*/
public interface IManagedContainer extends IContainer<Object>, ILifecycle
{
+ /**
+ * Returns the name of this container, or <code>null</code> if no name has been set.
+ *
+ * @since 3.8
+ */
+ public String getName();
+
+ /**
+ * Sets the name of this container before it is activated.
+ *
+ * @since 3.8
+ */
+ public void setName(String name);
+
public IRegistry<IFactoryKey, IFactory> getFactoryRegistry();
public IManagedContainer registerFactory(IFactory factory);
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ManagedContainer.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ManagedContainer.java
index c67a95a05e..26302571a2 100644
--- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ManagedContainer.java
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/container/ManagedContainer.java
@@ -53,6 +53,8 @@ import java.util.Set;
*/
public class ManagedContainer extends Lifecycle implements IManagedContainer
{
+ private String name;
+
private IRegistry<IFactoryKey, IFactory> factoryRegistry;
private List<IElementProcessor> postProcessors;
@@ -85,6 +87,23 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
{
}
+ /**
+ * @since 3.8
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @since 3.8
+ */
+ public void setName(String name)
+ {
+ checkInactive();
+ this.name = name;
+ }
+
public synchronized IRegistry<IFactoryKey, IFactory> getFactoryRegistry()
{
if (factoryRegistry == null)
@@ -515,6 +534,19 @@ public class ManagedContainer extends Lifecycle implements IManagedContainer
@Override
public String toString()
{
+ if (name != null)
+ {
+ return getTypeName() + "[" + name + "]";
+ }
+
+ return getTypeName();
+ }
+
+ /**
+ * @since 3.8
+ */
+ protected String getTypeName()
+ {
return "ManagedContainer"; //$NON-NLS-1$
}

Back to the top