summaryrefslogtreecommitdiff
path: root/qpid/java/broker/src
diff options
context:
space:
mode:
authorKeith Wall <kwall@apache.org>2012-08-03 15:09:42 +0000
committerKeith Wall <kwall@apache.org>2012-08-03 15:09:42 +0000
commitea4789318932d359cb4de57e0cd055bf5622d937 (patch)
tree7b7e4fd98405f5900891e329fdf0a5e44625cb5d /qpid/java/broker/src
parent3cb4c0545dec3ae5539fe66b4b881c4c3329dfaf (diff)
downloadqpid-python-ea4789318932d359cb4de57e0cd055bf5622d937.tar.gz
QPID-4189: Add unit tests for ConfiguredObjectToMapConverter
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1369015 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker/src')
-rw-r--r--qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java62
1 files changed, 34 insertions, 28 deletions
diff --git a/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java b/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
index fd429321c8..36179fc105 100644
--- a/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
+++ b/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Model.java
@@ -29,33 +29,20 @@ import java.util.Map;
public class Model
{
- private static final Map<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>
- PARENTS = new HashMap<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>();
+ private static final Model MODEL_INSTANCE = new Model();
+ private final Map<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>
+ _parents = new HashMap<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>();
- private static final Map<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>
- CHILDREN = new HashMap<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>();
+ private final Map<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>
+ _children = new HashMap<Class<? extends ConfiguredObject>, Collection<Class<? extends ConfiguredObject>>>();
- static void addRelationship(Class<? extends ConfiguredObject> parent, Class<? extends ConfiguredObject> child)
+ public static Model getInstance()
{
- Collection<Class<? extends ConfiguredObject>> parents = PARENTS.get(child);
- if(parents == null)
- {
- parents = new ArrayList<Class<? extends ConfiguredObject>>();
- PARENTS.put(child, parents);
- }
- parents.add(parent);
-
- Collection<Class<? extends ConfiguredObject>> children = CHILDREN.get(parent);
- if(children == null)
- {
- children = new ArrayList<Class<? extends ConfiguredObject>>();
- CHILDREN.put(parent, children);
- }
- children.add(child);
+ return MODEL_INSTANCE;
}
- static
+ private Model()
{
addRelationship(Broker.class, VirtualHost.class);
addRelationship(Broker.class, Port.class);
@@ -78,20 +65,39 @@ public class Model
addRelationship(Session.class, Consumer.class);
addRelationship(Session.class, Publisher.class);
-
}
- public static Collection<Class<? extends ConfiguredObject>> getParentTypes(Class<? extends ConfiguredObject> child)
+ public Collection<Class<? extends ConfiguredObject>> getParentTypes(Class<? extends ConfiguredObject> child)
{
- Collection<Class<? extends ConfiguredObject>> parentTypes = PARENTS.get(child);
- return parentTypes == null ? Collections.EMPTY_LIST
+ Collection<Class<? extends ConfiguredObject>> parentTypes = _parents.get(child);
+ return parentTypes == null ? Collections.<Class<? extends ConfiguredObject>>emptyList()
: Collections.unmodifiableCollection(parentTypes);
}
- public static Collection<Class<? extends ConfiguredObject>> getChildTypes(Class<? extends ConfiguredObject> parent)
+ public Collection<Class<? extends ConfiguredObject>> getChildTypes(Class<? extends ConfiguredObject> parent)
{
- Collection<Class<? extends ConfiguredObject>> childTypes = CHILDREN.get(parent);
- return childTypes == null ? Collections.EMPTY_LIST
+ Collection<Class<? extends ConfiguredObject>> childTypes = _children.get(parent);
+ return childTypes == null ? Collections.<Class<? extends ConfiguredObject>>emptyList()
: Collections.unmodifiableCollection(childTypes);
}
+
+ private void addRelationship(Class<? extends ConfiguredObject> parent, Class<? extends ConfiguredObject> child)
+ {
+ Collection<Class<? extends ConfiguredObject>> parents = _parents.get(child);
+ if(parents == null)
+ {
+ parents = new ArrayList<Class<? extends ConfiguredObject>>();
+ _parents.put(child, parents);
+ }
+ parents.add(parent);
+
+ Collection<Class<? extends ConfiguredObject>> children = _children.get(parent);
+ if(children == null)
+ {
+ children = new ArrayList<Class<? extends ConfiguredObject>>();
+ _children.put(parent, children);
+ }
+ children.add(child);
+ }
+
}