BrokerModel.java
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.web.action;
22 
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Set;
28 
29 import javax.management.ObjectName;
30 
31 import org.apache.qpid.management.Names;
32 
33 public class BrokerModel
34 {
35   private Map<String, List<ObjectName>> objectsByType = new HashMap<String, List<ObjectName>>();
36   
37   private String id;
38   
39   void addObject(ObjectName name)
40   {
41     String packageName = name.getKeyProperty(Names.PACKAGE);
42     String className = name.getKeyProperty(Names.CLASS);
43     if (className != null)
44     {
45       String fqn = packageName+"."+className;
46       
47       List<ObjectName> objects = objectsByType.get(fqn);
48       if (objects == null)
49       {
50         objects = new ArrayList<ObjectName>();
51         objectsByType.put(fqn,objects);
52       }
53       objects.add(name);    
54     }
55   }
56 
57   public String getId()
58   {
59     return id;
60   }
61 
62   public void setId(String id)
63   {
64     this.id = id;
65   }
66   
67   public Set<String> getCategoryNames(){
68     return objectsByType.keySet();
69   }
70   
71   public List<ObjectName> getCategory(String name
72   {
73     return objectsByType.get(name);
74   }
75   
76   public int getCategoryCount()
77   {
78     return objectsByType.keySet().size();
79   }
80 }