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    
014    package org.hornetq.api.core.management;
015    
016    import org.hornetq.utils.json.JSONObject;
017    
018    /**
019     * A AddressSettingsInfo
020     *
021     * @author jmesnil
022     *
023     *
024     */
025    public 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 maxDeliveryAttempts;
039    
040       private long redeliveryDelay;
041    
042       private String deadLetterAddress;
043    
044       private String expiryAddress;
045    
046       private boolean lastValueQueue;
047    
048       private long redistributionDelay;
049    
050       private boolean sendToDLAOnNoRoute;
051    
052       // Static --------------------------------------------------------
053    
054       public static final AddressSettingsInfo from(final String jsonString) throws Exception
055       {
056          JSONObject object = new JSONObject(jsonString);
057          return new AddressSettingsInfo(object.getString("addressFullMessagePolicy"),
058                                         object.getLong("maxSizeBytes"),
059                                         object.getInt("pageSizeBytes"),
060                                         object.getInt("maxDeliveryAttempts"),
061                                         object.getLong("redeliveryDelay"),
062                                         object.getString("DLA"),
063                                         object.getString("expiryAddress"),
064                                         object.getBoolean("lastValueQueue"),
065                                         object.getLong("redistributionDelay"),
066                                         object.getBoolean("sendToDLAOnNoRoute"));
067       }
068    
069       // Constructors --------------------------------------------------
070    
071       public AddressSettingsInfo(String addressFullMessagePolicy,
072                                  long maxSizeBytes,
073                                  int pageSizeBytes,
074                                  int maxDeliveryAttempts,
075                                  long redeliveryDelay,
076                                  String deadLetterAddress,
077                                  String expiryAddress,
078                                  boolean lastValueQueue,
079                                  long redistributionDelay,
080                                  boolean sendToDLAOnNoRoute)
081       {
082          this.addressFullMessagePolicy = addressFullMessagePolicy;
083          this.maxSizeBytes = maxSizeBytes;
084          this.pageSizeBytes = pageSizeBytes;
085          this.maxDeliveryAttempts = maxDeliveryAttempts;
086          this.redeliveryDelay = redeliveryDelay;
087          this.deadLetterAddress = deadLetterAddress;
088          this.expiryAddress = expiryAddress;
089          this.lastValueQueue = lastValueQueue;
090          this.redistributionDelay = redistributionDelay;
091          this.sendToDLAOnNoRoute = sendToDLAOnNoRoute;
092       }
093    
094       // Public --------------------------------------------------------
095    
096       public String getAddressFullMessagePolicy()
097       {
098          return addressFullMessagePolicy;
099       }
100    
101       public long getMaxSizeBytes()
102       {
103          return maxSizeBytes;
104       }
105    
106       public int getPageSizeBytes()
107       {
108          return pageSizeBytes;
109       }
110    
111       public int getMaxDeliveryAttempts()
112       {
113          return maxDeliveryAttempts;
114       }
115    
116       public long getRedeliveryDelay()
117       {
118          return redeliveryDelay;
119       }
120    
121       public String getDeadLetterAddress()
122       {
123          return deadLetterAddress;
124       }
125    
126       public String getExpiryAddress()
127       {
128          return expiryAddress;
129       }
130    
131       public boolean isLastValueQueue()
132       {
133          return lastValueQueue;
134       }
135    
136       public long getRedistributionDelay()
137       {
138          return redistributionDelay;
139       }
140    
141       public boolean isSendToDLAOnNoRoute()
142       {
143          return sendToDLAOnNoRoute;
144       }
145    
146       // Package protected ---------------------------------------------
147    
148       // Protected -----------------------------------------------------
149    
150       // Private -------------------------------------------------------
151    
152       // Inner classes -------------------------------------------------
153    
154    }