01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.management.ui.model;
22
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26
27 import javax.management.MBeanOperationInfo;
28 import javax.management.MBeanParameterInfo;
29
30 public class OperationDataModel
31 {
32 HashMap<String, OperationData> _operationMap = new HashMap<String, OperationData>();
33
34 public void addOperation(MBeanOperationInfo opInfo)
35 {
36 OperationData opData = new OperationData(opInfo.getName());
37 opData.setDescription(opInfo.getDescription());
38 opData.setImpact(opInfo.getImpact());
39 opData.setReturnType(opInfo.getReturnType());
40
41 int parametersCount = opInfo.getSignature().length;
42 if (parametersCount != 0)
43 {
44 List<ParameterData> paramList = new ArrayList<ParameterData>();
45 for (int i = 0; i < parametersCount; i++)
46 {
47 MBeanParameterInfo paramInfo = opInfo.getSignature()[i];
48 ParameterData param = new ParameterData(paramInfo.getName(), paramInfo.getDescription(),
49 paramInfo.getType());
50 paramList.add(param);
51 }
52 opData.setParameters(paramList);
53 }
54
55 _operationMap.put(opInfo.getName(), opData);
56 }
57
58 public OperationData getOperation(String name)
59 {
60 return _operationMap.get(name);
61 }
62
63 public List<OperationData> getOperations()
64 {
65 return new ArrayList<OperationData>(_operationMap.values());
66 }
67
68 public int getCount()
69 {
70 return _operationMap.size();
71 }
72 }
|