1 17 package org.apache.servicemix.jbi.framework; 18 19 import java.beans.PropertyChangeListener ; 20 21 import javax.management.JMException ; 22 import javax.management.MBeanAttributeInfo ; 23 import javax.management.MBeanOperationInfo ; 24 import javax.xml.namespace.QName ; 25 import javax.xml.transform.TransformerException ; 26 27 import org.apache.servicemix.jbi.management.AttributeInfoHelper; 28 import org.apache.servicemix.jbi.management.MBeanInfoProvider; 29 import org.apache.servicemix.jbi.management.OperationInfoHelper; 30 import org.apache.servicemix.jbi.servicedesc.AbstractServiceEndpoint; 31 import org.apache.servicemix.jbi.servicedesc.ExternalEndpoint; 32 import org.apache.servicemix.jbi.servicedesc.InternalEndpoint; 33 import org.apache.servicemix.jbi.servicedesc.LinkedEndpoint; 34 import org.apache.servicemix.jbi.util.DOMUtil; 35 36 public class Endpoint implements EndpointMBean, MBeanInfoProvider { 37 38 private AbstractServiceEndpoint endpoint; 39 private Registry registry; 40 41 public Endpoint(AbstractServiceEndpoint endpoint, Registry registry) { 42 this.endpoint = endpoint; 43 this.registry = registry; 44 } 45 46 public String getEndpointName() { 47 return endpoint.getEndpointName(); 48 } 49 50 public QName [] getInterfaces() { 51 return endpoint.getInterfaces(); 52 } 53 54 public QName getServiceName() { 55 return endpoint.getServiceName(); 56 } 57 58 public String getReference() { 59 try { 60 return DOMUtil.asIndentedXML(endpoint.getAsReference(null)); 61 } catch (TransformerException e) { 62 return null; 63 } 64 } 65 66 public String getWSDL() { 67 try { 68 return DOMUtil.asXML(registry.getEndpointDescriptor(endpoint)); 69 } catch (Exception e) { 70 return null; 71 } 72 } 73 74 public String getComponentName() { 75 if (endpoint.getComponentNameSpace() != null) { 76 return endpoint.getComponentNameSpace().getName(); 77 } else { 78 return null; 79 } 80 } 81 82 public MBeanAttributeInfo [] getAttributeInfos() throws JMException { 83 AttributeInfoHelper helper = new AttributeInfoHelper(); 84 helper.addAttribute(getObjectToManage(), "endpointName", "name of the endpoint"); 85 helper.addAttribute(getObjectToManage(), "serviceName", "name of the service"); 86 helper.addAttribute(getObjectToManage(), "componentName", "component name of the service unit"); 87 helper.addAttribute(getObjectToManage(), "interfaces", "interfaces implemented by this endpoint"); 88 return helper.getAttributeInfos(); 89 } 90 91 public MBeanOperationInfo [] getOperationInfos() throws JMException { 92 OperationInfoHelper helper = new OperationInfoHelper(); 93 helper.addOperation(getObjectToManage(), "getReference", "retrieve the endpoint reference"); 94 helper.addOperation(getObjectToManage(), "getWSDL", "retrieve the wsdl description of this endpoint"); 95 return helper.getOperationInfos(); 96 } 97 98 public Object getObjectToManage() { 99 return this; 100 } 101 102 public String getName() { 103 return endpoint.getServiceName() + endpoint.getEndpointName(); 104 } 105 106 public String getType() { 107 return "Endpoint"; 108 } 109 110 public String getSubType() { 111 if (endpoint instanceof InternalEndpoint) { 112 return "Internal"; 113 } else if (endpoint instanceof LinkedEndpoint) { 114 return "Linked"; 115 } else if (endpoint instanceof ExternalEndpoint) { 116 return "External"; 117 } 118 return null; 119 } 120 121 public String getDescription() { 122 return null; 123 } 124 125 public void setPropertyChangeListener(PropertyChangeListener l) { 126 } 127 128 protected AbstractServiceEndpoint getEndpoint() { 129 return endpoint; 130 } 131 132 } 133 | Popular Tags |