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/03 21:59:01 UTC
svn commit: r1584365 [12/15] - in
/qpid/branches/java-broker-config-store-changes/qpid/java: ./
bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/
bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/
bdbstore/src/main/ja...
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/DurableConfigurationRecovererTest.java Thu Apr 3 19:58:53 2014
@@ -33,13 +33,16 @@ import org.apache.qpid.server.logging.Ev
import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.exchange.DirectExchange;
import org.apache.qpid.server.exchange.ExchangeFactory;
import org.apache.qpid.server.exchange.ExchangeRegistry;
+import org.apache.qpid.server.exchange.FanoutExchange;
import org.apache.qpid.server.exchange.HeadersExchange;
import org.apache.qpid.server.exchange.TopicExchange;
import org.apache.qpid.server.model.Binding;
import org.apache.qpid.server.model.Queue;
+import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.plugin.ExchangeType;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.QueueFactory;
@@ -60,19 +63,21 @@ import static org.mockito.Mockito.doAnsw
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-
import static org.apache.qpid.server.model.VirtualHost.CURRENT_CONFIG_VERSION;
public class DurableConfigurationRecovererTest extends QpidTestCase
{
+ private static final String VIRTUAL_HOST_NAME = "test";
private static final UUID QUEUE_ID = new UUID(0,0);
- private static final UUID TOPIC_EXCHANGE_ID = new UUID(0,1);
- private static final UUID DIRECT_EXCHANGE_ID = new UUID(0,2);
+ private static final UUID TOPIC_EXCHANGE_ID = UUIDGenerator.generateExchangeUUID(TopicExchange.TYPE.getDefaultExchangeName(), VIRTUAL_HOST_NAME);
+ private static final UUID DIRECT_EXCHANGE_ID = UUIDGenerator.generateExchangeUUID(DirectExchange.TYPE.getDefaultExchangeName(), VIRTUAL_HOST_NAME);
private static final String CUSTOM_EXCHANGE_NAME = "customExchange";
private DurableConfigurationRecoverer _durableConfigurationRecoverer;
- private ExchangeImpl _directExchange;
- private ExchangeImpl _topicExchange;
+ private ExchangeImpl<?> _directExchange;
+ private ExchangeImpl<?> _topicExchange;
+ private ExchangeImpl<?> _matchExchange;
+ private ExchangeImpl<?> _fanoutExchange;
private VirtualHost _vhost;
private DurableConfigurationStore _store;
private ExchangeFactory _exchangeFactory;
@@ -84,21 +89,19 @@ public class DurableConfigurationRecover
{
super.setUp();
+ _exchangeFactory = mock(ExchangeFactory.class);
- _directExchange = mock(ExchangeImpl.class);
- when(_directExchange.getExchangeType()).thenReturn(DirectExchange.TYPE);
-
-
- _topicExchange = mock(ExchangeImpl.class);
- when(_topicExchange.getExchangeType()).thenReturn(TopicExchange.TYPE);
+ _directExchange = createAndRegisterDefaultExchangeWithFactory(DirectExchange.TYPE);
+ _topicExchange = createAndRegisterDefaultExchangeWithFactory(TopicExchange.TYPE);
+ _matchExchange = createAndRegisterDefaultExchangeWithFactory(HeadersExchange.TYPE);
+ _fanoutExchange = createAndRegisterDefaultExchangeWithFactory(FanoutExchange.TYPE);
- AMQQueue queue = mock(AMQQueue.class);
+ AMQQueue<?> queue = mock(AMQQueue.class);
_vhost = mock(VirtualHost.class);
+ when(_vhost.getName()).thenReturn(VIRTUAL_HOST_NAME);
_exchangeRegistry = mock(ExchangeRegistry.class);
- when(_exchangeRegistry.getExchange(eq(DIRECT_EXCHANGE_ID))).thenReturn(_directExchange);
- when(_exchangeRegistry.getExchange(eq(TOPIC_EXCHANGE_ID))).thenReturn(_topicExchange);
when(_vhost.getQueue(eq(QUEUE_ID))).thenReturn(queue);
@@ -166,7 +169,6 @@ public class DurableConfigurationRecover
}
});
- _exchangeFactory = mock(ExchangeFactory.class);
DurableConfiguredObjectRecoverer[] recoverers = {
@@ -182,12 +184,25 @@ public class DurableConfigurationRecover
}
_durableConfigurationRecoverer =
new DurableConfigurationRecoverer(_vhost.getName(), recovererMap,
- new DefaultUpgraderProvider(_vhost, _exchangeRegistry), new EventLogger());
+ new DefaultUpgraderProvider(_vhost), new EventLogger());
_store = mock(DurableConfigurationStore.class);
}
+ private ExchangeImpl<?> createAndRegisterDefaultExchangeWithFactory(ExchangeType<?> exchangeType) throws AMQUnknownExchangeType, UnknownExchangeException
+ {
+ ExchangeImpl exchange = mock(ExchangeImpl.class);
+ when(exchange.getExchangeType()).thenReturn(exchangeType);
+ Map<String, Object> directExchangeAttrsWithId = new HashMap<String, Object>();
+ directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.ID, UUIDGenerator.generateExchangeUUID(exchangeType.getDefaultExchangeName(), VIRTUAL_HOST_NAME));
+ directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.DURABLE, true);
+ directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.TYPE, exchangeType.getType());
+ directExchangeAttrsWithId.put(org.apache.qpid.server.model.Exchange.NAME, exchangeType.getDefaultExchangeName());
+ when(_exchangeFactory.restoreExchange(directExchangeAttrsWithId)).thenReturn(exchange);
+ return exchange;
+ }
+
public void testUpgradeEmptyStore() throws Exception
{
_durableConfigurationRecoverer.beginConfigurationRecovery(_store, 0);
@@ -273,12 +288,29 @@ public class DurableConfigurationRecover
public ExchangeImpl answer(final InvocationOnMock invocation) throws Throwable
{
Map arguments = attributesCaptor.getValue();
- if(CUSTOM_EXCHANGE_NAME.equals(arguments.get(org.apache.qpid.server.model.Exchange.NAME))
+ String exchangeName = (String) arguments.get(org.apache.qpid.server.model.Exchange.NAME);
+ if(CUSTOM_EXCHANGE_NAME.equals(exchangeName)
&& HeadersExchange.TYPE.getType().equals(arguments.get(org.apache.qpid.server.model.Exchange.TYPE))
- && customExchangeId.equals(arguments.get(org.apache.qpid.server.model.Exchange.ID)))
+ && customExchangeId.equals((UUID) arguments.get(org.apache.qpid.server.model.Exchange.ID)))
{
return customExchange;
}
+ else if ("amq.topic".equals(exchangeName))
+ {
+ return _topicExchange;
+ }
+ else if ("amq.direct".equals(exchangeName))
+ {
+ return _directExchange;
+ }
+ else if ("amq.fanout".equals(exchangeName))
+ {
+ return _fanoutExchange;
+ }
+ else if ("amq.match".equals(exchangeName))
+ {
+ return _matchExchange;
+ }
else
{
return null;
@@ -406,12 +438,29 @@ public class DurableConfigurationRecover
public ExchangeImpl answer(final InvocationOnMock invocation) throws Throwable
{
Map arguments = attributesCaptor.getValue();
- if(CUSTOM_EXCHANGE_NAME.equals(arguments.get(org.apache.qpid.server.model.Exchange.NAME))
+ String exchangeName = (String) arguments.get(org.apache.qpid.server.model.Exchange.NAME);
+ if(CUSTOM_EXCHANGE_NAME.equals(exchangeName)
&& HeadersExchange.TYPE.getType().equals(arguments.get(org.apache.qpid.server.model.Exchange.TYPE))
&& exchangeId.equals(arguments.get(org.apache.qpid.server.model.Exchange.ID)))
{
return customExchange;
}
+ else if ("amq.topic".equals(exchangeName))
+ {
+ return _topicExchange;
+ }
+ else if ("amq.direct".equals(exchangeName))
+ {
+ return _directExchange;
+ }
+ else if ("amq.fanout".equals(exchangeName))
+ {
+ return _fanoutExchange;
+ }
+ else if ("amq.match".equals(exchangeName))
+ {
+ return _matchExchange;
+ }
else
{
return null;
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java Thu Apr 3 19:58:53 2014
@@ -23,7 +23,6 @@ package org.apache.qpid.server.virtualho
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.connection.IConnectionRegistry;
import org.apache.qpid.server.exchange.ExchangeImpl;
@@ -73,11 +72,6 @@ public class MockVirtualHost implements
return null;
}
- public VirtualHostConfiguration getConfiguration()
- {
- return null;
- }
-
public IConnectionRegistry getConnectionRegistry()
{
return null;
@@ -370,4 +364,10 @@ public class MockVirtualHost implements
{
return null;
}
+
+ @Override
+ public boolean getDefaultDeadLetterQueueEnabled()
+ {
+ return false;
+ }
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory Thu Apr 3 19:58:53 2014
@@ -17,3 +17,4 @@
# under the License.
#
org.apache.qpid.server.store.TestMemoryMessageStoreFactory
+org.apache.qpid.server.store.TestableMemoryMessageStoreFactory
\ No newline at end of file
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java (from r1580888, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java&r1=1580888&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AccessControlProviderAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProvider.java Thu Apr 3 19:58:53 2014
@@ -18,74 +18,66 @@
* under the License.
*
*/
-package org.apache.qpid.server.model.adapter;
+package org.apache.qpid.server.security.access.plugins;
import java.security.AccessControlException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import java.util.Map;
-import java.util.UUID;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.log4j.Logger;
import org.apache.qpid.server.model.*;
-import org.apache.qpid.server.plugin.AccessControlFactory;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
+import org.apache.qpid.server.plugin.AccessControlProviderFactory;
import org.apache.qpid.server.security.AccessControl;
import org.apache.qpid.server.security.access.Operation;
import org.apache.qpid.server.util.MapValueConverter;
-public class AccessControlProviderAdapter extends AbstractConfiguredObject<AccessControlProviderAdapter> implements AccessControlProvider<AccessControlProviderAdapter>
+@ManagedObject( category = false, type="AclFile" )
+public class ACLFileAccessControlProvider
+ extends AbstractConfiguredObject<ACLFileAccessControlProvider>
+ implements AccessControlProvider<ACLFileAccessControlProvider>
{
- private static final Logger LOGGER = Logger.getLogger(AccessControlProviderAdapter.class);
+ private static final Logger LOGGER = Logger.getLogger(ACLFileAccessControlProvider.class);
- protected AccessControl _accessControl;
+ protected DefaultAccessControl _accessControl;
protected final Broker _broker;
- protected Collection<String> _supportedAttributes;
- protected Map<String, AccessControlFactory> _factories;
+ protected Map<String, AccessControlProviderFactory> _factories;
private AtomicReference<State> _state;
- public AccessControlProviderAdapter(UUID id, Broker broker, AccessControl accessControl, Map<String, Object> attributes, Collection<String> attributeNames)
+ @ManagedAttributeField
+ private String _path;
+
+ @ManagedAttributeField
+ private String _type;
+
+ public ACLFileAccessControlProvider(Broker broker,
+ Map<String, Object> attributes)
{
- super(id, Collections.<String,Object>emptyMap(), Collections.singletonMap(NAME,attributes.get(NAME)), broker.getTaskExecutor());
+ super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, broker),
+ Collections.<String,Object>emptyMap(), attributes, broker.getTaskExecutor());
- if (accessControl == null)
- {
- throw new IllegalArgumentException("AccessControl must not be null");
- }
- _accessControl = accessControl;
+ _accessControl = new DefaultAccessControl(getPath(), broker);
_broker = broker;
- _supportedAttributes = createSupportedAttributes(attributeNames);
- addParent(Broker.class, broker);
State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING);
_state = new AtomicReference<State>(state);
- // set attributes now after all attribute names are known
- if (attributes != null)
- {
- for (String name : _supportedAttributes)
- {
- if (attributes.containsKey(name))
- {
- changeAttribute(name, null, attributes.get(name));
- }
- }
- }
}
- protected Collection<String> createSupportedAttributes(Collection<String> factoryAttributes)
+ @ManagedAttribute( automate = true, mandatory = true )
+ public String getPath()
{
- List<String> attributesNames = new ArrayList<String>(getAttributeNames(AccessControlProvider.class));
- if (factoryAttributes != null)
- {
- attributesNames.addAll(factoryAttributes);
- }
+ return _path;
+ }
- return Collections.unmodifiableCollection(attributesNames);
+ @ManagedAttribute( automate = true )
+ public String getType()
+ {
+ return _type;
}
@Override
@@ -128,7 +120,7 @@ public class AccessControlProviderAdapte
@Override
public Collection<String> getAttributeNames()
{
- return _supportedAttributes;
+ return getAttributeNames(getClass());
}
@Override
@@ -138,10 +130,6 @@ public class AccessControlProviderAdapte
{
return true;
}
- else if(ID.equals(name))
- {
- return getId();
- }
else if(LIFETIME_POLICY.equals(name))
{
return LifetimePolicy.PERMANENT;
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java (from r1580888, qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java&p1=qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java&r1=1580888&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactory.java Thu Apr 3 19:58:53 2014
@@ -20,62 +20,34 @@
*/
package org.apache.qpid.server.security.access.plugins;
-import static org.apache.qpid.server.security.access.FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE;
-import static org.apache.qpid.server.security.access.FileAccessControlProviderConstants.PATH;
-import static org.apache.qpid.server.util.MapValueConverter.getStringAttribute;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.logging.EventLogger;
-import org.apache.qpid.server.logging.EventLoggerProvider;
-import org.apache.qpid.server.plugin.AccessControlFactory;
-import org.apache.qpid.server.security.AccessControl;
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.plugin.AccessControlProviderFactory;
import org.apache.qpid.server.util.ResourceBundleLoader;
-public class DefaultAccessControlFactory implements AccessControlFactory
+import java.util.Map;
+
+public class ACLFileAccessControlProviderFactory extends AbstractConfiguredObjectTypeFactory<ACLFileAccessControlProvider> implements AccessControlProviderFactory<ACLFileAccessControlProvider>
{
public static final String RESOURCE_BUNDLE = "org.apache.qpid.server.security.access.plugins.FileAccessControlProviderAttributeDescriptions";
- public static final Collection<String> ATTRIBUTES = Collections.<String> unmodifiableList(Arrays.asList(
- ATTRIBUTE_TYPE,
- PATH
- ));
-
- public AccessControl createInstance(Map<String, Object> attributes, final EventLoggerProvider eventLogger)
+ public ACLFileAccessControlProviderFactory()
{
- if(attributes == null || !ACL_FILE_PROVIDER_TYPE.equals(attributes.get(ATTRIBUTE_TYPE)))
- {
- return null;
- }
-
- String path = getStringAttribute(PATH, attributes, null);
- if (path == null || "".equals(path.trim()))
- {
- throw new IllegalConfigurationException("Path to ACL was not specified!");
- }
-
- return new DefaultAccessControl(path, eventLogger);
+ super(ACLFileAccessControlProvider.class);
}
@Override
- public String getType()
+ public Map<String, String> getAttributeDescriptions()
{
- return ACL_FILE_PROVIDER_TYPE;
+ return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
}
@Override
- public Collection<String> getAttributeNames()
+ public ACLFileAccessControlProvider createInstance(final Map<String, Object> attributes,
+ final ConfiguredObject<?>... parents)
{
- return ATTRIBUTES;
+ return new ACLFileAccessControlProvider(getParent(Broker.class,parents), attributes);
}
- @Override
- public Map<String, String> getAttributeDescriptions()
- {
- return ResourceBundleLoader.getResources(RESOURCE_BUNDLE);
- }
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControl.java Thu Apr 3 19:58:53 2014
@@ -29,7 +29,6 @@ import java.util.Set;
import javax.security.auth.Subject;
-import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.lang.ObjectUtils;
import org.apache.log4j.Logger;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
@@ -64,7 +63,7 @@ public class DefaultAccessControl implem
_aclFile = new File(fileName);
}
- DefaultAccessControl(RuleSet rs) throws ConfigurationException
+ DefaultAccessControl(RuleSet rs)
{
_ruleSet = rs;
_eventLogger = rs;
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AccessControlProviderFactory (from r1580888, qpid/trunk/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AccessControlFactory)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AccessControlProviderFactory?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AccessControlProviderFactory&p1=qpid/trunk/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AccessControlFactory&r1=1580888&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AccessControlFactory (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.AccessControlProviderFactory Thu Apr 3 19:58:53 2014
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.qpid.server.security.access.plugins.DefaultAccessControlFactory
+org.apache.qpid.server.security.access.plugins.ACLFileAccessControlProviderFactory
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory Thu Apr 3 19:58:53 2014
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.qpid.server.security.access.plugins.ACLFileAccessControlProviderFactory
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/config/PlainConfigurationTest.java Thu Apr 3 19:58:53 2014
@@ -36,12 +36,6 @@ import org.apache.qpid.server.security.a
import static org.mockito.Mockito.mock;
-/**
- * These tests check that the ACL file parsing works correctly.
- *
- * For each message that can be returned in a {@link ConfigurationException}, an ACL file is created that should trigger this
- * particular message.
- */
public class PlainConfigurationTest extends TestCase
{
private PlainConfiguration writeACLConfig(String...aclData) throws Exception
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java (from r1580888, qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java&p1=qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java&r1=1580888&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlFactoryTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/ACLFileAccessControlProviderFactoryTest.java Thu Apr 3 19:58:53 2014
@@ -23,11 +23,13 @@ package org.apache.qpid.server.security.
import java.io.File;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import java.util.regex.Pattern;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.logging.EventLoggerProvider;
+import org.apache.qpid.server.model.AccessControlProvider;
+import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.GroupProvider;
import org.apache.qpid.server.security.AccessControl;
import org.apache.qpid.server.security.access.FileAccessControlProviderConstants;
@@ -36,25 +38,36 @@ import org.apache.qpid.test.utils.TestFi
import static org.mockito.Mockito.mock;
-public class DefaultAccessControlFactoryTest extends QpidTestCase
+public class ACLFileAccessControlProviderFactoryTest extends QpidTestCase
{
public void testCreateInstanceWhenAclFileIsNotPresent()
{
- DefaultAccessControlFactory factory = new DefaultAccessControlFactory();
+ ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
- AccessControl acl = factory.createInstance(attributes, mock(EventLoggerProvider.class));
- assertNull("ACL was created without a configuration file", acl);
+ attributes.put(AccessControlProvider.ID, UUID.randomUUID());
+ attributes.put(AccessControlProvider.NAME, "acl");
+ try
+ {
+ AccessControlProvider acl = factory.create(attributes, mock(Broker.class));
+ fail("ACL was created without a configuration file path specified");
+ }
+ catch(IllegalArgumentException e)
+ {
+ // pass
+ }
}
public void testCreateInstanceWhenAclFileIsSpecified()
{
File aclFile = TestFileUtils.createTempFile(this, ".acl", "ACL ALLOW all all");
- DefaultAccessControlFactory factory = new DefaultAccessControlFactory();
+ ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(AccessControlProvider.ID, UUID.randomUUID());
+ attributes.put(AccessControlProvider.NAME, "acl");
attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath());
- AccessControl acl = factory.createInstance(attributes, mock(EventLoggerProvider.class));
- acl.open();
+ AccessControlProvider acl = factory.create(attributes, mock(Broker.class));
+ acl.getAccessControl().open();
assertNotNull("ACL was not created from acl file: " + aclFile.getAbsolutePath(), acl);
}
@@ -63,14 +76,16 @@ public class DefaultAccessControlFactory
{
File aclFile = new File(TMP_FOLDER, "my-non-existing-acl-" + System.currentTimeMillis());
assertFalse("ACL file " + aclFile.getAbsolutePath() + " actually exists but should not", aclFile.exists());
- DefaultAccessControlFactory factory = new DefaultAccessControlFactory();
+ ACLFileAccessControlProviderFactory factory = new ACLFileAccessControlProviderFactory();
Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(AccessControlProvider.ID, UUID.randomUUID());
+ attributes.put(AccessControlProvider.NAME, "acl");
attributes.put(GroupProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
attributes.put(FileAccessControlProviderConstants.PATH, aclFile.getAbsolutePath());
try
{
- AccessControl control = factory.createInstance(attributes, mock(EventLoggerProvider.class));
- control.open();
+ AccessControlProvider control = factory.create(attributes, mock(Broker.class));
+ control.getAccessControl().open();
fail("It should not be possible to create and initialise ACL with non existing file");
}
catch (IllegalConfigurationException e)
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/access-control/src/test/java/org/apache/qpid/server/security/access/plugins/DefaultAccessControlTest.java Thu Apr 3 19:58:53 2014
@@ -33,7 +33,6 @@ import javax.security.auth.Subject;
import junit.framework.TestCase;
-import org.apache.commons.configuration.ConfigurationException;
import org.apache.qpid.server.connection.ConnectionPrincipal;
import org.apache.qpid.server.logging.EventLogger;
import org.apache.qpid.server.logging.EventLoggerProvider;
@@ -70,12 +69,12 @@ public class DefaultAccessControlTest ex
_plugin = null;
}
- private void setUpGroupAccessControl() throws ConfigurationException
+ private void setUpGroupAccessControl()
{
configureAccessControl(createGroupRuleSet());
}
- private void configureAccessControl(final RuleSet rs) throws ConfigurationException
+ private void configureAccessControl(final RuleSet rs)
{
_plugin = new DefaultAccessControl(rs);
}
@@ -100,7 +99,7 @@ public class DefaultAccessControlTest ex
/**
* ACL plugin must always abstain if there is no subject attached to the thread.
*/
- public void testNoSubjectAlwaysAbstains() throws ConfigurationException
+ public void testNoSubjectAlwaysAbstains()
{
setUpGroupAccessControl();
final Result result = _plugin.authorise(Operation.ACCESS, ObjectType.VIRTUALHOST, ObjectProperties.EMPTY);
@@ -111,7 +110,7 @@ public class DefaultAccessControlTest ex
* Tests that an allow rule expressed with a username allows an operation performed by a thread running
* with the same username.
*/
- public void testUsernameAllowsOperation() throws ConfigurationException
+ public void testUsernameAllowsOperation()
{
setUpGroupAccessControl();
Subject.doAs(TestPrincipalUtils.createTestSubject("user1"), new PrivilegedAction<Object>()
@@ -130,7 +129,7 @@ public class DefaultAccessControlTest ex
* Tests that an allow rule expressed with an <b>ACL groupname</b> allows an operation performed by a thread running
* by a user who belongs to the same group..
*/
- public void testGroupMembershipAllowsOperation() throws ConfigurationException
+ public void testGroupMembershipAllowsOperation()
{
setUpGroupAccessControl();
@@ -143,7 +142,7 @@ public class DefaultAccessControlTest ex
* Tests that a deny rule expressed with a <b>groupname</b> denies an operation performed by a thread running
* by a user who belongs to the same group.
*/
- public void testGroupMembershipDeniesOperation() throws ConfigurationException
+ public void testGroupMembershipDeniesOperation()
{
setUpGroupAccessControl();
authoriseAndAssertResult(Result.DENIED, "user3", DENIED_GROUP);
@@ -152,7 +151,7 @@ public class DefaultAccessControlTest ex
/**
* Tests that the catch all deny denies the operation and logs with the logging actor.
*/
- public void testCatchAllRuleDeniesUnrecognisedUsername() throws ConfigurationException
+ public void testCatchAllRuleDeniesUnrecognisedUsername()
{
setUpGroupAccessControl();
Subject.doAs(TestPrincipalUtils.createTestSubject("unknown", "unkgroup1", "unkgroup2"),
@@ -179,7 +178,7 @@ public class DefaultAccessControlTest ex
/**
* Tests that a grant access method rule allows any access operation to be performed on any component
*/
- public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnAllComponents() throws ConfigurationException
+ public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnAllComponents()
{
final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
@@ -205,7 +204,7 @@ public class DefaultAccessControlTest ex
/**
* Tests that a grant access method rule allows any access operation to be performed on a specified component
*/
- public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+ public void testAuthoriseAccessMethodWhenAllAccessOperationsAllowedOnSpecifiedComponent()
{
final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
@@ -305,7 +304,7 @@ public class DefaultAccessControlTest ex
/**
* Tests that a grant access method rule allows any access operation to be performed on a specified component
*/
- public void testAuthoriseAccessMethodWhenSpecifiedAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+ public void testAuthoriseAccessMethodWhenSpecifiedAccessOperationsAllowedOnSpecifiedComponent()
{
final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
@@ -342,7 +341,7 @@ public class DefaultAccessControlTest ex
/**
* Tests that granting of all method rights on a method allows a specified operation to be performed on any component
*/
- public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnSpecifiedMethodForAllComponents() throws ConfigurationException
+ public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnSpecifiedMethodForAllComponents()
{
final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
@@ -381,7 +380,7 @@ public class DefaultAccessControlTest ex
/**
* Tests that granting of all method rights allows any operation to be performed on any component
*/
- public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnAllMethodsInAllComponents() throws ConfigurationException
+ public void testAuthoriseAccessUpdateMethodWhenAllRightsGrantedOnAllMethodsInAllComponents()
{
final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
@@ -419,7 +418,7 @@ public class DefaultAccessControlTest ex
/**
* Tests that granting of access method rights with mask allows matching operations to be performed on the specified component
*/
- public void testAuthoriseAccessMethodWhenMatchingAccessOperationsAllowedOnSpecifiedComponent() throws ConfigurationException
+ public void testAuthoriseAccessMethodWhenMatchingAccessOperationsAllowedOnSpecifiedComponent()
{
final RuleSet rs = new RuleSet(mock(EventLoggerProvider.class));
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java Thu Apr 3 19:58:53 2014
@@ -32,14 +32,13 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+
import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.AbstractJDBCMessageStore;
import org.apache.qpid.server.store.DurableConfigurationStore;
import org.apache.qpid.server.store.Event;
-import org.apache.qpid.server.store.EventListener;
import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreConstants;
import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.util.FileUtils;
@@ -124,19 +123,17 @@ public class DerbyMessageStore extends A
}
@Override
- protected void implementationSpecificConfiguration(String name,
- VirtualHost virtualHost)
+ protected void implementationSpecificConfiguration(String name, Map<String, Object> messageStoreSettings)
throws ClassNotFoundException
{
//Update to pick up QPID_WORK and use that as the default location not just derbyDB
-
_driverClass = (Class<Driver>) Class.forName(SQL_DRIVER_NAME);
- String defaultPath = System.getProperty("QPID_WORK") + File.separator + "derbyDB";
- String databasePath = isConfigStoreOnly() ? (String) virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH) : (String) virtualHost.getAttribute(VirtualHost.STORE_PATH);
+ String databasePath = (String) messageStoreSettings.get(MessageStore.STORE_PATH);;
+
if(databasePath == null)
{
- databasePath = defaultPath;
+ databasePath = System.getProperty("QPID_WORK") + File.separator + "derbyDB";
}
if(!MEMORY_STORE_LOCATION.equals(databasePath))
@@ -154,8 +151,8 @@ public class DerbyMessageStore extends A
_storeLocation = databasePath;
- Object overfullAttr = virtualHost.getAttribute(MessageStoreConstants.OVERFULL_SIZE_ATTRIBUTE);
- Object underfullAttr = virtualHost.getAttribute(MessageStoreConstants.UNDERFULL_SIZE_ATTRIBUTE);
+ Object overfullAttr = messageStoreSettings.get(MessageStore.OVERFULL_SIZE);
+ Object underfullAttr = messageStoreSettings.get(MessageStore.UNDERFULL_SIZE);
_persistentSizeHighThreshold = overfullAttr == null ? -1l :
overfullAttr instanceof Number ? ((Number) overfullAttr).longValue() : Long.parseLong(overfullAttr.toString());
@@ -170,16 +167,7 @@ public class DerbyMessageStore extends A
//FIXME this the _vhost name should not be added here, but derby wont use an empty directory as was possibly just created.
_connectionURL = "jdbc:derby" + (databasePath.equals(MEMORY_STORE_LOCATION) ? databasePath: ":" + databasePath+ "/") + name + ";create=true";
-
-
- _eventManager.addEventListener(new EventListener()
- {
- @Override
- public void event(Event event)
- {
- setInitialSize();
- }
- }, Event.BEFORE_ACTIVATE);
+ setInitialSize();
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java Thu Apr 3 19:58:53 2014
@@ -20,9 +20,8 @@
*/
package org.apache.qpid.server.store.derby;
-import java.util.Collections;
import java.util.Map;
-import org.apache.commons.configuration.Configuration;
+
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory;
import org.apache.qpid.server.plugin.MessageStoreFactory;
@@ -51,31 +50,30 @@ public class DerbyMessageStoreFactory im
}
@Override
- public Map<String, Object> convertStoreConfiguration(Configuration configuration)
- {
- return Collections.emptyMap();
- }
-
-
- @Override
public void validateAttributes(Map<String, Object> attributes)
{
- if(getType().equals(attributes.get(VirtualHost.STORE_TYPE)))
+ @SuppressWarnings("unchecked")
+ Map<String, Object> messageStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.MESSAGE_STORE_SETTINGS);
+
+ if(getType().equals(messageStoreSettings.get(MessageStore.STORE_TYPE)))
{
- Object storePath = attributes.get(VirtualHost.STORE_PATH);
+ Object storePath = messageStoreSettings.get(MessageStore.STORE_PATH);
if(!(storePath instanceof String))
{
- throw new IllegalArgumentException("Attribute '"+ VirtualHost.STORE_PATH
+ throw new IllegalArgumentException("Setting '"+ MessageStore.STORE_PATH
+"' is required and must be of type String.");
}
}
- if(getType().equals(attributes.get(VirtualHost.CONFIG_STORE_TYPE)))
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> configurationStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.CONFIGURATION_STORE_SETTINGS);
+ if(configurationStoreSettings != null && getType().equals(configurationStoreSettings.get(DurableConfigurationStore.STORE_TYPE)))
{
- Object storePath = attributes.get(VirtualHost.CONFIG_STORE_PATH);
+ Object storePath = configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH);
if(!(storePath instanceof String))
{
- throw new IllegalArgumentException("Attribute '"+ VirtualHost.CONFIG_STORE_PATH
+ throw new IllegalArgumentException("Setting '"+ DurableConfigurationStore.STORE_PATH
+"' is required and must be of type String.");
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreConfigurationTest.java Thu Apr 3 19:58:53 2014
@@ -25,48 +25,10 @@ import org.apache.qpid.server.store.Abst
public class DerbyMessageStoreConfigurationTest extends AbstractDurableConfigurationStoreTestCase
{
- private DerbyMessageStore _derbyMessageStore;
-
- @Override
- protected DerbyMessageStore createMessageStore() throws Exception
- {
- createStoreIfNecessary();
- return _derbyMessageStore;
- }
-
- @Override
- protected void closeMessageStore() throws Exception
- {
- closeStoreIfNecessary();
- }
-
- private void createStoreIfNecessary()
- {
- if(_derbyMessageStore == null)
- {
- _derbyMessageStore = new DerbyMessageStore();
- }
- }
-
@Override
protected DerbyMessageStore createConfigStore() throws Exception
{
- createStoreIfNecessary();
- return _derbyMessageStore;
+ return new DerbyMessageStore();
}
- @Override
- protected void closeConfigStore() throws Exception
- {
- closeStoreIfNecessary();
- }
-
- private void closeStoreIfNecessary() throws Exception
- {
- if (_derbyMessageStore != null)
- {
- _derbyMessageStore.close();
- _derbyMessageStore = null;
- }
- }
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreQuotaEventsTest.java Thu Apr 3 19:58:53 2014
@@ -20,15 +20,13 @@
*/
package org.apache.qpid.server.store.derby;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
-import org.apache.qpid.server.store.MessageStoreConstants;
import org.apache.qpid.server.store.MessageStoreQuotaEventsTestBase;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
public class DerbyMessageStoreQuotaEventsTest extends MessageStoreQuotaEventsTestBase
{
private static final Logger _logger = Logger.getLogger(DerbyMessageStoreQuotaEventsTest.class);
@@ -50,17 +48,21 @@ public class DerbyMessageStoreQuotaEvent
}
@Override
- protected void applyStoreSpecificConfiguration(VirtualHost vhost)
+ protected MessageStore createStore() throws Exception
{
- _logger.debug("Applying store specific config. overfull-sze=" + OVERFULL_SIZE + ", underfull-size=" + UNDERFULL_SIZE);
-
- when(vhost.getAttribute(eq(MessageStoreConstants.OVERFULL_SIZE_ATTRIBUTE))).thenReturn(OVERFULL_SIZE);
- when(vhost.getAttribute(eq(MessageStoreConstants.UNDERFULL_SIZE_ATTRIBUTE))).thenReturn(UNDERFULL_SIZE);
+ return new DerbyMessageStore();
}
@Override
- protected MessageStore createStore() throws Exception
+ protected Map<String, Object> createStoreSettings(String storeLocation)
{
- return new DerbyMessageStore();
+ _logger.debug("Applying store specific config. overfull-size=" + OVERFULL_SIZE + ", underfull-size=" + UNDERFULL_SIZE);
+
+ Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+ messageStoreSettings.put(MessageStore.STORE_PATH, storeLocation);
+ messageStoreSettings.put(MessageStore.OVERFULL_SIZE, OVERFULL_SIZE);
+ messageStoreSettings.put(MessageStore.UNDERFULL_SIZE, UNDERFULL_SIZE);
+ return messageStoreSettings;
}
+
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/derby-store/src/test/java/org/apache/qpid/server/store/derby/DerbyMessageStoreTest.java Thu Apr 3 19:58:53 2014
@@ -20,16 +20,15 @@
*/
package org.apache.qpid.server.store.derby;
+
import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.MessageStoreTestCase;
import org.apache.qpid.util.FileUtils;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
public class DerbyMessageStoreTest extends MessageStoreTestCase
{
private String _storeLocation;
@@ -52,7 +51,7 @@ public class DerbyMessageStoreTest exten
File location = new File(_storeLocation);
assertTrue("Store does not exist at " + _storeLocation, location.exists());
- getStore().close();
+ getStore().closeMessageStore();
assertTrue("Store does not exist at " + _storeLocation, location.exists());
getStore().onDelete();
@@ -60,11 +59,13 @@ public class DerbyMessageStoreTest exten
}
@Override
- protected void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception
+ protected Map<String, Object> getStoreSettings() throws Exception
{
_storeLocation = TMP_FOLDER + File.separator + getTestName();
- when(virtualHost.getAttribute(eq(VirtualHost.STORE_PATH))).thenReturn(_storeLocation);
deleteStoreIfExists();
+ Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+ messageStoreSettings.put(MessageStore.STORE_PATH, _storeLocation);
+ return messageStoreSettings;
}
private void deleteStoreIfExists()
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java Thu Apr 3 19:58:53 2014
@@ -22,56 +22,35 @@ package org.apache.qpid.server.store.jdb
import com.jolbox.bonecp.BoneCP;
import com.jolbox.bonecp.BoneCPConfig;
+import org.apache.qpid.server.store.jdbc.ConnectionProvider;
+import org.apache.qpid.server.util.MapValueConverter;
+
import java.sql.Connection;
import java.sql.SQLException;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.store.jdbc.ConnectionProvider;
+import java.util.Map;
public class BoneCPConnectionProvider implements ConnectionProvider
{
+ public static final String PARTITION_COUNT = "partitionCount";
+ public static final String MAX_CONNECTIONS_PER_PARTITION = "maxConnectionsPerPartition";
+ public static final String MIN_CONNECTIONS_PER_PARTITION = "minConnectionsPerPartition";
+
public static final int DEFAULT_MIN_CONNECTIONS_PER_PARTITION = 5;
public static final int DEFAULT_MAX_CONNECTIONS_PER_PARTITION = 10;
public static final int DEFAULT_PARTITION_COUNT = 4;
+
private final BoneCP _connectionPool;
- public BoneCPConnectionProvider(String connectionUrl, VirtualHost virtualHost) throws SQLException
+ public BoneCPConnectionProvider(String connectionUrl, Map<String, Object> storeSettings) throws SQLException
{
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl(connectionUrl);
-
-
- config.setMinConnectionsPerPartition(getIntegerAttribute(virtualHost, "minConnectionsPerPartition", DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
- config.setMaxConnectionsPerPartition(getIntegerAttribute(virtualHost, "maxConnectionsPerPartition", DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
- config.setPartitionCount(getIntegerAttribute(virtualHost, "partitionCount",DEFAULT_PARTITION_COUNT));
+ config.setMinConnectionsPerPartition(MapValueConverter.getIntegerAttribute(MIN_CONNECTIONS_PER_PARTITION, storeSettings, DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
+ config.setMaxConnectionsPerPartition(MapValueConverter.getIntegerAttribute(MAX_CONNECTIONS_PER_PARTITION, storeSettings, DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
+ config.setPartitionCount(MapValueConverter.getIntegerAttribute(PARTITION_COUNT, storeSettings, DEFAULT_PARTITION_COUNT));
_connectionPool = new BoneCP(config);
}
- private int getIntegerAttribute(VirtualHost virtualHost, String attributeName, int defaultVal)
- {
- Object attrValue = virtualHost.getAttribute(attributeName);
- if(attrValue != null)
- {
- if(attrValue instanceof Number)
- {
- return ((Number) attrValue).intValue();
- }
- else if(attrValue instanceof String)
- {
- try
- {
- return Integer.parseInt((String)attrValue);
- }
- catch (NumberFormatException e)
- {
- return defaultVal;
- }
- }
-
- }
- return defaultVal;
- }
-
@Override
public Connection getConnection() throws SQLException
{
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java Thu Apr 3 19:58:53 2014
@@ -21,8 +21,8 @@
package org.apache.qpid.server.store.jdbc.bonecp;
import java.sql.SQLException;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
+
import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
import org.apache.qpid.server.store.jdbc.ConnectionProvider;
@@ -34,10 +34,9 @@ public class BoneCPConnectionProviderFac
return "BONECP";
}
- @Override
- public ConnectionProvider getConnectionProvider(String connectionUrl, VirtualHost virtualHost)
+ public ConnectionProvider getConnectionProvider(String connectionUrl, Map<String, Object> storeSettings)
throws SQLException
{
- return new BoneCPConnectionProvider(connectionUrl, virtualHost);
+ return new BoneCPConnectionProvider(connectionUrl, storeSettings);
}
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProviderFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProviderFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/DefaultConnectionProviderFactory.java Thu Apr 3 19:58:53 2014
@@ -20,21 +20,23 @@
*/
package org.apache.qpid.server.store.jdbc;
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
+
import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
public class DefaultConnectionProviderFactory implements JDBCConnectionProviderFactory
{
+ public static final String TYPE = "DEFAULT";
+
@Override
public String getType()
{
- return "NONE";
+ return TYPE;
}
@Override
- public ConnectionProvider getConnectionProvider(String connectionUrl,
- VirtualHost virtualHost)
+ public ConnectionProvider getConnectionProvider(String connectionUrl, Map<String, Object> settings)
{
return new DefaultConnectionProvider(connectionUrl);
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java Thu Apr 3 19:58:53 2014
@@ -29,14 +29,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
+
import org.apache.log4j.Logger;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
import org.apache.qpid.server.store.AbstractJDBCMessageStore;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.StoreException;
import org.apache.qpid.server.store.StoreFuture;
import org.apache.qpid.server.store.Transaction;
+import org.apache.qpid.server.util.MapValueConverter;
/**
* An implementation of a {@link org.apache.qpid.server.store.MessageStore} that uses a JDBC database as the persistence
@@ -48,10 +49,13 @@ public class JDBCMessageStore extends Ab
private static final Logger _logger = Logger.getLogger(JDBCMessageStore.class);
-
public static final String TYPE = "JDBC";
public static final String CONNECTION_URL = "connectionURL";
- public static final String CONFIG_CONNECTION_URL = "configConnectionURL";
+ public static final String CONNECTION_POOL = "connectionPool";
+ public static final String JDBC_BIG_INT_TYPE = "jdbcBigIntType";
+ public static final String JDBC_BYTES_FOR_BLOB = "jdbcBytesForBlob";
+ public static final String JDBC_VARBINARY_TYPE = "jdbcVarbinaryType";
+ public static final String JDBC_BLOB_TYPE = "jdbcBlobType";
protected String _connectionURL;
private ConnectionProvider _connectionProvider;
@@ -254,18 +258,24 @@ public class JDBCMessageStore extends Ab
@Override
protected void doClose()
{
- while(!_transactions.isEmpty())
- {
- RecordedJDBCTransaction txn = _transactions.get(0);
- txn.abortTran();
- }
try
{
- _connectionProvider.close();
+ while(!_transactions.isEmpty())
+ {
+ RecordedJDBCTransaction txn = _transactions.get(0);
+ txn.abortTran();
+ }
}
- catch (SQLException e)
+ finally
{
- throw new StoreException("Unable to close connection provider ", e);
+ try
+ {
+ _connectionProvider.close();
+ }
+ catch (SQLException e)
+ {
+ throw new StoreException("Unable to close connection provider ", e);
+ }
}
}
@@ -276,28 +286,15 @@ public class JDBCMessageStore extends Ab
}
- protected void implementationSpecificConfiguration(String name,
- VirtualHost virtualHost)
+ protected void implementationSpecificConfiguration(String name, Map<String, Object> storeSettings)
throws ClassNotFoundException, SQLException
{
+ _connectionURL = String.valueOf(storeSettings.get(CONNECTION_URL));
+ Object poolAttribute = storeSettings.get(CONNECTION_POOL);
- String connectionURL;
- if(!isConfigStoreOnly())
- {
- connectionURL = virtualHost.getAttribute(CONNECTION_URL) == null
- ? String.valueOf(virtualHost.getAttribute(VirtualHost.STORE_PATH))
- : String.valueOf(virtualHost.getAttribute(CONNECTION_URL));
- }
- else
- {
- connectionURL = virtualHost.getAttribute(CONFIG_CONNECTION_URL) == null
- ? String.valueOf(virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH))
- : String.valueOf(virtualHost.getAttribute(CONFIG_CONNECTION_URL));
-
- }
JDBCDetails details = null;
- String[] components = connectionURL.split(":",3);
+ String[] components = _connectionURL.split(":",3);
if(components.length >= 2)
{
String vendor = components[1];
@@ -306,15 +303,13 @@ public class JDBCMessageStore extends Ab
if(details == null)
{
- getLogger().info("Do not recognize vendor from connection URL: " + connectionURL);
+ getLogger().info("Do not recognize vendor from connection URL: " + _connectionURL);
// TODO - is there a better default than derby
details = DERBY_DETAILS;
}
-
- Object poolAttribute = virtualHost.getAttribute("connectionPool");
- String connectionPoolType = poolAttribute == null ? "DEFAULT" : String.valueOf(poolAttribute);
+ String connectionPoolType = poolAttribute == null ? DefaultConnectionProviderFactory.TYPE : String.valueOf(poolAttribute);
JDBCConnectionProviderFactory connectionProviderFactory =
JDBCConnectionProviderFactory.FACTORIES.get(connectionPoolType);
@@ -324,44 +319,14 @@ public class JDBCMessageStore extends Ab
connectionProviderFactory = new DefaultConnectionProviderFactory();
}
- _connectionProvider = connectionProviderFactory.getConnectionProvider(connectionURL, virtualHost);
-
- _blobType = getStringAttribute(virtualHost, "jdbcBlobType",details.getBlobType());
- _varBinaryType = getStringAttribute(virtualHost, "jdbcVarbinaryType",details.getVarBinaryType());
- _useBytesMethodsForBlob = getBooleanAttribute(virtualHost, "jdbcBytesForBlob",details.isUseBytesMethodsForBlob());
- _bigIntType = getStringAttribute(virtualHost, "jdbcBigIntType", details.getBigintType());
+ _connectionProvider = connectionProviderFactory.getConnectionProvider(_connectionURL, storeSettings);
+ _blobType = MapValueConverter.getStringAttribute(JDBC_BLOB_TYPE, storeSettings, details.getBlobType());
+ _varBinaryType = MapValueConverter.getStringAttribute(JDBC_VARBINARY_TYPE, storeSettings, details.getVarBinaryType());
+ _useBytesMethodsForBlob = MapValueConverter.getBooleanAttribute(JDBC_BYTES_FOR_BLOB, storeSettings, details.isUseBytesMethodsForBlob());
+ _bigIntType = MapValueConverter.getStringAttribute(JDBC_BIG_INT_TYPE, storeSettings, details.getBigintType());
}
-
- private String getStringAttribute(VirtualHost virtualHost, String attributeName, String defaultVal)
- {
- Object attrValue = virtualHost.getAttribute(attributeName);
- if(attrValue != null)
- {
- return attrValue.toString();
- }
- return defaultVal;
- }
-
- private boolean getBooleanAttribute(VirtualHost virtualHost, String attributeName, boolean defaultVal)
- {
- Object attrValue = virtualHost.getAttribute(attributeName);
- if(attrValue != null)
- {
- if(attrValue instanceof Boolean)
- {
- return ((Boolean) attrValue).booleanValue();
- }
- else if(attrValue instanceof String)
- {
- return Boolean.parseBoolean((String)attrValue);
- }
-
- }
- return defaultVal;
- }
-
-
+ @Override
protected void storedSizeChange(int contentSize)
{
}
@@ -369,7 +334,7 @@ public class JDBCMessageStore extends Ab
@Override
public String getStoreLocation()
{
- return "";
+ return _connectionURL;
}
@Override
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java Thu Apr 3 19:58:53 2014
@@ -20,9 +20,8 @@
*/
package org.apache.qpid.server.store.jdbc;
-import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.configuration.Configuration;
+
import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory;
import org.apache.qpid.server.plugin.MessageStoreFactory;
@@ -51,56 +50,30 @@ public class JDBCMessageStoreFactory imp
}
@Override
- public Map<String, Object> convertStoreConfiguration(Configuration storeConfiguration)
- {
- Map<String,Object> convertedMap = new HashMap<String,Object>();
- convertedMap.put("jdbcBlobType", storeConfiguration.getString("sqlBlobType"));
- convertedMap.put("jdbcVarbinaryType", storeConfiguration.getString("sqlVarbinaryType"));
- if(storeConfiguration.containsKey("useBytesForBlob"))
- {
- convertedMap.put("jdbcUseBytesForBlob", storeConfiguration.getBoolean("useBytesForBlob"));
- }
- convertedMap.put("jdbcBigIntType", storeConfiguration.getString("sqlBigIntType"));
- convertedMap.put("connectionPool", storeConfiguration.getString("pool.type"));
- convertedMap.put("minConnectionsPerPartition", storeConfiguration.getInteger("pool.minConnectionsPerPartition",
- null));
- convertedMap.put("maxConnectionsPerPartition", storeConfiguration.getInteger("pool.maxConnectionsPerPartition",
- null));
- convertedMap.put("partitionCount", storeConfiguration.getInteger("pool.partitionCount", null));
-
- return convertedMap;
- }
-
-
- @Override
public void validateAttributes(Map<String, Object> attributes)
{
- if(getType().equals(attributes.get(VirtualHost.STORE_TYPE)))
+ @SuppressWarnings("unchecked")
+ Map<String, Object> messageStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.MESSAGE_STORE_SETTINGS);
+ if(getType().equals(messageStoreSettings.get(MessageStore.STORE_TYPE)))
{
- Object connectionURL = attributes.get(JDBCMessageStore.CONNECTION_URL);
+ Object connectionURL = messageStoreSettings.get(JDBCMessageStore.CONNECTION_URL);
if(!(connectionURL instanceof String))
{
- Object storePath = attributes.get(VirtualHost.STORE_PATH);
- if(!(storePath instanceof String))
- {
- throw new IllegalArgumentException("Attribute '"+ JDBCMessageStore.CONNECTION_URL
- +"' is required and must be of type String.");
+ throw new IllegalArgumentException("Setting '"+ JDBCMessageStore.CONNECTION_URL
+ +"' is required and must be of type String.");
- }
}
}
- if(getType().equals(attributes.get(VirtualHost.CONFIG_STORE_TYPE)))
+
+ @SuppressWarnings("unchecked")
+ Map<String, Object> configurationStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.CONFIGURATION_STORE_SETTINGS);
+ if(configurationStoreSettings != null && getType().equals(configurationStoreSettings.get(DurableConfigurationStore.STORE_TYPE)))
{
- Object connectionURL = attributes.get(JDBCMessageStore.CONFIG_CONNECTION_URL);
+ Object connectionURL = configurationStoreSettings.get(JDBCMessageStore.CONNECTION_URL);
if(!(connectionURL instanceof String))
{
- Object storePath = attributes.get(VirtualHost.CONFIG_STORE_PATH);
- if(!(storePath instanceof String))
- {
- throw new IllegalArgumentException("Attribute '"+ JDBCMessageStore.CONFIG_CONNECTION_URL
- +"' is required and must be of type String.");
-
- }
+ throw new IllegalArgumentException("Setting '"+ JDBCMessageStore.CONNECTION_URL
+ +"' is required and must be of type String.");
}
}
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/jdbc-store/src/test/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreTest.java Thu Apr 3 19:58:53 2014
@@ -25,16 +25,14 @@ import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
-import org.apache.qpid.server.model.VirtualHost;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.store.MessageStoreTestCase;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.when;
-
public class JDBCMessageStoreTest extends MessageStoreTestCase
{
private String _connectionURL;
@@ -54,29 +52,31 @@ public class JDBCMessageStoreTest extend
public void testOnDelete() throws Exception
{
- String[] expectedTables = JDBCMessageStore.ALL_TABLES;
+ Set<String> expectedTables = JDBCMessageStore.MESSAGE_STORE_TABLE_NAMES;
assertTablesExist(expectedTables, true);
- getStore().close();
+ getStore().closeMessageStore();
assertTablesExist(expectedTables, true);
getStore().onDelete();
assertTablesExist(expectedTables, false);
}
@Override
- protected void setUpStoreConfiguration(VirtualHost virtualHost) throws Exception
+ protected Map<String, Object> getStoreSettings()
{
_connectionURL = "jdbc:derby:memory:/" + getTestName() + ";create=true";
-
- when(virtualHost.getAttribute(eq("connectionURL"))).thenReturn(_connectionURL);
+ Map<String, Object> messageStoreSettings = new HashMap<String, Object>();
+ messageStoreSettings.put(JDBCMessageStore.CONNECTION_URL, _connectionURL);
+ return messageStoreSettings;
}
+
@Override
protected MessageStore createMessageStore()
{
return new JDBCMessageStore();
}
- private void assertTablesExist(String[] expectedTables, boolean exists) throws SQLException
+ private void assertTablesExist(Set<String> expectedTables, boolean exists) throws SQLException
{
Set<String> existingTables = getTableNames();
for (String tableName : expectedTables)
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-amqp/src/main/java/org/apache/qpid/server/management/amqp/ManagementNode.java Thu Apr 3 19:58:53 2014
@@ -37,7 +37,7 @@ import org.apache.qpid.server.model.Conf
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.Model;
import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.adapter.AbstractConfiguredObject;
+import org.apache.qpid.server.model.AbstractConfiguredObject;
import org.apache.qpid.server.plugin.MessageConverter;
import org.apache.qpid.server.plugin.SystemNodeCreator;
import org.apache.qpid.server.protocol.AMQSessionModel;
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java Thu Apr 3 19:58:53 2014
@@ -20,17 +20,6 @@
*/
package org.apache.qpid.server.management.plugin;
-import java.lang.reflect.Type;
-import java.net.SocketAddress;
-import java.security.GeneralSecurityException;
-import java.util.*;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import javax.servlet.DispatcherType;
-
import org.apache.log4j.Logger;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.logging.messages.ManagementConsoleMessages;
@@ -39,21 +28,10 @@ import org.apache.qpid.server.management
import org.apache.qpid.server.management.plugin.servlet.DefinedFileServlet;
import org.apache.qpid.server.management.plugin.servlet.FileServlet;
import org.apache.qpid.server.management.plugin.servlet.LogFileServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.HelperServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.LogFileListingServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.LogRecordsServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.LogoutServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.MessageContentServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.MessageServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.LoggedOnUserPreferencesServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.UserPreferencesServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.RestServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.SaslServlet;
-import org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet;
+import org.apache.qpid.server.management.plugin.servlet.rest.*;
import org.apache.qpid.server.model.*;
import org.apache.qpid.server.model.Queue;
import org.apache.qpid.server.model.adapter.AbstractPluginAdapter;
-import org.apache.qpid.server.plugin.PluginFactory;
import org.apache.qpid.server.util.MapValueConverter;
import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager;
@@ -67,6 +45,17 @@ import org.eclipse.jetty.servlet.Servlet
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.ssl.SslContextFactory;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+import javax.servlet.DispatcherType;
+import java.lang.reflect.Type;
+import java.net.SocketAddress;
+import java.security.GeneralSecurityException;
+import java.util.*;
+
+@ManagedObject( category = false, type = "MANAGEMENT-HTTP" )
public class HttpManagement extends AbstractPluginAdapter<HttpManagement> implements HttpManagementConfiguration<HttpManagement>
{
private final Logger _logger = Logger.getLogger(HttpManagement.class);
@@ -109,7 +98,7 @@ public class HttpManagement extends Abst
put(HTTPS_SASL_AUTHENTICATION_ENABLED, Boolean.class);
put(NAME, String.class);
put(TIME_OUT, Integer.class);
- put(PluginFactory.PLUGIN_TYPE, String.class);
+ put(TYPE, String.class);
}});
private static final String JSESSIONID_COOKIE_PREFIX = "JSESSIONID_";
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagementConfiguration.java Thu Apr 3 19:58:53 2014
@@ -25,6 +25,7 @@ import java.net.SocketAddress;
import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.ManagedObject;
import org.apache.qpid.server.model.Plugin;
public interface HttpManagementConfiguration<X extends HttpManagementConfiguration<X>> extends Plugin<X>
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org