qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1584931 [7/7] - in /qpid/trunk/qpid/java: ./ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/ bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ bdbstore/src/main/java/org/apache/qpid/server/store/be...
Date Fri, 04 Apr 2014 22:34:30 GMT
Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/destination/AddressBasedDestinationTest.java
Fri Apr  4 22:34:26 2014
@@ -20,8 +20,34 @@
  */
 package org.apache.qpid.test.client.destination;
 
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jms.Connection;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.QueueBrowser;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.jms.Topic;
+import javax.jms.TopicSession;
+import javax.jms.TopicSubscriber;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.client.AMQAnyDestination;
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
@@ -35,17 +61,6 @@ import org.apache.qpid.test.utils.QpidBr
 import org.apache.qpid.test.utils.TestBrokerConfiguration;
 import org.apache.qpid.transport.ExecutionErrorCode;
 
-import javax.jms.*;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 public class AddressBasedDestinationTest extends QpidBrokerTestCase
 {
     private static final Logger _logger = LoggerFactory.getLogger(AddressBasedDestinationTest.class);
@@ -55,7 +70,7 @@ public class AddressBasedDestinationTest
     public void setUp() throws Exception
     {
         TestBrokerConfiguration config = getBrokerConfiguration();
-        config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST, VirtualHost.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS,
0);
+        config.setObjectAttribute(VirtualHost.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST,
VirtualHost.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, 0);
 
         super.setUp();
         _connection = getConnection() ;

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
Fri Apr  4 22:34:26 2014
@@ -31,13 +31,14 @@ import javax.jms.MessageProducer;
 import javax.jms.Queue;
 import javax.jms.Session;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.qpid.server.model.VirtualHost;
 import org.apache.qpid.server.store.MessageStore;
 import org.apache.qpid.server.store.SlowMessageStore;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 import org.apache.qpid.test.utils.TestBrokerConfiguration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * This tests that when the commit takes a long time(due to POST_COMMIT_DELAY) that the commit
does not timeout
@@ -66,7 +67,7 @@ public class SyncWaitDelayTest extends Q
         messageStoreSettings.put(SlowMessageStore.DELAYS, slowMessageStoreDelays);
 
         TestBrokerConfiguration config = getBrokerConfiguration();
-        config.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST, VirtualHost.MESSAGE_STORE_SETTINGS,
messageStoreSettings);
+        config.setObjectAttribute(VirtualHost.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST,
VirtualHost.MESSAGE_STORE_SETTINGS, messageStoreSettings);
 
         super.setUp();
 

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
Fri Apr  4 22:34:26 2014
@@ -17,36 +17,6 @@
  */
 package org.apache.qpid.test.utils;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.BytesMessage;
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.qpid.AMQException;
@@ -71,6 +41,23 @@ import org.apache.qpid.url.URLSyntaxExce
 import org.apache.qpid.util.FileUtils;
 import org.apache.qpid.util.SystemUtils;
 
+import javax.jms.*;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.lang.IllegalStateException;
+
 /**
  * Qpid base class for system testing test cases.
  */
@@ -232,17 +219,17 @@ public class QpidBrokerTestCase extends 
         }
         if (actualPort != DEFAULT_PORT)
         {
-            configuration.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT,
Port.PORT, actualPort);
-            configuration.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_RMI_PORT,
Port.PORT, getManagementPort(actualPort));
-            configuration.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_JMX_PORT,
Port.PORT, getManagementPort(actualPort) + JMXPORT_CONNECTORSERVER_OFFSET);
+            configuration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT,
Port.PORT, actualPort);
+            configuration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_RMI_PORT,
Port.PORT, getManagementPort(actualPort));
+            configuration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_JMX_PORT,
Port.PORT, getManagementPort(actualPort) + JMXPORT_CONNECTORSERVER_OFFSET);
 
             String workDir = System.getProperty("QPID_WORK") + File.separator + TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST
+ File.separator + actualPort;
-            Map<String, Object> virtualHostSettings = configuration.getObjectAttributes(TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST);
+            Map<String, Object> virtualHostSettings = configuration.getObjectAttributes(VirtualHost.class,
TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST);
 
             @SuppressWarnings("unchecked")
             Map<String, Object> storeSettings = (Map<String, Object>)virtualHostSettings.get(VirtualHost.MESSAGE_STORE_SETTINGS);
             storeSettings.put(MessageStore.STORE_PATH, workDir);
-            configuration.setObjectAttribute(TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST,
VirtualHost.MESSAGE_STORE_SETTINGS, storeSettings);
+            configuration.setObjectAttribute(VirtualHost.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST,
VirtualHost.MESSAGE_STORE_SETTINGS, storeSettings);
         }
 
         return configuration;
@@ -851,7 +838,7 @@ public class QpidBrokerTestCase extends 
         messageStoreSettings.put(MessageStore.STORE_PATH, storeDir);
         attributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, messageStoreSettings );
         int port = getPort(brokerPort);
-        getBrokerConfiguration(port).addVirtualHostConfiguration(attributes);
+        getBrokerConfiguration(port).addObjectConfiguration(VirtualHost.class, attributes);
     }
 
     /**

Propchange: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java:r1584338-1584926

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java?rev=1584931&r1=1584930&r2=1584931&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/TestBrokerConfiguration.java
Fri Apr  4 22:34:26 2014
@@ -20,33 +20,34 @@
  */
 package org.apache.qpid.test.utils;
 
-import java.io.ByteArrayOutputStream;
+import static org.mockito.Mockito.mock;
+
 import java.io.File;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import java.util.UUID;
 
-import org.apache.qpid.server.configuration.ConfigurationEntry;
-import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.BrokerOptions;
 import org.apache.qpid.server.configuration.store.MemoryConfigurationEntryStore;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.logging.LogRecorder;
 import org.apache.qpid.server.model.AccessControlProvider;
 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.server.model.ConfiguredObjectFactory;
 import org.apache.qpid.server.model.GroupProvider;
-import org.apache.qpid.server.model.KeyStore;
 import org.apache.qpid.server.model.Plugin;
-import org.apache.qpid.server.model.Port;
 import org.apache.qpid.server.model.PreferencesProvider;
-import org.apache.qpid.server.model.TrustStore;
+import org.apache.qpid.server.model.SystemContext;
 import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.plugin.PluginFactory;
 import org.apache.qpid.server.security.access.FileAccessControlProviderConstants;
 import org.apache.qpid.server.security.group.FileGroupManagerFactory;
-import org.apache.qpid.util.FileUtils;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.ConfiguredObjectRecordImpl;
+import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler;
 
 public class TestBrokerConfiguration
 {
@@ -73,17 +74,30 @@ public class TestBrokerConfiguration
 
     public TestBrokerConfiguration(String storeType, String intialStoreLocation)
     {
-        _store = new MemoryConfigurationEntryStore(intialStoreLocation, null, Collections.<String,String>emptyMap());
+        _store = new MemoryConfigurationEntryStore(new SystemContext(new TaskExecutor(),
new ConfiguredObjectFactory(),
+                                                                     mock(EventLogger.class),
mock(LogRecorder.class),
+                                                                     mock(BrokerOptions.class)),
+                                                   intialStoreLocation,
+                                                   null, Collections.<String,String>emptyMap());
     }
 
     public boolean setBrokerAttribute(String name, Object value)
     {
-        return setObjectAttribute(_store.getRootEntry(), name, value);
+        ConfiguredObjectRecord entry = findObject(Broker.class, null);
+        if (entry == null)
+        {
+            return false;
+        }
+
+        return setObjectAttribute(entry, name, value);
     }
 
-    public boolean setObjectAttribute(String objectName, String attributeName, Object value)
+    public boolean setObjectAttribute(final Class<? extends ConfiguredObject> category,
+                                      String objectName,
+                                      String attributeName,
+                                      Object value)
     {
-        ConfigurationEntry entry = findObjectByName(objectName);
+        ConfiguredObjectRecord entry = findObject(category, objectName);
         if (entry == null)
         {
             return false;
@@ -91,9 +105,11 @@ public class TestBrokerConfiguration
         return setObjectAttribute(entry, attributeName, value);
     }
 
-    public boolean setObjectAttributes(String objectName, Map<String, Object> attributes)
+    public boolean setObjectAttributes(final Class<? extends ConfiguredObject> category,
+                                       String objectName,
+                                       Map<String, Object> attributes)
     {
-        ConfigurationEntry entry = findObjectByName(objectName);
+        ConfiguredObjectRecord entry = findObject(category, objectName);
         if (entry == null)
         {
             return false;
@@ -107,37 +123,38 @@ public class TestBrokerConfiguration
         return true;
     }
 
-    public UUID[] removeObjectConfiguration(String name)
+    public UUID[] removeObjectConfiguration(final Class<? extends ConfiguredObject>
category,
+                                            String name)
     {
-        ConfigurationEntry entry = findObjectByName(name);
+        final ConfiguredObjectRecord entry = findObject(category, name);
         if (entry != null)
         {
-            return _store.remove(entry.getId());
+            return _store.remove(entry);
         }
         return null;
     }
 
-    public UUID addObjectConfiguration(String name, String type, Map<String, Object>
attributes)
+    public UUID addObjectConfiguration(Class<? extends ConfiguredObject> type, Map<String,
Object> attributes)
     {
         UUID id = UUIDGenerator.generateRandomUUID();
-        addObjectConfiguration(id, type, attributes);
+        addObjectConfiguration(id, type.getSimpleName(), attributes);
         return id;
     }
 
     public UUID addJmxManagementConfiguration()
     {
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(PluginFactory.PLUGIN_TYPE, MANAGEMENT_JMX_PLUGIN_TYPE);
+        attributes.put(Plugin.TYPE, MANAGEMENT_JMX_PLUGIN_TYPE);
         attributes.put(Plugin.NAME, ENTRY_NAME_JMX_MANAGEMENT);
-        return addObjectConfiguration(ENTRY_NAME_JMX_MANAGEMENT, Plugin.class.getSimpleName(),
attributes);
+        return addObjectConfiguration(Plugin.class, attributes);
     }
 
     public UUID addHttpManagementConfiguration()
     {
         Map<String, Object> attributes = new HashMap<String, Object>();
-        attributes.put(PluginFactory.PLUGIN_TYPE, MANAGEMENT_HTTP_PLUGIN_TYPE);
+        attributes.put(Plugin.TYPE, MANAGEMENT_HTTP_PLUGIN_TYPE);
         attributes.put(Plugin.NAME, ENTRY_NAME_HTTP_MANAGEMENT);
-        return addObjectConfiguration(ENTRY_NAME_HTTP_MANAGEMENT, Plugin.class.getSimpleName(),
attributes);
+        return addObjectConfiguration(Plugin.class, attributes);
     }
 
     public UUID addGroupFileConfiguration(String groupFilePath)
@@ -147,7 +164,7 @@ public class TestBrokerConfiguration
         attributes.put(GroupProvider.TYPE, FileGroupManagerFactory.GROUP_FILE_PROVIDER_TYPE);
         attributes.put(FileGroupManagerFactory.PATH, groupFilePath);
 
-        return addGroupProviderConfiguration(attributes);
+        return addObjectConfiguration(GroupProvider.class, attributes);
     }
 
     public UUID addAclFileConfiguration(String aclFilePath)
@@ -157,161 +174,107 @@ public class TestBrokerConfiguration
         attributes.put(AccessControlProvider.TYPE, FileAccessControlProviderConstants.ACL_FILE_PROVIDER_TYPE);
         attributes.put(FileAccessControlProviderConstants.PATH, aclFilePath);
 
-        return addAccessControlConfiguration(attributes);
+        return addObjectConfiguration(AccessControlProvider.class, attributes);
     }
 
-    public UUID addPortConfiguration(Map<String, Object> attributes)
+    private boolean setObjectAttributes(ConfiguredObjectRecord entry, Map<String, Object>
attributes)
     {
-        String name = (String) attributes.get(Port.NAME);
-        return addObjectConfiguration(name, Port.class.getSimpleName(), attributes);
+        Map<String, Object> newAttributes = new HashMap<String, Object>(entry.getAttributes());
+        newAttributes.putAll(attributes);
+        ConfiguredObjectRecord newEntry = new ConfiguredObjectRecordImpl(entry.getId(), entry.getType(),
newAttributes,
+                                                                         entry.getParents());
+        _store.update(false, newEntry);
+        return true;
     }
 
-    public UUID addVirtualHostConfiguration(Map<String, Object> attributes)
+    private ConfiguredObjectRecord findObject(final Class<? extends ConfiguredObject>
category, final String objectName)
     {
-        String name = (String) attributes.get(VirtualHost.NAME);
-        return addObjectConfiguration(name, VirtualHost.class.getSimpleName(), attributes);
+        final RecordFindingVisitor visitor = new RecordFindingVisitor(category, objectName);
+        _store.visitConfiguredObjectRecords(visitor);
+        return visitor.getFoundRecord();
     }
 
-    public UUID addAuthenticationProviderConfiguration(Map<String, Object> attributes)
+    private void addObjectConfiguration(UUID id, String type, Map<String, Object> attributes)
     {
-        String name = (String) attributes.get(AuthenticationProvider.NAME);
-        return addObjectConfiguration(name, AuthenticationProvider.class.getSimpleName(),
attributes);
-    }
+        ConfiguredObjectRecord entry = new ConfiguredObjectRecordImpl(id, type, attributes,
Collections.singletonMap(Broker.class.getSimpleName(), findObject(Broker.class,null)));
 
-    public UUID addGroupProviderConfiguration(Map<String, Object> attributes)
-    {
-        String name = (String) attributes.get(GroupProvider.NAME);
-        return addObjectConfiguration(name, GroupProvider.class.getSimpleName(), attributes);
+        _store.update(true, entry);
     }
 
-    public UUID addAccessControlConfiguration(Map<String, Object> attributes)
+    private boolean setObjectAttribute(ConfiguredObjectRecord entry, String attributeName,
Object value)
     {
-        String name = (String) attributes.get(AccessControlProvider.NAME);
-        return addObjectConfiguration(name, AccessControlProvider.class.getSimpleName(),
attributes);
+        Map<String, Object> attributes = new HashMap<String, Object>(entry.getAttributes());
+        attributes.put(attributeName, value);
+        ConfiguredObjectRecord newEntry = new ConfiguredObjectRecordImpl(entry.getId(), entry.getType(),
attributes, entry.getParents());
+        _store.update(false, newEntry);
+        return true;
     }
 
-    public UUID addTrustStoreConfiguration(Map<String, Object> attributes)
+    public boolean isSaved()
     {
-        String name = (String) attributes.get(TrustStore.NAME);
-        return addObjectConfiguration(name, TrustStore.class.getSimpleName(), attributes);
+        return _saved;
     }
 
-    public UUID addKeyStoreConfiguration(Map<String, Object> attributes)
+    public void setSaved(boolean saved)
     {
-        String name = (String) attributes.get(KeyStore.NAME);
-        return addObjectConfiguration(name, KeyStore.class.getSimpleName(), attributes);
+        _saved = saved;
     }
 
-    private boolean setObjectAttributes(ConfigurationEntry entry, Map<String, Object>
attributes)
+    public void addPreferencesProviderConfiguration(String authenticationProvider, Map<String,
Object> attributes)
     {
-        Map<String, Object> newAttributes = new HashMap<String, Object>(entry.getAttributes());
-        newAttributes.putAll(attributes);
-        ConfigurationEntry newEntry = new ConfigurationEntry(entry.getId(), entry.getType(),
newAttributes,
-                entry.getChildrenIds(), _store);
-        _store.save(newEntry);
-        return true;
+        ConfiguredObjectRecord authProviderRecord = findObject(AuthenticationProvider.class,
authenticationProvider);
+        ConfiguredObjectRecord pp = new ConfiguredObjectRecordImpl(UUIDGenerator.generateRandomUUID(),
+                                                                   PreferencesProvider.class.getSimpleName(),
attributes, Collections.<String, ConfiguredObjectRecord>singletonMap(AuthenticationProvider.class.getSimpleName(),authProviderRecord));
+
+        _store.create(pp);
     }
 
-    private ConfigurationEntry findObjectByName(String objectName)
+    public Map<String,Object> getObjectAttributes(final Class<? extends ConfiguredObject>
category, final String name)
     {
-        ConfigurationEntry root = _store.getRootEntry();
-        return findObjectByName(root, objectName);
+        return findObject(category, name).getAttributes();
     }
 
-    private ConfigurationEntry findObjectByName(ConfigurationEntry entry, String objectName)
+    private static class RecordFindingVisitor implements ConfiguredObjectRecordHandler
     {
-        Map<String, Object> attributes = entry.getAttributes();
-        if (attributes != null)
+        private final Class<? extends ConfiguredObject> _category;
+        private final String _objectName;
+        public ConfiguredObjectRecord _foundRecord;
+        private int _version;
+
+        public RecordFindingVisitor(final Class<? extends ConfiguredObject> category,
final String objectName)
         {
-            String name = (String) attributes.get("name");
-            if (objectName.equals(name))
-            {
-                return entry;
-            }
+            _category = category;
+            _objectName = objectName;
         }
-        Set<UUID> childrenIds = entry.getChildrenIds();
-        for (UUID uuid : childrenIds)
+
+        @Override
+        public void begin(final int configVersion)
         {
-            ConfigurationEntry child = _store.getEntry(uuid);
-            ConfigurationEntry result = findObjectByName(child, objectName);
-            if (result != null)
-            {
-                return result;
-            }
+            _version = configVersion;
         }
-        return null;
-    }
-
-    private void addObjectConfiguration(UUID id, String type, Map<String, Object> attributes)
-    {
-        ConfigurationEntry entry = new ConfigurationEntry(id, type, attributes, Collections.<UUID>
emptySet(), _store);
-        ConfigurationEntry root = _store.getRootEntry();
-
-        Map<String, Collection<ConfigurationEntry>> children = root.getChildren();
 
-        verifyChildWithNameDoesNotExist(id, type, attributes, children);
-
-        Set<UUID> childrenIds = new HashSet<UUID>(root.getChildrenIds());
-        childrenIds.add(id);
-        ConfigurationEntry newRoot = new ConfigurationEntry(root.getId(), root.getType(),
root.getAttributes(), childrenIds,
-                _store);
-        _store.save(newRoot, entry);
-    }
-
-    private void verifyChildWithNameDoesNotExist(UUID id, String type,
-            Map<String, Object> attributes,
-            Map<String, Collection<ConfigurationEntry>> children)
-    {
-        Collection<ConfigurationEntry> childrenOfType = children.get(type);
-
-        if(childrenOfType != null)
+        @Override
+        public boolean handle(final ConfiguredObjectRecord object)
         {
-            String name = (String) attributes.get("name");
-            for(ConfigurationEntry ce : childrenOfType)
+            if (object.getType().equals(_category.getSimpleName())
+                && (_objectName == null
+                    || _objectName.equals(object.getAttributes().get(ConfiguredObject.NAME))))
             {
-                Object ceName = ce.getAttributes().get("name");
-                if(name.equals(ceName) && !id.equals(ce.getId()))
-                {
-                    throw new IllegalConfigurationException("A " + type + " with name " +
name + " already exists with a different ID");
-                }
+                _foundRecord = object;
+                return false;
             }
+            return true;
         }
-    }
 
-    private boolean setObjectAttribute(ConfigurationEntry entry, String attributeName, Object
value)
-    {
-        Map<String, Object> attributes = new HashMap<String, Object>(entry.getAttributes());
-        attributes.put(attributeName, value);
-        ConfigurationEntry newEntry = new ConfigurationEntry(entry.getId(), entry.getType(),
attributes, entry.getChildrenIds(),
-                _store);
-        _store.save(newEntry);
-        return true;
-    }
-
-    public boolean isSaved()
-    {
-        return _saved;
-    }
-
-    public void setSaved(boolean saved)
-    {
-        _saved = saved;
-    }
-
-    public void addPreferencesProviderConfiguration(String authenticationProvider, Map<String,
Object> attributes)
-    {
-        ConfigurationEntry pp = new ConfigurationEntry(UUIDGenerator.generateRandomUUID(),
-                PreferencesProvider.class.getSimpleName(), attributes, Collections.<UUID>
emptySet(), _store);
-        ConfigurationEntry ap = findObjectByName(authenticationProvider);
-        Set<UUID> children = new HashSet<UUID>();
-        children.addAll(ap.getChildrenIds());
-        children.add(pp.getId());
-        ConfigurationEntry newAp = new ConfigurationEntry(ap.getId(), ap.getType(), ap.getAttributes(),
children, _store);
-        _store.save(newAp, pp);
-    }
+        @Override
+        public int end()
+        {
+            return _version;
+        }
 
-    public Map<String, Object> getObjectAttributes(String name)
-    {
-        return findObjectByName(name).getAttributes();
+        public ConfiguredObjectRecord getFoundRecord()
+        {
+            return _foundRecord;
+        }
     }
 }

Propchange: qpid/trunk/qpid/java/test-profiles/CPPExcludes
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/CPPExcludes:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/JavaBDBExcludes
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/JavaBDBExcludes:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/JavaTransientExcludes
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/JavaTransientExcludes:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/java-bdb-spawn.0-9-1.testprofile
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/java-bdb-spawn.0-9-1.testprofile:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/java-bdb.0-9-1.testprofile
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/java-bdb.0-9-1.testprofile:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/java-dby-spawn.0-9-1.testprofile
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/java-dby-spawn.0-9-1.testprofile:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/java-dby.0-9-1.testprofile
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/java-dby.0-9-1.testprofile:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/java-mms-spawn.0-10.testprofile
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/java-mms-spawn.0-10.testprofile:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/java-mms-spawn.0-9-1.testprofile
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/java-mms-spawn.0-9-1.testprofile:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/java-mms.0-9-1.testprofile
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/java-mms.0-9-1.testprofile:r1584338-1584926

Propchange: qpid/trunk/qpid/java/test-profiles/testprofile.defaults
------------------------------------------------------------------------------
  Merged /qpid/branches/java-broker-config-store-changes/qpid/java/test-profiles/testprofile.defaults:r1584338-1584926



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message