summaryrefslogtreecommitdiff
path: root/java/broker/src/main/java/org/apache/qpid/server/configuration/SystemConfigType.java
blob: f5aabd2345a32251b2dbde12eea379cb8fbef9a0 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 *
 * 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.server.configuration;

import java.util.*;

public final class SystemConfigType extends ConfigObjectType<SystemConfigType, SystemConfig>
{
    private static final List<SystemProperty<?>> SYSTEM_PROPERTIES = new ArrayList<SystemProperty<?>>();

    public static interface SystemProperty<S> extends ConfigProperty<SystemConfigType, SystemConfig, S>
    {
    }

    private abstract static class SystemReadWriteProperty<S>  extends ConfigProperty.ReadWriteConfigProperty<SystemConfigType, SystemConfig, S> implements SystemProperty<S>
    {
        public SystemReadWriteProperty(String name)
        {
            super(name);
            SYSTEM_PROPERTIES.add(this);
        }
    }

    private abstract static class SystemReadOnlyProperty<S> extends ConfigProperty.ReadOnlyConfigProperty<SystemConfigType, SystemConfig, S> implements SystemProperty<S>
    {
        public SystemReadOnlyProperty(String name)
        {
            super(name);
            SYSTEM_PROPERTIES.add(this);
        }
    }

    public static final SystemReadOnlyProperty<String> NAME_PROPERTY = new SystemReadOnlyProperty<String>("name")
    {
        public String getValue(SystemConfig object)
        {
            return object.getName();
        }
    };

    public static final SystemReadOnlyProperty<UUID> ID_PROPERTY = new SystemReadOnlyProperty<UUID>("id")
    {
        public UUID getValue(SystemConfig object)
        {
            return object.getId();
        }
    };

    public static final SystemReadOnlyProperty<String> OS_NAME_PROPERTY = new SystemReadOnlyProperty<String>("osName")
    {
        public String getValue(SystemConfig object)
        {
            return object.getOperatingSystemName();
        }
    };

    public static final SystemReadOnlyProperty<String> NODE_NAME_PROPERTY = new SystemReadOnlyProperty<String>("nodeName")
    {
        public String getValue(SystemConfig object)
        {
            return object.getNodeName();
        }
    };

    public static final SystemReadOnlyProperty<String> RELEASE_PROPERTY = new SystemReadOnlyProperty<String>("release")
    {
        public String getValue(SystemConfig object)
        {
            return object.getOSRelease();
        }
    };

    public static final SystemReadOnlyProperty<String> VERSION_PROPERTY = new SystemReadOnlyProperty<String>("version")
    {
        public String getValue(SystemConfig object)
        {
            return object.getOSVersion();
        }
    };

    public static final SystemReadOnlyProperty<String> MACHINE_PROPERTY = new SystemReadOnlyProperty<String>("machine")
    {
        public String getValue(SystemConfig object)
        {
            return object.getOSArchitecture();
        }
    };

    private static final SystemConfigType INSTANCE = new SystemConfigType();

    private SystemConfigType()
    {
    }

    public Collection<SystemProperty<?>> getProperties()
    {
        return Collections.unmodifiableList(SYSTEM_PROPERTIES);
    }



    public static SystemConfigType getInstance()
    {
        return INSTANCE;
    }



}