You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2014/04/03 21:59:01 UTC
svn commit: r1584365 [6/15] - in
/qpid/branches/java-broker-config-store-changes/qpid/java: ./
bdbstore/jmx/src/main/java/org/apache/qpid/server/store/berkeleydb/jmx/
bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/
bdbstore/src/main/jav...
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAdapter.java Thu Apr 3 19:58:53 2014
@@ -20,51 +20,44 @@
*/
package org.apache.qpid.server.model.adapter;
-import java.io.File;
-import java.lang.reflect.Type;
-import java.security.AccessControlException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.commons.configuration.CompositeConfiguration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.commons.configuration.SystemConfiguration;
import org.apache.log4j.Logger;
-import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
-import org.apache.qpid.server.configuration.VirtualHostConfiguration;
-import org.apache.qpid.server.configuration.XmlConfigurationUtilities.MyConfiguration;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.exchange.AMQUnknownExchangeType;
import org.apache.qpid.server.exchange.ExchangeImpl;
import org.apache.qpid.server.message.MessageInstance;
import org.apache.qpid.server.message.ServerMessage;
import org.apache.qpid.server.model.*;
-import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.plugin.ExchangeType;
+import org.apache.qpid.server.plugin.VirtualHostFactory;
import org.apache.qpid.server.protocol.AMQConnectionModel;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.ConflationQueue;
import org.apache.qpid.server.security.access.Operation;
-import org.apache.qpid.server.stats.StatisticsGatherer;
import org.apache.qpid.server.store.MessageStore;
import org.apache.qpid.server.txn.LocalTransaction;
import org.apache.qpid.server.txn.ServerTransaction;
import org.apache.qpid.server.util.MapValueConverter;
-import org.apache.qpid.server.plugin.VirtualHostFactory;
-import org.apache.qpid.server.util.ServerScopedRuntimeException;
+import org.apache.qpid.server.util.ParameterizedTypeImpl;
import org.apache.qpid.server.virtualhost.ExchangeExistsException;
+import org.apache.qpid.server.virtualhost.QueueExistsException;
import org.apache.qpid.server.virtualhost.ReservedExchangeNameException;
import org.apache.qpid.server.virtualhost.UnknownExchangeException;
import org.apache.qpid.server.virtualhost.VirtualHostListener;
import org.apache.qpid.server.virtualhost.VirtualHostRegistry;
-import org.apache.qpid.server.virtualhost.QueueExistsException;
-public final class VirtualHostAdapter extends AbstractConfiguredObject<VirtualHostAdapter> implements VirtualHost<VirtualHostAdapter>, VirtualHostListener
+import java.lang.reflect.Type;
+import java.security.AccessControlException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+@ManagedObject( category = false, type = "STANDARD")
+public class VirtualHostAdapter<X extends VirtualHostAdapter<X>> extends AbstractConfiguredObject<X> implements VirtualHost<X>, VirtualHostListener
{
private static final Logger LOGGER = Logger.getLogger(VirtualHostAdapter.class);
@@ -72,10 +65,32 @@ public final class VirtualHostAdapter ex
public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{
put(NAME, String.class);
put(TYPE, String.class);
- put(STORE_PATH, String.class);
- put(STORE_TYPE, String.class);
- put(CONFIG_PATH, String.class);
put(STATE, State.class);
+
+ put(QUEUE_ALERT_REPEAT_GAP, Long.class);
+ put(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE, Long.class);
+ put(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE, Long.class);
+ put(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES, Long.class);
+ put(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, Long.class);
+ put(QUEUE_DEAD_LETTER_QUEUE_ENABLED, Boolean.class);
+ put(QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, Integer.class);
+ put(QUEUE_FLOW_CONTROL_SIZE_BYTES, Long.class);
+ put(QUEUE_FLOW_RESUME_SIZE_BYTES, Long.class);
+
+ put(HOUSEKEEPING_CHECK_PERIOD, Long.class);
+ put(STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE, Long.class);
+ put(STORE_TRANSACTION_IDLE_TIMEOUT_WARN, Long.class);
+ put(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, Long.class);
+ put(STORE_TRANSACTION_OPEN_TIMEOUT_WARN, Long.class);
+
+ put(MESSAGE_STORE_SETTINGS, new ParameterizedTypeImpl(Map.class, String.class, Object.class));
+ put(CONFIGURATION_STORE_SETTINGS, new ParameterizedTypeImpl(Map.class, String.class, Object.class));
+
+ }});
+
+ @SuppressWarnings("serial")
+ private static final Map<String, Object> DEFAULTS = Collections.unmodifiableMap(new HashMap<String, Object>(){{
+ put(HOUSE_KEEPING_THREAD_COUNT, Runtime.getRuntime().availableProcessors());
}});
private org.apache.qpid.server.virtualhost.VirtualHost _virtualHost;
@@ -85,15 +100,19 @@ public final class VirtualHostAdapter ex
private final Broker<?> _broker;
private final List<VirtualHostAlias> _aliases = new ArrayList<VirtualHostAlias>();
- private StatisticsGatherer _brokerStatisticsGatherer;
- public VirtualHostAdapter(UUID id, Map<String, Object> attributes, Broker<?> broker, StatisticsGatherer brokerStatisticsGatherer, TaskExecutor taskExecutor)
- {
- super(id, Collections.<String,Object>emptyMap(), MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false), taskExecutor, false);
+ public VirtualHostAdapter(UUID id,
+ Map<String, Object> attributes,
+ Broker<?> broker)
+ {
+ super(Collections.<Class<? extends ConfiguredObject>, ConfiguredObject<?>>singletonMap(Broker.class,broker),
+ DEFAULTS,
+ combineIdWithAttributes(id, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES, false)),
+ broker.getTaskExecutor(),
+ false);
+
_broker = broker;
- _brokerStatisticsGatherer = brokerStatisticsGatherer;
validateAttributes();
- addParent(Broker.class, broker);
}
private void validateAttributes()
@@ -103,58 +122,19 @@ public final class VirtualHostAdapter ex
{
throw new IllegalConfigurationException("Virtual host name must be specified");
}
-
- String configurationFile = (String) getAttribute(CONFIG_PATH);
- String type = (String) getAttribute(TYPE);
-
- boolean invalidAttributes = false;
- if (configurationFile == null)
- {
- if (type == null)
- {
- invalidAttributes = true;
- }
- else
- {
- validateAttributes(type);
- }
- }/*
- else
- {
- if (type != null)
- {
- invalidAttributes = true;
- }
-
- }*/
- if (invalidAttributes)
- {
- throw new IllegalConfigurationException("Please specify either the 'configPath' attribute or 'type' attributes");
- }
-
- // pre-load the configuration in order to validate
- try
- {
- createVirtualHostConfiguration(name);
- }
- catch(ConfigurationException e)
+ String type = getType();
+ if (type == null || "".equals(type.trim()))
{
- throw new IllegalConfigurationException("Failed to validate configuration", e);
+ throw new IllegalConfigurationException("Virtual host type must be specified");
}
- }
-
- private void validateAttributes(String type)
- {
final VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
if(factory == null)
{
throw new IllegalArgumentException("Unknown virtual host type '"+ type +"'. Valid types are: " + VirtualHostFactory.TYPES.get());
}
factory.validateAttributes(getActualAttributes());
-
}
-
public Collection<VirtualHostAlias> getAliases()
{
return Collections.unmodifiableCollection(_aliases);
@@ -681,95 +661,88 @@ public final class VirtualHostAdapter ex
{
return LifetimePolicy.PERMANENT;
}
- else if (_virtualHost != null)
+ else if(QUEUE_ALERT_REPEAT_GAP.equals(name))
{
- return getAttributeFromVirtualHostImplementation(name);
+ return getAttribute(QUEUE_ALERT_REPEAT_GAP, Broker.QUEUE_ALERT_REPEAT_GAP);
}
- return super.getAttribute(name);
- }
-
- private Object getAttributeFromVirtualHostImplementation(String name)
- {
- if(SUPPORTED_EXCHANGE_TYPES.equals(name))
+ else if(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE.equals(name))
{
- List<String> types = new ArrayList<String>();
- for(@SuppressWarnings("rawtypes") ExchangeType type : _virtualHost.getExchangeTypes())
- {
- types.add(type.getType());
- }
- return Collections.unmodifiableCollection(types);
+ return getAttribute(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE, Broker.QUEUE_ALERT_THRESHOLD_MESSAGE_AGE);
+ }
+ else if(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE.equals(name))
+ {
+ return getAttribute(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE, Broker.QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE);
}
- else if(SUPPORTED_QUEUE_TYPES.equals(name))
+ else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES.equals(name))
{
- // TODO
+ return getAttribute(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES, Broker.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES);
}
- else if(QUEUE_DEAD_LETTER_QUEUE_ENABLED.equals(name))
+ else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES.equals(name))
{
- return _virtualHost.getConfiguration().isDeadLetterQueueEnabled();
+ return getAttribute(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES, Broker.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES);
}
- else if(HOUSEKEEPING_CHECK_PERIOD.equals(name))
+ else if(QUEUE_DEAD_LETTER_QUEUE_ENABLED.equals(name))
{
- return _virtualHost.getConfiguration().getHousekeepingCheckPeriod();
+ return getAttribute(QUEUE_DEAD_LETTER_QUEUE_ENABLED, Broker.QUEUE_DEAD_LETTER_QUEUE_ENABLED);
}
else if(QUEUE_MAXIMUM_DELIVERY_ATTEMPTS.equals(name))
{
- return _virtualHost.getConfiguration().getMaxDeliveryCount();
+ return getAttribute(QUEUE_MAXIMUM_DELIVERY_ATTEMPTS, Broker.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS);
}
else if(QUEUE_FLOW_CONTROL_SIZE_BYTES.equals(name))
{
- return _virtualHost.getConfiguration().getCapacity();
+ return getAttribute(QUEUE_FLOW_CONTROL_SIZE_BYTES, Broker.QUEUE_FLOW_CONTROL_SIZE_BYTES);
}
else if(QUEUE_FLOW_RESUME_SIZE_BYTES.equals(name))
{
- return _virtualHost.getConfiguration().getFlowResumeCapacity();
+ return getAttribute(QUEUE_FLOW_RESUME_SIZE_BYTES, Broker.QUEUE_FLOW_CONTROL_RESUME_SIZE_BYTES);
}
- else if(STORE_TYPE.equals(name))
- {
- return _virtualHost.getMessageStore().getStoreType();
- }
- else if(STORE_PATH.equals(name))
+ else if(HOUSEKEEPING_CHECK_PERIOD.equals(name))
{
- return _virtualHost.getMessageStore().getStoreLocation();
+ return getAttribute(HOUSEKEEPING_CHECK_PERIOD, Broker.VIRTUALHOST_HOUSEKEEPING_CHECK_PERIOD);
}
else if(STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE.equals(name))
{
- return _virtualHost.getConfiguration().getTransactionTimeoutIdleClose();
+ return getAttribute(STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE, Broker.VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE);
}
else if(STORE_TRANSACTION_IDLE_TIMEOUT_WARN.equals(name))
{
- return _virtualHost.getConfiguration().getTransactionTimeoutIdleWarn();
+ return getAttribute(STORE_TRANSACTION_IDLE_TIMEOUT_WARN, Broker.VIRTUALHOST_STORE_TRANSACTION_IDLE_TIMEOUT_WARN);
}
else if(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE.equals(name))
{
- return _virtualHost.getConfiguration().getTransactionTimeoutOpenClose();
+ return getAttribute(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE);
}
else if(STORE_TRANSACTION_OPEN_TIMEOUT_WARN.equals(name))
{
- return _virtualHost.getConfiguration().getTransactionTimeoutOpenWarn();
+ return getAttribute(STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE, Broker.VIRTUALHOST_STORE_TRANSACTION_OPEN_TIMEOUT_WARN);
}
- else if(QUEUE_ALERT_REPEAT_GAP.equals(name))
- {
- return _virtualHost.getConfiguration().getMinimumAlertRepeatGap();
- }
- else if(QUEUE_ALERT_THRESHOLD_MESSAGE_AGE.equals(name))
- {
- return _virtualHost.getConfiguration().getMaximumMessageAge();
- }
- else if(QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE.equals(name))
- {
- return _virtualHost.getConfiguration().getMaximumMessageSize();
- }
- else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES.equals(name))
- {
- return _virtualHost.getConfiguration().getMaximumQueueDepth();
- }
- else if(QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES.equals(name))
+ else if (_virtualHost != null)
{
- return _virtualHost.getConfiguration().getMaximumMessageCount();
+ if(SUPPORTED_EXCHANGE_TYPES.equals(name))
+ {
+ List<String> types = new ArrayList<String>();
+ for(@SuppressWarnings("rawtypes") ExchangeType type : _virtualHost.getExchangeTypes())
+ {
+ types.add(type.getType());
+ }
+ return Collections.unmodifiableCollection(types);
+ }
+ else if(SUPPORTED_QUEUE_TYPES.equals(name))
+ {
+ // TODO
+ }
}
return super.getAttribute(name);
}
+
+ Object getAttribute(String name, String brokerAttributeName)
+ {
+ return getAttribute(name, _broker, brokerAttributeName);
+ }
+
+
@Override
public Collection<String> getAttributeNames()
{
@@ -806,115 +779,99 @@ public final class VirtualHostAdapter ex
@Override
public boolean isQueue_deadLetterQueueEnabled()
{
- return _virtualHost.getConfiguration().isDeadLetterQueueEnabled();
+ return (Boolean)getAttribute(VirtualHost.QUEUE_DEAD_LETTER_QUEUE_ENABLED);
}
@Override
public long getHousekeepingCheckPeriod()
{
- return _virtualHost.getConfiguration().getHousekeepingCheckPeriod();
+ return (Long)getAttribute(VirtualHost.HOUSEKEEPING_CHECK_PERIOD);
}
@Override
public int getQueue_maximumDeliveryAttempts()
{
- return _virtualHost.getConfiguration().getMaxDeliveryCount();
+ return (Integer)getAttribute(VirtualHost.QUEUE_MAXIMUM_DELIVERY_ATTEMPTS);
}
@Override
public long getQueue_flowControlSizeBytes()
{
- return _virtualHost.getConfiguration().getCapacity();
+ return (Long)getAttribute(VirtualHost.QUEUE_FLOW_CONTROL_SIZE_BYTES);
}
@Override
public long getQueue_flowResumeSizeBytes()
{
- return _virtualHost.getConfiguration().getFlowResumeCapacity();
- }
-
- @Override
- public String getConfigStoreType()
- {
- return (String) getAttribute(CONFIG_STORE_TYPE);
- }
-
- @Override
- public String getConfigStorePath()
- {
- return (String) getAttribute(CONFIG_PATH);
- }
-
- @Override
- public String getStoreType()
- {
- return _virtualHost.getMessageStore().getStoreType();
- }
-
- @Override
- public String getStorePath()
- {
- return _virtualHost.getMessageStore().getStoreLocation();
+ return (Long)getAttribute(VirtualHost.QUEUE_FLOW_RESUME_SIZE_BYTES);
}
@Override
public long getStoreTransactionIdleTimeoutClose()
{
- return _virtualHost.getConfiguration().getTransactionTimeoutIdleClose();
+ return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_IDLE_TIMEOUT_CLOSE);
}
@Override
public long getStoreTransactionIdleTimeoutWarn()
{
- return _virtualHost.getConfiguration().getTransactionTimeoutIdleWarn();
+ return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_IDLE_TIMEOUT_WARN);
}
@Override
public long getStoreTransactionOpenTimeoutClose()
{
- return _virtualHost.getConfiguration().getTransactionTimeoutOpenClose();
+ return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_OPEN_TIMEOUT_CLOSE);
}
@Override
public long getStoreTransactionOpenTimeoutWarn()
{
- return _virtualHost.getConfiguration().getTransactionTimeoutOpenWarn();
+ return (Long)getAttribute(VirtualHost.STORE_TRANSACTION_OPEN_TIMEOUT_WARN);
}
@Override
public long getQueue_alertRepeatGap()
{
- return _virtualHost.getConfiguration().getMinimumAlertRepeatGap();
+ return (Long)getAttribute(VirtualHost.QUEUE_ALERT_REPEAT_GAP);
}
@Override
public long getQueue_alertThresholdMessageAge()
{
- return _virtualHost.getConfiguration().getMaximumMessageAge();
+ return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_MESSAGE_AGE);
}
@Override
public long getQueue_alertThresholdMessageSize()
{
- return _virtualHost.getConfiguration().getMaximumMessageSize();
+ return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_MESSAGE_SIZE);
}
@Override
public long getQueue_alertThresholdQueueDepthBytes()
{
- return _virtualHost.getConfiguration().getMaximumQueueDepth();
+ return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_BYTES);
}
@Override
public long getQueue_alertThresholdQueueDepthMessages()
{
- return _virtualHost.getConfiguration().getMaximumMessageCount();
+ return (Long)getAttribute(VirtualHost.QUEUE_ALERT_THRESHOLD_QUEUE_DEPTH_MESSAGES);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Map<String, Object> getMessageStoreSettings()
+ {
+ return (Map<String, Object>)getAttribute(VirtualHost.MESSAGE_STORE_SETTINGS);
}
+ @SuppressWarnings("unchecked")
@Override
- public String getConfigPath()
+ public Map<String, Object> getConfigurationStoreSettings()
{
- return (String) getAttribute(CONFIG_PATH);
+ return (Map<String, Object>)getAttribute(VirtualHost.CONFIGURATION_STORE_SETTINGS);
}
@Override
@@ -959,6 +916,17 @@ public final class VirtualHostAdapter ex
return _virtualHost.getMessageDeliveryStatistics().getTotal();
}
+ @Override
+ public String getSecurityAcl()
+ {
+ return (String)getAttribute(SECURITY_ACL);
+ }
+
+ @Override
+ public int getHouseKeepingThreadCount()
+ {
+ return (Integer)getAttribute(HOUSE_KEEPING_THREAD_COUNT);
+ }
@Override
protected boolean setState(State currentState, State desiredState)
@@ -1038,27 +1006,18 @@ public final class VirtualHostAdapter ex
{
VirtualHostRegistry virtualHostRegistry = _broker.getVirtualHostRegistry();
String virtualHostName = getName();
- try
+ String type = (String) getAttribute(TYPE);
+ final VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
+ if(factory == null)
{
- VirtualHostConfiguration configuration = createVirtualHostConfiguration(virtualHostName);
- String type = configuration.getType();
- final VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
- if(factory == null)
- {
- throw new IllegalArgumentException("Unknown virtual host type: " + type);
- }
- else
- {
- _virtualHost = factory.createVirtualHost(_broker.getVirtualHostRegistry(),
- _brokerStatisticsGatherer,
- _broker.getSecurityManager(),
- configuration,
- this);
- }
+ throw new IllegalArgumentException("Unknown virtual host type: " + type);
}
- catch (ConfigurationException e)
+ else
{
- throw new ServerScopedRuntimeException("Failed to create virtual host " + virtualHostName, e);
+ _virtualHost = factory.createVirtualHost(_broker.getVirtualHostRegistry(),
+ _broker,
+ _broker.getSecurityManager(),
+ this);
}
virtualHostRegistry.registerVirtualHost(_virtualHost);
@@ -1077,53 +1036,6 @@ public final class VirtualHostAdapter ex
}
}
- private VirtualHostConfiguration createVirtualHostConfiguration(String virtualHostName) throws ConfigurationException
- {
- VirtualHostConfiguration configuration;
- String configurationFile = (String)getAttribute(CONFIG_PATH);
- if (configurationFile == null)
- {
- final MyConfiguration basicConfiguration = new MyConfiguration();
- PropertiesConfiguration config = new PropertiesConfiguration();
- final String type = (String) getAttribute(TYPE);
- config.addProperty("type", type);
- VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
- if(factory != null)
- {
- for(Map.Entry<String,Object> entry : factory.createVirtualHostConfiguration(this).entrySet())
- {
- config.addProperty(entry.getKey(), entry.getValue());
- }
- }
- basicConfiguration.addConfiguration(config);
-
- CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
- compositeConfiguration.addConfiguration(new SystemConfiguration());
- compositeConfiguration.addConfiguration(basicConfiguration);
- configuration = new VirtualHostConfiguration(virtualHostName, compositeConfiguration , _broker);
- }
- else
- {
- if (!new File(configurationFile).exists())
- {
- throw new IllegalConfigurationException("Configuration file '" + configurationFile + "' does not exist");
- }
- configuration = new VirtualHostConfiguration(virtualHostName, new File(configurationFile) , _broker);
- String type = configuration.getType();
- changeAttribute(TYPE,null,type);
- VirtualHostFactory factory = VirtualHostFactory.FACTORIES.get(type);
- if(factory != null)
- {
- for(Map.Entry<String,Object> entry : factory.convertVirtualHostConfiguration(configuration.getConfig()).entrySet())
- {
- changeAttribute(entry.getKey(), getAttribute(entry.getKey()), entry.getValue());
- }
- }
-
- }
- return configuration;
- }
-
@Override
public MessageStore getMessageStore()
{
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/VirtualHostAliasAdapter.java Thu Apr 3 19:58:53 2014
@@ -23,14 +23,8 @@ package org.apache.qpid.server.model.ada
import java.util.HashMap;
import java.util.Map;
-import org.apache.qpid.server.model.AuthenticationMethod;
-import org.apache.qpid.server.model.ConfiguredObject;
-import org.apache.qpid.server.model.LifetimePolicy;
-import org.apache.qpid.server.model.Port;
-import org.apache.qpid.server.model.State;
-import org.apache.qpid.server.model.UUIDGenerator;
-import org.apache.qpid.server.model.VirtualHost;
-import org.apache.qpid.server.model.VirtualHostAlias;
+
+import org.apache.qpid.server.model.*;
import java.security.AccessControlException;
import java.util.Collection;
@@ -119,12 +113,6 @@ public class VirtualHostAliasAdapter ext
}
@Override
- public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
protected boolean setState(State currentState, State desiredState)
{
// TODO: state is not supported at the moment
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java Thu Apr 3 19:58:53 2014
@@ -19,7 +19,7 @@
*
*/
-package org.apache.qpid.server.model.adapter;
+package org.apache.qpid.server.model.port;
import java.lang.reflect.Type;
import java.security.AccessControlException;
@@ -40,7 +40,7 @@ import org.apache.qpid.server.util.Param
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
-abstract public class PortAdapter<X extends PortAdapter<X>> extends AbstractConfiguredObject<X> implements Port<X>
+abstract public class AbstractPort<X extends AbstractPort<X>> extends AbstractConfiguredObject<X> implements Port<X>
{
@SuppressWarnings("serial")
public static final Map<String, Type> ATTRIBUTE_TYPES = Collections.unmodifiableMap(new HashMap<String, Type>(){{
@@ -60,35 +60,67 @@ abstract public class PortAdapter<X exte
put(AUTHENTICATION_PROVIDER, String.class);
}});
+ public static final Transport DEFAULT_TRANSPORT = Transport.TCP;
+
private final Broker<?> _broker;
- private AuthenticationProvider _authenticationProvider;
private AtomicReference<State> _state;
- public PortAdapter(UUID id, Broker<?> broker, Map<String, Object> attributes, Map<String, Object> defaults, TaskExecutor taskExecutor)
- {
- super(id, defaults, MapValueConverter.convert(attributes, ATTRIBUTE_TYPES), taskExecutor);
+ public AbstractPort(UUID id,
+ Broker<?> broker,
+ Map<String, Object> attributes,
+ Map<String, Object> defaults,
+ TaskExecutor taskExecutor)
+ {
+ super(Collections.<Class<? extends ConfiguredObject>,ConfiguredObject<?>>singletonMap(Broker.class, broker),
+ updateDefaults(defaults, attributes),
+ combineIdWithAttributes(id,MapValueConverter.convert(attributes, ATTRIBUTE_TYPES)),
+ taskExecutor);
_broker = broker;
+
+ Object portValue = attributes.get(Port.PORT);
+ if (portValue == null)
+ {
+ throw new IllegalConfigurationException("Port attribute is not specified for port: " + attributes);
+ }
+
State state = MapValueConverter.getEnumAttribute(State.class, STATE, attributes, State.INITIALISING);
+ _state = new AtomicReference<State>(state);
+
+
+ boolean useClientAuth = Boolean.TRUE.equals(getAttribute(Port.NEED_CLIENT_AUTH))
+ || Boolean.TRUE.equals(getAttribute(Port.WANT_CLIENT_AUTH));
- Collection<Protocol> protocols = getProtocols();
- boolean rmiRegistry = protocols != null && protocols.contains(Protocol.RMI);
- if (!rmiRegistry)
+ if(useClientAuth && getTrustStores().isEmpty())
{
- String authProvider = (String)getAttribute(Port.AUTHENTICATION_PROVIDER);
- if (authProvider == null)
- {
- throw new IllegalConfigurationException("An authentication provider must be specified for port : " + getName());
- }
- _authenticationProvider = broker.findAuthenticationProviderByName(authProvider);
+ throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust stores configured.");
+ }
- if(_authenticationProvider == null)
- {
- throw new IllegalConfigurationException("The authentication provider '" + authProvider + "' could not be found for port : " + getName());
- }
+ boolean useTLSTransport = getTransports().contains(Transport.SSL) || getTransports().contains(Transport.WSS);
+ if(useClientAuth && !useTLSTransport)
+ {
+ throw new IllegalConfigurationException(
+ "Can't create port which requests SSL client certificates but doesn't use SSL transport.");
+ }
+ if(useTLSTransport && getKeyStore() == null)
+ {
+ throw new IllegalConfigurationException("Can't create a port which uses a secure transport but has no KeyStore");
}
+ }
- _state = new AtomicReference<State>(state);
- addParent(Broker.class, broker);
+
+ private static Map<String, Object> updateDefaults(final Map<String, Object> defaults,
+ final Map<String, Object> attributes)
+ {
+ Map<String, Object> updatedDefaults = new HashMap<String, Object>(defaults);
+ if(!defaults.containsKey(TRANSPORTS))
+ {
+ updatedDefaults.put(Port.TRANSPORTS, Collections.singleton(DEFAULT_TRANSPORT));
+ }
+ if(!defaults.containsKey(NAME))
+ {
+ updatedDefaults.put(NAME, attributes.get(PORT) + "-" + attributes.get(TYPE));
+ }
+ return updatedDefaults;
}
@Override
@@ -220,12 +252,6 @@ abstract public class PortAdapter<X exte
}
@Override
- public <C extends ConfiguredObject> C createChild(Class<C> childClass, Map<String, Object> attributes, ConfiguredObject... otherParents)
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
public Object getAttribute(String name)
{
if(ID.equals(name))
@@ -250,7 +276,7 @@ abstract public class PortAdapter<X exte
@Override
public Collection<String> getAttributeNames()
{
- return getAttributeNames(Port.class);
+ return getAttributeNames(getClass());
}
@Override
@@ -325,12 +351,6 @@ abstract public class PortAdapter<X exte
}
@Override
- public AuthenticationProvider getAuthenticationProvider()
- {
- return _authenticationProvider;
- }
-
- @Override
protected void changeAttributes(Map<String, Object> attributes)
{
Map<String, Object> converted = MapValueConverter.convert(attributes, ATTRIBUTE_TYPES);
@@ -546,4 +566,30 @@ abstract public class PortAdapter<X exte
{
return (Boolean)getAttribute(WANT_CLIENT_AUTH);
}
+
+ protected void validateOnlyOneInstance(final Broker<?> broker)
+ {
+ if(!broker.isManagementMode())
+ {
+ //ManagementMode needs this relaxed to allow its overriding management ports to be inserted.
+
+ //Enforce only a single port of each management protocol, as the plugins will only use one.
+ Collection<Port<?>> existingPorts = broker.getPorts();
+ existingPorts.remove(this);
+
+ for (Port<?> existingPort : existingPorts)
+ {
+ Collection<Protocol> portProtocols = existingPort.getProtocols();
+ if (portProtocols != null)
+ {
+ final ArrayList<Protocol> intersection = new ArrayList(portProtocols);
+ intersection.retainAll(getProtocols());
+ if(!intersection.isEmpty())
+ {
+ throw new IllegalConfigurationException("Port for protocols " + intersection + " already exists. Only one management port per protocol can be created.");
+ }
+ }
+ }
+ }
+ }
}
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/AmqpPortAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPort.java Thu Apr 3 19:58:53 2014
@@ -17,15 +17,10 @@
* under the License.
*
*/
-package org.apache.qpid.server.model.adapter;
+package org.apache.qpid.server.model.port;
import java.security.GeneralSecurityException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
@@ -37,6 +32,7 @@ import org.apache.qpid.server.configurat
import org.apache.qpid.server.logging.messages.BrokerMessages;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.KeyStore;
+import org.apache.qpid.server.model.ManagedObject;
import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.server.model.Transport;
import org.apache.qpid.server.model.TrustStore;
@@ -49,17 +45,73 @@ import org.apache.qpid.server.transport.
import org.apache.qpid.server.util.ServerScopedRuntimeException;
import org.apache.qpid.transport.network.security.ssl.QpidMultipleTrustManager;
-public class AmqpPortAdapter extends PortAdapter<AmqpPortAdapter>
+@ManagedObject( category = false, type = "AMQP")
+public class AmqpPort extends PortWithAuthProvider<AmqpPort>
{
+ public static final int DEFAULT_AMQP_SEND_BUFFER_SIZE = 262144;
+ public static final int DEFAULT_AMQP_RECEIVE_BUFFER_SIZE = 262144;
+ public static final boolean DEFAULT_AMQP_NEED_CLIENT_AUTH = false;
+ public static final boolean DEFAULT_AMQP_WANT_CLIENT_AUTH = false;
+ public static final boolean DEFAULT_AMQP_TCP_NO_DELAY = true;
+ public static final String DEFAULT_AMQP_BINDING = "*";
+
private final Broker<?> _broker;
private AcceptingTransport _transport;
- public AmqpPortAdapter(UUID id, Broker<?> broker, Map<String, Object> attributes, Map<String, Object> defaultAttributes, TaskExecutor taskExecutor)
+ public AmqpPort(UUID id,
+ Broker<?> broker,
+ Map<String, Object> attributes,
+ TaskExecutor taskExecutor)
{
- super(id, broker, attributes, defaultAttributes, taskExecutor);
+ super(id, broker, attributes, defaults(attributes), taskExecutor);
_broker = broker;
}
+ private static Map<String, Object> defaults(Map<String,Object> attributes)
+ {
+ Map<String,Object> defaults = new HashMap<String, Object>();
+
+ defaults.put(BINDING_ADDRESS, DEFAULT_AMQP_BINDING);
+ defaults.put(NAME, attributes.containsKey(BINDING_ADDRESS) ? attributes.get(BINDING_ADDRESS) : DEFAULT_AMQP_BINDING + ":" + attributes.get(PORT));
+ defaults.put(PROTOCOLS, getDefaultProtocols());
+ defaults.put(TCP_NO_DELAY, DEFAULT_AMQP_TCP_NO_DELAY);
+ defaults.put(WANT_CLIENT_AUTH, DEFAULT_AMQP_WANT_CLIENT_AUTH);
+ defaults.put(NEED_CLIENT_AUTH, DEFAULT_AMQP_NEED_CLIENT_AUTH);
+ defaults.put(RECEIVE_BUFFER_SIZE, DEFAULT_AMQP_RECEIVE_BUFFER_SIZE);
+ defaults.put(SEND_BUFFER_SIZE, DEFAULT_AMQP_SEND_BUFFER_SIZE);
+
+ return defaults;
+ }
+
+
+ private static Set<Protocol> getDefaultProtocols()
+ {
+ Set<Protocol> defaultProtocols = EnumSet.of(Protocol.AMQP_0_8, Protocol.AMQP_0_9, Protocol.AMQP_0_9_1,
+ Protocol.AMQP_0_10, Protocol.AMQP_1_0);
+ String excludedProtocols = System.getProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES);
+ if (excludedProtocols != null)
+ {
+ String[] excludes = excludedProtocols.split(",");
+ for (String exclude : excludes)
+ {
+ Protocol protocol = Protocol.valueOf(exclude);
+ defaultProtocols.remove(protocol);
+ }
+ }
+ String includedProtocols = System.getProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_INCLUDES);
+ if (includedProtocols != null)
+ {
+ String[] includes = includedProtocols.split(",");
+ for (String include : includes)
+ {
+ Protocol protocol = Protocol.valueOf(include);
+ defaultProtocols.add(protocol);
+ }
+ }
+ return defaultProtocols;
+ }
+
+
@Override
protected void onActivate()
{
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortFactory.java Thu Apr 3 19:58:53 2014
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.port;
+
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Port;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class AmqpPortFactory extends AbstractConfiguredObjectTypeFactory<AmqpPort>
+{
+ public AmqpPortFactory()
+ {
+ super(AmqpPort.class);
+ }
+
+ @Override
+ public AmqpPort createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
+ {
+ Broker broker = getParent(Broker.class, parents);
+ Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes);
+ Object idObj = attributesWithoutId.remove(Port.ID);
+ UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString());
+
+ return new AmqpPort(id, broker, attributesWithoutId, broker.getTaskExecutor());
+ }
+
+}
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPort.java Thu Apr 3 19:58:53 2014
@@ -18,22 +18,24 @@
* under the License.
*
*/
-package org.apache.qpid.server.model.adapter;
+package org.apache.qpid.server.model.port;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedObject;
+import java.util.Collections;
import java.util.Map;
import java.util.UUID;
-public class NonAmqpPortAdapter extends PortAdapter<NonAmqpPortAdapter>
+@ManagedObject( category = false, type = "HTTP")
+public class HttpPort extends PortWithAuthProvider<HttpPort>
{
- public NonAmqpPortAdapter(final UUID id,
- final Broker<?> broker,
- final Map<String, Object> attributes,
- final Map<String, Object> defaults,
- final TaskExecutor taskExecutor)
+ public HttpPort(final UUID id,
+ final Broker<?> broker,
+ final Map<String, Object> attributes,
+ final TaskExecutor taskExecutor)
{
- super(id, broker, attributes, defaults, taskExecutor);
+ super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor);
}
}
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/HttpPortFactory.java Thu Apr 3 19:58:53 2014
@@ -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.model.port;
+
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Port;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class HttpPortFactory extends AbstractConfiguredObjectTypeFactory<HttpPort>
+{
+ public HttpPortFactory()
+ {
+ super(HttpPort.class);
+ }
+
+ @Override
+ public HttpPort createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
+ {
+ Broker broker = getParent(Broker.class, parents);
+ Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes);
+ Object idObj = attributesWithoutId.remove(Port.ID);
+ UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString());
+ return new HttpPort(id, broker, attributesWithoutId, broker.getTaskExecutor());
+ }
+
+}
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPort.java Thu Apr 3 19:58:53 2014
@@ -18,22 +18,27 @@
* under the License.
*
*/
-package org.apache.qpid.server.model.adapter;
+package org.apache.qpid.server.model.port;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedObject;
+import java.util.Collections;
import java.util.Map;
import java.util.UUID;
-public class NonAmqpPortAdapter extends PortAdapter<NonAmqpPortAdapter>
+@ManagedObject( category = false, type = "JMX")
+public class JmxPort extends PortWithAuthProvider<JmxPort>
{
- public NonAmqpPortAdapter(final UUID id,
- final Broker<?> broker,
- final Map<String, Object> attributes,
- final Map<String, Object> defaults,
- final TaskExecutor taskExecutor)
+ public JmxPort(final UUID id,
+ final Broker<?> broker,
+ final Map<String, Object> attributes,
+ final TaskExecutor taskExecutor)
{
- super(id, broker, attributes, defaults, taskExecutor);
+ super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor);
+
+ validateOnlyOneInstance(broker);
+
}
}
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/JmxPortFactory.java Thu Apr 3 19:58:53 2014
@@ -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.model.port;
+
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Port;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class JmxPortFactory extends AbstractConfiguredObjectTypeFactory<JmxPort>
+{
+ public JmxPortFactory()
+ {
+ super(JmxPort.class);
+ }
+
+ @Override
+ public JmxPort createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
+ {
+ Broker broker = getParent(Broker.class, parents);
+ Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes);
+ Object idObj = attributesWithoutId.remove(Port.ID);
+ UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString());
+ return new JmxPort(id, broker, attributesWithoutId, broker.getTaskExecutor());
+ }
+
+}
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/PortFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortFactory.java Thu Apr 3 19:58:53 2014
@@ -18,27 +18,31 @@
* under the License.
*
*/
-package org.apache.qpid.server.model.adapter;
+package org.apache.qpid.server.model.port;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
-import org.apache.qpid.server.configuration.BrokerProperties;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.ConfiguredObjectFactory;
import org.apache.qpid.server.model.Port;
import org.apache.qpid.server.model.Protocol;
import org.apache.qpid.server.model.Protocol.ProtocolType;
import org.apache.qpid.server.model.Transport;
+import org.apache.qpid.server.model.port.AmqpPort;
+import org.apache.qpid.server.model.port.HttpPort;
+import org.apache.qpid.server.model.port.JmxPort;
+import org.apache.qpid.server.model.port.RmiPort;
+import org.apache.qpid.server.plugin.ConfiguredObjectTypeFactory;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.UnresolvedConfiguredObject;
import org.apache.qpid.server.util.MapValueConverter;
-public class PortFactory
+public class PortFactory<X extends Port<X>> implements ConfiguredObjectTypeFactory<X>
{
public static final int DEFAULT_AMQP_SEND_BUFFER_SIZE = 262144;
public static final int DEFAULT_AMQP_RECEIVE_BUFFER_SIZE = 262144;
@@ -47,146 +51,109 @@ public class PortFactory
public static final boolean DEFAULT_AMQP_TCP_NO_DELAY = true;
public static final String DEFAULT_AMQP_BINDING = "*";
public static final Transport DEFAULT_TRANSPORT = Transport.TCP;
+ private ConfiguredObjectFactory _configuredObjectFactory;
- private final Collection<Protocol> _defaultProtocols;
public PortFactory()
{
- Set<Protocol> defaultProtocols = EnumSet.of(Protocol.AMQP_0_8, Protocol.AMQP_0_9, Protocol.AMQP_0_9_1,
- Protocol.AMQP_0_10, Protocol.AMQP_1_0);
- String excludedProtocols = System.getProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_EXCLUDES);
- if (excludedProtocols != null)
- {
- String[] excludes = excludedProtocols.split(",");
- for (String exclude : excludes)
- {
- Protocol protocol = Protocol.valueOf(exclude);
- defaultProtocols.remove(protocol);
- }
- }
- String includedProtocols = System.getProperty(BrokerProperties.PROPERTY_BROKER_DEFAULT_AMQP_PROTOCOL_INCLUDES);
- if (includedProtocols != null)
- {
- String[] includes = includedProtocols.split(",");
- for (String include : includes)
- {
- Protocol protocol = Protocol.valueOf(include);
- defaultProtocols.add(protocol);
- }
- }
- _defaultProtocols = Collections.unmodifiableCollection(defaultProtocols);
}
public Port createPort(UUID id, Broker broker, Map<String, Object> attributes)
{
- final Port port;
- Map<String, Object> defaults = new HashMap<String, Object>();
- defaults.put(Port.TRANSPORTS, Collections.singleton(DEFAULT_TRANSPORT));
- Object portValue = attributes.get(Port.PORT);
- if (portValue == null)
- {
- throw new IllegalConfigurationException("Port attribute is not specified for port: " + attributes);
- }
- Set<Protocol> protocols = MapValueConverter.getEnumSetAttribute(Port.PROTOCOLS, attributes, Protocol.class);
- if (isAmqpProtocol(protocols, attributes))
- {
- Object binding = attributes.get(Port.BINDING_ADDRESS);
- if (binding == null)
- {
- binding = DEFAULT_AMQP_BINDING;
- defaults.put(Port.BINDING_ADDRESS, DEFAULT_AMQP_BINDING);
- }
- defaults.put(Port.NAME, binding + ":" + portValue);
- defaults.put(Port.PROTOCOLS, _defaultProtocols);
- defaults.put(Port.TCP_NO_DELAY, DEFAULT_AMQP_TCP_NO_DELAY);
- defaults.put(Port.WANT_CLIENT_AUTH, DEFAULT_AMQP_WANT_CLIENT_AUTH);
- defaults.put(Port.NEED_CLIENT_AUTH, DEFAULT_AMQP_NEED_CLIENT_AUTH);
- defaults.put(Port.RECEIVE_BUFFER_SIZE, DEFAULT_AMQP_RECEIVE_BUFFER_SIZE);
- defaults.put(Port.SEND_BUFFER_SIZE, DEFAULT_AMQP_SEND_BUFFER_SIZE);
- port = new AmqpPortAdapter(id, broker, attributes, defaults, broker.getTaskExecutor());
+ attributes = new HashMap<String, Object>(attributes);
+ attributes.put(Port.ID, id);
+ return create(attributes,broker);
+ }
- boolean useClientAuth = (Boolean) port.getAttribute(Port.NEED_CLIENT_AUTH) || (Boolean) port.getAttribute(Port.WANT_CLIENT_AUTH);
- if(useClientAuth && port.getTrustStores().isEmpty())
- {
- throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but has no trust stores configured.");
- }
+ private ProtocolType getProtocolType(Map<String, Object> portAttributes)
+ {
- if(useClientAuth && !(port.getTransports().contains(Transport.SSL) || port.getTransports().contains(Transport.WSS)))
- {
- throw new IllegalConfigurationException("Can't create port which requests SSL client certificates but doesn't use SSL transport.");
- }
+ Set<Protocol> protocols = MapValueConverter.getEnumSetAttribute(Port.PROTOCOLS, portAttributes, Protocol.class);
+
+ ProtocolType protocolType = null;
+
+ if(protocols == null || protocols.isEmpty())
+ {
+ // defaulting to AMQP if protocol is not specified
+ protocolType = ProtocolType.AMQP;
}
else
{
- if (protocols.size() > 1)
+ for (Protocol protocol : protocols)
{
- throw new IllegalConfigurationException("Only one protocol can be used on non AMQP port");
- }
- Protocol protocol = protocols.iterator().next();
-
- if(!broker.isManagementMode() && protocol.getProtocolType() != ProtocolType.HTTP)
- {
- //ManagementMode needs this relaxed to allow its overriding management ports to be inserted.
-
- //Enforce only a single port of each management protocol, as the plugins will only use one.
- Collection<Port> existingPorts = broker.getPorts();
- for (Port existingPort : existingPorts)
+ if (protocolType == null)
{
- Collection<Protocol> portProtocols = existingPort.getProtocols();
- if (portProtocols != null && portProtocols.contains(protocol))
- {
- throw new IllegalConfigurationException("Port for protocol " + protocol + " already exists. Only one management port per protocol can be created.");
- }
+ protocolType = protocol.getProtocolType();
}
- }
+ else if (protocolType != protocol.getProtocolType())
+ {
- defaults.put(Port.NAME, portValue + "-" + protocol.name());
- port = new NonAmqpPortAdapter(id, broker, attributes, defaults, broker.getTaskExecutor());
+ throw new IllegalConfigurationException("Found different protocol types '" + protocolType
+ + "' and '" + protocol.getProtocolType()
+ + "' for port configuration: " + portAttributes);
- boolean rmiPort = port.getProtocols().contains(Protocol.RMI);
- if (rmiPort && port.getTransports().contains(Transport.SSL))
- {
- throw new IllegalConfigurationException("Can't create RMI registry port which requires SSL");
+ }
}
}
- if(port.getTransports().contains(Transport.SSL))
- {
- if(port.getKeyStore() == null)
- {
- throw new IllegalConfigurationException("Can't create port which requires SSL but has no key store configured.");
- }
- }
+ return protocolType;
+ }
+
- return port;
+ @Override
+ public Class<? super Port> getCategoryClass()
+ {
+ return Port.class;
}
- private boolean isAmqpProtocol(Set<Protocol> protocols, Map<String, Object> portAttributes)
+ @Override
+ public X create(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
{
- if (protocols == null || protocols.isEmpty())
+ return getPortFactory(attributes).create(attributes,parents);
+ }
+
+ @Override
+ public UnresolvedConfiguredObject<X> recover(final ConfiguredObjectRecord record,
+ final ConfiguredObject<?>... parents)
+ {
+ return getPortFactory(record.getAttributes()).recover(record, parents);
+ }
+
+ public ConfiguredObjectTypeFactory<X> getPortFactory(Map<String,Object> attributes)
+ {
+ String type;
+
+ if(attributes.containsKey(Port.TYPE))
{
- // defaulting to AMQP if protocol is not specified
- return true;
+ type = (String) attributes.get(Port.TYPE);
}
-
- Set<ProtocolType> protocolTypes = new HashSet<ProtocolType>();
- for (Protocol protocolObject : protocols)
+ else
{
- protocolTypes.add(protocolObject.getProtocolType());
+ type = getProtocolType(attributes).name();
}
- if (protocolTypes.size() > 1)
+ synchronized (this)
{
- throw new IllegalConfigurationException("Found different protocol types '" + protocolTypes
- + "' for port configuration: " + portAttributes);
+ if(_configuredObjectFactory == null)
+ {
+ _configuredObjectFactory = new ConfiguredObjectFactory();
+ }
}
-
- return protocolTypes.contains(ProtocolType.AMQP);
+ return _configuredObjectFactory.getConfiguredObjectTypeFactory(Port.class.getSimpleName(), type);
}
- public Collection<Protocol> getDefaultProtocols()
+ private Broker getBroker(final ConfiguredObject<?>[] parents)
{
- return _defaultProtocols;
+ if(parents.length != 1 || !(parents[0] instanceof Broker))
+ {
+ throw new IllegalConfigurationException("Port should have exactly one parent, of type Broker");
+ }
+ return (Broker<?>) parents[0];
}
+ @Override
+ public String getType()
+ {
+ return null;
+ }
}
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/PortWithAuthProvider.java Thu Apr 3 19:58:53 2014
@@ -0,0 +1,63 @@
+/*
+ *
+ * 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.port;
+
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.model.AuthenticationProvider;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.Port;
+
+import java.util.Map;
+import java.util.UUID;
+
+abstract public class PortWithAuthProvider<X extends PortWithAuthProvider<X>> extends AbstractPort<X>
+{
+ private AuthenticationProvider _authenticationProvider;
+
+ public PortWithAuthProvider(final UUID id,
+ final Broker<?> broker,
+ final Map<String, Object> attributes,
+ final Map<String, Object> defaults,
+ final TaskExecutor taskExecutor)
+ {
+ super(id, broker, attributes, defaults, taskExecutor);
+ String authProvider = (String)getAttribute(Port.AUTHENTICATION_PROVIDER);
+ if (authProvider == null)
+ {
+ throw new IllegalConfigurationException("An authentication provider must be specified for port : " + getName());
+ }
+ _authenticationProvider = broker.findAuthenticationProviderByName(authProvider);
+
+ if(_authenticationProvider == null)
+ {
+ throw new IllegalConfigurationException("The authentication provider '" + authProvider + "' could not be found for port : " + getName());
+ }
+ }
+
+
+ @ManagedAttribute
+ public AuthenticationProvider getAuthenticationProvider()
+ {
+ return _authenticationProvider;
+ }
+}
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java (from r1582544, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java&r1=1582544&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/NonAmqpPortAdapter.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPort.java Thu Apr 3 19:58:53 2014
@@ -18,22 +18,33 @@
* under the License.
*
*/
-package org.apache.qpid.server.model.adapter;
+package org.apache.qpid.server.model.port;
+import org.apache.qpid.server.configuration.IllegalConfigurationException;
import org.apache.qpid.server.configuration.updater.TaskExecutor;
import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ManagedObject;
+import org.apache.qpid.server.model.Transport;
+import java.util.Collections;
import java.util.Map;
import java.util.UUID;
-public class NonAmqpPortAdapter extends PortAdapter<NonAmqpPortAdapter>
+@ManagedObject( category = false, type = "RMI")
+public class RmiPort extends AbstractPort<RmiPort>
{
- public NonAmqpPortAdapter(final UUID id,
- final Broker<?> broker,
- final Map<String, Object> attributes,
- final Map<String, Object> defaults,
- final TaskExecutor taskExecutor)
+ public RmiPort(final UUID id,
+ final Broker<?> broker,
+ final Map<String, Object> attributes,
+ final TaskExecutor taskExecutor)
{
- super(id, broker, attributes, defaults, taskExecutor);
+ super(id, broker, attributes, Collections.<String,Object>emptyMap(), taskExecutor);
+
+ validateOnlyOneInstance(broker);
+
+ if (getTransports().contains(Transport.SSL))
+ {
+ throw new IllegalConfigurationException("Can't create RMI registry port which requires SSL");
+ }
}
}
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/model/port/RmiPortFactory.java Thu Apr 3 19:58:53 2014
@@ -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.model.port;
+
+import org.apache.qpid.server.model.AbstractConfiguredObjectTypeFactory;
+import org.apache.qpid.server.model.Broker;
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.model.Port;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+public class RmiPortFactory extends AbstractConfiguredObjectTypeFactory<RmiPort>
+{
+ public RmiPortFactory()
+ {
+ super(RmiPort.class);
+ }
+
+ @Override
+ public RmiPort createInstance(final Map<String, Object> attributes, final ConfiguredObject<?>... parents)
+ {
+ Broker broker = getParent(Broker.class, parents);
+ Map<String,Object> attributesWithoutId = new HashMap<String, Object>(attributes);
+ Object idObj = attributesWithoutId.remove(Port.ID);
+ UUID id = idObj == null ? UUID.randomUUID() : idObj instanceof UUID ? (UUID) idObj : UUID.fromString(idObj.toString());
+ return new RmiPort(id, broker, attributesWithoutId, broker.getTaskExecutor());
+ }
+
+}
Copied: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java (from r1580888, qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java)
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java?p2=qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java&p1=qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java&r1=1580888&r2=1584365&rev=1584365&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AccessControlProviderFactory.java Thu Apr 3 19:58:53 2014
@@ -26,26 +26,10 @@ import org.apache.qpid.server.logging.Ev
import org.apache.qpid.server.model.AccessControlProvider;
import org.apache.qpid.server.security.AccessControl;
-public interface AccessControlFactory extends Pluggable
+public interface AccessControlProviderFactory<X extends AccessControlProvider<X>> extends ConfiguredObjectTypeFactory<X>
{
public static final String ATTRIBUTE_TYPE = AccessControlProvider.TYPE;
- AccessControl createInstance(Map<String, Object> attributes, final EventLoggerProvider eventLogger);
-
- /**
- * Returns the access control provider type
- * @return authentication provider type
- */
- String getType();
-
- /**
- * Get the names of attributes of the access control which can be passed into
- * {@link #createInstance(java.util.Map, org.apache.qpid.server.logging.EventLogger)} to create the group manager
- *
- * @return the collection of attribute names
- */
- Collection<String> getAttributeNames();
-
/**
* @return returns human readable descriptions for the attributes
*/
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AuthenticationManagerFactory.java Thu Apr 3 19:58:53 2014
@@ -21,10 +21,11 @@ package org.apache.qpid.server.plugin;
import java.util.Collection;
import java.util.Map;
+import org.apache.qpid.server.model.AuthenticationProvider;
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.security.auth.manager.AbstractAuthenticationManager;
-public interface AuthenticationManagerFactory extends Pluggable
+public interface AuthenticationManagerFactory<X extends AuthenticationProvider<X>> extends ConfiguredObjectTypeFactory<X>
{
/**
@@ -34,22 +35,7 @@ public interface AuthenticationManagerFa
String getType();
/**
- * Creates authentication manager from the provided attributes
- *
- * @param broker
- * broker model object
- * @param attributes
- * attributes to create authentication manager
- *
- * @param recovering
- * @return authentication manager instance
- */
- AbstractAuthenticationManager createInstance(Broker broker,
- Map<String, Object> attributes,
- final boolean recovering);
-
- /**
- * Get the names of attributes the authentication manager which can be passed into {@link #createInstance(org.apache.qpid.server.model.Broker, java.util.Map, boolean)} to create the
+ * Get the names of attributes the authentication manager
* authentication manager
*
* @return the collection of attribute names
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfigurationStoreFactory.java Thu Apr 3 19:58:53 2014
@@ -24,6 +24,7 @@ import java.util.Map;
import org.apache.qpid.server.configuration.ConfigurationEntryStore;
import org.apache.qpid.server.configuration.IllegalConfigurationException;
+import org.apache.qpid.server.model.SystemContext;
public interface ConfigurationStoreFactory extends Pluggable
@@ -38,11 +39,11 @@ public interface ConfigurationStoreFacto
* <p>
* If location does not exist, or the overwrite option is specified, then a new store is created from the initial store if it is provided
*
- * @param storeLocation store location
+ * @param systemContext application configuration
* @param initialStore initial store
* @param overwrite overwrite existing store with initial store
* @param configProperties a map of configuration properties the store can use to resolve configuration variables
* @throws IllegalConfigurationException if store cannot be opened in the given location
*/
- public ConfigurationEntryStore createStore(String storeLocation, ConfigurationEntryStore initialStore, boolean overwrite, Map<String, String> configProperties);
+ public ConfigurationEntryStore createStore(SystemContext systemContext, ConfigurationEntryStore initialStore, boolean overwrite, Map<String, String> configProperties);
}
Added: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectTypeFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectTypeFactory.java?rev=1584365&view=auto
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectTypeFactory.java (added)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ConfiguredObjectTypeFactory.java Thu Apr 3 19:58:53 2014
@@ -0,0 +1,36 @@
+/*
+ *
+ * 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.plugin;
+
+import org.apache.qpid.server.model.ConfiguredObject;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.UnresolvedConfiguredObject;
+
+import java.util.Map;
+
+public interface ConfiguredObjectTypeFactory<X extends ConfiguredObject<X>> extends Pluggable
+{
+ Class<? super X> getCategoryClass();
+
+ X create(Map<String, Object> attributes, ConfiguredObject<?>... parents);
+
+ UnresolvedConfiguredObject<X> recover(ConfiguredObjectRecord record, ConfiguredObject<?>... parents);
+}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java Thu Apr 3 19:58:53 2014
@@ -21,9 +21,7 @@
package org.apache.qpid.server.plugin;
import java.util.Map;
-import org.apache.commons.configuration.Configuration;
import org.apache.qpid.server.store.DurableConfigurationStore;
-import org.apache.qpid.server.store.MessageStore;
public interface DurableConfigurationStoreFactory extends Pluggable
{
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/JDBCConnectionProviderFactory.java Thu Apr 3 19:58:53 2014
@@ -25,15 +25,15 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import org.apache.commons.configuration.Configuration;
-import org.apache.qpid.server.model.VirtualHost;
+import java.util.Map;
+
import org.apache.qpid.server.store.jdbc.ConnectionProvider;
public interface JDBCConnectionProviderFactory extends Pluggable
{
String getType();
- ConnectionProvider getConnectionProvider(String connectionUrl, VirtualHost virtualHost)
+ ConnectionProvider getConnectionProvider(String connectionUrl, Map<String, Object> storeSettings)
throws SQLException;
static final class TYPES
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java Thu Apr 3 19:58:53 2014
@@ -21,16 +21,16 @@
package org.apache.qpid.server.plugin;
import java.util.Map;
-import org.apache.commons.configuration.Configuration;
+
import org.apache.qpid.server.store.MessageStore;
public interface MessageStoreFactory extends Pluggable
{
+ PluggableFactoryLoader<MessageStoreFactory> FACTORY_LOADER = new PluggableFactoryLoader<MessageStoreFactory>(MessageStoreFactory.class);
+
String getType();
MessageStore createMessageStore();
- public Map<String, Object> convertStoreConfiguration(Configuration configuration);
-
void validateAttributes(Map<String, Object> attributes);
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluggableFactoryLoader.java Thu Apr 3 19:58:53 2014
@@ -19,7 +19,6 @@
package org.apache.qpid.server.plugin;
-import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -56,7 +55,7 @@ public class PluggableFactoryLoader<T ex
return _factoriesMap.get(type);
}
- public Collection<String> getDescriptiveTypes()
+ public Set<String> getSupportedTypes()
{
return _types;
}
Modified: qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java
URL: http://svn.apache.org/viewvc/qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java?rev=1584365&r1=1584364&r2=1584365&view=diff
==============================================================================
--- qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java (original)
+++ qpid/branches/java-broker-config-store-changes/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/PluginFactory.java Thu Apr 3 19:58:53 2014
@@ -18,15 +18,13 @@
*/
package org.apache.qpid.server.plugin;
-import java.util.Map;
-import java.util.UUID;
-
import org.apache.qpid.server.model.Broker;
import org.apache.qpid.server.model.Plugin;
+import java.util.Map;
+import java.util.UUID;
+
public interface PluginFactory extends Pluggable
{
- static final String PLUGIN_TYPE = "pluginType";
-
Plugin createInstance(UUID id, Map<String, Object> attributes, Broker broker);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org