KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > console > jmsmanager > DestinationInfo


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.console.jmsmanager;
19
20 import javax.jms.Queue JavaDoc;
21
22 public class DestinationInfo implements Comparable JavaDoc {
23
24     private final String JavaDoc name;
25
26     private final String JavaDoc physicalName;
27
28     private final Class JavaDoc type;
29
30     private final String JavaDoc applicationName;
31
32     private final String JavaDoc moduleName;
33
34     private final String JavaDoc configURI;
35
36     public DestinationInfo(String JavaDoc name, String JavaDoc physicalName, Class JavaDoc type,
37             String JavaDoc applicationName, String JavaDoc moduleName, String JavaDoc configURI) {
38         this.name = name;
39         this.physicalName = physicalName;
40         this.type = type;
41         this.applicationName = applicationName;
42         this.moduleName = moduleName;
43         this.configURI = configURI;
44     }
45
46     public String JavaDoc getName() {
47         return name;
48     }
49
50     public String JavaDoc getPhysicalName() {
51         return physicalName;
52     }
53
54     public Class JavaDoc getType() {
55         return type;
56     }
57
58     public String JavaDoc getApplicationName() {
59         return applicationName;
60     }
61
62     public String JavaDoc getModuleName() {
63         return moduleName;
64     }
65
66     public String JavaDoc getConfigURI() {
67         return configURI;
68     }
69
70     /**
71      * Determines if the destination that this objects represents is viewable
72      * from the console this means that either the destination that this object
73      * represents was added via the Geronimo JMS Console or it is a Queue.
74      *
75      * @return true if the console knows how to display this Destination
76      * otherwise returns false.
77      */

78     public boolean isViewable() {
79         return Queue JavaDoc.class.isAssignableFrom(type) || isConsoleManaged();
80     }
81
82     /**
83      * Determines if the destination that this objects represents is removable
84      * from the console this means that the destination that this object
85      * represents was added via the Geronimo JMS Console.
86      *
87      * @return true if the console knows how to remove this Destination
88      * otherwise returns false.
89      */

90     public boolean isRemovable() {
91         return isConsoleManaged();
92     }
93
94     /**
95      * Determines if the destination that this objects represents was added via
96      * the console.
97      *
98      * @return true if the destination that this objects represents was added
99      * via the console otherwise returns false.
100      */

101     private boolean isConsoleManaged() {
102         return configURI.indexOf(AbstractJMSManager.BASE_CONFIG_URI + name) > -1;
103     }
104
105     public int compareTo(Object JavaDoc o) {
106         if (o instanceof DestinationInfo) {
107             DestinationInfo rhs = (DestinationInfo) o;
108             // If one of the objects is removable and the other is not, the
109
// removable one is less (comes first in a descending sort).
110
if (rhs.isRemovable() != this.isRemovable()) {
111                 if (this.isRemovable()) {
112                     return -1;
113                 } else {
114                     return 1;
115                 }
116                 // If one of the objects is viewable and the other is not the
117
// viewable one is less (comes first in a descending sort).
118
} else if (rhs.isViewable() != this.isViewable()) {
119                 if (this.isViewable()) {
120                     return -1;
121                 } else {
122                     return 1;
123                 }
124                 // Sort by name if all else fails.
125
} else {
126                 return this.name.compareTo(rhs.getName());
127             }
128         }
129         return 1;
130     }
131
132 }
133
Popular Tags