diff options
Diffstat (limited to 'java/broker/src/main/java/org/apache/qpid/server/configuration/startup')
10 files changed, 673 insertions, 0 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java new file mode 100644 index 0000000000..9b06a2b499 --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java @@ -0,0 +1,55 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import java.util.Map; + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.RecovererProvider; +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.adapter.AuthenticationProviderFactory; + +public class AuthenticationProviderRecoverer implements ConfiguredObjectRecoverer<AuthenticationProvider> +{ + private final AuthenticationProviderFactory _authenticationProviderFactory; + + public AuthenticationProviderRecoverer(AuthenticationProviderFactory authenticationProviderFactory) + { + _authenticationProviderFactory = authenticationProviderFactory; + } + + @Override + public AuthenticationProvider create(RecovererProvider recovererProvider, ConfigurationEntry configurationEntry, ConfiguredObject... parents) + { + Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents); + Map<String, Object> attributes = configurationEntry.getAttributes(); + AuthenticationProvider authenticationProvider = _authenticationProviderFactory.create( + configurationEntry.getId(), + broker, + attributes, null); + + return authenticationProvider; + } + +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java new file mode 100644 index 0000000000..4bfa0ca7a3 --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java @@ -0,0 +1,139 @@ +package org.apache.qpid.server.configuration.startup; + +import java.util.Collection; +import java.util.Map; + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.logging.LogRecorder; +import org.apache.qpid.server.logging.RootMessageLogger; +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.Port; +import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory; +import org.apache.qpid.server.model.adapter.BrokerAdapter; +import org.apache.qpid.server.model.adapter.PortFactory; +import org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener; +import org.apache.qpid.server.configuration.updater.TaskExecutor; +import org.apache.qpid.server.security.group.GroupPrincipalAccessor; +import org.apache.qpid.server.stats.StatisticsGatherer; +import org.apache.qpid.server.virtualhost.VirtualHostRegistry; + +public class BrokerRecoverer implements ConfiguredObjectRecoverer<Broker> +{ + private final StatisticsGatherer _statisticsGatherer; + private final VirtualHostRegistry _virtualHostRegistry; + private final LogRecorder _logRecorder; + private final RootMessageLogger _rootMessageLogger; + private final AuthenticationProviderFactory _authenticationProviderFactory; + private final PortFactory _portFactory; + private final TaskExecutor _taskExecutor; + + public BrokerRecoverer(AuthenticationProviderFactory authenticationProviderFactory, PortFactory portFactory, + StatisticsGatherer statisticsGatherer, VirtualHostRegistry virtualHostRegistry, LogRecorder logRecorder, + RootMessageLogger rootMessageLogger, TaskExecutor taskExecutor) + { + _portFactory = portFactory; + _authenticationProviderFactory = authenticationProviderFactory; + _statisticsGatherer = statisticsGatherer; + _virtualHostRegistry = virtualHostRegistry; + _logRecorder = logRecorder; + _rootMessageLogger = rootMessageLogger; + _taskExecutor = taskExecutor; + } + + @Override + public Broker create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents) + { + StoreConfigurationChangeListener storeChangeListener = new StoreConfigurationChangeListener(entry.getStore()); + BrokerAdapter broker = new BrokerAdapter(entry.getId(), entry.getAttributes(), _statisticsGatherer, _virtualHostRegistry, + _logRecorder, _rootMessageLogger, _authenticationProviderFactory, _portFactory, _taskExecutor); + broker.addChangeListener(storeChangeListener); + Map<String, Collection<ConfigurationEntry>> childEntries = entry.getChildren(); + for (String type : childEntries.keySet()) + { + ConfiguredObjectRecoverer<?> recoverer = recovererProvider.getRecoverer(type); + if (recoverer == null) + { + throw new IllegalConfigurationException("Cannot recover entry for the type '" + type + "' from broker"); + } + Collection<ConfigurationEntry> entries = childEntries.get(type); + for (ConfigurationEntry childEntry : entries) + { + ConfiguredObject object = recoverer.create(recovererProvider, childEntry, broker); + if (object == null) + { + throw new IllegalConfigurationException("Cannot create configured object for the entry " + childEntry); + } + broker.recoverChild(object); + object.addChangeListener(storeChangeListener); + } + } + wireUpConfiguredObjects(broker, entry.getAttributes()); + + return broker; + } + + private void wireUpConfiguredObjects(BrokerAdapter broker, Map<String, Object> brokerAttributes) + { + AuthenticationProvider defaultAuthenticationProvider = null; + Collection<AuthenticationProvider> authenticationProviders = broker.getAuthenticationProviders(); + int numberOfAuthenticationProviders = authenticationProviders.size(); + if (numberOfAuthenticationProviders == 0) + { + throw new IllegalConfigurationException("No authentication provider was configured"); + } + else if (numberOfAuthenticationProviders == 1) + { + defaultAuthenticationProvider = authenticationProviders.iterator().next(); + } + else + { + String name = (String) brokerAttributes.get(Broker.DEFAULT_AUTHENTICATION_PROVIDER); + if (name == null) + { + throw new IllegalConfigurationException("Multiple authentication providers defined, but no default was configured."); + } + + defaultAuthenticationProvider = getAuthenticationProviderByName(broker, name); + } + broker.setDefaultAuthenticationProvider(defaultAuthenticationProvider); + + GroupPrincipalAccessor groupPrincipalAccessor = new GroupPrincipalAccessor(broker.getGroupProviders()); + for (AuthenticationProvider authenticationProvider : authenticationProviders) + { + authenticationProvider.setGroupAccessor(groupPrincipalAccessor); + } + + Collection<Port> ports = broker.getPorts(); + for (Port port : ports) + { + String authenticationProviderName = (String) port.getAttribute(Port.AUTHENTICATION_MANAGER); + AuthenticationProvider provider = null; + if (authenticationProviderName != null) + { + provider = getAuthenticationProviderByName(broker, authenticationProviderName); + } + else + { + provider = defaultAuthenticationProvider; + } + port.setAuthenticationProvider(provider); + } + } + + private AuthenticationProvider getAuthenticationProviderByName(BrokerAdapter broker, String authenticationProviderName) + { + AuthenticationProvider provider = broker.getAuthenticationProviderByName(authenticationProviderName); + if (provider == null) + { + throw new IllegalConfigurationException("Cannot find the authentication provider with name: " + + authenticationProviderName); + } + return provider; + } + +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java new file mode 100644 index 0000000000..15cb229d8a --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/DefaultRecovererProvider.java @@ -0,0 +1,112 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.logging.LogRecorder; +import org.apache.qpid.server.logging.RootMessageLogger; +import org.apache.qpid.server.model.AuthenticationProvider; +import org.apache.qpid.server.model.Broker; +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.TrustStore; +import org.apache.qpid.server.model.VirtualHost; +import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory; +import org.apache.qpid.server.model.adapter.PortFactory; +import org.apache.qpid.server.configuration.updater.TaskExecutor; +import org.apache.qpid.server.plugin.AuthenticationManagerFactory; +import org.apache.qpid.server.plugin.GroupManagerFactory; +import org.apache.qpid.server.plugin.PluginFactory; +import org.apache.qpid.server.plugin.QpidServiceLoader; +import org.apache.qpid.server.stats.StatisticsGatherer; +import org.apache.qpid.server.virtualhost.VirtualHostRegistry; + +public class DefaultRecovererProvider implements RecovererProvider +{ + + private final StatisticsGatherer _brokerStatisticsGatherer; + private final VirtualHostRegistry _virtualHostRegistry; + private final LogRecorder _logRecorder; + private final RootMessageLogger _rootMessageLogger; + private final AuthenticationProviderFactory _authenticationProviderFactory; + private final PortFactory _portFactory; + private final QpidServiceLoader<GroupManagerFactory> _groupManagerServiceLoader; + private final QpidServiceLoader<PluginFactory> _pluginFactoryServiceLoader; + private final TaskExecutor _taskExecutor; + + public DefaultRecovererProvider(StatisticsGatherer brokerStatisticsGatherer, VirtualHostRegistry virtualHostRegistry, + LogRecorder logRecorder, RootMessageLogger rootMessageLogger, TaskExecutor taskExecutor) + { + _authenticationProviderFactory = new AuthenticationProviderFactory(new QpidServiceLoader<AuthenticationManagerFactory>()); + _portFactory = new PortFactory(); + _brokerStatisticsGatherer = brokerStatisticsGatherer; + _virtualHostRegistry = virtualHostRegistry; + _logRecorder = logRecorder; + _rootMessageLogger = rootMessageLogger; + _groupManagerServiceLoader = new QpidServiceLoader<GroupManagerFactory>(); + _pluginFactoryServiceLoader = new QpidServiceLoader<PluginFactory>(); + _taskExecutor = taskExecutor; + } + + @Override + public ConfiguredObjectRecoverer<?> getRecoverer(String type) + { + if (Broker.class.getSimpleName().equals(type)) + { + return new BrokerRecoverer(_authenticationProviderFactory, _portFactory, _brokerStatisticsGatherer, _virtualHostRegistry, + _logRecorder, _rootMessageLogger, _taskExecutor); + } + else if(VirtualHost.class.getSimpleName().equals(type)) + { + return new VirtualHostRecoverer(_brokerStatisticsGatherer); + } + else if(AuthenticationProvider.class.getSimpleName().equals(type)) + { + return new AuthenticationProviderRecoverer(_authenticationProviderFactory); + } + else if(Port.class.getSimpleName().equals(type)) + { + return new PortRecoverer(_portFactory); + } + else if(GroupProvider.class.getSimpleName().equals(type)) + { + return new GroupProviderRecoverer(_groupManagerServiceLoader); + } + else if(KeyStore.class.getSimpleName().equals(type)) + { + return new KeyStoreRecoverer(); + } + else if(TrustStore.class.getSimpleName().equals(type)) + { + return new TrustStoreRecoverer(); + } + else if(Plugin.class.getSimpleName().equals(type)) + { + return new PluginRecoverer(_pluginFactoryServiceLoader); + } + + return null; + } + +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java new file mode 100644 index 0000000000..275a0c736c --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java @@ -0,0 +1,74 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import java.util.Map; + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.GroupProvider; +import org.apache.qpid.server.model.adapter.GroupProviderAdapter; +import org.apache.qpid.server.plugin.GroupManagerFactory; +import org.apache.qpid.server.plugin.QpidServiceLoader; +import org.apache.qpid.server.security.group.GroupManager; + +public class GroupProviderRecoverer implements ConfiguredObjectRecoverer<GroupProvider> +{ + private QpidServiceLoader<GroupManagerFactory> _groupManagerServiceLoader; + + public GroupProviderRecoverer(QpidServiceLoader<GroupManagerFactory> groupManagerServiceLoader) + { + super(); + _groupManagerServiceLoader = groupManagerServiceLoader; + } + + @Override + public GroupProvider create(RecovererProvider recovererProvider, ConfigurationEntry configurationEntry, ConfiguredObject... parents) + { + Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents); + Map<String, Object> attributes = configurationEntry.getAttributes(); + GroupManager groupManager = createGroupManager(attributes); + if (groupManager == null) + { + throw new IllegalConfigurationException("Cannot create GroupManager from attributes : " + attributes); + } + GroupProviderAdapter groupProviderAdapter = new GroupProviderAdapter(configurationEntry.getId(), groupManager, broker); + return groupProviderAdapter; + } + + private GroupManager createGroupManager(Map<String, Object> attributes) + { + for(GroupManagerFactory factory : _groupManagerServiceLoader.instancesOf(GroupManagerFactory.class)) + { + GroupManager groupManager = factory.createInstance(attributes); + if (groupManager != null) + { + return groupManager; + } + } + return null; + } + +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/KeyStoreRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/KeyStoreRecoverer.java new file mode 100644 index 0000000000..8efedd37b5 --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/KeyStoreRecoverer.java @@ -0,0 +1,40 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.KeyStore; +import org.apache.qpid.server.model.adapter.KeyStoreAdapter; + +public class KeyStoreRecoverer implements ConfiguredObjectRecoverer<KeyStore> +{ + @Override + public KeyStore create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents) + { + Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents); + return new KeyStoreAdapter(entry.getId(), broker, entry.getAttributes()); + } + +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java new file mode 100644 index 0000000000..ddc4482953 --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PluginRecoverer.java @@ -0,0 +1,66 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import java.util.Map; +import java.util.UUID; + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.plugin.PluginFactory; +import org.apache.qpid.server.plugin.QpidServiceLoader; + +public class PluginRecoverer implements ConfiguredObjectRecoverer<ConfiguredObject> +{ + private QpidServiceLoader<PluginFactory> _serviceLoader; + + public PluginRecoverer(QpidServiceLoader<PluginFactory> serviceLoader) + { + _serviceLoader = serviceLoader; + } + + @Override + public ConfiguredObject create(RecovererProvider recovererProvider, ConfigurationEntry configurationEntry, ConfiguredObject... parents) + { + Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents); + Map<String, Object> attributes = configurationEntry.getAttributes(); + Iterable<PluginFactory> factories = _serviceLoader.instancesOf(PluginFactory.class); + for (PluginFactory pluginFactory : factories) + { + UUID configurationId = configurationEntry.getId(); + ConfiguredObject pluginObject = pluginFactory.createInstance(configurationId, attributes, broker); + if (pluginObject != null) + { + UUID pluginId = pluginObject.getId(); + if (!configurationId.equals(pluginId)) + { + throw new IllegalStateException("Plugin object id '" + pluginId + "' does not equal expected id " + configurationId); + } + return pluginObject; + } + } + throw new IllegalConfigurationException("Cannot create a plugin object for " + attributes + " with factories " + factories); + } +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java new file mode 100644 index 0000000000..147e835a8d --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java @@ -0,0 +1,52 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.Port; +import org.apache.qpid.server.model.adapter.BrokerAdapter; +import org.apache.qpid.server.model.adapter.PortFactory; + +public class PortRecoverer implements ConfiguredObjectRecoverer<Port> +{ + /** + * delegates to a {@link PortFactory} so that the logic can be shared by + * {@link BrokerAdapter} + */ + private final PortFactory _portFactory; + + public PortRecoverer(PortFactory portFactory) + { + _portFactory = portFactory; + } + + @Override + public Port create(RecovererProvider recovererProvider, ConfigurationEntry configurationEntry, ConfiguredObject... parents) + { + Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents); + return _portFactory.createPort(configurationEntry.getId(), broker, configurationEntry.getAttributes()); + } + +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/RecovererHelper.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/RecovererHelper.java new file mode 100644 index 0000000000..b60c9c289f --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/RecovererHelper.java @@ -0,0 +1,44 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; + +public class RecovererHelper +{ + public static Broker verifyOnlyBrokerIsParent(ConfiguredObject... parents) + { + if (parents == null || parents.length == 0) + { + throw new IllegalArgumentException("Broker parent is not passed!"); + } + if (parents.length != 1) + { + throw new IllegalArgumentException("Only one parent is expected!"); + } + if (!(parents[0] instanceof Broker)) + { + throw new IllegalArgumentException("Parent is not a broker"); + } + return (Broker)parents[0]; + } +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/TrustStoreRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/TrustStoreRecoverer.java new file mode 100644 index 0000000000..7e9428a4d6 --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/TrustStoreRecoverer.java @@ -0,0 +1,40 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.TrustStore; +import org.apache.qpid.server.model.adapter.TrustStoreAdapter; + +public class TrustStoreRecoverer implements ConfiguredObjectRecoverer<TrustStore> +{ + @Override + public TrustStore create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents) + { + Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents); + return new TrustStoreAdapter(entry.getId(), broker, entry.getAttributes()); + } + +} diff --git a/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java new file mode 100644 index 0000000000..4f863adfb5 --- /dev/null +++ b/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java @@ -0,0 +1,51 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.configuration.startup; + + +import org.apache.qpid.server.configuration.ConfigurationEntry; +import org.apache.qpid.server.configuration.ConfiguredObjectRecoverer; +import org.apache.qpid.server.configuration.RecovererProvider; +import org.apache.qpid.server.model.Broker; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.model.VirtualHost; +import org.apache.qpid.server.model.adapter.VirtualHostAdapter; +import org.apache.qpid.server.stats.StatisticsGatherer; + +public class VirtualHostRecoverer implements ConfiguredObjectRecoverer<VirtualHost> +{ + private StatisticsGatherer _brokerStatisticsGatherer; + + public VirtualHostRecoverer(StatisticsGatherer brokerStatisticsGatherer) + { + super(); + _brokerStatisticsGatherer = brokerStatisticsGatherer; + } + + @Override + public VirtualHost create(RecovererProvider recovererProvider, ConfigurationEntry entry, ConfiguredObject... parents) + { + Broker broker = RecovererHelper.verifyOnlyBrokerIsParent(parents); + + return new VirtualHostAdapter(entry.getId(), entry.getAttributes(), broker, _brokerStatisticsGatherer, broker.getTaskExecutor()); + } + +} |