001 /*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements. See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership. The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License. You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied. See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 *
020 */
021 package org.apache.qpid.management.ui;
022
023 import static org.apache.qpid.management.ui.Constants.*;
024 import java.util.HashMap;
025
026 /**
027 * Class representing a managed bean on the managed server
028 * @author Bhupendra Bhardwaj
029 *
030 */
031 public abstract class ManagedBean extends ManagedObject
032 {
033 private String _uniqueName = "";
034 private String _domain = "";
035 private String _type = "";
036 private String _virtualHostName = null;
037 private ManagedServer _server = null;
038 private HashMap _properties = null;
039
040 public String getProperty(String key)
041 {
042 return (String)_properties.get(key);
043 }
044
045 public HashMap getProperties()
046 {
047 return _properties;
048 }
049 public void setProperties(HashMap properties)
050 {
051 this._properties = properties;
052 setName(getProperty("name"));
053 setType(getProperty("type"));
054 _virtualHostName = getProperty(VIRTUAL_HOST);
055 }
056 public String getDomain()
057 {
058 return _domain;
059 }
060 public void setDomain(String domain)
061 {
062 this._domain = domain;
063 }
064
065 public ManagedServer getServer()
066 {
067 return _server;
068 }
069 public void setServer(ManagedServer server)
070 {
071 this._server = server;
072 }
073 public String getType()
074 {
075 return _type;
076 }
077 public void setType(String type)
078 {
079 this._type = type;
080 }
081 public String getUniqueName()
082 {
083 return _uniqueName;
084 }
085 public void setUniqueName(String uniqueName)
086 {
087 this._uniqueName = uniqueName;
088 }
089
090 public String getVirtualHostName()
091 {
092 // To make it work with the broker with no virtual host implementation
093 return _virtualHostName == null ? DEFAULT_VH : _virtualHostName;
094 }
095
096 /**
097 * Returns mbean instance name. MBeans which have only one instance, the type attribute will be returned
098 * @return
099 */
100 public String getInstanceName()
101 {
102 if (getName() != null)
103 return getName();
104 else
105 return getType();
106 }
107
108 public boolean isQueue()
109 {
110 return _type.endsWith(QUEUE);
111 }
112
113 public boolean isConnection()
114 {
115 return _type.endsWith(CONNECTION);
116 }
117
118 public boolean isExchange()
119 {
120 return _type.endsWith(EXCHANGE);
121 }
122
123 public boolean isTempQueue()
124 {
125 return (isQueue() && getName().startsWith("tmp_"));
126 }
127
128 public boolean isAdmin()
129 {
130 return _type.endsWith(ADMIN_MBEAN_TYPE);
131 }
132 }
|