01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.console.util;
17:
18: import java.io.Serializable;
19: import org.apache.geronimo.kernel.management.State;
20: import org.apache.geronimo.kernel.config.ConfigurationModuleType;
21: import org.apache.geronimo.kernel.repository.Artifact;
22: import org.apache.geronimo.gbean.AbstractName;
23:
24: /**
25: * Standard metadata about a configuration
26: *
27: * @version $Rev: 476061 $ $Date: 2006-11-16 22:36:50 -0800 (Thu, 16 Nov 2006) $
28: */
29: public class ConfigurationData implements Serializable, Comparable {
30: private final Artifact configID;
31: private final State state;
32: private final AbstractName parentName;
33: private final String childName;
34: private final ConfigurationModuleType type;
35: private final AbstractName moduleBeanName;
36:
37: public ConfigurationData(Artifact configID,
38: AbstractName parentName, String childName, State state,
39: ConfigurationModuleType type, AbstractName moduleBeanName) {
40: this .configID = configID;
41: this .childName = childName;
42: this .parentName = parentName;
43: this .state = state;
44: this .type = type;
45: this .moduleBeanName = moduleBeanName;
46: }
47:
48: public boolean isChild() {
49: return childName != null;
50: }
51:
52: public String getChildName() {
53: return childName;
54: }
55:
56: public AbstractName getModuleBeanName() {
57: return moduleBeanName;
58: }
59:
60: public AbstractName getParentName() {
61: return parentName;
62: }
63:
64: public State getState() {
65: return state;
66: }
67:
68: public ConfigurationModuleType getType() {
69: return type;
70: }
71:
72: public Artifact getConfigID() {
73: return configID;
74: }
75:
76: public boolean isRunning() {
77: return state.toInt() == State.RUNNING_INDEX;
78: }
79:
80: public int compareTo(Object o) {
81: ConfigurationData other = (ConfigurationData) o;
82: int test = getParentName().toString().compareTo(
83: other.getParentName().toString());
84: if (test == 0) {
85: if (getChildName() != null && other.getChildName() != null) {
86: return getChildName().compareTo(other.getChildName());
87: } else if (getChildName() == null
88: && other.getChildName() == null) {
89: return 0;
90: } else
91: return getChildName() == null ? 1 : -1;
92: } else
93: return test;
94: }
95: }
|