001/*
002 * Copyright 2010 Red Hat, Inc.
003 * Red Hat licenses this file to you under the Apache License, version
004 * 2.0 (the "License"); you may not use this file except in compliance
005 * with the License.  You may obtain a copy of the License at
006 *    http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing, software
008 * distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
010 * implied.  See the License for the specific language governing
011 * permissions and limitations under the License.
012 */
013
014package org.hornetq.api.core.management;
015
016import org.hornetq.utils.json.JSONObject;
017
018/**
019 * A AddressSettingsInfo
020 *
021 * @author jmesnil
022 *
023 *
024 */
025public class AddressSettingsInfo
026{
027
028   // Constants -----------------------------------------------------
029
030   // Attributes ----------------------------------------------------
031
032   private String addressFullMessagePolicy;
033
034   private long maxSizeBytes;
035
036   private int pageSizeBytes;
037   
038   private int pageCacheMaxSize;
039
040   private int maxDeliveryAttempts;
041
042   private long redeliveryDelay;
043
044   private String deadLetterAddress;
045
046   private String expiryAddress;
047
048   private boolean lastValueQueue;
049
050   private long redistributionDelay;
051
052   private boolean sendToDLAOnNoRoute;
053
054   // Static --------------------------------------------------------
055
056   public static final AddressSettingsInfo from(final String jsonString) throws Exception
057   {
058      JSONObject object = new JSONObject(jsonString);
059      return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"),
060                                     object.getLong("maxSizeBytes"),
061                                     object.getInt("pageSizeBytes"),
062                                     object.getInt("pageCacheMaxSize"),
063                                     object.getInt("maxDeliveryAttempts"),
064                                     object.getLong("redeliveryDelay"),
065                                     object.getString("DLA"),
066                                     object.getString("expiryAddress"),
067                                     object.getBoolean("lastValueQueue"),
068                                     object.getLong("redistributionDelay"),
069                                     object.getBoolean("sendToDLAOnNoRoute"));
070   }
071
072   // Constructors --------------------------------------------------
073
074   public AddressSettingsInfo(String addressFullMessagePolicy,
075                              long maxSizeBytes,
076                              int pageSizeBytes,
077                              int pageCacheMaxSize,
078                              int maxDeliveryAttempts,
079                              long redeliveryDelay,
080                              String deadLetterAddress,
081                              String expiryAddress,
082                              boolean lastValueQueue,
083                              long redistributionDelay,
084                              boolean sendToDLAOnNoRoute)
085   {
086      this.addressFullMessagePolicy = addressFullMessagePolicy;
087      this.maxSizeBytes = maxSizeBytes;
088      this.pageSizeBytes = pageSizeBytes;
089      this.pageCacheMaxSize = pageCacheMaxSize;
090      this.maxDeliveryAttempts = maxDeliveryAttempts;
091      this.redeliveryDelay = redeliveryDelay;
092      this.deadLetterAddress = deadLetterAddress;
093      this.expiryAddress = expiryAddress;
094      this.lastValueQueue = lastValueQueue;
095      this.redistributionDelay = redistributionDelay;
096      this.sendToDLAOnNoRoute = sendToDLAOnNoRoute;
097   }
098
099   // Public --------------------------------------------------------
100
101   public int getPageCacheMaxSize()
102   {
103      return pageCacheMaxSize;
104   }
105
106   public void setPageCacheMaxSize(int pageCacheMaxSize)
107   {
108      this.pageCacheMaxSize = pageCacheMaxSize;
109   }
110
111   public String getAddressFullMessagePolicy()
112   {
113      return addressFullMessagePolicy;
114   }
115
116   public long getMaxSizeBytes()
117   {
118      return maxSizeBytes;
119   }
120
121   public int getPageSizeBytes()
122   {
123      return pageSizeBytes;
124   }
125
126   public int getMaxDeliveryAttempts()
127   {
128      return maxDeliveryAttempts;
129   }
130
131   public long getRedeliveryDelay()
132   {
133      return redeliveryDelay;
134   }
135
136   public String getDeadLetterAddress()
137   {
138      return deadLetterAddress;
139   }
140
141   public String getExpiryAddress()
142   {
143      return expiryAddress;
144   }
145
146   public boolean isLastValueQueue()
147   {
148      return lastValueQueue;
149   }
150
151   public long getRedistributionDelay()
152   {
153      return redistributionDelay;
154   }
155
156   public boolean isSendToDLAOnNoRoute()
157   {
158      return sendToDLAOnNoRoute;
159   }
160
161   // Package protected ---------------------------------------------
162
163   // Protected -----------------------------------------------------
164
165   // Private -------------------------------------------------------
166
167   // Inner classes -------------------------------------------------
168
169}