You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2012/11/01 10:48:57 UTC
svn commit: r1404521 [2/6] - in
/qpid/branches/java-broker-config-qpid-4390/qpid/java: ./
broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/
broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/
bro...
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerLauncher.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,321 @@
+/*
+ *
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.logging.SystemOutMessageLogger;
+import org.apache.qpid.server.logging.actors.BrokerActor;
+import org.apache.qpid.server.logging.actors.CurrentActor;
+import org.apache.qpid.server.logging.actors.GenericActor;
+import org.apache.qpid.server.logging.log4j.LoggingManagementFacade;
+import org.apache.qpid.server.logging.messages.BrokerMessages;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.Protocol;
+import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.registry.ApplicationRegistry;
+
+public class BrokerLauncher
+{
+ private static final Logger LOGGER = Logger.getLogger(BrokerLauncher.class);
+
+ private volatile Thread _shutdownHookThread;
+
+ protected static class InitException extends RuntimeException
+ {
+ private static final long serialVersionUID = 1L;
+
+ InitException(String msg, Throwable cause)
+ {
+ super(msg, cause);
+ }
+ }
+
+ public void shutdown()
+ {
+ try
+ {
+ removeShutdownHook();
+ }
+ finally
+ {
+ try
+ {
+ ApplicationRegistry.remove();
+ }
+ finally
+ {
+ clearAMQShortStringCache();
+ }
+ }
+ }
+
+ public void startup() throws Exception
+ {
+ startup(new BrokerOptions());
+ }
+
+ public void startup(final BrokerOptions options) throws Exception
+ {
+ CurrentActor.set(new BrokerActor(new SystemOutMessageLogger()));
+ try
+ {
+ startupImpl(options);
+ addShutdownHook();
+ }
+ finally
+ {
+ try
+ {
+ CurrentActor.remove();
+ }
+ finally
+ {
+ clearAMQShortStringCache();
+ }
+ }
+ }
+
+ private void startupImpl(final BrokerOptions options) throws Exception
+ {
+ final String qpidHome = options.getQpidHome();
+ final File configFile = getConfigFile(options.getConfigFile(),
+ BrokerOptions.DEFAULT_CONFIG_FILE, qpidHome, true);
+
+ CurrentActor.get().message(BrokerMessages.CONFIG(configFile.getAbsolutePath()));
+
+ File logConfigFile = getConfigFile(options.getLogConfigFile(),
+ BrokerOptions.DEFAULT_LOG_CONFIG_FILE, qpidHome, false);
+
+ configureLogging(logConfigFile, options.getLogWatchFrequency());
+
+ ServerConfiguration serverConfig = new ServerConfiguration(configFile);
+
+ ApplicationRegistry applicationRegistry = new ApplicationRegistry(serverConfig, options);
+
+ ApplicationRegistry.initialise(applicationRegistry);
+
+ // We have already loaded the BrokerMessages class by this point so we
+ // need to refresh the locale setting in case we had a different value in
+ // the configuration.
+ // BrokerMessages.reload();
+
+ // AR.initialise() sets and removes its own actor so we now need to set the actor
+ // for the remainder of the startup, and the default actor if the stack is empty
+ //CurrentActor.set(new BrokerActor(applicationRegistry.getCompositeStartupMessageLogger()));
+ //CurrentActor.setDefault(new BrokerActor(applicationRegistry.getRootMessageLogger()));
+ //GenericActor.setDefaultMessageLogger(applicationRegistry.getRootMessageLogger());
+/*
+ try
+ {
+ CurrentActor.get().message(BrokerMessages.READY());
+ }
+ finally
+ {
+ // Startup is complete so remove the AR initialised Startup actor
+ CurrentActor.remove();
+ }
+ */
+ }
+
+
+ private File getConfigFile(final String fileName,
+ final String defaultFileName,
+ final String qpidHome, boolean throwOnFileNotFound) throws InitException
+ {
+ File configFile = null;
+ if (fileName != null)
+ {
+ configFile = new File(fileName);
+ }
+ else
+ {
+ configFile = new File(qpidHome, defaultFileName);
+ }
+
+ if (!configFile.exists() && throwOnFileNotFound)
+ {
+ String error = "File " + configFile + " could not be found. Check the file exists and is readable.";
+
+ if (qpidHome == null)
+ {
+ error = error + "\nNote: " + BrokerOptions.QPID_HOME + " is not set.";
+ }
+
+ throw new InitException(error, null);
+ }
+
+ return configFile;
+ }
+
+ public static void parsePortList(Set<Integer> output, List<?> ports) throws InitException
+ {
+ if(ports != null)
+ {
+ for(Object o : ports)
+ {
+ try
+ {
+ output.add(Integer.parseInt(String.valueOf(o)));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new InitException("Invalid port: " + o, e);
+ }
+ }
+ }
+ }
+
+ private void configureLogging(File logConfigFile, int logWatchTime) throws InitException, IOException
+ {
+ if (logConfigFile.exists() && logConfigFile.canRead())
+ {
+ CurrentActor.get().message(BrokerMessages.LOG_CONFIG(logConfigFile.getAbsolutePath()));
+
+ if (logWatchTime > 0)
+ {
+ System.out.println("log file " + logConfigFile.getAbsolutePath() + " will be checked for changes every "
+ + logWatchTime + " seconds");
+ // log4j expects the watch interval in milliseconds
+ try
+ {
+ LoggingManagementFacade.configureAndWatch(logConfigFile.getPath(), logWatchTime * 1000);
+ }
+ catch (Exception e)
+ {
+ throw new InitException(e.getMessage(),e);
+ }
+ }
+ else
+ {
+ try
+ {
+ LoggingManagementFacade.configure(logConfigFile.getPath());
+ }
+ catch (Exception e)
+ {
+ throw new InitException(e.getMessage(),e);
+ }
+ }
+ }
+ else
+ {
+ System.err.println("Logging configuration error: unable to read file " + logConfigFile.getAbsolutePath());
+ System.err.println("Using the fallback internal fallback-log4j.properties configuration");
+
+ InputStream propsFile = this.getClass().getResourceAsStream("/fallback-log4j.properties");
+ if(propsFile == null)
+ {
+ throw new IOException("Unable to load the fallback internal fallback-log4j.properties configuration file");
+ }
+ else
+ {
+ try
+ {
+ Properties fallbackProps = new Properties();
+ fallbackProps.load(propsFile);
+ PropertyConfigurator.configure(fallbackProps);
+ }
+ finally
+ {
+ propsFile.close();
+ }
+ }
+ }
+ }
+
+
+ private void addShutdownHook()
+ {
+ Thread shutdownHookThread = new Thread(new ShutdownService());
+ shutdownHookThread.setName("QpidBrokerShutdownHook");
+
+ Runtime.getRuntime().addShutdownHook(shutdownHookThread);
+ _shutdownHookThread = shutdownHookThread;
+
+ LOGGER.debug("Added shutdown hook");
+ }
+
+ private void removeShutdownHook()
+ {
+ Thread shutdownThread = _shutdownHookThread;
+
+ //if there is a shutdown thread and we aren't it, we should remove it
+ if(shutdownThread != null && !(Thread.currentThread() == shutdownThread))
+ {
+ LOGGER.debug("Removing shutdown hook");
+
+ _shutdownHookThread = null;
+
+ boolean removed = false;
+ try
+ {
+ removed = Runtime.getRuntime().removeShutdownHook(shutdownThread);
+ }
+ catch(IllegalStateException ise)
+ {
+ //ignore, means the JVM is already shutting down
+ }
+
+ if(LOGGER.isDebugEnabled())
+ {
+ LOGGER.debug("Removed shutdown hook: " + removed);
+ }
+ }
+ else
+ {
+ LOGGER.debug("Skipping shutdown hook removal as there either isnt one, or we are it.");
+ }
+ }
+ /**
+ * Workaround that prevents AMQShortStrings cache from being left in the thread local. This is important
+ * when embedding the Broker in containers where the starting thread may not belong to Qpid.
+ * The long term solution here is to stop our use of AMQShortString outside the AMQP transport layer.
+ */
+ private void clearAMQShortStringCache()
+ {
+ AMQShortString.clearLocalCache();
+ }
+
+ private class ShutdownService implements Runnable
+ {
+ public void run()
+ {
+ LOGGER.debug("Shutdown hook running");
+ BrokerLauncher.this.shutdown();
+ }
+ }
+
+}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/Main.java Thu Nov 1 09:48:52 2012
@@ -30,7 +30,7 @@ import org.apache.commons.cli.PosixParse
import org.apache.log4j.Logger;
import org.apache.qpid.common.QpidProperties;
import org.apache.qpid.framing.ProtocolVersion;
-import org.apache.qpid.server.Broker.InitException;
+import org.apache.qpid.server.BrokerLauncher.InitException;
import org.apache.qpid.server.registry.ApplicationRegistry;
@@ -383,7 +383,7 @@ private static final Option OPTION_INCLU
protected void startBroker(final BrokerOptions options) throws Exception
{
- Broker broker = new Broker();
+ BrokerLauncher broker = new BrokerLauncher();
broker.startup(options);
}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntry.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,151 @@
+/*
+ *
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.qpid.server.configuration.startup.AttributeMap;
+import org.apache.qpid.server.model.ConfiguredObjectType;
+
+public class ConfigurationEntry
+{
+ private final UUID _id;
+ private final ConfiguredObjectType _type;
+ private final Map<String, Object> _attributes;
+ private final Set<UUID> _childrenIds;
+ private final ConfigurationEntryStore _store;
+
+ public ConfigurationEntry(UUID id, ConfiguredObjectType type, Map<String, Object> attributes, Set<UUID> childrenIds,
+ ConfigurationEntryStore store)
+ {
+ super();
+ _id = id;
+ _type = type;
+ _attributes = attributes;
+ _childrenIds = childrenIds;
+ _store = store;
+ }
+
+ public UUID getId()
+ {
+ return _id;
+ }
+
+ public ConfiguredObjectType getType()
+ {
+ return _type;
+ }
+
+ public Map<String, Object> getAttributes()
+ {
+ return _attributes;
+ }
+
+ public AttributeMap getAttributesAsAttributeMap()
+ {
+ return new AttributeMap(getAttributes());
+ }
+
+ public Set<UUID> getChildrenIds()
+ {
+ return _childrenIds;
+ }
+
+ public ConfigurationEntryStore getStore()
+ {
+ return _store;
+ }
+
+ /**
+ * Returns this entry's children. The collection should not be modified.
+ */
+ public Map<ConfiguredObjectType, Collection<ConfigurationEntry>> getChildren()
+ {
+ if (_childrenIds == null)
+ {
+ return Collections.emptyMap();
+ }
+ Map<ConfiguredObjectType, Collection<ConfigurationEntry>> children = new HashMap<ConfiguredObjectType, Collection<ConfigurationEntry>>();
+ for (UUID childId : _childrenIds)
+ {
+ ConfigurationEntry entry = _store.getEntry(childId);
+ ConfiguredObjectType type = entry.getType();
+ Collection<ConfigurationEntry> childrenOfType = children.get(type);
+ if (childrenOfType == null)
+ {
+ childrenOfType = new ArrayList<ConfigurationEntry>();
+ children.put(type, childrenOfType);
+ }
+ childrenOfType.add(entry);
+ }
+ return Collections.unmodifiableMap(children);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return _id.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ ConfigurationEntry other = (ConfigurationEntry) obj;
+ if (_id == null)
+ {
+ if (other._id != null)
+ {
+ return false;
+ }
+ }
+ else if (!_id.equals(other._id))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ConfigurationEntry [_id=" + _id + ", _type=" + _type + ", _attributes=" + _attributes + ", _childrenIds="
+ + _childrenIds + ", _store=" + _store + "]";
+ }
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStore.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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;
+
+import java.util.UUID;
+
+public interface ConfigurationEntryStore
+{
+ ConfigurationEntry getRootEntry();
+
+ ConfigurationEntry getEntry(UUID id);
+
+ void save(ConfigurationEntry... entries);
+
+ void remove(UUID... entryIds);
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStoreException.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStoreException.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStoreException.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ConfigurationEntryStoreException.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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;
+
+@SuppressWarnings("serial")
+public class ConfigurationEntryStoreException extends RuntimeException
+{
+
+ public ConfigurationEntryStoreException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public ConfigurationEntryStoreException(String message)
+ {
+ super(message);
+ }
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/IllegalConfigurationException.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/IllegalConfigurationException.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/IllegalConfigurationException.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/IllegalConfigurationException.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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;
+
+public class IllegalConfigurationException extends RuntimeException
+{
+ private static final long serialVersionUID = 1130064756291179812L;
+
+ public IllegalConfigurationException(String message)
+ {
+ super(message);
+ }
+
+ public IllegalConfigurationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java Thu Nov 1 09:48:52 2012
@@ -74,8 +74,6 @@ public class ServerConfiguration extends
private File _configFile;
private File _vhostsFile;
- private String _qpidWork;
- private String _qpidHome;
// Map of environment variables to config items
private static final Map<String, String> envVarMap = new HashMap<String, String>();
@@ -455,31 +453,6 @@ public class ServerConfiguration extends
return _configFile == null ? "" : _configFile.getAbsolutePath();
}
-
- public String getQpidWork()
- {
- if ( _qpidWork == null )
- {
- return System.getProperty(QPID_WORK, System.getProperty("java.io.tmpdir"));
- }
- else
- {
- return _qpidWork;
- }
- }
-
- public String getQpidHome()
- {
- if ( _qpidHome == null )
- {
- return System.getProperty(QPID_HOME);
- }
- else
- {
- return _qpidHome;
- }
- }
-
public void setJMXPortRegistryServer(int registryServerPort)
{
getConfig().setProperty(MGMT_JMXPORT_REGISTRYSERVER, registryServerPort);
@@ -564,7 +537,7 @@ public class ServerConfiguration extends
return getBooleanValue("management.https.sasl-auth", true);
}
- public String[] getVirtualHosts()
+ public String[] getVirtualHostsNames()
{
return _virtualHosts.keySet().toArray(new String[_virtualHosts.size()]);
}
@@ -978,17 +951,4 @@ public class ServerConfiguration extends
return reply == null ? null : AmqpProtocolVersion.valueOf(reply);
}
-
- public void setQpidWork(String path)
- {
- _qpidWork = path;
- }
-
- public void setQpidHome(String path)
- {
- _qpidHome = path;
- }
-
-
-
}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AttributeMap.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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.Set;
+
+import org.apache.qpid.server.util.MapValueConverter;
+
+public class AttributeMap
+{
+ private Map<String, Object> _source;
+
+ public AttributeMap(Map<String, Object> source)
+ {
+ _source = source;
+ }
+
+ public String getStringAttribute(String name, String defaultVal)
+ {
+ return MapValueConverter.getStringAttribute(name, _source, defaultVal);
+ }
+
+ public Map<String, Object> getMapAttribute(String name, Map<String, Object> defaultVal)
+ {
+ return MapValueConverter.getMapAttribute(name, _source, defaultVal);
+ }
+
+ public <E extends Enum<?>> E getEnumAttribute(Class<E> clazz, String name, E defaultVal)
+ {
+ return MapValueConverter.getEnumAttribute(clazz, name, _source, defaultVal);
+ }
+
+ public <E extends Enum<?>> E getEnumAttribute(Class<E> clazz, String name)
+ {
+ return MapValueConverter.getEnumAttribute(clazz, name, _source);
+ }
+
+ public Boolean getBooleanAttribute(String name, Boolean defaultValue)
+ {
+ return MapValueConverter.getBooleanAttribute(name, _source, defaultValue);
+ }
+
+ public Integer getIntegerAttribute(String name, Integer defaultValue)
+ {
+ return MapValueConverter.getIntegerAttribute(name, _source, defaultValue);
+ }
+
+ public Long getLongAttribute(String name, Long defaultValue)
+ {
+ return MapValueConverter.getLongAttribute(name, _source, defaultValue);
+ }
+
+ public <T> Set<T> getSetAttribute(String name)
+ {
+ return MapValueConverter.getSetAttribute(name, _source);
+ }
+
+ public <T> Set<T> getSetAttribute(String name, Set<T> defaultValue)
+ {
+ return MapValueConverter.getSetAttribute(name, _source, defaultValue);
+ }
+
+ public String getStringAttribute(String name)
+ {
+ String value = getStringAttribute(name, null);
+ if (value == null)
+ {
+ throw new IllegalArgumentException("Attribute with name '" + name + "' is not found!");
+ }
+ return value;
+ }
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/AuthenticationProviderRecoverer.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
+
+public class AuthenticationProviderRecoverer
+{
+ private final AuthenticationProviderFactory _authenticationProviderFactory;
+
+ public AuthenticationProviderRecoverer(AuthenticationProviderFactory authenticationProviderFactory)
+ {
+ _authenticationProviderFactory = authenticationProviderFactory;
+ }
+
+ public AuthenticationProvider create(ConfigurationEntry configurationEntry, Broker broker)
+ {
+ Map<String, Object> attributes = configurationEntry.getAttributes();
+ AuthenticationProvider authenticationProvider = _authenticationProviderFactory.create(
+ configurationEntry.getId(),
+ broker,
+ attributes, null);
+
+ return authenticationProvider;
+ }
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/BrokerRecoverer.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,198 @@
+/*
+ *
+ * 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.Collection;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObjectType;
+import org.apache.qpid.server.model.GroupProvider;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderAdapter;
+import org.apache.qpid.server.model.adapter.AuthenticationProviderFactory;
+import org.apache.qpid.server.model.adapter.BrokerAdapter;
+import org.apache.qpid.server.model.adapter.PortAdapter;
+import org.apache.qpid.server.model.adapter.PortFactory;
+import org.apache.qpid.server.registry.IApplicationRegistry;
+import org.apache.qpid.server.security.group.GroupPrincipalAccessor;
+
+public class BrokerRecoverer
+{
+ private static final Logger LOGGER = Logger.getLogger(BrokerRecoverer.class);
+
+ private final IApplicationRegistry _registry;
+ private final VirtualHostRecoverer _virtualHostRecoverer;
+ private final PortRecoverer _portRecoverer;
+ private final AuthenticationProviderRecoverer _authenticationProviderRecoverer;
+
+ private final AuthenticationProviderFactory _authenticationProviderFactory;
+
+ private final PortFactory _portFactory;
+
+ private final GroupProviderRecoverer _groupProviderRecoverer;
+
+ public BrokerRecoverer(PortRecoverer portRecoverer, VirtualHostRecoverer virtualHostRecoverer,
+ AuthenticationProviderRecoverer authenticationProviderRecoverer,
+ AuthenticationProviderFactory authenticationProviderFactory, PortFactory portFactory,
+ GroupProviderRecoverer groupProviderRecoverer, IApplicationRegistry registry)
+ {
+ _registry = registry;
+ _virtualHostRecoverer = virtualHostRecoverer;
+ _portRecoverer = portRecoverer;
+ _portFactory = portFactory;
+ _authenticationProviderRecoverer = authenticationProviderRecoverer;
+ _authenticationProviderFactory = authenticationProviderFactory;
+ _groupProviderRecoverer = groupProviderRecoverer;
+ }
+
+ public Broker create(ConfigurationEntry entry)
+ {
+ BrokerAdapter broker = new BrokerAdapter(entry.getId(), _registry, _authenticationProviderFactory, _portFactory);
+ Map<ConfiguredObjectType, Collection<ConfigurationEntry>> childEntries = entry.getChildren();
+ recoverVirtualHosts(broker, childEntries);
+ recoverPorts(broker, childEntries);
+ recoverGroupProviders(broker, childEntries);
+ recoverAuthenticationProviders(broker, childEntries);
+
+ wireUpAuthenticationProviders(broker, entry.getAttributesAsAttributeMap());
+
+ return broker;
+ }
+
+ // XXX unit test this
+ private void wireUpAuthenticationProviders(BrokerAdapter broker, AttributeMap brokerAttributes)
+ {
+ AuthenticationProvider defaultAuthenticationProvider = null;
+ Collection<AuthenticationProvider> authenticationProviders = broker.getAuthenticationProviders();
+ int numberOfAuthenticationProviders = authenticationProviders.size();
+ if (numberOfAuthenticationProviders == 0)
+ {
+ LOGGER.error("No authentication providers configured");
+ return;
+ // XXX reinstate when wire-up has been separated from createion: throw new IllegalConfigurationException("No authentication providers configured");
+ }
+ else if (numberOfAuthenticationProviders == 1)
+ {
+ defaultAuthenticationProvider = authenticationProviders.iterator().next();
+ }
+ else
+ {
+ String name = brokerAttributes.getStringAttribute(Broker.DEFAULT_AUTHENTICATION_PROVIDER);
+ defaultAuthenticationProvider = getAuthenticationProviderByName(broker, name);
+ }
+ broker.setDefaultAuthenticationProvider(defaultAuthenticationProvider);
+
+ GroupPrincipalAccessor groupPrincipalAccessor = new GroupPrincipalAccessor(broker.getGroupProviders());
+ for (AuthenticationProvider authenticationProvider : authenticationProviders)
+ {
+ // XXX : review this cast
+ if (authenticationProvider instanceof AuthenticationProviderAdapter)
+ {
+ ((AuthenticationProviderAdapter<?>)authenticationProvider).setGroupAccessor(groupPrincipalAccessor);
+ }
+ }
+ Collection<Port> ports = broker.getPorts();
+ for (Port port : ports)
+ {
+ String authenticationProviderName = port.getAuthenticationManager();
+ AuthenticationProvider provider = null;
+ if (authenticationProviderName != null)
+ {
+ provider = getAuthenticationProviderByName(broker, authenticationProviderName);
+ }
+ else
+ {
+ provider = defaultAuthenticationProvider;
+ }
+ ((PortAdapter)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;
+ }
+
+ private void recoverPorts(BrokerAdapter broker, Map<ConfiguredObjectType, Collection<ConfigurationEntry>> childEntries)
+ {
+ Collection<ConfigurationEntry> portEntries = childEntries.get(ConfiguredObjectType.PORT);
+ if (portEntries != null)
+ {
+ for (ConfigurationEntry portEntry : portEntries)
+ {
+ Port port = _portRecoverer.create(portEntry, broker);
+ broker.addPort(port);
+ }
+ }
+ }
+
+ private void recoverVirtualHosts(BrokerAdapter broker, Map<ConfiguredObjectType, Collection<ConfigurationEntry>> childEntries)
+ {
+ Collection<ConfigurationEntry> virtualHostEntries = childEntries.get(ConfiguredObjectType.VIRTUAL_HOST);
+ if (virtualHostEntries != null)
+ {
+ for (ConfigurationEntry virtualHostEntry : virtualHostEntries)
+ {
+ VirtualHost host = _virtualHostRecoverer.create(virtualHostEntry, broker);
+ broker.addVirtualHost(host);
+ }
+ }
+ }
+
+ private void recoverAuthenticationProviders(BrokerAdapter broker,
+ Map<ConfiguredObjectType, Collection<ConfigurationEntry>> childEntries)
+ {
+ Collection<ConfigurationEntry> entries = childEntries.get(ConfiguredObjectType.AUTHENTICATION_PROVIDER);
+ if (entries != null)
+ {
+ for (ConfigurationEntry entry : entries)
+ {
+ AuthenticationProvider authenticationProvider = _authenticationProviderRecoverer.create(entry, broker);
+ broker.addAuthenticationProvider(authenticationProvider);
+ }
+ }
+ }
+
+ private void recoverGroupProviders(BrokerAdapter broker,
+ Map<ConfiguredObjectType, Collection<ConfigurationEntry>> childEntries)
+ {
+ Collection<ConfigurationEntry> entries = childEntries.get(ConfiguredObjectType.GROUP_PROVIDER);
+ if (entries != null)
+ {
+ for (ConfigurationEntry entry : entries)
+ {
+ GroupProvider groupProvider = _groupProviderRecoverer.create(entry, broker);
+ broker.addGroupProvider(groupProvider);
+ }
+ }
+ }
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/GroupProviderRecoverer.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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.IllegalConfigurationException;
+import org.apache.qpid.server.model.Broker;
+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
+{
+ private QpidServiceLoader<GroupManagerFactory> _groupManagerServiceLoader;
+
+ public GroupProviderRecoverer(QpidServiceLoader<GroupManagerFactory> groupManagerServiceLoader)
+ {
+ super();
+ _groupManagerServiceLoader = groupManagerServiceLoader;
+ }
+
+ public GroupProvider create(ConfigurationEntry configurationEntry, Broker broker)
+ {
+ 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;
+ }
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/PortRecoverer.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.model.Broker;
+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
+{
+ /**
+ * 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;
+ }
+
+ public Port create(ConfigurationEntry configurationEntry, Broker broker)
+ {
+ return _portFactory.createPort(configurationEntry.getId(), broker, configurationEntry.getAttributes());
+ }
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/startup/VirtualHostRecoverer.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.VirtualHostConfiguration;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.VirtualHost;
+import org.apache.qpid.server.model.adapter.VirtualHostAdapter;
+import org.apache.qpid.server.security.SecurityManager;
+import org.apache.qpid.server.stats.StatisticsGatherer;
+import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
+
+public class VirtualHostRecoverer
+{
+ private VirtualHostRegistry _virtualHostRegistry;
+ private StatisticsGatherer _statisticsGatherer;
+ private SecurityManager _securityManager;
+ private Map<String, VirtualHostConfiguration> _configurations;
+
+ public VirtualHostRecoverer(VirtualHostRegistry virtualHostRegistry, StatisticsGatherer statisticsGatherer,
+ SecurityManager securityManager, Map<String, VirtualHostConfiguration> configurations)
+ {
+ super();
+ _virtualHostRegistry = virtualHostRegistry;
+ _statisticsGatherer = statisticsGatherer;
+ _securityManager = securityManager;
+ _configurations = configurations;
+ }
+
+ public VirtualHost create(ConfigurationEntry entry, Broker parent)
+ {
+ String name = (String) entry.getAttributes().get(VirtualHost.NAME);
+ if (name == null)
+ {
+ throw new IllegalConfigurationException("Mandatory attribute name is not found in virtual host configuration :"
+ + entry);
+ }
+ return new VirtualHostAdapter(entry.getId(), parent, entry.getAttributes(), _virtualHostRegistry,
+ _statisticsGatherer, _securityManager, _configurations.get(name));
+ }
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/PortConfigurationHelper.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/PortConfigurationHelper.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/PortConfigurationHelper.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/PortConfigurationHelper.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,260 @@
+/*
+ *
+ * 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.store;
+
+import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.qpid.server.BrokerOptions;
+import org.apache.qpid.server.ProtocolExclusion;
+import org.apache.qpid.server.ProtocolInclusion;
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.model.ConfiguredObjectType;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.Protocol;
+import org.apache.qpid.server.model.Transport;
+
+public class PortConfigurationHelper
+{
+ private final ConfigurationEntryStore _configurationEntryStore;
+
+ public PortConfigurationHelper(ConfigurationEntryStore configurationEntryStore)
+ {
+ _configurationEntryStore = configurationEntryStore;
+ }
+
+ public Map<UUID, ConfigurationEntry> getPortConfiguration(ServerConfiguration serverConfig, BrokerOptions options)
+ {
+ Map<UUID, ConfigurationEntry> portConfiguration = new HashMap<UUID, ConfigurationEntry>();
+
+ Set<Integer> ports = new HashSet<Integer>(options.getPorts());
+ if (ports.isEmpty())
+ {
+ parsePortList(ports, serverConfig.getPorts());
+ }
+
+ Set<Integer> sslPorts = new HashSet<Integer>(options.getSSLPorts());
+ if (sslPorts.isEmpty())
+ {
+ parsePortList(sslPorts, serverConfig.getSSLPorts());
+ }
+
+ // 1-0 excludes and includes
+ Set<Integer> exclude_1_0 = new HashSet<Integer>(options.getExcludedPorts(ProtocolExclusion.v1_0));
+ if (exclude_1_0.isEmpty())
+ {
+ parsePortList(exclude_1_0, serverConfig.getPortExclude10());
+ }
+
+ Set<Integer> include_1_0 = new HashSet<Integer>(options.getIncludedPorts(ProtocolInclusion.v1_0));
+ if (include_1_0.isEmpty())
+ {
+ parsePortList(include_1_0, serverConfig.getPortInclude10());
+ }
+
+ // 0-10 excludes and includes
+ Set<Integer> exclude_0_10 = new HashSet<Integer>(options.getExcludedPorts(ProtocolExclusion.v0_10));
+ if (exclude_0_10.isEmpty())
+ {
+ parsePortList(exclude_0_10, serverConfig.getPortExclude010());
+ }
+
+ Set<Integer> include_0_10 = new HashSet<Integer>(options.getIncludedPorts(ProtocolInclusion.v0_10));
+ if (include_0_10.isEmpty())
+ {
+ parsePortList(include_0_10, serverConfig.getPortInclude010());
+ }
+
+ // 0-9-1 excludes and includes
+ Set<Integer> exclude_0_9_1 = new HashSet<Integer>(options.getExcludedPorts(ProtocolExclusion.v0_9_1));
+ if (exclude_0_9_1.isEmpty())
+ {
+ parsePortList(exclude_0_9_1, serverConfig.getPortExclude091());
+ }
+
+ Set<Integer> include_0_9_1 = new HashSet<Integer>(options.getIncludedPorts(ProtocolInclusion.v0_9_1));
+ if (include_0_9_1.isEmpty())
+ {
+ parsePortList(include_0_9_1, serverConfig.getPortInclude091());
+ }
+
+ // 0-9 excludes and includes
+ Set<Integer> exclude_0_9 = new HashSet<Integer>(options.getExcludedPorts(ProtocolExclusion.v0_9));
+ if (exclude_0_9.isEmpty())
+ {
+ parsePortList(exclude_0_9, serverConfig.getPortExclude09());
+ }
+
+ Set<Integer> include_0_9 = new HashSet<Integer>(options.getIncludedPorts(ProtocolInclusion.v0_9));
+ if (include_0_9.isEmpty())
+ {
+ parsePortList(include_0_9, serverConfig.getPortInclude09());
+ }
+
+ // 0-8 excludes and includes
+ Set<Integer> exclude_0_8 = new HashSet<Integer>(options.getExcludedPorts(ProtocolExclusion.v0_8));
+ if (exclude_0_8.isEmpty())
+ {
+ parsePortList(exclude_0_8, serverConfig.getPortExclude08());
+ }
+
+ Set<Integer> include_0_8 = new HashSet<Integer>(options.getIncludedPorts(ProtocolInclusion.v0_8));
+ if (include_0_8.isEmpty())
+ {
+ parsePortList(include_0_8, serverConfig.getPortInclude08());
+ }
+
+ String bindAddress = getBindAddress(options, serverConfig);
+
+ if (!serverConfig.getSSLOnly())
+ {
+ addAmqpPort(bindAddress, ports, Transport.TCP, serverConfig, exclude_1_0, include_1_0, exclude_0_10,
+ include_0_10, exclude_0_9_1, include_0_9_1, exclude_0_9, include_0_9, exclude_0_8, include_0_8,
+ portConfiguration);
+ }
+
+ if (serverConfig.getEnableSSL())
+ {
+ addAmqpPort(bindAddress, sslPorts, Transport.SSL, serverConfig, exclude_1_0, include_1_0, exclude_0_10,
+ include_0_10, exclude_0_9_1, include_0_9_1, exclude_0_9, include_0_9, exclude_0_8, include_0_8,
+ portConfiguration);
+ }
+
+ return portConfiguration;
+ }
+
+ private String getBindAddress(final BrokerOptions options, ServerConfiguration serverConfig)
+ {
+ String bindAddr = options.getBind();
+ if (bindAddr == null)
+ {
+ bindAddr = serverConfig.getBind();
+ }
+
+ String bindAddress;
+ if (bindAddr.equals(WILDCARD_ADDRESS))
+ {
+ bindAddress = null;
+ }
+ else
+ {
+ bindAddress = bindAddr;
+ }
+ return bindAddress;
+ }
+
+ private void parsePortList(Set<Integer> output, List<?> ports)
+ {
+ if (ports != null)
+ {
+ for (Object o : ports)
+ {
+ try
+ {
+ output.add(Integer.parseInt(String.valueOf(o)));
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalConfigurationException("Invalid port: " + o, e);
+ }
+ }
+ }
+ }
+
+ private void addAmqpPort(String bindAddress, Set<Integer> ports, Transport transport, ServerConfiguration serverConfig,
+ Set<Integer> exclude_1_0, Set<Integer> include_1_0, Set<Integer> exclude_0_10, Set<Integer> include_0_10,
+ Set<Integer> exclude_0_9_1, Set<Integer> include_0_9_1, Set<Integer> exclude_0_9, Set<Integer> include_0_9,
+ Set<Integer> exclude_0_8, Set<Integer> include_0_8, Map<UUID, ConfigurationEntry> portConfiguration)
+ {
+ for (int port : ports)
+ {
+ final Set<Protocol> supported = getSupportedVersions(port, exclude_1_0, exclude_0_10, exclude_0_9_1,
+ exclude_0_9, exclude_0_8, include_1_0, include_0_10, include_0_9_1, include_0_9, include_0_8,
+ serverConfig);
+
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(Port.PROTOCOLS, supported);
+ attributes.put(Port.TRANSPORTS, Collections.singleton(transport));
+ attributes.put(Port.PORT, port);
+ attributes.put(Port.BINDING_ADDRESS, bindAddress);
+ attributes.put(Port.TCP_NO_DELAY, serverConfig.getTcpNoDelay());
+ attributes.put(Port.RECEIVE_BUFFER_SIZE, serverConfig.getReceiveBufferSize());
+ attributes.put(Port.SEND_BUFFER_SIZE, serverConfig.getWriteBufferSize());
+ attributes.put(Port.NEED_CLIENT_AUTH, serverConfig.needClientAuth());
+ attributes.put(Port.WANT_CLIENT_AUTH, serverConfig.wantClientAuth());
+ attributes.put(Port.AUTHENTICATION_MANAGER, serverConfig.getPortAuthenticationMappings().get(port));
+
+ ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PORT, attributes,
+ null, _configurationEntryStore);
+
+ portConfiguration.put(entry.getId(), entry);
+ }
+ }
+
+ private Set<Protocol> getSupportedVersions(final int port, final Set<Integer> exclude_1_0,
+ final Set<Integer> exclude_0_10, final Set<Integer> exclude_0_9_1, final Set<Integer> exclude_0_9,
+ final Set<Integer> exclude_0_8, final Set<Integer> include_1_0, final Set<Integer> include_0_10,
+ final Set<Integer> include_0_9_1, final Set<Integer> include_0_9, final Set<Integer> include_0_8,
+ final ServerConfiguration serverConfig)
+ {
+ final EnumSet<Protocol> supported = EnumSet.of(Protocol.AMQP_1_0, Protocol.AMQP_0_10, Protocol.AMQP_0_9_1,
+ Protocol.AMQP_0_9, Protocol.AMQP_0_8);
+
+ if ((exclude_1_0.contains(port) || !serverConfig.isAmqp10enabled()) && !include_1_0.contains(port))
+ {
+ supported.remove(Protocol.AMQP_1_0);
+ }
+
+ if ((exclude_0_10.contains(port) || !serverConfig.isAmqp010enabled()) && !include_0_10.contains(port))
+ {
+ supported.remove(Protocol.AMQP_0_10);
+ }
+
+ if ((exclude_0_9_1.contains(port) || !serverConfig.isAmqp091enabled()) && !include_0_9_1.contains(port))
+ {
+ supported.remove(Protocol.AMQP_0_9_1);
+ }
+
+ if ((exclude_0_9.contains(port) || !serverConfig.isAmqp09enabled()) && !include_0_9.contains(port))
+ {
+ supported.remove(Protocol.AMQP_0_9);
+ }
+
+ if ((exclude_0_8.contains(port) || !serverConfig.isAmqp08enabled()) && !include_0_8.contains(port))
+ {
+ supported.remove(Protocol.AMQP_0_8);
+ }
+
+ return supported;
+ }
+
+}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/store/XMLConfigurationEntryStore.java Thu Nov 1 09:48:52 2012
@@ -0,0 +1,344 @@
+/*
+ *
+ * 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.store;
+
+import static org.apache.qpid.transport.ConnectionSettings.WILDCARD_ADDRESS;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationUtils;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.tree.ConfigurationNode;
+import org.apache.log4j.Logger;
+import org.apache.qpid.server.BrokerOptions;
+import org.apache.qpid.server.configuration.ConfigurationEntry;
+import org.apache.qpid.server.configuration.ConfigurationEntryStore;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.ServerConfiguration;
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObjectType;
+import org.apache.qpid.server.model.GroupProvider;
+import org.apache.qpid.server.model.Port;
+import org.apache.qpid.server.model.Protocol;
+import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.security.group.FileGroupManagerFactory;
+
+public class XMLConfigurationEntryStore implements ConfigurationEntryStore
+{
+ private static final Logger _logger = Logger.getLogger(XMLConfigurationEntryStore.class);
+
+ private UUID _rootId;
+ private HierarchicalConfiguration _configuration;
+ private Map<UUID, ConfigurationEntry> _rootChildren;
+ private ServerConfiguration _serverConfiguration;
+
+ private PortConfigurationHelper _portConfigurationHelper;
+
+ public XMLConfigurationEntryStore(ServerConfiguration config, BrokerOptions options)
+ {
+ _serverConfiguration = config;
+ _configuration = ConfigurationUtils.convertToHierarchical(config.getConfig());
+ _rootId = UUID.randomUUID();
+ _rootChildren = new HashMap<UUID, ConfigurationEntry>();
+
+ _portConfigurationHelper = new PortConfigurationHelper(this);
+
+ updateManagementPorts(_serverConfiguration, options);
+
+ getGroupProviders(_configuration, _rootChildren);
+ getAuthenticationProviders(_configuration, _rootChildren);
+ getAmqpPorts(_serverConfiguration, _rootChildren, options);
+ getManagementPorts(_serverConfiguration, _rootChildren, options);
+ getVirtualHosts(_serverConfiguration, _rootChildren);
+ _logger.warn("Root children are: " + _rootChildren);
+ }
+
+ @Override
+ public ConfigurationEntry getRootEntry()
+ {
+ // XXX include all broker attributes
+ Map<String, Object> brokerAttributes = new HashMap<String, Object>();
+ brokerAttributes.put(Broker.DEFAULT_AUTHENTICATION_PROVIDER, _serverConfiguration.getDefaultAuthenticationManager());
+ ConfigurationEntry rootEntry = new ConfigurationEntry(_rootId, ConfiguredObjectType.BROKER, brokerAttributes,
+ Collections.unmodifiableSet(_rootChildren.keySet()), this);
+
+ _logger.warn("Returning root entry: " + rootEntry);
+
+ return rootEntry;
+ }
+
+ private void getAuthenticationProviders(Configuration configuration, Map<UUID, ConfigurationEntry> rootChildren)
+ {
+ HierarchicalConfiguration securityConfiguration = ConfigurationUtils.convertToHierarchical(
+ configuration.subset("security"));
+
+ Collection<ConfigurationNode> nodes = securityConfiguration.getRootNode().getChildren();
+ for (ConfigurationNode configurationNode : nodes)
+ {
+ String name = configurationNode.getName();
+ if (name.contains("auth-manager") && !"default-auth-manager".equals(name))
+ {
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(AuthenticationProvider.TYPE, name);
+ Configuration config = configuration.subset("security." + name);
+ Iterator<String> keysIterator = config.getKeys();
+ while (keysIterator.hasNext())
+ {
+ String key = keysIterator.next();
+ if (!"".equals(key))
+ {
+ List<Object> object = configuration.getList("security." + name + "." + key);
+ int size = object.size();
+ if (size == 0)
+ {
+ attributes.put(key, null);
+ }
+ else if (size == 1)
+ {
+ attributes.put(key, object.get(0));
+ }
+ else
+ {
+ attributes.put(key, object);
+ }
+ }
+ }
+ ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(),
+ ConfiguredObjectType.AUTHENTICATION_PROVIDER, attributes, null, this);
+ rootChildren.put(entry.getId(), entry);
+ }
+ }
+
+ }
+
+ /** hard-coded values match those in {@link FileGroupManagerFactory} */
+ private void getGroupProviders(Configuration configuration, Map<UUID, ConfigurationEntry> rootChildren)
+ {
+ Configuration fileGroupManagerConfig = configuration.subset("security.file-group-manager");
+ if(fileGroupManagerConfig != null && !fileGroupManagerConfig.isEmpty())
+ {
+ String file = fileGroupManagerConfig.getString("attributes.attribute.value");
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(GroupProvider.TYPE, "file-group-manager");
+ attributes.put("file", file);
+ ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.GROUP_PROVIDER, attributes, null, this);
+ rootChildren.put(entry.getId(), entry);
+ }
+ }
+
+ private void getAmqpPorts(ServerConfiguration serverConfig, Map<UUID, ConfigurationEntry> rootChildren,
+ BrokerOptions options)
+ {
+ Map<UUID, ConfigurationEntry> amqpPortConfiguration = _portConfigurationHelper.getPortConfiguration(serverConfig,
+ options);
+ rootChildren.putAll(amqpPortConfiguration);
+
+ }
+
+ private void getManagementPorts(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren,
+ BrokerOptions options)
+ {
+ if (serverConfiguration.getHTTPManagementEnabled())
+ {
+ ConfigurationEntry entry = createManagementHttpPort(serverConfiguration.getHTTPManagementPort(), Protocol.HTTP,
+ Transport.TCP);
+ rootChildren.put(entry.getId(), entry);
+ }
+ if (serverConfiguration.getHTTPSManagementEnabled())
+ {
+ ConfigurationEntry entry = createManagementHttpPort(serverConfiguration.getHTTPSManagementPort(),
+ Protocol.HTTPS, Transport.SSL);
+ rootChildren.put(entry.getId(), entry);
+ }
+ if (serverConfiguration.getJMXManagementEnabled())
+ {
+ // XXX: change JMX port to not rely on names
+ ConfigurationEntry entryRegistry = createManagementJmxPort(serverConfiguration.getJMXPortRegistryServer(),
+ "registry", Protocol.JMX_RMI, Transport.TCP);
+ rootChildren.put(entryRegistry.getId(), entryRegistry);
+ Transport connectorTransport = serverConfiguration.getManagementSSLEnabled() ? Transport.SSL : Transport.TCP;
+ ConfigurationEntry entryConnector = createManagementJmxPort(serverConfiguration.getJMXConnectorServerPort(),
+ "connector", Protocol.JMX_RMI, connectorTransport);
+ rootChildren.put(entryConnector.getId(), entryConnector);
+ }
+ }
+
+ /**
+ * Update the configuration data with the management port.
+ */
+ private void updateManagementPorts(ServerConfiguration configuration, BrokerOptions options)
+ {
+ Integer registryServerPort = options.getJmxPortRegistryServer();
+ Integer connectorServerPort = options.getJmxPortConnectorServer();
+
+ if (registryServerPort != null)
+ {
+ try
+ {
+ configuration.setJMXPortRegistryServer(registryServerPort);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalConfigurationException("Invalid management (registry server) port: " + registryServerPort,
+ null);
+ }
+ }
+ if (connectorServerPort != null)
+ {
+ try
+ {
+ configuration.setJMXPortConnectorServer(connectorServerPort);
+ }
+ catch (NumberFormatException e)
+ {
+ throw new IllegalConfigurationException(
+ "Invalid management (connector server) port: " + connectorServerPort, null);
+ }
+ }
+ }
+
+ private ConfigurationEntry createManagementHttpPort(int port, final Protocol protocol, final Transport transport)
+ {
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(Port.PROTOCOLS, Collections.singleton(protocol));
+ attributes.put(Port.TRANSPORTS, Collections.singleton(transport));
+ attributes.put(Port.PORT, port);
+ attributes.put(Port.BINDING_ADDRESS, null);
+ return new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PORT, attributes, null, this);
+ }
+
+ private ConfigurationEntry createManagementJmxPort(int port, String name, final Protocol protocol,
+ final Transport transport)
+ {
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ // We current use the a special port name to distinguish between the
+ // connection/registry servers. We need another 'type' attribute so we can determine its
+ // role.
+ attributes.put(Port.NAME, name);
+ attributes.put(Port.PROTOCOLS, Collections.singleton(protocol));
+ attributes.put(Port.TRANSPORTS, Collections.singleton(transport));
+ attributes.put(Port.PORT, port);
+ attributes.put(Port.BINDING_ADDRESS, null);
+ return new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PORT, attributes, null, this);
+ }
+
+ private void getVirtualHosts(ServerConfiguration serverConfiguration, Map<UUID, ConfigurationEntry> rootChildren)
+ {
+ for (String name : serverConfiguration.getVirtualHostsNames())
+ {
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(org.apache.qpid.server.model.VirtualHost.NAME, name);
+ ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.VIRTUAL_HOST,
+ attributes, null, this);
+ rootChildren.put(entry.getId(), entry);
+ }
+ }
+
+ protected ConfigurationEntry createPortConfigurationEntry(ServerConfiguration serverConfiguration, Integer portNumber,
+ Transport transport)
+ {
+ final Set<Protocol> supported = new HashSet<Protocol>();
+ if (serverConfiguration.isAmqp010enabled())
+ {
+ supported.add(Protocol.AMQP_0_10);
+ }
+ if (serverConfiguration.isAmqp091enabled())
+ {
+ supported.add(Protocol.AMQP_0_9_1);
+ }
+ if (serverConfiguration.isAmqp09enabled())
+ {
+ supported.add(Protocol.AMQP_0_9);
+ }
+ if (serverConfiguration.isAmqp08enabled())
+ {
+ supported.add(Protocol.AMQP_0_8);
+ }
+ if (serverConfiguration.isAmqp10enabled())
+ {
+ supported.add(Protocol.AMQP_1_0);
+ }
+
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ attributes.put(Port.PROTOCOLS, supported);
+ attributes.put(Port.TRANSPORTS, Collections.singleton(transport));
+ attributes.put(Port.PORT, portNumber);
+ attributes.put(Port.BINDING_ADDRESS, getBindAddress(serverConfiguration));
+ attributes.put(Port.TCP_NO_DELAY, serverConfiguration.getTcpNoDelay());
+ attributes.put(Port.RECEIVE_BUFFER_SIZE, serverConfiguration.getReceiveBufferSize());
+ attributes.put(Port.SEND_BUFFER_SIZE, serverConfiguration.getWriteBufferSize());
+ attributes.put(Port.NEED_CLIENT_AUTH, serverConfiguration.needClientAuth());
+ attributes.put(Port.WANT_CLIENT_AUTH, serverConfiguration.wantClientAuth());
+ attributes.put(Port.AUTHENTICATION_MANAGER, serverConfiguration.getPortAuthenticationMappings().get(portNumber));
+
+ ConfigurationEntry entry = new ConfigurationEntry(UUID.randomUUID(), ConfiguredObjectType.PORT, attributes, null,
+ this);
+ return entry;
+ }
+
+ private String getBindAddress(ServerConfiguration serverConfig)
+ {
+ String bindAddr = serverConfig.getBind();
+
+ String bindAddress;
+ if (bindAddr.equals(WILDCARD_ADDRESS))
+ {
+ bindAddress = null;
+ }
+ else
+ {
+ bindAddress = bindAddr;
+ }
+ return bindAddress;
+ }
+
+ /** note that this only works if the id is an immediate child of root */
+ @Override
+ public ConfigurationEntry getEntry(UUID id)
+ {
+ return _rootChildren.get(id);
+ }
+
+ @Override
+ public void save(ConfigurationEntry... entries)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void remove(UUID... entryIds)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/AuthenticationProvider.java Thu Nov 1 09:48:52 2012
@@ -24,6 +24,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import org.apache.qpid.server.security.SubjectCreator;
+
public interface AuthenticationProvider extends ConfiguredObject
{
@@ -52,4 +54,13 @@ public interface AuthenticationProvider
TYPE));
//children
Collection<VirtualHostAlias> getVirtualHostPortBindings();
+
+ String getName();
+
+ /**
+ * A temporary method to create SubjectCreator.
+ *
+ * TODO: move all the functionality from SubjectCreator into AuthenticationProvider
+ */
+ SubjectCreator getSubjectCreator();
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/Broker.java Thu Nov 1 09:48:52 2012
@@ -44,6 +44,7 @@ public interface Broker extends Configur
String STATE = "state";
String TIME_TO_LIVE = "timeToLive";
String UPDATED = "updated";
+ String DEFAULT_AUTHENTICATION_PROVIDER = "defaultAuthenticationProvider";
// Attributes
public static final Collection<String> AVAILABLE_ATTRIBUTES =
@@ -62,7 +63,8 @@ public interface Broker extends Configur
NAME,
STATE,
TIME_TO_LIVE,
- UPDATED));
+ UPDATED,
+ DEFAULT_AUTHENTICATION_PROVIDER));
//children
Collection < VirtualHost > getVirtualHosts();
@@ -75,6 +77,7 @@ public interface Broker extends Configur
LifetimePolicy lifetime, long ttl, Map<String, Object> attributes)
throws AccessControlException, IllegalArgumentException;
- void deleteVirtualHost(VirtualHost virtualHost)
- throws AccessControlException, IllegalStateException;
+ AuthenticationProvider getDefaultAuthenticationProvider();
+
+ Collection<GroupProvider> getGroupProviders();
}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObject.java Thu Nov 1 09:48:52 2012
@@ -25,13 +25,16 @@ import java.util.Collection;
import java.util.Map;
import java.util.UUID;
+/**
+ * An object that can be "managed" (eg via the web interface) and usually read from configuration.
+ */
public interface ConfiguredObject
{
/**
* Get the universally unique identifier for the object
*
- * @return the objects id
+ * @return the object's id
*/
UUID getId();
@@ -47,7 +50,7 @@ public interface ConfiguredObject
* Attempt to change the name of the object
*
* Request a change to the name of the object. The caller must pass in the name it believes the object currently
- * has. If the current name differes from this expected value, then no name change will occur
+ * has. If the current name differs from this expected value, then no name change will occur
*
* @param currentName the name the caller believes the object to have
* @param desiredName the name the caller would like the object to have
@@ -243,4 +246,7 @@ public interface ConfiguredObject
<C extends ConfiguredObject> C createChild(Class<C> childClass,
Map<String, Object> attributes,
ConfiguredObject... otherParents);
+
+ ConfiguredObjectType getConfiguredObjectType();
+
}
Added: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java?rev=1404521&view=auto
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java (added)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/ConfiguredObjectType.java Thu Nov 1 09:48:52 2012
@@ -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.model;
+
+public enum ConfiguredObjectType
+{
+ BROKER(Broker.class),
+ VIRTUAL_HOST(VirtualHost.class),
+ PORT(Port.class),
+ AUTHENTICATION_PROVIDER(AuthenticationProvider.class),
+ PASSWORD_CREDENTIAL_MANAGING_AUTHENTICATION_PROVIDER(PasswordCredentialManagingAuthenticationProvider.class),
+ AUTHENTICATION_METHOD(AuthenticationMethod.class),
+ EXCHANGE(Exchange.class),
+ USER(User.class),
+ BINDING(Binding.class),
+ VIRTUAL_HOST_ALIAS(VirtualHostAlias.class),
+ CONSUMER(Consumer.class),
+ GROUP(Group.class),
+ GROUP_MEMBER(GroupMember.class),
+ SESSION(Session.class),
+ PUBLISHER(Publisher.class),
+ QUEUE(Queue.class),
+ CONNECTION(Connection.class),
+ GROUP_PROVIDER(GroupProvider.class);
+
+ private final Class<? extends ConfiguredObject> _type;
+
+ private ConfiguredObjectType(Class<? extends ConfiguredObject> classObject)
+ {
+ _type = classObject;
+ }
+
+ public Class<? extends ConfiguredObject> getType()
+ {
+ return _type;
+ }
+}
Modified: qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/GroupProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/GroupProvider.java?rev=1404521&r1=1404520&r2=1404521&view=diff
==============================================================================
--- qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/GroupProvider.java (original)
+++ qpid/branches/java-broker-config-qpid-4390/qpid/java/broker/src/main/java/org/apache/qpid/server/model/GroupProvider.java Thu Nov 1 09:48:52 2012
@@ -19,9 +19,11 @@
*/
package org.apache.qpid.server.model;
+import java.security.Principal;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.Set;
public interface GroupProvider extends ConfiguredObject
{
@@ -48,4 +50,6 @@ public interface GroupProvider extends C
CREATED,
UPDATED,
TYPE));
+
+ Set<Principal> getGroupPrincipalsForUser(String username);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org