~ubuntu-branches/ubuntu/trusty/ehcache/trusty

« back to all changes in this revision

Viewing changes to src/main/java/net/sf/ehcache/config/generator/model/elements/ManagementRESTServiceConfigurationElement.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2013-05-06 14:53:07 UTC
  • mfrom: (1.1.7) (2.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130506145307-v5bhw5yu70re00l3
Tags: 2.6.7-1
* Team upload.
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 *  Copyright Terracotta, Inc.
 
3
 *
 
4
 *  Licensed under the Apache License, Version 2.0 (the "License");
 
5
 *  you may not use this file except in compliance with the License.
 
6
 *  You may obtain a copy of the License at
 
7
 *
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 *  Unless required by applicable law or agreed to in writing, software
 
11
 *  distributed under the License is distributed on an "AS IS" BASIS,
 
12
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 *  See the License for the specific language governing permissions and
 
14
 *  limitations under the License.
 
15
 */
 
16
 
 
17
package net.sf.ehcache.config.generator.model.elements;
 
18
 
 
19
import net.sf.ehcache.config.ManagementRESTServiceConfiguration;
 
20
import net.sf.ehcache.config.generator.model.NodeElement;
 
21
import net.sf.ehcache.config.generator.model.SimpleNodeAttribute;
 
22
import net.sf.ehcache.config.generator.model.SimpleNodeElement;
 
23
import net.sf.ehcache.statistics.sampled.CacheStatisticsSampler;
 
24
 
 
25
/**
 
26
 * Element representing the {@link net.sf.ehcache.config.ManagementRESTServiceConfiguration}
 
27
 *
 
28
 * @author Ludovic Orban
 
29
 *
 
30
 */
 
31
public class ManagementRESTServiceConfigurationElement extends SimpleNodeElement {
 
32
    private final ManagementRESTServiceConfiguration managementRESTServiceConfiguration;
 
33
 
 
34
    /**
 
35
     * Construtor accepting the parent and the {@link net.sf.ehcache.config.ManagementRESTServiceConfiguration}
 
36
     *
 
37
     * @param parent
 
38
     * @param cfg
 
39
     */
 
40
    public ManagementRESTServiceConfigurationElement(ConfigurationElement parent, ManagementRESTServiceConfiguration cfg) {
 
41
        super(parent, "managementRESTService");
 
42
        this.managementRESTServiceConfiguration = cfg;
 
43
        init();
 
44
    }
 
45
 
 
46
    /**
 
47
     * Construtor accepting the element and the {@link net.sf.ehcache.config.ManagementRESTServiceConfiguration}
 
48
     *
 
49
     * @param element
 
50
     * @param cfg
 
51
     */
 
52
    public ManagementRESTServiceConfigurationElement(NodeElement element, ManagementRESTServiceConfiguration cfg) {
 
53
        super(element, "managementRESTService");
 
54
        this.managementRESTServiceConfiguration = cfg;
 
55
        init();
 
56
    }
 
57
 
 
58
    private void init() {
 
59
        if (managementRESTServiceConfiguration == null) {
 
60
            return;
 
61
        }
 
62
        addAttribute(new SimpleNodeAttribute("enabled", managementRESTServiceConfiguration.isEnabled()).defaultValue(false));
 
63
        addAttribute(new SimpleNodeAttribute("bind", managementRESTServiceConfiguration.getBind())
 
64
            .defaultValue(ManagementRESTServiceConfiguration.DEFAULT_BIND));
 
65
        addAttribute(new SimpleNodeAttribute("securityServiceLocation", managementRESTServiceConfiguration
 
66
            .getSecurityServiceLocation()).optional(true));
 
67
        addAttribute(new SimpleNodeAttribute("securityServiceTimeout", managementRESTServiceConfiguration
 
68
            .getSecurityServiceTimeout()).optional(true)
 
69
            .defaultValue(ManagementRESTServiceConfiguration.DEFAULT_SECURITY_SVC_TIMEOUT));
 
70
        addAttribute(new SimpleNodeAttribute("sslEnabled", managementRESTServiceConfiguration.isSslEnabled())
 
71
            .optional(true).defaultValue(false));
 
72
        addAttribute(new SimpleNodeAttribute("needClientAuth", managementRESTServiceConfiguration.isNeedClientAuth())
 
73
            .optional(true).defaultValue(false));
 
74
        addAttribute(new SimpleNodeAttribute("sampleHistorySize", managementRESTServiceConfiguration.getSampleHistorySize())
 
75
            .optional(true).defaultValue(CacheStatisticsSampler.DEFAULT_HISTORY_SIZE));
 
76
        addAttribute(new SimpleNodeAttribute("sampleIntervalSeconds", managementRESTServiceConfiguration
 
77
            .getSampleIntervalSeconds()).optional(true).defaultValue(CacheStatisticsSampler.DEFAULT_INTERVAL_SECS));
 
78
        addAttribute(new SimpleNodeAttribute("sampleSearchIntervalSeconds", managementRESTServiceConfiguration
 
79
            .getSampleSearchIntervalSeconds()).optional(true).defaultValue(CacheStatisticsSampler.DEFAULT_SEARCH_INTERVAL_SEC));
 
80
    }
 
81
}