You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/04/24 17:56:34 UTC
svn commit: r1589777 - in /qpid/trunk/qpid/java/broker-core/src:
main/java/org/apache/qpid/server/exchange/
main/java/org/apache/qpid/server/model/
main/java/org/apache/qpid/server/queue/
test/java/org/apache/qpid/server/virtualhost/
Author: rgodfrey
Date: Thu Apr 24 15:56:34 2014
New Revision: 1589777
URL: http://svn.apache.org/r1589777
Log:
QPID-5709 : [Java Broker] address review comments from Keith Wall
Removed:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/DefaultQueueRegistry.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/queue/QueueRegistry.java
Modified:
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java?rev=1589777&r1=1589776&r2=1589777&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/exchange/TopicExchange.java Thu Apr 24 15:56:34 2014
@@ -73,7 +73,7 @@ public class TopicExchange extends Abstr
}
@Override
- protected void onBindingUpdated(final BindingImpl binding, final Map<String, Object> oldArguments)
+ protected synchronized void onBindingUpdated(final BindingImpl binding, final Map<String, Object> oldArguments)
{
final String bindingKey = binding.getBindingKey();
AMQQueue queue = binding.getAMQQueue();
@@ -82,7 +82,7 @@ public class TopicExchange extends Abstr
assert queue != null;
assert bindingKey != null;
- _logger.debug("Registering queue " + queue.getName() + " with routing key " + bindingKey);
+ _logger.debug("Updating binding of queue " + queue.getName() + " with routing key " + bindingKey);
String routingKey = TopicNormalizer.normalize(bindingKey);
@@ -253,7 +253,7 @@ public class TopicExchange extends Abstr
}
- private boolean deregisterQueue(final BindingImpl binding)
+ private synchronized boolean deregisterQueue(final BindingImpl binding)
{
if(_bindings.containsKey(binding))
{
Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java?rev=1589777&r1=1589776&r2=1589777&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/AbstractConfiguredObject.java Thu Apr 24 15:56:34 2014
@@ -212,13 +212,10 @@ public abstract class AbstractConfigured
_type = Model.getType(getClass());
_bestFitInterface = calculateBestFitInterface();
- if(attributes.get(TYPE) != null)
+ if(attributes.get(TYPE) != null && !_type.equals(attributes.get(TYPE)))
{
- if(!_type.equals(attributes.get(TYPE)))
- {
- throw new IllegalConfigurationException("Provided type is " + attributes.get(TYPE)
- + " but calculated type is " + _type);
- }
+ throw new IllegalConfigurationException("Provided type is " + attributes.get(TYPE)
+ + " but calculated type is " + _type);
}
for (Class<? extends ConfiguredObject> childClass : getModel().getChildTypes(getCategoryClass()))
@@ -244,18 +241,14 @@ public abstract class AbstractConfigured
Object durableObj = attributes.get(DURABLE);
_durable = AttributeValueConverter.BOOLEAN_CONVERTER.convert(durableObj == null ? _attributeTypes.get(DURABLE).getAnnotation().defaultValue() : durableObj, this);
- Collection<String> names = getAttributeNames();
- if(names!=null)
+ for (String name : getAttributeNames())
{
- for (String name : names)
+ if (attributes.containsKey(name))
{
- if (attributes.containsKey(name))
+ final Object value = attributes.get(name);
+ if (value != null)
{
- final Object value = attributes.get(name);
- if(value != null)
- {
- _attributes.put(name, value);
- }
+ _attributes.put(name, value);
}
}
}
@@ -800,10 +793,7 @@ public abstract class AbstractConfigured
public <T extends ConfiguredObject> T getParent(final Class<T> clazz)
{
- synchronized (_parents)
- {
- return (T) _parents.get(clazz);
- }
+ return (T) _parents.get(clazz);
}
private <T extends ConfiguredObject> void addParent(Class<T> clazz, T parent)
@@ -924,33 +914,16 @@ public abstract class AbstractConfigured
{
throw new DuplicateIdException(child);
}
- if(_childrenByName.get(categoryClass).containsKey(name))
+ if(getModel().getParentTypes(categoryClass).size() == 1)
{
- Collection<Class<? extends ConfiguredObject>> parentTypes =
- new ArrayList<Class<? extends ConfiguredObject>>(child.getModel().getParentTypes(categoryClass));
- parentTypes.remove(getCategoryClass());
- boolean duplicate = true;
-
- C existing = (C) _childrenByName.get(categoryClass).get(name);
- for(Class<? extends ConfiguredObject> parentType : parentTypes)
- {
- ConfiguredObject existingParent = existing.getParent(parentType);
- ConfiguredObject childParent = child.getParent(parentType);
- duplicate = existingParent == childParent;
- if(!duplicate)
- {
- break;
- }
- }
-
- if(duplicate)
+ if (_childrenByName.get(categoryClass).containsKey(name))
{
throw new DuplicateNameException(child);
}
+ _childrenByName.get(categoryClass).put(name, child);
}
_children.get(categoryClass).add(child);
_childrenById.get(categoryClass).put(childId,child);
- _childrenByName.get(categoryClass).put(name, child);
}
@@ -986,7 +959,13 @@ public abstract class AbstractConfigured
@Override
public final <C extends ConfiguredObject> C getChildByName(final Class<C> clazz, final String name)
{
- return (C) _childrenByName.get(Model.getCategory(clazz)).get(name);
+ Class<? extends ConfiguredObject> categoryClass = Model.getCategory(clazz);
+ if(getModel().getParentTypes(categoryClass).size() != 1)
+ {
+ throw new UnsupportedOperationException("Cannot use getChildByName for objects of category "
+ + categoryClass.getSimpleName() + " as it has more than one parent");
+ }
+ return (C) _childrenByName.get(categoryClass).get(name);
}
@Override
@@ -1072,8 +1051,9 @@ public abstract class AbstractConfigured
private ConfiguredObject<?> createProxyForValidation(final Map<String, Object> attributes)
{
- return (ConfiguredObject<?>) Proxy.newProxyInstance(getClass().getClassLoader(),new Class<?>[]{_bestFitInterface},
- new AttributeGettingHandler(attributes));
+ return (ConfiguredObject<?>) Proxy.newProxyInstance(getClass().getClassLoader(),
+ new Class<?>[]{_bestFitInterface},
+ new AttributeGettingHandler(attributes));
}
protected void authoriseSetDesiredState(State currentState, State desiredState) throws AccessControlException
Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java?rev=1589777&r1=1589776&r2=1589777&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java (original)
+++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java Thu Apr 24 15:56:34 2014
@@ -45,7 +45,6 @@ import org.apache.qpid.server.model.Stat
import org.apache.qpid.server.model.VirtualHostAlias;
import org.apache.qpid.server.protocol.LinkRegistry;
import org.apache.qpid.server.queue.AMQQueue;
-import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.security.SecurityManager;
import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
import org.apache.qpid.server.stats.StatisticsCounter;
@@ -197,11 +196,6 @@ public class MockVirtualHost implements
return null;
}
- public QueueRegistry getQueueRegistry()
- {
- return null;
- }
-
@Override
public AMQQueue<?> getQueue(String name)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org