diff options
Diffstat (limited to 'qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model')
7 files changed, 674 insertions, 0 deletions
diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/AttributeData.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/AttributeData.java new file mode 100644 index 0000000000..ccd4cf8df8 --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/AttributeData.java @@ -0,0 +1,96 @@ +/* + * + * 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.management.ui.model; + +public class AttributeData +{ + String name = ""; + String description = ""; + String dataType = ""; + Object value = ""; + boolean readable = true; + boolean writable = false; + + + public String getDataType() + { + return dataType; + } + public void setDataType(String dataType) + { + this.dataType = dataType; + } + + public String getDescription() + { + return description; + } + public void setDescription(String description) + { + this.description = description; + } + + public String getName() + { + return name; + } + public void setName(String name) + { + this.name = name; + } + + public Object getValue() + { + return value; + } + public void setValue(Object value) + { + if (value != null) + this.value = value; + } + public boolean isReadable() + { + return readable; + } + public void setReadable(boolean readable) + { + this.readable = readable; + } + public boolean isWritable() + { + return writable; + } + public void setWritable(boolean writable) + { + this.writable = writable; + } + + public boolean isNumber() + { + if ("int".equals(dataType) || "java.lang.Integer".equals(dataType) || + "long".equals(dataType) || "java.lang.Long".equals(dataType) ) + { + return true; + } + else + return false; + } +} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java new file mode 100644 index 0000000000..b3219f15ea --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ManagedAttributeModel.java @@ -0,0 +1,118 @@ +/* + * + * 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.management.ui.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class ManagedAttributeModel +{ + HashMap<String, AttributeData> _attributeMap = new HashMap<String, AttributeData>(); + + public void setAttributeValue(String name, Object value) + { + if (value == null) + return; + + AttributeData data = null; + String dataType = value.getClass().getName(); + if (_attributeMap.containsKey(name)) + { + data = _attributeMap.get(name); + data.setValue(value); + } + else + { + data = new AttributeData(); + data.setName(name); + data.setValue(value); + _attributeMap.put(name, data); + } + data.setDataType(dataType); + } + + + public void setAttributeDescription(String name, String value) + { + if (_attributeMap.containsKey(name)) + { + _attributeMap.get(name).setDescription(value); + } + else + { + AttributeData data = new AttributeData(); + data.setName(name); + data.setDescription(value); + _attributeMap.put(name, data); + } + } + + public void setAttributeReadable(String name, boolean readable) + { + if (_attributeMap.containsKey(name)) + { + _attributeMap.get(name).setReadable(readable); + } + else + { + AttributeData data = new AttributeData(); + data.setName(name); + data.setReadable(readable); + _attributeMap.put(name, data); + } + } + + public void setAttributeWritable(String name, boolean writable) + { + if (_attributeMap.containsKey(name)) + { + _attributeMap.get(name).setWritable(writable); + } + else + { + AttributeData data = new AttributeData(); + data.setName(name); + data.setWritable(writable); + _attributeMap.put(name, data); + } + } + + public List<String> getAttributeNames() + { + return new ArrayList<String>(_attributeMap.keySet()); + } + + public AttributeData[] getAttributes() + { + return _attributeMap.values().toArray(new AttributeData[0]); + } + + public AttributeData getAttribute(String name) + { + return _attributeMap.get(name); + } + + public int getCount() + { + return _attributeMap.size(); + } +} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationInfoModel.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationInfoModel.java new file mode 100644 index 0000000000..6d4160889e --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationInfoModel.java @@ -0,0 +1,51 @@ +/* + * + * 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.management.ui.model; + +public class NotificationInfoModel +{ + String name; + String description; + String[] types; + + public NotificationInfoModel(String name, String desc, String[] types) + { + this.name = name; + this.description = desc; + this.types = types; + } + + public String getDescription() + { + return description; + } + + public String getName() + { + return name; + } + + public String[] getTypes() + { + return types; + } + +} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java new file mode 100644 index 0000000000..35cc9f6e27 --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/NotificationObject.java @@ -0,0 +1,132 @@ +/* + * + * 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.management.ui.model; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.TimeZone; + +import javax.management.ObjectName; + +import static org.apache.qpid.management.ui.Constants.VIRTUAL_HOST; + +public class NotificationObject +{ + + private long _sequenceNo; + private Date _timeStamp; + private String _message; + private Object _source; + private String _type; // INFO, WARN, etc + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss dd/MM/yy z"); + + public NotificationObject(long seqNo, Date timeStamp, String message, Object source, String type) + { + this._sequenceNo = seqNo; + this._message = message; + this._source = source; + this._type = type; + this._timeStamp = timeStamp; + dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); + } + + public Object getSource() + { + return _source; + } + public void setSource(Object _source) + { + this._source = _source; + } + + public String getSourceName() + { + if (_source instanceof ObjectName) + { + return unquote(((ObjectName)_source).getKeyProperty("name")); + } + + return null; + } + + public String getSourceVirtualHost() + { + if (_source instanceof ObjectName) + { + return unquote(((ObjectName)_source).getKeyProperty(VIRTUAL_HOST)); + } + + return null; + } + + private String unquote(String value) + { + if(value != null) + { + try + { + //if the value is quoted in the ObjectName, unquote it + value = ObjectName.unquote(value); + } + catch(IllegalArgumentException e) + { + //ignore, this just means the value is not quoted + //and can be left unchanged + } + } + + return value; + } + + public String getMessage() + { + return _message; + } + public void setMessage(String _message) + { + this._message = _message; + } + public long getSequenceNo() + { + return _sequenceNo; + } + public void setSequenceNo(long no) + { + _sequenceNo = no; + } + public String getTimeStamp() + { + return dateFormat.format(_timeStamp); + } + public void setTimeStamp(Date stamp) + { + _timeStamp = stamp; + } + public String getType() + { + return _type; + } + public void setType(String _type) + { + this._type = _type; + } + +} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java new file mode 100644 index 0000000000..bf3b730b3e --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationData.java @@ -0,0 +1,110 @@ +/* + * + * 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.management.ui.model; + +import java.util.List; + +public class OperationData +{ + private String _name; + private String _description; + private String _returnType; + private int _impact; + private List<ParameterData> _parameters; + + public OperationData(String value) + { + this._name = value; + } + + public String getName() + { + return _name; + } + + public String getDescription() + { + return _description; + } + + public void setDescription(String description) + { + this._description = description; + } + + public List<ParameterData> getParameters() + { + return _parameters; + } + + public void setParameters(List<ParameterData> parameters) + { + this._parameters = parameters; + } + + public int getImpact() + { + return _impact; + } + + public void setImpact(int impact) + { + this._impact = impact; + } + + public String getReturnType() + { + return _returnType; + } + + public void setReturnType(String returnType) + { + this._returnType = returnType; + } + + public boolean isReturnTypeBoolean() + { + return (_returnType.equals("boolean") || _returnType.equals("java.lang.Boolean")); + } + + public boolean isReturnTypeVoid() + { + return (_returnType.equals("void") || _returnType.equals("java.lang.Void")); + } + + public Object getParameterValue(String paramName) + { + if (_parameters == null) + { + return null; + } + + for (int i = 0; i < _parameters.size(); i++) + { + if (paramName.equalsIgnoreCase(_parameters.get(i).getName())) + { + return _parameters.get(i).getValue(); + } + } + + return null; + } +}
\ No newline at end of file diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationDataModel.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationDataModel.java new file mode 100644 index 0000000000..96964a81ef --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/OperationDataModel.java @@ -0,0 +1,72 @@ +/* + * + * 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.management.ui.model; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.management.MBeanOperationInfo; +import javax.management.MBeanParameterInfo; + +public class OperationDataModel +{ + HashMap<String, OperationData> _operationMap = new HashMap<String, OperationData>(); + + public void addOperation(MBeanOperationInfo opInfo) + { + OperationData opData = new OperationData(opInfo.getName()); + opData.setDescription(opInfo.getDescription()); + opData.setImpact(opInfo.getImpact()); + opData.setReturnType(opInfo.getReturnType()); + + int parametersCount = opInfo.getSignature().length; + if (parametersCount != 0) + { + List<ParameterData> paramList = new ArrayList<ParameterData>(); + for (int i = 0; i < parametersCount; i++) + { + MBeanParameterInfo paramInfo = opInfo.getSignature()[i]; + ParameterData param = new ParameterData(paramInfo.getName(), paramInfo.getDescription(), + paramInfo.getType()); + paramList.add(param); + } + opData.setParameters(paramList); + } + + _operationMap.put(opInfo.getName(), opData); + } + + public OperationData getOperation(String name) + { + return _operationMap.get(name); + } + + public List<OperationData> getOperations() + { + return new ArrayList<OperationData>(_operationMap.values()); + } + + public int getCount() + { + return _operationMap.size(); + } +} diff --git a/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ParameterData.java b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ParameterData.java new file mode 100644 index 0000000000..d12217c6eb --- /dev/null +++ b/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/model/ParameterData.java @@ -0,0 +1,95 @@ +/* + * + * 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.management.ui.model; + +/** + * Class representing an mbean operation parameter + * @author Bhupendra Bhardwaj + */ +public class ParameterData +{ + private String _name; + private String _description; + private String _type; + private Object _value; + + ParameterData(String name, String desc, String type) + { + this._name = name; + this._description = desc; + this._type = type; + setDefaultValue(); + } + + public String getDescription() + { + return _description; + } + + public String getName() + { + return _name; + } + + public String getType() + { + return _type; + } + + public Object getValue() + { + return _value; + } + + public void setValueFromString(String strValue) + { + if ("int".equals(_type)) + _value = Integer.parseInt(strValue); + else if (isBoolean()) + _value = Boolean.valueOf(strValue); + else if ("long".equals(_type)) + _value = Long.parseLong(strValue); + else + _value = strValue; + } + + public void setValue(Object value) + { + this._value = value; + } + + public boolean isBoolean() + { + return (_type.equals("boolean") || _type.equals("java.lang.Boolean")); + } + + public void setDefaultValue() + { + if (isBoolean()) + { + _value = Boolean.valueOf("false"); + } + else + { + _value = null; + } + } +} |