01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.servicemix.web.model;
18:
19: import java.util.Arrays;
20: import java.util.Collections;
21: import java.util.List;
22:
23: import javax.management.ObjectName;
24: import javax.xml.namespace.QName;
25:
26: import org.apache.servicemix.jbi.framework.EndpointMBean;
27:
28: public class Endpoint {
29:
30: private Registry registry;
31:
32: private EndpointMBean mbean;
33:
34: private ObjectName objectName;
35:
36: private boolean showWsdl;
37:
38: public Endpoint(Registry registry, EndpointMBean mbean,
39: ObjectName objectName) {
40: this .registry = registry;
41: this .mbean = mbean;
42: this .objectName = objectName;
43: }
44:
45: public String getName() {
46: return mbean.getServiceName() + ":" + mbean.getEndpointName();
47: }
48:
49: public ObjectName getObjectName() {
50: return objectName;
51: }
52:
53: public String getType() throws Exception {
54: return objectName.getKeyProperty("SubType");
55: }
56:
57: public Component getComponent() throws Exception {
58: return registry.getComponent(mbean.getComponentName());
59: }
60:
61: public boolean equals(Object o) {
62: if (o instanceof Endpoint) {
63: return ((Endpoint) o).objectName.equals(objectName);
64: } else {
65: return false;
66: }
67: }
68:
69: public int hashCode() {
70: return objectName.hashCode();
71: }
72:
73: public boolean isShowWsdl() {
74: return showWsdl;
75: }
76:
77: public void setShowWsdl(boolean showWsdl) {
78: this .showWsdl = showWsdl;
79: }
80:
81: public String getWsdl() {
82: return mbean.loadWSDL().replace("<", "<");
83: }
84:
85: public List<QName> getInterfaces() {
86: QName[] names = mbean.getInterfaces();
87: if (names != null) {
88: return Arrays.asList(names);
89: } else {
90: return Collections.emptyList();
91: }
92: }
93:
94: }
|