001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 package org.apache.geronimo.console.util; 018 019 import java.io.Serializable; 020 import org.apache.geronimo.kernel.management.State; 021 import org.apache.geronimo.kernel.config.ConfigurationModuleType; 022 import org.apache.geronimo.kernel.repository.Artifact; 023 import org.apache.geronimo.gbean.AbstractName; 024 025 /** 026 * Standard metadata about a configuration 027 * 028 * @version $Rev: 476061 $ $Date: 2006-11-17 01:36:50 -0500 (Fri, 17 Nov 2006) $ 029 */ 030 public class ConfigurationData implements Serializable, Comparable { 031 private final Artifact configID; 032 private final State state; 033 private final AbstractName parentName; 034 private final String childName; 035 private final ConfigurationModuleType type; 036 private final AbstractName moduleBeanName; 037 038 public ConfigurationData(Artifact configID, AbstractName parentName, String childName, State state, ConfigurationModuleType type, AbstractName moduleBeanName) { 039 this.configID = configID; 040 this.childName = childName; 041 this.parentName = parentName; 042 this.state = state; 043 this.type = type; 044 this.moduleBeanName = moduleBeanName; 045 } 046 047 public boolean isChild() { 048 return childName != null; 049 } 050 051 public String getChildName() { 052 return childName; 053 } 054 055 public AbstractName getModuleBeanName() { 056 return moduleBeanName; 057 } 058 059 public AbstractName getParentName() { 060 return parentName; 061 } 062 063 public State getState() { 064 return state; 065 } 066 067 public ConfigurationModuleType getType() { 068 return type; 069 } 070 071 public Artifact getConfigID() { 072 return configID; 073 } 074 075 public boolean isRunning() { 076 return state.toInt() == State.RUNNING_INDEX; 077 } 078 079 public int compareTo(Object o) { 080 ConfigurationData other = (ConfigurationData) o; 081 int test = getParentName().toString().compareTo(other.getParentName().toString()); 082 if(test == 0) { 083 if(getChildName() != null && other.getChildName() != null) { 084 return getChildName().compareTo(other.getChildName()); 085 } else if(getChildName() == null && other.getChildName() == null) { 086 return 0; 087 } else return getChildName() == null ? 1 : -1; 088 } else return test; 089 } 090 }