summaryrefslogtreecommitdiff
path: root/java/client/src/main/java/org/apache/qpid/client/messaging/address/QpidQueueOptions.java
blob: 04aa7d146fe23620629dd2b853ebd7ad752d2f24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
 *
 * 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.client.messaging.address;

import java.util.HashMap;

public class QpidQueueOptions extends HashMap<String,Object> 
{	
	public static final String QPID_MAX_COUNT = "qpid.max_count";
    public static final String QPID_MAX_SIZE = "qpid.max_size";
    public static final String QPID_POLICY_TYPE = "qpid.policy_type";    
    public static final String QPID_PERSIST_LAST_NODE = "qpid.persist_last_node";
    public static final String QPID_LVQ_KEY = "qpid.LVQ_key";
    public static final String QPID_LAST_VALUE_QUEUE = "qpid.last_value_queue";
    public static final String QPID_LAST_VALUE_QUEUE_NO_BROWSE = "qpid.last_value_queue_no_browse";
    public static final String QPID_QUEUE_EVENT_GENERATION = "qpid.queue_event_generation";

    public void validatePolicyType(String type)
    {
        if (type == null || 
           !("reject".equals(type) || "flow_to_disk".equals(type) || 
            "ring".equals(type) || "ring_strict".equals(type)))
        {
            throw new IllegalArgumentException("Invalid Queue Policy Type" +
                    " should be one of {reject|flow_to_disk|ring|ring_strict}");
        }
    }
    
	public void setPolicyType(String s)
	{
	    validatePolicyType(s);
	    this.put(QPID_POLICY_TYPE, s);
	}

    public void setMaxCount(Integer i)
    {
        this.put(QPID_MAX_COUNT, i);
    }
    
    public void setMaxSize(Integer i)
    {
        this.put(QPID_MAX_SIZE, i);
    }
    
    public void setPersistLastNode()
    {
        this.put(QPID_PERSIST_LAST_NODE, 1);
    }
    
    public void setOrderingPolicy(String s)
    {
        if (QpidQueueOptions.QPID_LAST_VALUE_QUEUE.equals(s))
        {
            this.put(QPID_LAST_VALUE_QUEUE, 1);
        }
        else if (QpidQueueOptions.QPID_LAST_VALUE_QUEUE_NO_BROWSE.equals(s))
        {
            this.put(QPID_LAST_VALUE_QUEUE_NO_BROWSE,1);
        }
        else
        {
            throw new IllegalArgumentException("Invalid Ordering Policy" +
            " should be one of {" + QpidQueueOptions.QPID_LAST_VALUE_QUEUE + "|" + 
            QPID_LAST_VALUE_QUEUE_NO_BROWSE + "}");
        }
    }
    
    public void setLvqKey(String key)
    {
        this.put(QPID_LVQ_KEY, key);
    }
    
    public void setQueueEvents(String value)
    {
        if (value != null &&  (value.equals("1") || value.equals("2")))
        {
            this.put(QPID_QUEUE_EVENT_GENERATION, value);
        }
        else
        {
            throw new IllegalArgumentException("Invalid value for " + 
                    QPID_QUEUE_EVENT_GENERATION + " should be one of {1|2}");
        }
    }
}