summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/management-http
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-04-18 22:38:03 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-04-18 22:38:03 +0000
commit2c60d3390a322642b1dcd64f59612dc6ae1bb760 (patch)
treeced06903f8f7b138929ee97010905298251ab289 /qpid/java/broker-plugins/management-http
parent178745059c1265f8cae71f8b19caf448b580afb0 (diff)
downloadqpid-python-2c60d3390a322642b1dcd64f59612dc6ae1bb760.tar.gz
QPID-5578 : [Java Broker] Tidy up - minimize use of MapValueConverter, make constructors consistent across ConfiguredObjects
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1588586 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/management-http')
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java31
-rw-r--r--qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java11
-rw-r--r--qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java4
3 files changed, 19 insertions, 27 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
index 37e85831a6..b72ecb950d 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
@@ -30,7 +30,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import java.util.UUID;
+import java.util.Set;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
@@ -70,7 +70,6 @@ import org.apache.qpid.server.management.plugin.servlet.rest.UserPreferencesServ
import org.apache.qpid.server.model.*;
import org.apache.qpid.server.model.adapter.AbstractPluginAdapter;
import org.apache.qpid.server.model.port.AbstractPortWithAuthProvider;
-import org.apache.qpid.server.util.MapValueConverter;
import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager;
@@ -122,9 +121,9 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem
@ManagedAttributeField
private int _sessionTimeout;
- public HttpManagement(UUID id, Broker broker, Map<String, Object> attributes)
+ public HttpManagement(Map<String, Object> attributes, Broker broker)
{
- super(id, attributes, broker);
+ super(attributes, broker);
}
@Override
@@ -389,7 +388,7 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem
for (Connector connector : connectors)
{
getBroker().getEventLogger().message(ManagementConsoleMessages.LISTENING(stringifyConnectorScheme(connector),
- connector.getPort()));
+ connector.getPort()));
if (connector instanceof SslSocketConnector)
{
SslContextFactory sslContextFactory = ((SslSocketConnector)connector).getSslContextFactory();
@@ -460,28 +459,22 @@ public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implem
}
@Override
- protected void changeAttributes(Map<String, Object> attributes)
+ protected void validateChange(final ConfiguredObject<?> proxyForValidation, final Set<String> changedAttributes)
{
- Map<String, Object> convertedAttributes = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES);
- validateAttributes(convertedAttributes);
+ super.validateChange(proxyForValidation, changedAttributes);
- super.changeAttributes(convertedAttributes);
- }
-
- private void validateAttributes(Map<String, Object> convertedAttributes)
- {
- if(convertedAttributes.containsKey(HttpManagement.NAME))
+ HttpManagementConfiguration<?> updated = (HttpManagementConfiguration<?>)proxyForValidation;
+ if(changedAttributes.contains(HttpManagement.NAME))
{
- String newName = (String) convertedAttributes.get(HttpManagement.NAME);
- if(!getName().equals(newName))
+ if(!getName().equals(updated.getName()))
{
throw new IllegalConfigurationException("Changing the name of http management plugin is not allowed");
}
}
- if (convertedAttributes.containsKey(TIME_OUT))
+ if (changedAttributes.contains(TIME_OUT))
{
- Number value = (Number) convertedAttributes.get(TIME_OUT);
- if (value == null || value.longValue() < 0)
+ int value = updated.getSessionTimeout();
+ if (value < 0)
{
throw new IllegalConfigurationException("Only positive integer value can be specified for the session time out attribute");
}
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java
index 0431954879..518788a3d3 100644
--- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java
+++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementFactory.java
@@ -18,14 +18,13 @@
*/
package org.apache.qpid.server.management.plugin;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.ConfiguredObject;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
public class HttpManagementFactory extends AbstractConfiguredObjectTypeFactory<HttpManagement>
{
@@ -38,9 +37,7 @@ public class HttpManagementFactory extends AbstractConfiguredObjectTypeFactory<H
public HttpManagement createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
{
Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes);
- Object idObj = attributesWithoutId.remove(ConfiguredObject.ID);
- UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString());
- return new HttpManagement(id, getParent(Broker.class,parents), attributes);
+ return new HttpManagement(attributes, getParent(Broker.class,parents));
}
}
diff --git a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java
index ff96a4223e..56dc947482 100644
--- a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java
+++ b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/HttpManagementTest.java
@@ -31,6 +31,7 @@ import java.util.UUID;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.test.utils.QpidTestCase;
public class HttpManagementTest extends QpidTestCase
@@ -52,7 +53,8 @@ public class HttpManagementTest extends QpidTestCase
attributes.put(HttpManagement.HTTPS_SASL_AUTHENTICATION_ENABLED, true);
attributes.put(HttpManagement.NAME, getTestName());
attributes.put(HttpManagement.TIME_OUT, 10000l);
- _management = new HttpManagement(_id, _broker, attributes);
+ attributes.put(ConfiguredObject.ID, _id);
+ _management = new HttpManagement(attributes, _broker);
_management.open();
}