[jboss-cvs] JBoss Messaging SVN: r5797 - in trunk/src/main/org/jboss/messaging/core: settings/impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Feb 3 08:31:08 EST 2009


Author: ataylor
Date: 2009-02-03 08:31:08 -0500 (Tue, 03 Feb 2009)
New Revision: 5797

Removed:
   trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueSettingsDeployer.java
   trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java
Log:
some refactoring

Deleted: trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueSettingsDeployer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueSettingsDeployer.java	2009-02-03 13:20:44 UTC (rev 5796)
+++ trunk/src/main/org/jboss/messaging/core/deployers/impl/QueueSettingsDeployer.java	2009-02-03 13:31:08 UTC (rev 5797)
@@ -1,172 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
-
-package org.jboss.messaging.core.deployers.impl;
-
-import org.jboss.messaging.core.deployers.DeploymentManager;
-import org.jboss.messaging.core.settings.HierarchicalRepository;
-import org.jboss.messaging.core.settings.impl.QueueSettings;
-import org.jboss.messaging.util.SimpleString;
-import org.jboss.messaging.util.XMLUtil;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * A deployer for creating a set of queue settings and adding them to a repository
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class QueueSettingsDeployer extends XmlDeployer
-{   
-   private static final String CLUSTERED_NODE_NAME = "clustered";
-   
-   private static final String DEAD_LETTER_ADDRESS_NODE_NAME = "dead-letter-address";
-   
-   private static final String EXPIRY_ADDRESS_NODE_NAME = "expiry-address";
-   
-   private static final String REDELIVERY_DELAY_NODE_NAME = "redelivery-delay";
-   
-   private static final String MAX_SIZE_BYTES_NODE_NAME = "max-size-bytes";
-   
-   private static final String DROP_MESSAGES_WHEN_FULL_NODE_NAME = "drop-messages-when-full";
-   
-   private static final String PAGE_SIZE_BYTES_NODE_NAME = "page-size-bytes";
-   
-   private static final String DISTRIBUTION_POLICY_CLASS_NODE_NAME = "distribution-policy-class";
-   
-   private static final String MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME = "message-counter-history-day-limit";
-
-   private final HierarchicalRepository<QueueSettings> queueSettingsRepository;
-
-   public QueueSettingsDeployer(final DeploymentManager deploymentManager, final HierarchicalRepository<QueueSettings> queueSettingsRepository)
-   {
-   	super(deploymentManager);
-      this.queueSettingsRepository = queueSettingsRepository;
-   }
-   
-   /**
-    * the names of the elements to deploy
-    * @return the names of the elements todeploy
-    */
-   public String[] getElementTagName()
-   {
-      return new String[]{"queue-settings"};
-   }
-
-   @Override
-   public void validate(Node rootNode) throws Exception
-   {
-      if ("deployment".equals(rootNode.getNodeName()))
-      {
-         XMLUtil.validate(rootNode, "jbm-configuration.xsd");
-      } else 
-      {
-         XMLUtil.validate(rootNode, "jbm-queues.xsd");         
-      }
-   }
-
-   /**
-    * deploy an element
-    * @param node the element to deploy
-    * @throws Exception .
-    */
-   public void deploy(Node node) throws Exception
-   {
-      String match = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-      
-      NodeList children = node.getChildNodes();
-      
-      QueueSettings queueSettings = new QueueSettings();
-      
-      for (int i = 0; i < children.getLength(); i++)
-      {
-         Node child = children.item(i);
-         
-         if (CLUSTERED_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            queueSettings.setClustered(Boolean.valueOf(child.getTextContent()));
-         }
-         else if (DEAD_LETTER_ADDRESS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            SimpleString queueName = new SimpleString(child.getTextContent());
-            queueSettings.setDeadLetterAddress(queueName);
-         }
-         else if (EXPIRY_ADDRESS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-         	SimpleString queueName = new SimpleString(child.getTextContent());
-            queueSettings.setExpiryAddress(queueName);
-         }
-         else if (REDELIVERY_DELAY_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            queueSettings.setRedeliveryDelay(Long.valueOf(child.getTextContent()));
-         }
-         else if (MAX_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            queueSettings.setMaxSizeBytes(Integer.valueOf(child.getTextContent()));   
-         }
-         else if (PAGE_SIZE_BYTES_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            queueSettings.setPageSizeBytes(Integer.valueOf(child.getTextContent()));
-         }
-         else if (DISTRIBUTION_POLICY_CLASS_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            queueSettings.setDistributionPolicyClass(child.getTextContent());
-         }
-         else if (MESSAGE_COUNTER_HISTORY_DAY_LIMIT_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            queueSettings.setMessageCounterHistoryDayLimit(Integer.valueOf(child.getTextContent()));
-         }
-         else if (DROP_MESSAGES_WHEN_FULL_NODE_NAME.equalsIgnoreCase(child.getNodeName()))
-         {
-            queueSettings.setDropMessagesWhenFull(Boolean.valueOf(child.getTextContent().trim()));
-         }
-      }
-      
-      queueSettingsRepository.addMatch(match, queueSettings);
-   }
-
-   public String[] getConfigFileNames()
-   {
-      return new String[] {"jbm-configuration", "jbm-queues.xml"};
-   }
-
-   /**
-    * undeploys an element
-    * @param node the element to undeploy
-    * @throws Exception .
-    */
-   public void undeploy(Node node) throws Exception
-   {
-      String match = node.getAttributes().getNamedItem(getKeyAttribute()).getNodeValue();
-      
-      queueSettingsRepository.removeMatch(match);
-   }
-
-   /**
-    * the key attribute for theelement, usually 'name' but can be overridden
-    * @return the key attribute
-    */
-   public String getKeyAttribute()
-   {
-      return "match";
-   }
-
-}

Deleted: trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java	2009-02-03 13:20:44 UTC (rev 5796)
+++ trunk/src/main/org/jboss/messaging/core/settings/impl/QueueSettings.java	2009-02-03 13:31:08 UTC (rev 5797)
@@ -1,246 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.core.settings.impl;
-
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.server.Distributor;
-import org.jboss.messaging.core.server.impl.RoundRobinDistributor;
-import org.jboss.messaging.core.settings.Mergeable;
-import org.jboss.messaging.util.SimpleString;
-
-/**
- * Configuration settings that are applied on the address level
- * 
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- */
-public class QueueSettings implements Mergeable<QueueSettings>
-{
-   private static Logger log = Logger.getLogger(QueueSettings.class);
-
-   /**
-    * defaults used if null, this allows merging
-    */
-   public static final Class<?> DEFAULT_DISTRIBUTION_POLICY_CLASS = new RoundRobinDistributor().getClass();
-
-   public static final Boolean DEFAULT_CLUSTERED = false;
-
-   public static final Integer DEFAULT_MAX_SIZE_BYTES = -1;
-
-   public static final Boolean DEFAULT_DROP_MESSAGES_WHEN_FULL = Boolean.FALSE;
-
-   public static final Integer DEFAULT_MAX_DELIVERY_ATTEMPTS = 10;
-
-   public static final Integer DEFAULT_MESSAGE_COUNTER_HISTORY_DAY_LIMIT = 0;
-
-   public static final Long DEFAULT_REDELIVER_DELAY = 0L;
-
-   private Boolean clustered = null;
-
-   private Integer maxSizeBytes = null;
-
-   private Integer pageSizeBytes = null;
-
-   private Boolean dropMessagesWhenFull = null;
-
-   private String distributionPolicyClass = null;
-
-   private Integer maxDeliveryAttempts = null;
-
-   private Integer messageCounterHistoryDayLimit = null;
-
-   private Long redeliveryDelay = null;
-
-   private SimpleString deadLetterAddress = null;
-
-   private SimpleString ExpiryAddress = null;
-
-   public Boolean isClustered()
-   {
-      return clustered != null ? clustered : DEFAULT_CLUSTERED;
-   }
-
-   public void setClustered(Boolean clustered)
-   {
-      this.clustered = clustered;
-   }
-
-   public Integer getPageSizeBytes()
-   {
-      return pageSizeBytes;
-   }
-
-   public Boolean isDropMessagesWhenFull()
-   {
-      return dropMessagesWhenFull != null ? this.dropMessagesWhenFull : DEFAULT_DROP_MESSAGES_WHEN_FULL;
-   }
-
-   public void setDropMessagesWhenFull(Boolean value)
-   {
-      this.dropMessagesWhenFull = value;
-   }
-
-   public void setPageSizeBytes(Integer pageSize)
-   {
-      this.pageSizeBytes = pageSize;
-   }
-
-   public Integer getMaxSizeBytes()
-   {
-      return maxSizeBytes != null ? maxSizeBytes : DEFAULT_MAX_SIZE_BYTES;
-   }
-
-   public void setMaxSizeBytes(Integer maxSizeBytes)
-   {
-      this.maxSizeBytes = maxSizeBytes;
-   }
-
-   public Integer getMaxDeliveryAttempts()
-   {
-      return maxDeliveryAttempts != null ? maxDeliveryAttempts : DEFAULT_MAX_DELIVERY_ATTEMPTS;
-   }
-
-   public void setMaxDeliveryAttempts(Integer maxDeliveryAttempts)
-   {
-      this.maxDeliveryAttempts = maxDeliveryAttempts;
-   }
-
-   public Integer getMessageCounterHistoryDayLimit()
-   {
-      return messageCounterHistoryDayLimit != null ? messageCounterHistoryDayLimit
-                                                  : DEFAULT_MESSAGE_COUNTER_HISTORY_DAY_LIMIT;
-   }
-
-   public void setMessageCounterHistoryDayLimit(Integer messageCounterHistoryDayLimit)
-   {
-      this.messageCounterHistoryDayLimit = messageCounterHistoryDayLimit;
-   }
-
-   public Long getRedeliveryDelay()
-   {
-      return redeliveryDelay != null ? redeliveryDelay : DEFAULT_REDELIVER_DELAY;
-   }
-
-   public void setRedeliveryDelay(Long redeliveryDelay)
-   {
-      this.redeliveryDelay = redeliveryDelay;
-   }
-
-   public String getDistributionPolicyClass()
-   {
-      return distributionPolicyClass;
-   }
-
-   public void setDistributionPolicyClass(String distributionPolicyClass)
-   {
-      this.distributionPolicyClass = distributionPolicyClass;
-   }
-
-   public SimpleString getDeadLetterAddress()
-   {
-      return deadLetterAddress;
-   }
-
-   public void setDeadLetterAddress(SimpleString deadLetterAddress)
-   {
-      this.deadLetterAddress = deadLetterAddress;
-   }
-
-   public SimpleString getExpiryAddress()
-   {
-      return ExpiryAddress;
-   }
-
-   public void setExpiryAddress(SimpleString expiryAddress)
-   {
-      ExpiryAddress = expiryAddress;
-   }
-
-   public Distributor getDistributionPolicy()
-   {
-      try
-      {
-         if (distributionPolicyClass != null)
-         {
-            return (Distributor)getClass().getClassLoader().loadClass(distributionPolicyClass).newInstance();
-         }
-         else
-         {
-            return (Distributor)DEFAULT_DISTRIBUTION_POLICY_CLASS.newInstance();
-         }
-      }
-      catch (Exception e)
-      {
-         throw new IllegalArgumentException("Error instantiating distribution policy '" + e + " '");
-      }
-   }
-
-   /**
-    * merge 2 objects in to 1
-    * @param merged
-    */
-   public void merge(QueueSettings merged)
-   {
-      if (clustered == null)
-      {
-         clustered = merged.clustered;
-      }
-      if (maxDeliveryAttempts == null)
-      {
-         maxDeliveryAttempts = merged.maxDeliveryAttempts;
-      }
-      if (dropMessagesWhenFull == null)
-      {
-         dropMessagesWhenFull = merged.dropMessagesWhenFull;
-      }
-      if (maxSizeBytes == null)
-      {
-         maxSizeBytes = merged.maxSizeBytes;
-      }
-      if (pageSizeBytes == null)
-      {
-         pageSizeBytes = merged.getPageSizeBytes();
-      }
-      if (messageCounterHistoryDayLimit == null)
-      {
-         messageCounterHistoryDayLimit = merged.messageCounterHistoryDayLimit;
-      }
-      if (redeliveryDelay == null)
-      {
-         redeliveryDelay = merged.redeliveryDelay;
-      }
-      if (distributionPolicyClass == null)
-      {
-         distributionPolicyClass = merged.distributionPolicyClass;
-      }
-      if (deadLetterAddress == null)
-      {
-         deadLetterAddress = merged.deadLetterAddress;
-      }
-      if (ExpiryAddress == null)
-      {
-         ExpiryAddress = merged.ExpiryAddress;
-      }
-   }
-
-}




More information about the jboss-cvs-commits mailing list